ls command in linux




In this blog we will learn about ls command . ls is a linux shell command that lists directory .
First of all lets open our terminal , We can press ctrl+alt+ t to do this .ls command can be given by just writing ls on the eterminal but it has some options so these options will come in as a second argument  .
ls command comes with options first and then files and directory . ls [options][fd] . We are going to look at these here in details.

  1. first of all simple ls command will lists the content of a directory in the following way . Command : $ls

2.Now the second option of ls command is by using a directory name .Say we want to list all the files of documents directory . We can type : $ ls Documents

3.If you want to list out all the contents of our root folder , type : $ls / .

4.If you want to list out all the contents of our root folder , type : $ls ~

5.If you want to list out all the contents of one step back directory you can type : $ls ..

In the screenshot it is actually all the contents of one step back directory.

5.If you want to list out all the contents of two step back directory you can type : $ls ../..

6.To list out all the contents in long form simply type : $ ls -l

long format means it will give you the details so who is your user what are the rights for this file and what is the size of your file and at which date this file was created and the time that which this file is created

7.Now there is one more command which is $ls - a and this will give you the hidden files also .Then you can combines the option so whenever you give ls – a for showing the hidden file and then l for showing the long list then it will give you the hidden file and long list combined combined .Command look like this : $ls -al

8.Now there are some more commands for example you can sort your directory by their size so just give $ls - l for long list and then when you give capital S it will sort your directory by their size so press enter and you can see the file which has the biggest sizeis listed first and then they will go down as according to the size .Command : $ ls -lS

9.Now say I want to only list out all the pdf files which are there in the document folder , Command to do this will be : $ ls Documents/*.pdf

10 . We can list out only directories also , To do this simply type : $ls -d */

11.To know more about this ls command you can just write man , Command : $ man ls . man is dictionary kind of a thing for your Linux commands .It will giveyou all the options which you can use with ls .

This is all about ls command .


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com





Be the first to comment

Leave a Reply

Your email address will not be published.


*