ls command is used to list all files and directories in linux for the current working directory. By default, ls command returns the list in alphabetical order. In this tutorial, you will learn how to list and sort files by date and time in Linux or Ubuntu.

ls command

 

List All Files Along With Hidden Files

Use ls -a  or ls --all command in terminal to display all files and directories along with hidden files for the current working directory.

ls  -a

Output:

ls -a command

ls --all

Output:

ls -all command

List Files From Other Directories

Use ls /directory_name   command in terminal to display all files and directories along for the other directory.

** Don’t forget to change directory_name to available directory name on your computer.

List Files Based on Time and Date

Use ls -t  command in terminal to display files and directories based on modification time and date. The most recently modified files and directories will be shown at the top of the command output.

ls -t

Output:

ls-t command

 

List Files Based on Time and Date in Reverse Order

Use ls -tr  command in terminal to display files and directories based on modification time and date in reverse order. The most recently modified files and directories will be shown at the bottom of the command output.

ls -tr

Output:

ls-tr command

 

List Files Based on Time and Date in Human Readable Format

Use ls -halt  command in terminal to display files and directories based on modification time and date in a human-readable format. The most recently modified files and directories will be shown at the top of the command output. 

** -h for the human-readable format, and -a for showing all dot prefixed files or hidden files.

ls -halt

Output:

ls-halt command

 

Sharing is Caring
Scroll to Top