\

ls Command With All Its Parameter In Linux

ls Command With All Its Parameter In Linux

In this tutorial we will see, ls Command With All Its Parameter In Linux


ls Command

ls command is one of the most frequently used command in Linux. I believe ls command is the first command you may use when you get into the command prompt of Linux Box.
We use ls command daily and frequently even though we may not aware and never use all the ls with parameters available. In this article, we’ll be discussing basic ls command where we have tried to cover as many parameters as possible.

 

Commands With Output

  • How To List All Files And Directories ?
ubuntu@ubuntu:~$ ls
demo1    Documents  geekstrick  Pictures  Templates
Desktop  Downloads  Music       Public    Videos

 

  • How To List All Files And Directories In Long Listing Format ?

ubuntu@ubuntu:~$ ls -l
total 0
-rw-r--r-- 1 ubuntu ubuntu  0 Jun 14 07:00 demo1
drwxr-xr-x 2 ubuntu ubuntu 80 Jun 14 06:38 Desktop
drwxr-xr-x 2 ubuntu ubuntu 40 Jun 14 06:41 Documents
drwxr-xr-x 2 ubuntu ubuntu 40 Jun 14 06:41 Downloads
-rw-r--r-- 1 ubuntu ubuntu  0 Jun 14 07:00 geekstrick
drwxr-xr-x 2 ubuntu ubuntu 40 Jun 14 06:41 Music
drwxr-xr-x 2 ubuntu ubuntu 40 Jun 14 06:41 Pictures
drwxr-xr-x 2 ubuntu ubuntu 40 Jun 14 06:41 Public
drwxr-xr-x 2 ubuntu ubuntu 40 Jun 14 06:41 Templates
drwxr-xr-x 2 ubuntu ubuntu 40 Jun 14 06:41 Videos

Columns above indicate specific things:

  1. Column 1 indicates information regarding file permission.
  2. Column 2 indicates a number of links to the file.
  3. Column 3 & 4 indicates owner and group information.
  4. Column 5 indicates size of the file in bytes.
  5. Column 6 shows date and time on which file was recently modified.
  6. Column 7 shows the file fie or directory name.

 

  • How To List All The Files Identifying Directories And Executable Files ?

ubuntu@ubuntu:~$ ls -f
.              Videos     .xsession-errors           Desktop
..             Pictures   .dbus                      .profile
geekstrick     Music      .Xauthority                .bashrc
demo1          Documents  .sudo_as_admin_successful  .bash_logout
.mozilla       Public     .cache
.gconf         Templates  .local
.ICEauthority  Downloads  .config

 

  • How To List Recursive List Of Files And Directories ?

ubuntu@ubuntu:~$ ls -R
.:
demo1    Documents  geekstrick  Pictures  Templates
Desktop  Downloads  Music       Public    Videos
./Desktop:
examples.desktop  ubiquity.desktop
./Documents:

./Downloads:

./Music:

./Pictures:

./Public:

./Templates:

./Videos:

 

  • How To Give The File Listing In Reverse Order ?

ubuntu@ubuntu:~$ ls -r
Videos     Public    Music       Downloads  Desktop
Templates  Pictures  geekstrick  Documents  demo1

 

  • How To Give Listing Of All Files And Directories In Multi Column Format ?

ubuntu@ubuntu:~$ ls -L
demo1    Documents  geekstrick  Pictures  Templates
Desktop  Downloads  Music       Public    Videos

 

  • How To List All The File Names Sorted By Last Modification time ?

ubuntu@ubuntu:~$ ls -t
geekstrick  Documents  Music     Public     Videos
demo1       Downloads  Pictures  Templates  Desktop

 

  • How To Display All Files Sorted According To The Extension ?

ubuntu@ubuntu:~$ ls -X
demo1    Documents  geekstrick  Pictures  Templates
Desktop  Downloads  Music       Public    Videos

 

  • How To Display All Files Sorted According To The Extension In Reverse Order ?

ubuntu@ubuntu:~$ ls -rX
Videos     Public    Music       Downloads  Desktop
Templates  Pictures  geekstrick  Documents  demo1

 

  • How To display All Files Sorted According To The Modification Time In Reverse ?

ubuntu@ubuntu:~$ ls -tr
Desktop  Templates  Pictures  Downloads  demo1
Videos   Public     Music     Documents  geekstrick

 

  • How To Display Detailed Listing Including Hidden Files Sorted In Reverse Order ?

ubuntu@ubuntu:~$ ls -lar
total 24
-rw-------  1 ubuntu ubuntu 3769 Jun 14 06:42 .xsession-errors
-rw-------  1 ubuntu ubuntu   51 Jun 14 06:41 .Xauthority
-rw-r--r--  1 ubuntu ubuntu    0 Jun 14 07:00 geekstrick
drwx------  2 ubuntu ubuntu   40 Jun 14 06:44 .gconf
-rw-r--r--  1 ubuntu ubuntu    0 Jun 14 07:00 demo1
.
.
.
drwx------ 12 ubuntu ubuntu  260 Jun 14 06:43 .cache
-rw-r--r--  1 ubuntu ubuntu 3771 Jun 14 06:38 .bashrc
-rw-r--r--  1 ubuntu ubuntu  220 Jun 14 06:38 .bash_logout
drwxr-xr-x  3 root   root     60 Jun 14 06:38 ..
drwxr-xr-x 16 ubuntu ubuntu  500 Jun 14 07:00 .

 

  • How To List The Content Of Any Directory ? (e.x. geekstrick)

ubuntu@ubuntu:~$ ls geekstrick
geekstrick

 

  • How To List All Files Name With One Source At A Time ?

ubuntu@ubuntu:~$ ls |more
demo1
Desktop
Documents
Downloads
geekstrick
Music
Pictures
Public
Templates
Videos

 

  • How To List All Files Name With five Character ?

ubuntu@ubuntu:~$ ls ?????
demo1

Music:

Note : Number Of question Mark are equals to number of character.

 

  • How To List All File Name Starting With Uppercase Letter ‘D’ ?

ubuntu@ubuntu:~$ ls D*
Desktop:
examples.desktop  ubiquity.desktop

Documents:

Downloads:

Note : You can search with any character lowercase or uppercase. If you want to search with the last character then type $ ls *a

 

  • How To List All File Name Starting With Vowels ?

ubuntu@ubuntu:~$ ls [a,e,i,o,u]*
apple  eagleView  iphone  operator  ubuntu

Note : It just search the block of array from the directory. You can set the Lowercase and uppercase latter to search because it is case sensitive.

 

  • How To List All The File Name In Which First Character Is An Uppercase Letter And Second Character Is A Digit ?

ubuntu@ubuntu:~$ ls [A-Z][0-9]*
A324114

 

  • How To List All File Name Whose First Character Is Any Thing Or Then A Small Case Letter Vowel ?

ubuntu@ubuntu:~$ ls [^a,e,i,o,u]*
A324114  demo1  geekstrick
Desktop:
examples.desktop  ubiquity.desktop

Documents:

Downloads:

Music:

Pictures:

Public:

Templates:

Videos:

About This Author

Hi This Is Rehmaanali. Blogging Is Just A Hobby. Graduate In Bsc Computer Science

Post A Reply