Linux users must have seen similar details regarding file and directory and therefore should feel comfortable with it. However if you haven't seen such details before, then you either work too much in the GUI interface of Linux system, or simply haven't had much experience with the Linux OS.
Whatever the situation, don't worry - it's simpler than you think!!
So what does all this output means ? Especially all those 'rwx' lines?!
Let's start understanding the details in the previous screen shot.
In the yellow column on the right we have the computer file & directory names (anaconda-ks.cfg, Desktop, install.log etc.) - not to explain much here. Next, in the green column, it notifies time and date of creation.
e.g. Apr 5 00:05 messages
Note that date and time column will not always display time and date of creation. If the file or directory it refers to was created in a year different from the current one, it will then show only the date, month and year, discarding the time of creation.
For example, file 'install.log' was created on the 9th of Feb, 2012, hence the system is showing:
Feb 9 2012 install.log
A small but important note when examining files and folders! Lastly, the date will change when file gets modify. As such, if we edited a file created last year, then the next time we typed 'ls -l', the file's date information would change to today's date. This is a way you can check to see if files have been modified or tampered with.
The next column contains the file size in bytes - again nothing to explain much here.
The owner might belong to a specific group, in that case this file is also associated with that user's group. In our example, the left column labeled 'User' refers to the actual user that owns the file, while the right column labeled 'group' refers to the group the file belongs to.
Looking at the file named 'anaconda-ks.cfg', we can now understand that it belongs to the user named 'root' and group named 'root'.
Following the permissions is the column with the cyan border in the snapshot.
The system identifies files by their inode number, which is the unique file system identifier for the file. A directory is actually a listing of inode numbers with their corresponding filenames. Each filename in a directory is a link to a particular inode.
Links let you give a single file more than one name. Therefore, the numbers indicated in the cyan column specifies the number of links to the file.
As it turns out, a directory is actually just a file containing information about link-to-inode associations.
Now for the fun column, the first one on the left containing the '-rwx----w-' characters. These are the actual permissions set for the particular file or directory we are analyzing.
To make things easier, we've split the permissions section into a further 4 columns as shown below. The first column indicates whether we are talking about a directory (d), file (-) or link (l).
In the newer Linux distributions, the system will usually present the directory name in colour, helping it to stand out from the rest of the files. In the case of a file, a dash (-) or the letter 'f' is used, while links make the use of the letter 'l' (l). For those unfamiliar with links, consider them something similar to the Windows shortcuts.
r, w, x Permissions
If you want to give full access to the owner, only read and execute to the group, and only execute to everyone else, you'd work it out like this :
owner: rwx = 4 + 2 + 1 = 7
group: r-x = 4 + 0 + 1 = 5
everyone: --x = 0 + 0 + 1 = 1
So your number will be 751, 7 for owner, 5 for group, and 1 for everyone. The command will be 'chmod 751 file.txt'. It's simple isn't it ?
If you want to give full control to everyone using all possible combinations, you'd give them all 'rwx' which equals to the number '7', so the final three digit number would be '777':
If on the other hand you decide not to give anyone any permission, you would use '000' (now nobody can access the file, not even you!). However, you can always change the permissions to give yourself read access, by entering 'chmod 400 file.txt'.
For more details on the 'chmod' command, please take a look at the man pages.
As we will see soon, the correct combination of user and group permissions will allow us to perform our work while keeping our data safe from the rest of the world.
For example in order for a user or group to enter a directory, they must have at least read (r) and execute (x) permissions on the directory, otherwise access to it is denied:
As seen here, user 'mailman' is trying to access the 'red-bulb' directory which belongs to user 'david' and group 'sys'. Mailman is not a member of the 'sys' group and therefore can't access it. At the same time the folder's permissions allow neither the group nor everyone to access it.
Now, what we did is alter the permission so 'everyone' has at least read and execute permissions so they are able to enter the folder - let's check it out: