Linux how to

Below command have been tested on Ubuntu OS.
Remove a directory:
rmdir python

Remove a non empty directory:
rm -rf pythonscripts

To reach to your home directory:
cd ~

To create a path shortcut in linux:
Create a global variable:
export variablename=”path”
Use in the command for example:
cd $variablename

To check global variable:


To extract the tar file use following command:
tar -xf

To extract file to a new directory use following command:
mkdir techsupport && tar -xf techsupport.tgz -C techsupport

Search pattern with grep:
grep “pattern to search”

Show few line after the matched pattern:
grep -A “pattern to search”
grep -A4 “:packet” monitor.log

Search all file inside a directory and sub directory:
grep-R “pattern to search” *

To get list of installed software:
dpkg -l

To check the version of a software:
dpkg -l syslog-ng

To uninstall one software:
apt-get –purge remove

To check if a software is installed or not:
apt-cache policy openssl

To find a directory/file name in linux:
find / -name Desktop

To check Linux is listening on which ports:

To get folder size:

du -sh /var/

To get disk space:

df -h

To get file system type:

df -T

To get all folder size:


To capture traffic using tcpdump:

tcpdump -i any host and  port 18184

Root password: By default ubuntu root password is not set. You need to set the root password use following command to set root password

sudo passwd root
This entry was posted in Linux and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s