sensors
This program lets you access temperature sensors and fan speed sensors on your system. Root access is required to detect the sensors, but not to read them.
This will only work for systems running on bare metal, as opposed to a virtual server. Install the lm-sensors package with the following:
$ sudo apt-get install lm-sensors
Then, let sensors find which temperature sensors are available on your system with:
$ sudo sensors-detect
Accept the defaults to the prompts. If sensors-detect fails, check to make sure you are running as root and that you are not running on a virtual machine. Then, get readings from the sensors with:
$ sensors
Reading sensors does not require root privileges.
bwm-ng
This program tracks the network bandwidth usage of your machine in real-time. It stands for bandwidth monitor, new generation.
$ sudo apt-get install bwm-ng
Thereafter, you can track the receive rate (Rx), the transmit rate (Tx), and the total bandwidth usage with:
$ bwm-ng
You can also track disk I/O with this program using the -i switch:
$ bwm-ng -i libstatdisk
Read man bwm-ng for more details.
tail -f
The tail -n [n] [file] command by itself prints the last n lines of file. It’s useful for quickly reading recent system logs.
The -f switch lets you follow a log file so that new log entries are printed to you as they are written to the log. This is useful for seeing system activity in real-time.
For example, follow a Rails application log with:
$ cd /[path to rails application]
$ tail -f log/production.log
You can also follow global system logs like the apache access log with:
$ sudo tail -f /var/log/apache2/access.log
tar
Copying a large number of files over ftp or sftp involves a lot of overhead because each file needs to be transferred and recreated separately.
The linux command tar creates archives that condense a large number of files into one. By default, each file is appended to the end of the previous one, with an archive roughly the total size of the original files.
To create an archive of a folder:
$ tar cvf [archive name] [folder 1] [folder 2] ..
The first switch c stands for create, the v stands for verbose output which lets you better see what is going on, and the f stands for filename and f must be the last switch in the list and must be followed by the archive’s name.
The standard file extension for tar files, known as tarballs, is .tar.
To enable compression on a tar archive with gzip, add the z switch. For example:
$ tar czvf backup.tgz public_html
Both the .tgz and the .tar.gz file extensions are used for gzip-compressed tarballs.
To read a preexisting archive, use:
$ tar tvf backup.tgz | less
The t switch stands for list. It is useful to add the | less to the end of this command so that you can scroll up and down the output, and so that it doesn’t crowd up your terminal, but it is not necessary.
You should always examine the contents of a tarball before extracting it to make sure that it contains what you are expecting.
To extract a tarball to the current directory, use:
$ tar xvf backup.tgz
To only extract a certain file or directory from a tarball, use:
$ tar xvf backup.tgz file-name
$ tar xvf backup.tgz folder-name
To extract to a different directory, use:
$ tar xvf backup.tgz -C /tmp
Or combine the previous two options:
$ tar xvf backup.tgz -C /tmp file-name
After you create a tarball, you can send it to any other linux computer and extract it.
It is also possible to tunnel the output of tar over ssh to another server and extract it immediately. Read man tar and man ssh for more information.
telnet
Originally, telnet [host address] was used to remotely administrate servers over a network, but it was extremely insecure and has been replaced with ssh.
Nonetheless, telnet is useful for quickly setting up TCP connections and testing out certain services. To connect to port 80 to test a web server, use the following:
$ telnet syntaxionist.rogerhub.com 80
Output similar to the following will appear:
Trying 50.116.11.45...
Connected to syntaxionist.rogerhub.com.
Escape character is '^]'.
You have a couple of seconds to type responses back to the server. If you wait too long, the connection will be automatically closed.
Request a web page with by typing the following:
GET / HTTP/1.1
Host: syntaxionist.rogerhub.com
[press the return key]
[press the return key again]
You will get a page full of HTML, and depending on the server, the connection will either close or stay open for another request.
Additionally, you can test SMTP servers using:
$ telnet smtp.gmail.com 25
Then, enter the following commands:
helo example
mail from: Person
data
To: example@gmail.com
From: person@example.com
Subject: Greetings!
Hello there.[press the return key]
[press the return key again]
.[press the return key]
quit
You can read more about the SMTP and the HTTP protocols elsewhere.
These examples show that telnet is useful for testing simple connections when a full-blown web browser or email client is too troublesome to install and configure.