How to get a list of files and directories

ls

ls will show you a directory listing. It will also show various features such as symlinks and directories in color. For more information about ls, use the man ls command:

SYNOPSIS

ls [OPTION]... [FILE]...

ls -1 to display one file per line
To show a single entry per line, use the -1 option as shown below:

ls-1.bmp

ls -l to display all the information about files and directories:

ls-L.bmp

ls -lh to display the file size in the Human Readable format:

ls -lh.bmp

ls -ld to display directory information. When you use “ls -l”, you will get the details of the directories content. But if you want the details of the directory, then you can use the -d option.
For example, if you use ls -l /public_html, it will display all the files under this directory. But, if you want to display the information about the /public_html/ directory, use the -ld option as shown below:

ls -ld.bmp

ls –lt to show files list based on last modified time:

ls -lt.bmp

For more options, use the man ls command.

Updated
Viewed
39573 times

Need help? We're always here for you.

notmyip