Linux Terminal Listing-related (ls) Commands

The ls stands for "listing", ls command lists the files and directories. It is commonly used command in linux.

The following are the Linux terminal listing-related (ls) commands:

  1. ls
  2. ls --version
  3. ls -l
  4. ls -a
  5. ls -h and ls-lh
  6. ls -F
  7. ls -r
  8. ls -R
  9. ls -lt
  10. ls -lS
  11. ls -i
  12. ls -n

1. ls

Without any options, ls displays list of files and directories in bare format. You can not get size, access options etc.

Example

ih@linux:~$ ls
dir1  dir2  ok.txt  ok1.txt

2. ls --version

This option shows the linux ls command version.

Example

ih@linux:~$ ls --version
ls (GNU coreutils) 8.23
Packaged by Cygwin (8.23-4)
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Richard M. Stallman and David MacKenzie.

3. ls -l

This option displays files and directories with size, modified date and time, access permission and owner’s name.

Example

ih@linux:~$ ls -l
total 1
drwxr-xr-x+ 1 ih None   0 Apr  4 21:03 dir1
drwxr-xr-x+ 1 ih None   0 Apr  4 21:04 dir2
-rw-r--r--  1 ih None 128 Apr  4 01:05 ok.txt
-rw-r--r--  1 ih None   0 Apr  4 20:49 ok1.txt

4. ls- a

This option shows the all files & directories including hidden files and directories.

Example

ih@linux:~$ ls -a
.   .bash_history  .bashrc   .profile  dir2    ok1.txt
..  .bash_profile  .inputrc  dir1      ok.txt

5. ls -h and ls-lh

These options show the all files & directories in human readable format.

Example

ih@linux:~$  ls -h
dir1  dir2  ok.txt  ok1.txt

ih@linux:~$  ls -lh
total 1.0K
drwxr-xr-x+ 1 ih None   0 Apr  4 21:03 dir1
drwxr-xr-x+ 1 ih None   0 Apr  4 21:04 dir2
-rw-r--r--  1 ih None 128 Apr  4 01:05 ok.txt
-rw-r--r--  1 ih None   0 Apr  4 20:49 ok1.txt

6. ls -F

This option shows the all directories with "/" character. So that you can easily understand which directory and which is file.

Example

ih@linux:~$ ls -F
dir1/  dir2/  ok.txt  ok1.txt

7. ls -r

This option shows the list of all files and directories in reverse order.

Example

ih@linux:~$ ls -r
ok1.txt  ok.txt  dir2  dir1

8. ls -R

This option shows the list of all files and directories in tree format.

Example

ih@linux:~$ ls -R
.:
dir1  dir2  ok.txt  ok1.txt

./dir1:
f1  f2

./dir2:
f3  f4

9. ls -lt

This option is used to display latest modified (according to date & time) files and directories in reverse order.

Example

ih@linux:~$  ls -lt
total 1
drwxr-xr-x+ 1 Mike None   0 Apr  4 21:21 dir2
drwxr-xr-x+ 1 Mike None   0 Apr  4 21:21 dir1
-rw-r--r--  1 Mike None   0 Apr  4 20:49 ok1.txt
-rw-r--r--  1 Mike None 128 Apr  4 01:05 ok.txt

10. ls -lS

This option shows the files and directories sorted according to size.

Example

ih@linux:~$ ls -lS
total 1
-rw-r--r--  1 Mike None 128 Apr  4 01:05 ok.txt
drwxr-xr-x+ 1 Mike None   0 Apr  4 21:21 dir1
drwxr-xr-x+ 1 Mike None   0 Apr  4 21:21 dir2
-rw-r--r--  1 Mike None   0 Apr  4 20:49 ok1.txt

11. ls -i

This option shows the files and directories with inode (indexing) number before files and directories name.

Example

ih@linux:~$ ls -i
11258999068648575 dir1  17451448556084649 ok.txt
5910974511146142 dir2   9007199254962677 ok1.txt

12. ls -n

This option shows files and directories with numeric UIDs, GIDs number.

Example

ih@linux:~$ ls -n
total 1
drwxr-xr-x+ 1 197609 197121   0 Apr  4 21:21 dir1
drwxr-xr-x+ 1 197609 197121   0 Apr  4 21:21 dir2
-rw-r--r--  1 197609 197121 128 Apr  4 01:05 ok.txt
-rw-r--r--  1 197609 197121   0 Apr  4 20:49 ok1.txt

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.