Ls command In Linux
ls CommandThe ls command has the following syntax:
watch video for more details
ls displays a list of the names of all files in the current working directory when used without any options or arguments:
The files are listed alphabetically in as many columns as your terminal will allow:
To list files in a single directory, use the ls command with the directory path as an input. To list the contents of the /etc directory, for example, type:
You can also use space to separate several directories and files:
You'll get a notice claiming that ls can't open the directory because the user you're logged in with doesn't have read permissions:
Output
ls: cannot open directory '/root': Permission denied
There are several options for the ls command. We'll go over the most popular solutions in the sections below.