DEV Community

mahir dasare
mahir dasare

Posted on

Linux “ls” Command RHEL 9

  1. List files using ls with no option

ls with no option list files and directories in a bare format where we won’t be able to view
details like file types, size, modified date and time, permission and links etc.
ls

  1. List Files with option -l

Here, ls -l (-l is a character not one) shows file or directory, size, modified date and time, file
or folder name and owner of the file and its permission.
ls -l

  1. View Hidden Files

List all files including hidden files starting with “ls -a”.
ls -a

  1. List Files with Human Readable Format with option -lh

With a combination of -lh option, it shows sizes in a human-readable format.
ls -lh

  1. List Files and Directories with ‘/’ Character at the end

Using -F option with ls command will add the ‘/’ Character at the end of each directory.
ls -F

  1. List Files in Reverse Order

The following command with ls -r option displays files and directories in reverse order.
ls -r

  1. Recursively list Subdirectories

ls -R option will list very long listing directory trees. See an example of the output of the
command.
ls -R

  1. Reverse Output Order

With the combination of -ltr it will show the latest modification file or directory date as last.
ls -ltr
ls -ltra

  1. Sort Files by File Size

With the combination of -lS displays file size in order, it will display big at first.
ls -lS
ls -lSa

  1. The display Inode number of File or Directory

We can see some numbers printed before the file/directory name. With -i options list
file/directory with an inode number.
ls -ia

Top comments (0)