ls (List Directory Contents) Command

Used to see the files and sub-directories of the directory it’s in. If the specific name of the file or the directory isn’t defined on the command prompt, its shows the current directory you’re in. It lists the directories in alphabetical order as standard.

ls Command

You can use some options with the ls command. These are:

-a: Shows all the files including hidden ones. (They start with “.”)

Here is an example:

-l: Lists with more information.

Here is an example:

-R: Starting from the directory you’re currently in, lists untill the bottom.

Here is an example:

To list the hidden files with more information, you can use -a and -l commands  together. If there is no specific file you want to look for, you can combine them.

-a and -l combined using:

You can also use this command with a specific file name. As example, to list the png files in the user’s “Documents” file, ls -al /home/delosemre/delosemre-kernelblog/*.png command will be enough. With this all the png files in the directory will be in list.

Example:

Leave a Reply

Your email address will not be published. Required fields are marked *