Home | About | Categories | All Tips & Tutorials

List files in a directory using the ls command

ID: 173

Category: Linux Terminal

Added: 22nd of July 2020

Views: 3,044

The ls command is almost identical the dir command for listing files in a directory. From what I have seen the only difference is that the ls command can colourise the output

To use the ls command for example listing the contents of a directory use the folllowing command

ls


The ls -l command will display the file permission, owner and group, filesize and modification date and the filename
ls -l


To list a specific file type, for example only .txt files, we could enter the following command
ls -l *.txt


We can also output the listing to a text file for example
ls -l *.jpg > output.txt


You can get furter information about the ls command by enterting the following command in the terminal
ls --help