ls command – How to List Files and Directories in Linux ?

Spread the love

ls command –

The ls command looks at the directory you are in and list all the files and directories inside of it. Be sure to type the letter l as in “List” and not the number 1.

In the terminal, the first thing you see is $. This is called a shell prompt. It appears when the terminal is ready to accept a command.

If I type


the terminal would display our current directory’s files and directories.

Let’s say you want to know what’s inside the lwd directory without actually going into it. For that you have to type.

ls lwd

To know what under data folder, I can write

ls lwd/data/

At this moment my location is this.


I am inside the workspace directory.

If I want to what inside Asus, one directory above of it or I want to list the contents of the parent directory, I can type ls followed by space then two dots.

ls ..

If you want to know what inside the parent of the parent directory means two steps above me, you will write

ls ../..

Options in ls command –

There are various options that you can use with the ls command. Let’s look couple of them.

Show hidden files –

To show hidden files along with all the files and directories, we use the -a flag with ls

ls -a

Show files and directories in long format –

To show the files and directories in the long format we use the -l flag (l for List).

ls -l

The Long Format shows various information about files and directories like who created it , when created it, the size of the files and directories and the kind of rights we have related to these files.

Getting Help with ls –

To learn more about ls command and other options that we have, please type the following command in your terminal.

man ls 

Rating: 1 out of 5.

Leave a Reply