The ls command is one of the most frequently used commands in Linux. It is used to list the contents of a directory.
This primer will walk you through the basics of using it and some of its most useful options.
Basic Usage
To use the ls command in its simplest form, open a terminal and type:
This will display a list of files and directories in your current working directory.

Common Options
List all files, including hidden ones:
This shows all files, including those that start with a dot (.), which are usually hidden.

Display detailed information:
This shows a long listing format, including file permissions, number of links, owner, group, size, and timestamp.

Combine options:

This combines the above two options, showing all files in long listing format.
Display file sizes in human-readable format:
This shows file sizes in KB, MB, GB as appropriate, instead of in bytes.

List subdirectories recursively:
This lists the contents of directories recursively.

Advanced Usage
List files of a specific type:
This lists all files ending with .txt in the current directory.

List files in reverse order:

This reverses the order of the sort.
List directories only:
This lists only the directories in the current folder.

Pro Tips
You can combine multiple options like:
This lists all files and directories, including hidden ones, in human-readable format, sorted by time (newest first).

Man page for ls
As always with most Linux commands, refer to man ls to access the full manual for the ‘ls’ command.

All done.