Basic Linux/Unix commands


In this tutorial we will have a look onto the most basic commands in Linux.
Most, if not all, of these commands will be compatible with all UNIX OS. However, depending on the version, the arguments used may change.

CD - Change Directory

The cd command is one of the most basic, but important ones. It allows you to change the directory you are in on your shell.

Let's say, I am in my personal directory (home) and I want to access my log files.

Therefore I change into the directory /var/log/ :

cd /var/log/

You have changed the directory.

LS - List the content of a directory

This command allows you to display all the contents of a directory.

Let's continue with the previous case: I want to see all available log files.

alternatives.log        alternatives.log.7.gz  apport.log.5.gz  auth.log.4.gz  dmesg.0        dpkg.log.3.gz  fontconfig.log   kern.log.3.gz          pm-powersave.log.4.gz  syslog.2.gz          upstart
alternatives.log.1      alternatives.log.8.gz  apport.log.6.gz  boot.log       dmesg.1.gz     dpkg.log.4.gz  fsck             kern.log.4.gz          pm-suspend.log         syslog.3.gz          wtmp
alternatives.log.10.gz  alternatives.log.9.gz  apport.log.7.gz  bootstrap.log  dmesg.2.gz     dpkg.log.5.gz  gpu-manager.log  lastlog                pm-suspend.log.1       syslog.4.gz          wtmp.1

We can also perform a ls on another folder:

ls /etc
To have a detailed view on the files type ls -l, often abbreviated with the command ll
rm - Deletion of folders and files

To delete data, we need the command rm.

rm myFile

To delete folders:

rm -r myFolder

This will remove recursively all content that is in the folder, and the folder itself

To force the deletion: rm -rf myFolder
Pay attention when using this command! A mistake can easily delete your critial data without asking for your confirmation!
man - The manpages

In Linux everything is documented!

If you want to know how a certain program works, or want to know all its possibilities, man will give you the answer.

The usage is pretty simple: man COMMAND

For example: man ls
Will display you all the details about the command to list the content of a folder.

nano - File editor

If you want to edit a text file using the command line, the most simple solution is the editor nano.

Example: nano myFile.txt

Once you have finished to edit your file, terminate nano by pressing the keys: CTRL + X

If you made any changes, you will be asked to save them.