20150914-1 选题

This commit is contained in:
DeadFire 2015-09-14 16:18:35 +08:00
parent 64f540fec2
commit 243840381b
3 changed files with 246 additions and 0 deletions

View File

@ -0,0 +1,102 @@
How to Setup Node JS v4.0.0 on Ubuntu 14.04 / 15.04
================================================================================
Hi everyone, Node.JS Version 4.0.0 has been out, the popular server-side JavaScript platform has combines the Node.js and io.js code bases. This release represents the combined efforts encapsulated in both the Node.js project and the io.js project that are now combined in a single codebase. The most important change is this Node.js is ships with version 4.5 of Google's V8 JavaScript engine, which is the same version that ships with the current Chrome browser. So, being able to more closely track V8s releases means Node.js runs JavaScript faster, more securely, and with the ability to use many desirable ES6 language features.
![Node JS](http://blog.linoxide.com/wp-content/uploads/2015/09/nodejs.png)
Node.js 4.0.0 aims to provide an easy update path for current users of io.js and node as there are no major API changes. Lets see how you can easily get it installed and setup on Ubuntu server by following this simple article.
### Basic System Setup ###
Node works perfectly on Linux, Macintosh, and Solaris operating systems and among the Linux operating systems it has the best results using Ubuntu OS. That's why we are to setup it Ubuntu 15.04 while the same steps can be followed using Ubuntu 14.04.
#### 1) System Resources ####
The basic system resources for Node depend upon the size of your infrastructure requirements. So, here in this tutorial we will setup Node with 1 GB RAM, 1 GHz Processor and 10 GB of available disk space with minimal installation packages installed on the server that is no web or database server packages are installed.
#### 2) System Update ####
It always been recommended to keep your system upto date with latest patches and updates, so before we move to the installation on Node, let's login to your server with super user privileges and run update command.
# apt-get update
#### 3) Installing Dependencies ####
Node JS only requires some basic system and software utilities to be present on your server, for its successful installation like 'make' 'gcc' and 'wget'. Let's run the below command to get them installed if they are not already present.
# apt-get install python gcc make g++ wget
### Download Latest Node JS v4.0.0 ###
Let's download the latest Node JS version 4.0.0 by following this link of [Node JS Download Page][1].
![nodejs download](http://blog.linoxide.com/wp-content/uploads/2015/09/download.png)
We will copy the link location of its latest package and download it using 'wget' command as shown.
# wget https://nodejs.org/download/rc/v4.0.0-rc.1/node-v4.0.0-rc.1.tar.gz
Once download completes, unpack using 'tar' command as shown.
# tar -zxvf node-v4.0.0-rc.1.tar.gz
![wget nodejs](http://blog.linoxide.com/wp-content/uploads/2015/09/wget.png)
### Installing Node JS v4.0.0 ###
Now we have to start the installation of Node JS from its downloaded source code. So, change your directory and configure the source code by running its configuration script before compiling it on your ubuntu server.
root@ubuntu-15:~/node-v4.0.0-rc.1# ./configure
![Installing NodeJS](http://blog.linoxide.com/wp-content/uploads/2015/09/configure.png)
Now run the 'make install' command to compile the Node JS installation package as shown.
root@ubuntu-15:~/node-v4.0.0-rc.1# make install
The make command will take a couple of minutes while compiling its binaries so after executinf above command, wait for a while and keep calm.
### Testing Node JS Installation ###
Once the compilation process is complete, we will test it if every thing went fine. Let's run the following command to confirm the installed version of Node JS.
root@ubuntu-15:~# node -v
v4.0.0-pre
By executing 'node' without any arguments from the command-line you will be dropped into the REPL (Read-Eval-Print-Loop) that has simplistic emacs line-editing where you can interactively run JavaScript and see the results.
![node version](http://blog.linoxide.com/wp-content/uploads/2015/09/node.png)
### Writing Test Program ###
We can also try out a very simple console program to test the successful installation and proper working of Node JS. To do so we will create a file named "test.js" and write the following code into it and save the changes made in the file as shown.
root@ubuntu-15:~# vim test.js
var util = require("util");
console.log("Hello! This is a Node Test Program");
:wq!
Now in order to run the above program, from the command prompt run the below command.
root@ubuntu-15:~# node test.js
![Node Program](http://blog.linoxide.com/wp-content/uploads/2015/09/node-test.png)
So, upon successful installation we will get the output as shown in the screen, where as in the above program it loads the "util" class into a variable "util" and then uses the "util" object to perform the console tasks. While the console.log is a command similar to the cout in C++.
### Conclusion ###
Thats it. Hope this gives you a good idea of Node.js going with Node.js on Ubuntu. If you are new to developing applications with Node.js. After all we can say that we can expect significant performance gains with Node JS Version 4.0.0.
--------------------------------------------------------------------------------
via: http://linoxide.com/ubuntu-how-to/setup-node-js-4-0-ubuntu-14-04-15-04/
作者:[Kashif Siddique][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://linoxide.com/author/kashifs/
[1]:https://nodejs.org/download/rc/v4.0.0-rc.1/

View File

@ -0,0 +1,76 @@
Linux FAQs with Answers--How to check weather forecasts from the command line on Linux
================================================================================
> **Question**: I often check local weather forecasts on the Linux desktop. However, is there an easy way to access weather forecast information in the terminal environment, where I don't have access to desktop widgets or web browser?
For Linux desktop users, there are many ways to access weather forecasts, e.g., using standalone weather apps, desktop widgets, or panel applets. If your work environment is terminal-based, there are also several ways to access weather forecasts from the command line.
Among them is [wego][1], **a cute little weather app for the terminal**. Using an ncurses-based fancy interface, this command-line app allows you to see current weather conditions and forecasts at a glance. It retrieves the weather forecasts for the next 5 days via a weather forecast API.
### Install Wego on Linux ###
Installation of wego is pretty simple. wego is written in Go language, thus the first step is to [install Go language][2]. After installing Go, proceed to install wego as follows.
$ go get github.com/schachmat/wego
The wego tool will be installed under $GOPATH/bin. So add $GOPATH/bin to your $PATH variable.
$ echo 'export PATH="$PATH:$GOPATH/bin"' >> ~/.bashrc
$ source ~/.bashrc
Now go ahead and invoke wego from the command line.
$ wego
The first time you run wego, it will generate a config file (~/.wegorc), where you need to specify a weather API key.
You can obtain a free API key from [worldweatheronline.com][3]. Free sign-up is quick and easy. You only need a valid email address.
![](https://farm6.staticflickr.com/5781/21317466341_5a368b0d26_c.jpg)
Your .wegorc will look like the following.
![](https://farm6.staticflickr.com/5620/21121418558_df0d27cd0a_b.jpg)
Other than API key, you can specify in ~/.wegorc your preferred location, use of metric/imperial units, and language.
Note that the weather API is rate-limited; 5 queries per second, and 250 queries per day.
When you invoke wego command again, you will see the latest weather forecast (of your preferred location), shown as follows.
![](https://farm6.staticflickr.com/5776/21121218110_dd51e03ff4_c.jpg)
The displayed weather information includes: (1) temperature, (2) wind direction and speed, (3) viewing distance, and (4) precipitation amount and probability.
By default, it will show 3-day weather forecast. To change this behavior, you can supply the number of days (upto five) as an argument. For example, to see 5-day forecast:
$ wego 5
If you want to check the weather of any other location, you can specify the city name.
$ wego Seattle
### Troubleshooting ###
1. You encounter the following error while running wego.
user: Current not implemented on linux/amd64
This error can happen when you run wego on a platform which is not supported by the native Go compiler gc (e.g., Fedora). In that case, you can compile the program using gccgo, a compiler-frontend for Go language. This can be done as follows.
$ sudo yum install gcc-go
$ go get -compiler=gccgo github.com/schachmat/wego
--------------------------------------------------------------------------------
via: http://ask.xmodulo.com/weather-forecasts-command-line-linux.html
作者:[Dan Nanni][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://ask.xmodulo.com/author/nanni
[1]:https://github.com/schachmat/wego
[2]:http://ask.xmodulo.com/install-go-language-linux.html
[3]:https://developer.worldweatheronline.com/auth/register

View File

@ -0,0 +1,68 @@
Linux FAQs with Answers--How to remove unused old kernel images on Ubuntu
================================================================================
> **Question**: I have upgraded the kernel on my Ubuntu many times in the past. Now I would like to uninstall unused old kernel images to save some disk space. What is the easiest way to uninstall earlier versions of the Linux kernel on Ubuntu?
In Ubuntu environment, there are several ways for the kernel to get upgraded. On Ubuntu desktop, Software Updater allows you to check for and update to the latest kernel on a daily basis. On Ubuntu server, the unattended-upgrades package takes care of upgrading the kernel automatically as part of important security updates. Otherwise, you can manually upgrade the kernel using apt-get or aptitude command.
Over time, this ongoing kernel upgrade will leave you with a number of unused old kernel images accumulated on your system, wasting disk space. Each kernel image and associated modules/header files occupy 200-400MB of disk space, and so wasted space from unused kernel images will quickly add up.
![](https://farm1.staticflickr.com/636/21352725115_29ae7aab5f_c.jpg)
GRUB boot manager maintains GRUB entries for each old kernel, in case you want to boot into it.
![](https://farm6.staticflickr.com/5803/21164866468_07760fc23c_z.jpg)
As part of disk cleaning, you can consider removing old kernel images if you haven't used them for a while.
### How to Clean up Old Kernel Images ###
Before you remove old kernel images, remember that it is recommended to keep at least two kernel images (the latest one and an extra older version), in case the primary one goes wrong. That said, let's see how to uninstall old kernel images on Ubuntu platform.
In Ubuntu, kernel images consist of the following packages.
- **linux-image-<VERSION-NUMBER>**: kernel image
- **linux-image-extra-<VERSION-NUMBER>**: extra kernel modules
- **linux-headers-<VERSION-NUMBER>**: kernel header files
First, check what kernel image(s) are installed on your system.
$ dpkg --list | grep linux-image
$ dpkg --list | grep linux-headers
Among the listed kernel images, you can remove a particular version (e.g., 3.19.0-15) as follows.
$ sudo apt-get purge linux-image-3.19.0-15
$ sudo apt-get purge linux-headers-3.19.0-15
The above commands will remove the kernel image, and its associated kernel modules and header files.
Note that removing an old kernel will automatically trigger the installation of the latest Linux kernel image if you haven't upgraded to it yet. Also, after the old kernel is removed, GRUB configuration will automatically be updated to remove the corresponding GRUB entry from GRUB menu.
If you have many unused kernels, you can remove multiple of them in one shot using the following shell expansion syntax. Note that this brace expansion will work only for bash or any compatible shells.
$ sudo apt-get purge linux-image-3.19.0-{18,20,21,25}
$ sudo apt-get purge linux-headers-3.19.0-{18,20,21,25}
![](https://farm6.staticflickr.com/5619/21352725355_39cc4fc2d0_c.jpg)
The above command will remove 4 kernel images: 3.19.0-18, 3.19.0-20, 3.19.0-21 and 3.19.0-25.
If GRUB configuration is not properly updated for whatever reason after old kernels are removed, you can try to update GRUB configuration manually with update-grub2 command.
$ sudo update-grub2
Now reboot and verify that your GRUB menu has been properly cleaned up.
![](https://farm1.staticflickr.com/593/20731623163_cccfeac854_z.jpg)
--------------------------------------------------------------------------------
via: http://ask.xmodulo.com/remove-kernel-images-ubuntu.html
作者:[Dan Nanni][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://ask.xmodulo.com/author/nanni