How to get a list of files and directories


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:


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 -l to display all the information about files and directories:


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.

40183 times

Need help? We're always here for you.