linux ls command

Reading Time: 2 minutes

The basic syntax of the LS command is as follows:

ls [option] [path_to_file/directory]

The LS -l command lists files and directories together with additional information like permissions, owner, date of creation, etc. Let’s look at the image below before getting to every column and data presented.

ls -l

A common variation is the ls -ltr. It is used with file name or pattern. to show the latest modified files or directories in order. The latest modified is listed as the last while the oldest outputted as the first. Take a look at the image below.

This listing provides permissions, file modified date, user name, size, etc.

Unlike the ls -l command alone, which lists the size of files in bytes only, the ls -lh command will show the exact size in bytes(b), kilobytes(kb), megabytes(MB), etc.

You can also sort your files by size using the ls -las command. The most extensive file will be displayed first while the smallest last.

ls -laS