send a mail in command line in Ubuntu

Reading Time: < 1 minute By default the binary "mail" is not installed on Ubuntu. At least it’s not on my brand new Ubuntu 10.10.
You need to setup the package mailutils.

apt-get install mailutils

Then you can send an email using the command line:

ls | mail blabla@gmail.com

How to follow the progress of a gzip or tar

Reading Time: < 1 minute

First you need pv, Pipe Viewer

[bash]$ apt-get install pv
[bash]$ SIZE=`du -sk some-folder | cut -f 1`
[bash]$ tar cvf - some-folder | pv -p -s ${SIZE}k | gzip -c > folder.tar.bz2

extract one file from a tar.gz

Reading Time: < 1 minuteYou can simply use the following syntax:

[root@blub ~]# tar tzvf mytar.tar.gz
That will show you the list of files in the tar. t means test
 
[root@blub ~]# tar tzvf mytar.tar.gz myfile.txt
 -rw-rw-r-- scm/scm 373093723 2010-09-17 17:58:21 myfile.txt
You can do the same with a target file and test that one specific file really belong to a tar.gz

Finally you can extract that single file.

How to check if Virtualization is supported for your CPU

Reading Time: < 1 minute

Many ways
1. Use the following command:

Make a virtual machine out of a G4L archive

Reading Time: < 1 minuteSo I took a backup of a disk using G4L.
Let’s import it into a virtual machine on a RedHat running Xen.

virt-install --import --file <myfile> --prompt

answer the few questions.
Choose "Fully Virtualized".
Turn the SELinux into permissive mode in order to configure the network. This is a known bug and it looks like it’s not corrected yet.

setenforce Permissive

Once the import is done your virtual machine should pop and boot properly.

 

Transfer a very big file very fast

Reading Time: < 1 minute

ssh server "gzip -c remote_file " |gunzip > local_file

Secure connection without a password

Reading Time: < 1 minute

There are numbers of tutorials on the net on how to configure access from one machine to another without typing a password.
Here is the real way to do it.
First generate a pair of keys:

ssh-keygen -t rsa 

It’s important to choose a passphrase. Don’t leave it blank.
Then you need to copy the public key to the other server

ssh-copy-id -i .ssh/id_rsa.pub>

Make sure that ssh-agent is running.
Add a key using ssh-add

ssh-add

Try connecting
Should be working.

get the console from a VT

Reading Time: < 1 minute

xterm -C

opens an xterm with console messages

finding a file in a bunch of rpm

Reading Time: < 1 minuteSometimes it can be hard to resolve a dependency with rpms.

rpm -qpl *

will show the list of all the files installed with a list of rpm in the running directory.

rpm -qpl * | grep libcc

will show me the files that resolve a specific dependency.

Work with man pages

Reading Time: < 1 minute Finding more information with man pages
man -a intro (and press q)
shows the list of man books:
1 – introduction to user commands
2 – system calls
3 – library functions
4 – special files
5 – file formats
6 – games
7 – overview, conventions, and miscellany section
8 – administration and privileged commands