The ls
command lists all files and directories in the working directory.
We can use ls
as is, or attach an option. Options modify the behavior of commands.
For example:
ls -a
The command above displays the contents of the working directory in more detail. This command displays all the files and directories, including those starting with a dot (.
). Files starting with a dot are normally hidden, and don’t appear when using ls
alone.
The -a
is called an option. Options modify the behavior of commands.
In addition to -a
, the ls
command has several more options. Here are three common ones:
-a
- lists all contents, including hidden files and directories-l
- lists all contents of a directory in long format, as well as the file permissions-t
- orders files and directories by the time they were last modified.
Let’s practice using these options below.
Instructions
In the terminal, type:
ls -a
Do you see the differences between the outputs of both ls
and ls -a
?
Then type
ls -t
Do you see the differences between the outputs of both ls -a
and ls -t
?
In the terminal, type
ls -l
Click Next to find out what these columns mean.