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
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
---|---|---|---|---|---|---|---|---|---|
- | rwx | rw- | r— | 1 | root | root | 4096 | Dec 18 16:41 | somefile.txt |
-
for regular file,d
for Directory,l
for Symlink- The owner can read, write and execute this file
- The owner’s group can read and write this file
- Other users can read, but not write nor execute this file.
- The number of hard links to this file or directories inside this directory.
- The object’s owner
- 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. - The object’s size in bytes. Note:
ls -lh
will usek
,M
,G
,T
etc. for human readable. - The object’s last modified time; for directories this is not inheritive.
- The object’s name as stored in the filesystem’s table of contents