Common options in the ls command

The command to use when you want to know the contents of a directory in the terminal is ls. In this post, we'll cover some of the most commonly used options in ls.

Common options in the ls command

a option

A stands for all. The Unix file system has hidden files, which are files whose names start with . and have no extension. These files are invisible when you type the ls command or use GUI tools.

If you want to see all these hidden files and directories, you can run the ls -a command with the -a option added. The image below shows a comparison of the same directory without and with the -a option.

l Options

The output from using the ls command is just the name, so you can't tell what's a directory (folder) and what's a file. If you want more information, you can use the l option, where l stands for long format.

Using two options at the same time (ls -al)

By the way, you can also use both options at the same time to see more details, including hidden files, by typing ls -al and running it, as shown below.

Meaning of additional information shown by ls -l

Let's look at the meaning of the additional information we see when we run ls -l.

  • First, the first line, total, tells us how much space the contents of the directory take up.
  • Next, in the first column of the file, the first letter indicates the type of file, and the remaining letters relate to permissions.
    If it starts with d, it's a directory, if it starts with -, it's a regular file.
  • The second column indicates the number of links associated with this file.
  • The third column is the owner of the file.
  • The fourth column is the group the owner belongs to. Using the image above as an example, you can see that the 0_sticker-13.png file is owned by zoe.lee, who belongs to the staff group.
  • The fifth column tells you how many bytes the file is. For directories, this is not the capacity, so it doesn't need to mean much.
  • The capacity is followed by the file's modification date and time.
  • The last column is the file, directory name.

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish