Linux is very essential when you are entering an IT industry.  Linux commands makes our tasks very easy to work efficiently with terminals but those also makes your work faster.  e.g. copying a big file or folder from one location to another may take more time with graphic UI but its very fast and easy with the command.

Another simple usage could be like you want to delete multiple files starting with some name or ending with some extension, that is also very quick with the terminal commands.  So, lets dive into the article and learn about some of the useful Linux commands, by the way most of these are similar to mac terminal commands.

1) pwd : Present Working Directory

This command is useful to know where you are in the system.  Let’s say in windows we know when we click on downloads folder of C:drive then we are in downloads folder.  To know the location in Linux we just hit pwd command and it’ll show our present location, which we can copy also if we need it.

2) mkdir : Creating a directory

(itfreesourcetutorial)$ mkdir   ItFreeSourceTutorial
mkdir: cannot create directory ‘ItFreeSourceTutorial’: Permission denied

In above execution we got error because most of the Linux distributions requires super user approval for doing most of the tasks.  So for creating the directory we need to use sudo keyword which will let us execute the command.

$ signs shows that we are not a superuser.  It shows # command for a super user.  Please find following commands.

cloudshell:/home (itfreesourcetutorial)$ sudo mkdir TutorialsDirectory
cloudshell:/home (itfreesourcetutorial)$

3) ls : list everything without line breaks.

It shows all the content of the directory except hidden files and folders (starting with a . ).  To get those also, you need to you  -a in front of ls command.

cloudshell:/home (itfreesourcetutorial)$ ls
ItFreeSourceTutorial    lost+found    TutorialsDirectory

cloudshell:/home (itfreesourcetutorial)$ ls   -a
. .bashrc_sample lost+found .someHiddenDir TutorialsDirectory
.. ItFreeSourceTutorial  .someHiddenFile

The way -a in front of ls shows the hidden directories, in the same way -l   (L) shows all the files in list format and if used with -a shows all the files including hidden in list format.

cloudshell:/home (itfreesourcetutorial)$ ls   -al
total 40
drwxr-xr-x 7 root root 4096 Sep 25 10:49 .
drwxr-xr-x 1 root root 4096 Sep 25 10:06 ..
-rw-r–r– 1 root root 0 Sep 25 10:48 .bashrc_sample
drwxr-xr-x 2 root root 4096 Sep 25 10:08 ItFreeSourceTutorial
drwx—— 2 root root 16384 Mar 25 2015 lost+found
drwxr-xr-x   6    someOwnerUser    someOwnerGroup    4096    Sep 25 10:07    someDirectoryName
drwxr-xr-x 2 root root 4096 Sep 25 10:49 .someHiddenDir
-rw-r–r– 1 root root 0 Sep 25 10:48 .someHiddenFile
drwxr-xr-x 2 root root 4096 Sep 25 10:11 TutorialsDirectory
cloudshell:/home (itfreesourcetutorial)$

Similarly, ls -r shows everything in reverse order, ls -t shows the modified time, so if used ls -lrta then it lists all the files including hidden in reverse order with a latest modification in file or folder.  (one of the commonly used command).

You may use, -h with above one to get the size of the file and directories in human readable format like KB, MB or GB etc.

Important Notes:

A. In above output the first part shows the permissions which are allotted to that particular file or file.  Also its good to know that the . (dot) denotes current directory, we will learn its use in following commands and the .. (double dot) denotes previous directory.

B. You might have seen many fields after listing with ls e.g. above highlighted line with someOwnerUser name in it.  Here, we are going to understand them; very important of them are permissions, owner and group it belongs to.

Let’s execute ls -l then it shows as follows:

drwxr-xr-x   6    someOwnerUser    someOwnerGroup    4096    Sep 25 10:07    someDirectoryName

and if I use ls -lh then it shows like this

drwxr-xr-x   6    someOwnerUser    someOwnerGroup    4.0K    Sep 25 10:07    someDirectoryName

The only difference in both the outputs is because of -h which shows the size you can also use df -h to show the size etc.  But here, the difference is of the way the size is being shown.  In the first one it has been shown in Bytes form and in the second one it has been converted to next possible and easily readable conversion i.e. Kilobytes (KB).  However, if you want to know the details of any of the linux commands you just use man cmd-name and it will show the details e.g. man ls.

Explanation of the fields of above output will be given in part 2 of this Linux commands sequence.  Keep visiting IT Free Source for more  content like this.  Kindly visit Aptitude Section from IAS EasyWay for learning basic aptitude in an EasyWay if you are preparing for fresher jobs in IT or share with your friends preparing for government jobs.

Do ask your any kind of queries and we’ll try to provide an optimal solution for it with a roadmap.  Here, we will cover variety of topics like MBA subjects and help in its assignments of common subjects for multiple streams, IT topics like Computer Programming, latest tools and technologies that are being used in the industry and cyber security etc.  Following our website’s content you’ll get proper guidance for securing the job in IT industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 2022 - 2024 itfreesource.com