How to use “ls” command in Linux
In this article we are learn to use ‘ls’ commands with the help of these command we are able to list directory contents. For the users & administrators ‘ls’ is one of the most frequently used command in Linux.
We use ‘ls’ command on daily basis and frequently even though we may not aware and never use all the ls option available. In this article, we’ll be discussing basic ‘ls’ command where we have tried to cover as much parameters as possible.
1. List Files using “ls” with no option
“ls” with no option list files and directories in bare format where we won’t be able to view details like file types, size, modified date and time, permission and links etc.
2. List Files by using “ls -l”
Here, “ls -l” shows file or directory, size, modified date and time, file or folder name and owner of file and it’s permission.
3. List Hidden Files by using “ls -a”
“ls -a” that command Lists all the files including hidden file & starting with extension ‘.’
4. List Files with Human Readable Format by using “ls -lh”
By using -lh option with listing command ‘ls’, It shows sizes in human readable format.
5. List Files with “ls -F” and see Directories with ‘/’ Character at the end
By using “ls” with -F option , will add the ‘/’ Character at the end each directory.
6. List Files in Reverse Order by using “ls -r”
By using “ls” with option -r, It display files and directories in reverse order.
7. List Sub-Directories Recursively by using command “ls -R”
By using “ls’ with -R option will list very long listing directory trees. See an example of output of the command
8. List Reverse Output Order by using command “ls -ltr”
By using combination of -ltr with ‘ls’ , will shows latest modification file or directory date as last.
9. List files by File Size by using “ls -LS”
By using combination of -lS with “ls” , will displays file size in order, will display big in size first.
10. List display Inode number of File or Directory by using “ls -i”
In regular way we can see some number printed before file “/ ” directory name. By option -i options list file “/” directory with inode number.
11. Shows version by using command “ls –version”
By using “ls –version” command helps to check the version.
12. Show Help Page by using command “ls –help”
By using “ls –help” shows the help option.
13. List Directory Information by using command “ls -l / tmp”
With ls -l command list files under directory /tmp. Wherein with “-ld“parameters displays information of /tmp directory
14. Display UID and GID of Files
By use option “-n” with ls command, It display UID and GID of files and directories.
From all these commands user are easily access and knowing about the listing of directories in different in Linux operating system.