Understanding Linux File Permissions and Ownerships

From one of our previous articles "How to manage Linux Users and Groups" we discussed on how Linux becomes a multi-user OS, what is a user and a group with their configurations. By design, even though Linux allows multiple users can use the same computer in the same time without affecting others, Linux doesn't allow you to access or modify files belonging to other users. If Linux allows you to do it, that would be a security risk. But somehow they have implemented a security measure to mitigate that security risk. With that we can make sure only desired users and groups can access the relevant files and directories.

If we take a small demonstration. Here, we will log in as a normal user and try to access a root directory.

It gave a permission denied error when accessing. Why ? That's because /root directory is owned by user root. Only a privileged user can access or modify that.

So, Linux introduces two kind of factors which tells who can access or modify a file as w…

Different types of users in linux

There are different types of users in Linux.
  • Root user 
  • Super user 
  • Normal user 
Root user is like the Administrator account in windows. Root user  has the highest privileges. So, if you switch to root , you can do anything inside of the operating system. Because of that it's need to use that account very carefully.

Normal users are the account that you use regularly. I created a student named user account in the article which i installed CentOS-7 in VMware. A regular user has no previledges for changing system files and root managed files. But some system files can be viewed. Regular user access all the files in that user's domain. 

A super user is who can gain root power, which mean a super user can switch and gain root access on requirement.

Eg: A normal user can't install applications in Linux. But, a super user can do that by switching to root. 

Only root user can make a normal user as a super user.

Additionally, we will discuss the helpful Linux command for switching in between users.

  • su <user name> : switch user
  • su - : switch user to root
  • su root : same as above
  • sudo su : switch to root user without password ( this is for superusers only )
What is the difference in using  su <username> and su - <username> ?

It is like this. In Linux operating system, there are environmental variables. They are like unique things for users. Something like a home directory, host name, user name like that. So, if we switch user with "su - <username>" command, it will take us to other users account. Environmental variables will be changed accordingly. But if we use the command "su <username>", it will not take us to next users account. It will not change the environmental variables accordingly. Because we are accessing the other users files being inside of our account. But su - <username> will change the user account with it's environmental variables as well. 


Popular posts from this blog

Understanding Linux File Permissions and Ownerships

SUDO: What is it in Linux ?