Linux (Ubuntu) useful commands

Most of this will work on any Linux distribution, but some commands are Ubuntu Linux specific.

Get Ubuntu server version:

cat /etc/lsb-release

 Empty Ubuntu Gnome Trash from the Command Line:

rm -rf ~/.Trash/*

Kill user’s processes and logout the user:

sudo pkill -u username

 extract tar / tar.gz files:

To only extract .tar files:

tar xvf archivename.tar

Most of the time, however the archive will probably will be in gzip format as well (tar.gz) so to extract this you can use:

tar xvfz archivename.tar.gz

to extract only some items:

tar xvzf archivename.tar.gz */*

if you encountered with the bz2 extension then you need bzip2 (usually installed) program and this command:

tar yxf archivename.tar.bz2

Change file mode

You need to use the chmod command:

unzip or zip a file:

For this the zip and unzip utilities are the best.

apt-get install zip unzip -y
unzip [archive]