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.
$ls [OPTIONS] [FILE|DIRECTORY]
(1) Basic Usage of 'ls' command - list files and directories
(2) View hidden files including . and ..
(3) View details of files and directories
(4) View file details and hidden files both
(5) View sub-directories available in directory
(6) Append / to all directories
(7) List particular directory
$ls -l [DIRECTORY-PATH/]
(8) Details of files and directories with time
(9) View files and directories with full path
$ls -d $PWD/*
(10) View all the files and directories recursively
(11) View UID and GID of files and directories
(12) View all files and directories under quotes
(13) List one file/directory per line
(14) List files and directories with index number
(15) List files and directories with allocated size
(16) List files in reverse order
(17) List out root directory
(18) List out parent directory
(19) View only text file by using wild card
(20) Print version of ls command
(21) Print content of home directory
(22) Display size of file in desired format
--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
(24) List out details of files and directories but exclude group information
(25) List out output without any color coding
"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.