Command Line Tools
- This number is the number of hard links (pointers) to this file. You can use ln to create another hard-link to the file.
- This is the type of file. '-' means a regular file, 'd' would mean a directory, 'l' would mean a link. There are also other types such as 'c' for character device and 'b' for block device (found in the /dev/ directory).
- These are the permissions for the owner of the file (the user who created the file).
- These are the permissions for the group, any users who belong is the same group as the user who created the file will have these permissions.
- These are the permissions for everyone else. Any user who is outside the group will have these permissions to the file.
- Letters Method:
a (all (everyone)), u (user), g (group) and o (other).
chmod u+rw somefile
chmod o-rwx somefile
chmod a+r somefile
chmod a=rx somefile
chmod 777 somefile
chmod 521 somefile
This would give the user read and execute permission, and the group write permission (but not read permission!) and everyone else execute permission. (Note that it's just an example, settings like that don't really make sense...).
chown owner:group the_file_name
- sticky bit
chmod 1700 somedirectory (where 1 = sticky bit)
chmod +t somedirectory
chmod 0700 somefile (where the zero would mean no sticky bit)
Allow SUID/SGID (switch user ID/switch group ID) access. You would normally use chmod to turn this on or off for a particular file, suid is generally considered a security hazard so be careful when using this.
chmod u+s file_name
This is obviously a security hazard. You should avoid using the suid flag unless necessary.
Change file system attributes (works on ext2fs and possibly others...). Use the -R option to change files recursively, chattr has a large number of attributes which can be set on a file, read the manual page for further information.
chattr +i /sbin/lilo.conf
This sets the 'immutable' flag on a file. Use a '+' to add attributes and a '-' to take them away. The +i will prevent any changes (accidental or otherwise) to the “lilo.conf” file. If you wish to modify the lilo.conf file you will need to unset the immutable flag: chattr -i. Note some flags can only be used by root; -i, -a and probably many others.
A (no Access time) --- if a file or directory has this attribute set, whenever it is accessed, either for reading of for writing, it's last access time will not be updated. This can be useful, for example, on files or directories which are very often accessed for reading, especially since this parameter is the only one which changes on an inode when it's opened.
a (append only) --- if a file has this attribute set and is open for writing, the only operation possible will be to append data to it's previous contents. For a directory, this means that you can only add files to it, but not rename or delete any existing file. Only root can set or clear this attribute.
s (secure deletion) --- when such a file or directory with this attribute set is deleted, the blocks it was occupying on disk are written back with zeroes (similar to using shred). Note that this does work on the ext2, and ext3 filesystems but is unlikely to work on others (please see the documentation for the filesystem you are using). You may also like to see shred, please see Chapter 7
(list attributes). This will list if whether a file has any special attributes (as set by chattr). Use the -R option to list recursively and try using the -d option to list directories like other files rather than listing their contents.
This example and tiny parts of the explanation have been taken from the Linux Online Classroom, see  in the Bibliography for further information.
Leave a Reply
You must be logged in to post a comment.