25 Practical 'ls' Command Examples in Linux

'ls' is a frequently used command in Linux. In this article, I am showing you the usage of 25 practical 'ls' command examples in Linux. I am using the Ubuntu operating system for demonstration although the same commands you can use on any Linux flavor operating system. Click Here if you want to know the Top 25 Linux Commands for Beginners.



Help options

(1) Basic Usage of 'ls' command - list files and directories


(2) View hidden files including . and ..

#ls -a

(3) View details of files and directories

$ls -l

(4) View file details and hidden files both

$ls -la

(5) View sub-directories available in directory

$ls *

(6) Append / to all directories

$ls -F

(7) List particular directory


(8) Details of files and directories with time

$ls -la

(9) View files and directories with full path

$ls -d $PWD/*

(10) View all the files and directories recursively

$ls -R

(11) View UID and GID of files and directories

$ls -n

(12) View all files and directories under quotes

$ls -lQ

(13) List one file/directory per line

$ls -1

(14) List files and directories with index number

$ls -i

(15) List files and directories with allocated size

$ls -s

(16) List files in reverse order

$ls -r

(17) List out root directory

$ls /

(18) List out parent directory

$ls ..

(19) View only text file by using wild card

$ls *.txt

(20) Print version of ls command

$ls --version

(21) Print content of home directory

$ls ~

(22) Display size of file in desired format

$ls -l --block-size=K
Use below options for block size
K -> Kilobyt
M -> Megabyte
G -> Gigabyte
T -> Terabyte
P -> Petabyte
E -> Exabyte
Z -> Zettabyte
Y -> Yottabyte

(23) List out details of files and directories but exclude owner information

$ls -g

(24) List out details of files and directories but exclude group information

$ls -lG

(25) List out output without any color coding

$ls --color=never


"ls" is an awesome one-liner command. If you are using any Linux flavor operating system, you have already used some of the commands mentioned above.

Do let me know in comments if you have used any other command with "ls".

Subscribe us to receive more such articles updates in your email.

If you have any questions, feel free to ask in the comments section below. Nothing gives me greater joy than helping my readers!

Disclaimer: This tutorial is for educational purpose only. Individual is solely responsible for any illegal act.

You may also like...

1 Response

  1. venkat says:


    Good and very useful information about list command. Every option is explained well and easy to understand.

Leave a Reply

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