
Using this option, you will be able to quickly identify items listed by the ls command, such as directories and executables. You can use the -F or -classify option alongside the ls command to add additional identifiers to your listed files and directories. rwxr-xr-x 1 pi pi 1.8M Jun 19 06:04 hello-worldĭrwxr-xr-x 11 pi pi 4.0K Jun 19 05:54 mpv-build Listing Files and Directories with More Information For example, 4096 bytes would be displayed as 1K.įor this option to be useful you will need to use it alongside the long list format option ( -l) $ ls -lhĭrwxr-xr-x 2 pi pi 4.0K May 27 08:18 Bookshelf This means the numbers will be converted to shorthand to make them easier to read. However, you can specify the -h option to convert the numbers into the human-readable format. One thing that can become tricky to deal with is that the ls command only reports file sizes in bytes. ls -aīelow you can see how you can use the show hidden files option ( -a) alongside the long list format ( -l) option. To combat this behavior, the ls command has the -a option that will tell the tool to list all files. A file is considered hidden in Linux whenever the file name starts with a dot (.


One thing you may have noticed is that hidden files are not listed by default. Using the ls Command to View Hidden Files If you would like to learn about permissions, be sure to check out our Linux permission guide. rw-r-r- 1 pi pi 76 Jun 19 05:58 hello-world.goĭrwxr-xr-x 11 pi pi 4096 Jun 19 05:54 mpv-buildĪlongside these bits of information, the ls command also shows us the total number of file system blocks that are being used by the files in this directory. These include the file permissions, owner, group, file size in bytes, modification date, and filename. The long listing format will give you seven different pieces of information about the file.

Out of all of the options, this is the one that you will likely end up using the most as it provides you details about each file. This option tells the command that it should list out the files using the long listing format. To get more information from the ls command we can make use of the -l (Make sure you use a lowercase l) option. ls -l /home/pi More Information From ls Using -l However, if you are using an option such as -l you will need to specify the directory after that. The first way is to specify the directory after the command. It is also possible to specify the directory.īelow we are going to give you two examples of how you can specify a directory. While by default, the ls command only lists the files of the current working directory. Listing Files Within a Specified Directory You will only be able to view the name of the files and not any information about them. $ lsīin boot dev etc home lib lost+found media mnt opt You will get a list of all the files in the current working directory when you don’t specify any options. The easiest way to make use of the ls command, is to use it without specifying any additional options. ls īoth arguments are entirely optional, and you can specify one without having to specify the other. The ls command uses a simple syntax that is very straightforward to remember.Īll you need to do is enter ls, followed optionally by your options or the path to the directory, or file you want to list.

Throughout most of our Linux and Raspberry Pi projects, you will see that we often use ls. Within this guide, we will show you some of the various ways that you can put the ls command to use. When used without any options, this will list the files of the current working directory. The ls command is used to list the files within a directory. You will quickly find that you will be making use of this command often.Īlongside cd, it is one of the very first commands that you should learn when dealing with Linux. The ls command is crucial for navigating the Linux filesystem.
