ls
ls
is a command short for list
. It lists down the contents of a directory. By default, it lists the contents of the current working directory. From the example introduced at the start of the section, if we list down the contents of our current directory we get,
Syntax: ls[option]<location>
1user@localhost:~$ ls
2Documents Pictures Videos
ls
is mostly used with options
unlike pwd
or echo
which are mostly used without them (even though options are available for them). ls
can also take an optional argument (specified after options, if any), which can be the location of the directory.
Let's look at the usage of ls
using the -a
option. This option enables us to view hidden files. In the code block below, the files with a preceding dot .
, are hidden files. These hidden files are not visible on GUI unless you enable the option to view them.
1user@localhost:~$ ls -a
2Documents Pictures .temp_file Videos .webpage