In Linux command line interface you need to enter ls command to view directory contents. It is the most frequently used command by Linux users. ls command will display present working directory contents if run without giving any argument.


Syntax of ls:

$ ls [options] [file|dir]

See Example:

ls command without argument
ls command without argument

Image is showing, the first command was cd for change directory and then I enter ls command to view the content of /tmp/LinuxBasics directory. In the next orange block you can see the result showing this directory contains some text files.

Now let’s take another example, if you want to see content of directory which is not your present directory, in this case can either specify its name (if its subdirectory) or specify full path (if it’s not your present working directory).

Suppose I have directory called /tmp/RHCE and my current location is /tmp/LinuxBasics (Hint: use pwd command to know your present working directory), in this case I will use:

ls /tmp/RHCE

ls command with complete path
ls command with complete path

Graphical example is giving clear understanding to view any other directory contents which is not your present working directory.

The same command you can use with the arguments but the result will be different.

See table below

Command Explanation

ls -a: List all directories and files including hidden files starting with (.).

ls -l: show list with long format with more details such as permissions, size and time stamp etc.

ls -la: To show long format including hidden files.

ls -lh: long list format with human readable file size.

ls -ls: long content view list format with file size.

Linux is all about practice, nobody become expert in over night. so It is recommended for all learners, practice these commands one by one.

please leave comment if you need any help and don’t forget to say thanks.

Next: How to View File Contents in Linux

If you like this Post, please give us your valuable feedback by pressing Vote Up / Vote Down Button. Thanks.


Similar Posts