DEV Community

mahir dasare
mahir dasare

Posted on

1

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

AWS Q Developer image

Your AI Code Assistant

Implement features, document your code, or refactor your projects.
Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay