Useful Linux commands & what do they do ?

Linux can be intimidating until you actually start using it. It makes you all cool using different commands on terminal and processing – I personally feel like a hacker or so !

I have tried to compile few linux commands in here. Hope you enjoy it . You can also refer to this book here.

But before that, keep in mind that sudo is used only for providing root permissions. So, if you are not inside / (root) , then you don’t need to add sudo in-front of commands. And I guess, you are familiar with basics like – cd, ls, ls -l, apt-get

Tip – To delete something, which you installed from apt-get install, you can uninstall it using:

sudo apt-get purge <softname>

  • Remove ( rm ) :


    For a file :

    rm <filename >

    In root : sudo rm <filename>

    For a folder:

rmdir <filename > ( To make a directory, you can do : mkdir <foldername>

          In root : sudo rm -r <foldername> / sudo rm -rf <foldername>

  • Copy ( cp ) :


    For a file :

    cp <filename/ file path> <destination path>

    In root : sudo cp <filename/ file path> <destination path>

    For a folder:

    (sudo ) cp -R <folder name/ folder path> <destination path>

  • tar.gz  :

    So many times, you must have downloaded tar.gz files, but have no idea what to do with them. In simple words, we can tar is basically winrar/winzip for terminal. It unzips the files containing onto a specified path( or same folder, if not specified ).

    Lets do a small tutorial on it – We will install java jdk(we all need it). Download the latest version from here. (download the tar.gz one accepting the agreement).

    Now you can extract it in : /usr/local/bin or /usr/bin , because mainly all are installed here. You now know how to copy it.

    Now you can extract the files there using:

    sudo tar xzvf <filename>.tar.gz

    It will extract all files in there.

Now but, we know what does tar do, but what does xzvf do ?

-x/–extract is always required as the first argument when extracting an archive.

“z” is used to “filter the archive through gzip ( you can “j” if you have tar.bz2 file)

“v” is for verbose, to display a list of files/directories involved.. and is probably just personal preference.

“f” is apparently the option to specify the archive file.

And that’s it, you have installed your jdk ! You can delete the tar.gz file to save space.

  • chmod +x ( change file mode bits ) :

You can type in : man chmod to check out the manual for chmod( yes, man – manual).

chmod +x on file makes it executable. You can refer to my how to install netbeans tutorial to learn how and where to use it.

Now chmod again have many arguments. chmod mainly takes :

  1.  u stands for user.
  2. g stands for group.
  3. o stands for others.
  4. a stands for all.

That means that chmod u+x <filename> will grant only the owner of that file execution permissions whereas chmod +x <filename> is the same as chmod a+x <filename>.

  • curl / wget :

In simple words, both are used to download files from the internet.

  1. wget – is a tool to download files from servers.
  2. curl – is a tool that let’s you exchange requests/responses with a server.

wget :



curl :

curl -O

using -O is important. Because otherwise, it just dumps all the files. Using -O, it downloads the files in the same name as the remote server. In the above example, we are downloading strx25-, so the downloaded file will also be the same name.

  • revert

Suppose you accidentally deleted a file, but you want it back. So, you can revert back your changes !

hg revert –all

or you made changes to a file, but you want the original file back! So,

hg revert <filename>

I suppose, this much would be enough for this post. But there are many other commands which you will learn eventually.








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