Bash Terminal File Listing

You are new to the Linux bash terminal or you just didn’t had the time or motivation to read through the manual about how to list files? No problem, here is a quick guide with the most important functions.

Ls is used to list your files inside of a bash terminal. It’s like clicking through folders but with a higher customization capability. The overall concept of the ls function includes options and a directory.

ls [options] [directory or file path]

The basic command lists all files.


To list all files including hidden files, use option a.

ls -a

To list all files of a specific directory you have to include the path at the end of the ls command. For example, to view all files in your Downloads folder, use the command:

ls Downloads/

The same logic is possible for listing specific files. An important symbol therefore is *. Let’s use it to list all html files inside the directory Downloads.

ls Downloads/*.html

The ls command takes always your current location as the starting point. If you want to force it to start from your home directory use the symbol ~. Now let’s say in your home directory is a folder called Documents and inside is a folder called lib, and your terminal is currently pointing somewhere else. To list all files inside, type:

ls ~/Documents/lib

On default you will just see the names of all files. If you are interested in a advanced view, including the file rights and last edited datetime, use the option l:

ls -l

To sort all files by their last edited date time, use the option t:

ls -t

Combining both options togither is also possible. Just add them together without any additional spacing or symbols. For example listing all files in an advanced view and sorting the by their last edited date time is the option lt:

ls -lt

Now the last option chain ltr means to list all files in an advanced view, sort them by their last edited date time in reverse order, so ascending. So include r on your command and type:

ls -ltr

That’s all you need for your usual usage. For more options you can read through the manual with the command:

ls --help

If you liked my article or I have forgot to mention some functions, please leave a commend down below!

Leave a Reply

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