Linux ls command
The ls is the list command in Linux. It will show the full list or content of your directory. Just type ls and press the enter key. The whole content will be shown.
Below, you can see, after entering ls command, we got the whole content list of /home/sssit directory.
Linux ls command options
Linux ls -a command
It will give you the whole list of a directory including the hidden files also. In Linux, hidden files start with a dot (.) and can't be seen in the regular directory.
In the above example, you can see the whole list of files, including the hidden files.
Linux ls -l command
The ls command will only display the files. But if you want your files to be displayed in a long list format, then you can use ls -l command.
Here, as you can see the list in long list format.
Columns above indicate specific things:
Linux ls -l --block-size=[SIZE]
If you want to display the file size of your list in a particular format or size, then you can use this command. Just put the size in place of [SIZE] as per your requirement.
Let's see the output below.
Here, all file size has listed in Megabyte.
You can replace [SIZE] with the following measures:
Linux ls -d */
If you only want to display the sub-directories excluding all other files, you can use this command.
The above result only shows sub-directories excluding all the other files.
Linux ls -g
If you don't want to display the owner information in your list, then you can exclude this column with the help of this command.
Here owner column is excluded.
Linux ls -lG
If you don't want to display the group information in your list then you can exclude this column with the help of this command.
Here group column is excluded.
Linux ls --color=[VALUE]
This command is used to colorize and decolorize the list. If you replace the [VALUE] by 'auto', it will display the colored list. But, if you will replace the [VALUE] by 'never', it will decolorize the list.
You can easily notice the difference between auto and never command in the above image.
Linux ls ~
Linux ls ~ command shows the contents of the home directory. Let us see the example of ls ~ command.
Linux ls ../
This command contains the list of the parent directory.
In the given example, our current directory is Downloads, and by using ls ../ command, we have listed out the content of its parent directory "home directory".