The ls
(LiSt directory) command is used to list the contents of a directory. On the GUI (Graphic User Interface), you can see what directories and files are contained under a directory. On the CUI (Character User Interface), you need to use your keyboard to list up the directory contents.
When you run the ls
command without specifying a directory path, you get a list of the contents of your working directory like the one below.
ls
application media sample.txt
You can specify a file path to execute the ls command. This is an example of listing up the root directory contents.
ls /
bin dev home lib32 libx32 media opt root ....
With the -a
option, you can list up directory contents including hidden files.
ls -a
. .. .bash_history .bash_logout .bashrc .cache. .profile .ssh ...
With the -l
option, you can list directory contents with detailed information.
ls -l
drwxr-xr-x 3 usr_a staff 4096 Jul 16 2020 media
-rwxr-xr-x 15 usr_b staff 3180 Dec 21 12:53 sample.txt
Here is the list of information
d
= directory, -
= file)r
= read, w
= write, x
= execute)
Note: To learn about the access mode, check Permission (Access Mode) by Owner Status .
The ls
(LiSt directory) command is used to list the contents of a directory. On the GUI (Graphic User Interface), you can see what directories and files are contained under a directory. On the CUI (Character User Interface), you need to use your keyboard to list up the directory contents.
When you run the ls
command without specifying a directory path, you get a list of the contents of your working directory like the one below.
ls
application media sample.txt
You can specify a file path to execute the ls command. This is an example of listing up the root directory contents.
ls /
bin dev home lib32 libx32 media opt root ....
With the -a
option, you can list up directory contents including hidden files.
ls -a
. .. .bash_history .bash_logout .bashrc .cache. .profile .ssh ...
With the -l
option, you can list directory contents with detailed information.
ls -l
drwxr-xr-x 3 usr_a staff 4096 Jul 16 2020 media
-rwxr-xr-x 15 usr_b staff 3180 Dec 21 12:53 sample.txt
Here is the list of information
d
= directory, -
= file)r
= read, w
= write, x
= execute)
Note: To learn about the access mode, check Permission (Access Mode) by Owner Status .