Skip to main content
  1. Courses/
  2. Linux/

ls command

·310 words·2 mins· loading · loading ·
Russell Chubb
Author
Russell Chubb
Working at the intersection of Technology and Art.
Learn Linux - This article is part of a series.
Part 2: This Article

The “ls” command, (short for list) is used to list the contents of a directory.

What’s a directory you ask? Put simply, a directory in Linux is a folder in which you store files. NOTE: If you’d like to know more about Linux directories, I’ve linked off to Fireships video on the topic. Let’s take a look at the “ls” command in action. Start by typing “ls” and press enter. The result returned is a list of the files and directories in alphabetical order.

By default, the “ls” command returns the contents of the current directory, but you’re able to pass in the name of a different directory as well.

For example, if I pass in another directory, for example, /home I’m now able to see the contents of this directory.

The “ls” command comes with some useful options flags, starting with the “- l” flag. The “-l” flag stands for ’long listing format’ and provides detailed information about each file and directory.

To add the “-l” flag on, type “ls -l” then press enter, with the resulting output then displaying permissions, number of links, owner, group, size, modification date, and name of each item.

Another useful option is “-a”, which stands for ‘all’. This option shows all files, including hidden ones.

NOTE: Hidden files in Linux start with a period. Now, let’s run this command. As you can see, ls -a lists all files, including the hidden ones.

You can also combine options. For example, “ls -la” combines the both the “-l" Flag and the “-a” flag.

That’s it for my introduction to the “ls” command in Linux! Let me know in the comments if there are any other Linux commands or topics you’d like me to cover.

If you like the video, like the video, if you’d like to see more of me, press subscribe. Thanks for watching.

Learn Linux - This article is part of a series.
Part 2: This Article

Related

Cat Command

374 words·2 mins· loading · loading
Introduction to the Cat Command in Linux