Unix file system : Permissions

The file /etc/passwd is the password file. It contains all the login information about each user. We can discover each users id and group id by looking name in /etc/passwd.

$grep name /etc/passwd

The fields in the password file looks like ‘login-id:encrypted password:uid:group-id:miscellany:login-directory:shell’. The -l option of ls command prints the permissions.

$ls -l

We can find a string like ‘-rw-r–r–‘ . The first – means that it is an ordinary file. If it is a directory there prints a ‘d’. The next three field is the permissions of the owner followed by the next three field is the permissions of the group and the next is the others permissions. We cannot edit the passwd file . But the super user can do it.

The ‘chmod’ command changes the permissions of a file. ‘permissions’ may occupy octal numbers. The ‘+’ sign is for ‘ON’ permission modes and to OFF the ‘-‘ sign is using. The ‘-w’ option is for turn off the write permisssion for all incliding the owner. ‘+x’ allows every one to execute the following command.

$ chmod permissions filename
$ chmod -w filename
$ chmod +x command
$ chmod -w .
$ chmod 775 filename //Restores the permission.

The ‘-w .’ means removing the write permission of all files in that directory.

Unknown's avatar

Author: Abhilash

Hi, Iโ€™m Abhilash! A seasoned web developer with 15 years of experience specializing in Ruby and Ruby on Rails. Since 2010, Iโ€™ve built scalable, robust web applications and worked with frameworks like Angular, Sinatra, Laravel, Node.js, Vue and React. Passionate about clean, maintainable code and continuous learning, I share insights, tutorials, and experiences here. Letโ€™s explore the ever-evolving world of web development together!

Leave a comment