ls is used to list files (note the first letter is the letter L not the number 1!)

Let's try it from our home directory:

Notice that second command and its output?

ls -a shows all the files in a directory, including hidden ones. Why are there hidden files? Because in the Unix world, all directories contain two special sub-directories:

. points to the current directory - /home/pi is the same as /home/pi/.

.. points to the parent directory, the one that holds the current directory - /home/pi/.. is really just /home/

ls normally hides everything starting with a dot, because these don't really convey any extra information to a user.

To complicate matters even further, it's traditional for special configuration files to be stored in ~ and named like .something so that they won't show up in a directory listing by default.

Want to see more detail about individual files?

The -l option, for a long listing, will give you several columns of useful data. For the file called .bashrc, you have:

-rw-r--r--  1 pi   pi    3243 Sep  8 20:23 .bashrc

-rw-r--r-- is a shorthand for the file's type and mode or permissions. In this case, the file is a plain old file (not a directory or other special file) and:

  • readable and writeable by its owner
  • readable by its group
  • readable by everyone

The rest of the line, in order:

  • 1 is the number of hard links to the file
  • pi, repeated twice, tells you the owner and group of the file
  • 3243 is the number of bytes taken up by the file
  • Sep  8 20:23 is the file's modification time

You don't need to worry too much about this stuff yet - just remember that -l gives you more detail.

This guide was first published on Jan 13, 2015. It was last updated on Jan 13, 2015.

This page (Listing Files: ls) was last updated on Jan 03, 2015.

Text editor powered by tinymce.