ls command

Also see chmod. I recommend always using ls -lah. Set up the alias for ls.

  • l for long-listing format
  • a for all files
  • h for human-readable file sizes

I had this on my CS138 midterm and I had no idea how to read the things, so might as well write it down.

Let’s analyze this, which the console outputted after ls -la:

-rwxrw-r-- 1 root    root       4096 Dec 18 16:41 somefile.txt
12345678910
-rwxrw-r—1rootroot4096Dec 18 16:41somefile.txt
  1. - for regular file, d for Directory, l for Symlink
  2. The owner can read, write and execute this file
  3. The owner’s group can read and write this file
  4. Other users can read, but not write nor execute this file.
  5. The number of hard links to this file or directories inside this directory.
  6. The object’s owner
  7. The object’s owner’s group. All of the users in this group (for example, root, user, www-data, etc.) are affected by the permissions in 3.
  8. The object’s size in bytes. Note: ls -lh will use k, M, G, T etc. for human readable.
  9. The object’s last modified time; for directories this is not inheritive.
  10. The object’s name as stored in the filesystem’s table of contents