Table of Contents
In Linux Course and in real life works, we will work on files too much. So, we will use linux ls command very often. So, why we use linux ls command? What are Linux ls options? In this lesson, we will learn Linux ls options one by one.
Firstly, let’s answer the first question, why we use Linux ls command. We use ls command in Linux to list files. With different options, we can do this listing in different variations. In this lesson, we will talk about these options. In another lesson, we have talked about user listing in Linux . You can also check it.
You can use ls command without any parameter. When you use ls option without any parameter, you can list the files within the current directory. For example, if you are under root directory (/) and you use Linux ls command without any option, then you can list the files under root directory (/).
For more Linux Command, you can check also Linux Cheat Sheet!
To list the files under the current directory detailly, we use linux ls -l option. With linux ls -l option, all the files under the current directory are listed with their details. So, what are these file details. These are:
You can also watch the video of this Linux ls options lesson!
There are some files that are hidden in Linux. When you use ls without -a option, these hidden files are not listed. But if you would like to see linux ls hidden files also, you can use linux ls -a command. To show you this option better, we will use this option with -l option as ls -la. The files which start with dot (.), is an hidden file.
If you would like to list the files according to their modified date, you can use ls -t option. When you use ls with -t option, the files under that directory will be listed according to their modified date. And last modified file will be at the top. Again, we will use this option with -l option as ls -lt.
Another Linux ls command option is “h”. When we use h option, this converts the listing to human readable format. For example, the size of the files become easier to read. We use this option, with -l option together, as -lh.
To list files in the decending order, we use linux ls -lS option. This command will list our files in the decending order under the current directory. In other words, the largest file will be at the top. Here, there is a key point! The “S” is capital S.
To learn all the Linux ls options that can be used with ls, you can use ls –help command. Below, you can find the output of ls –help command.
You can use this command with “more” to see option page by page.
Or you can use only ls –help command to see the page completely.