Hosting or Servers Logo
Using the Linux ls Command
Linux ls Command Image

The Linux ls command is, in its most basic form, similar to the dir command in that it provides a listing of a folder/ directory.


Enter ls to receive a simple listing of the current directory's files and folders. Here it shows files test3.txt and test4.txt

Use the following command to obtain a listing of the parent directory.

ls ..

Here we see two files and a folder named "holds' The ls command shows files in white and the directory in blue to make it easier to understand.

ls Parent Directory Command

Use the following command to obtain a listing of the root directory.

ls /

Here we see the complete listing of the root directory. ls shows symbolic links in bold cyan. The writable directory tmp is shown in blue with a green background.

ls Root Directory Command

The following command shows the contents of your home directory.

ls ~

In this case it contains just one file nohup.out

ls Home Directory Command

Use the following to obtain an easily readable listing of the contents of a directory with their sizes.

ls -sh

In the example the files are both 4.0k in size.

ls Friendly Size Command

Use the following for a detailed listing of the directory's contents.

ls -l

This shows the date, access permissions, owner etc. of each file or directory

ls Verbose Directory Listing

Here are some other useful ways to utilize the ls command.


ls -d */

Only list directories/folders

ls -R

List files and directories including the contents of those directories.

ls -a

List all files, directories and hidden files.

ls -t

List contents in last modified date order.

ls -S

List contents in order of size.

ls -r

List contents in reverse order. The r can also be added to other commands such as size or date.

ls ------ version

Show which version of the ls command your computer is using.

ls ------ help

Show ls help pages.

The ls command is at its best when you have learned to combine the assorted options to obtain the output that is most useful to you.

You Are Leaving Us

This link is being provided as a convenience and for informational purposes only it is not an endorsement or an approval of any of the products, services or opinions of the corporation or organization or individual. bears no responsibility for the accuracy, legality or content of the external site or for that of subsequent links.