Understanding Linux File Permissions and Ownerships

Image
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…

Linux File System Hierarchy


Linux File System Hierarchy



In the linux file system hierarchy, all the files are stored in a single inverted tree, Because the root directory is on the top of the hierarchy and directories and sub directories are below the root.

The root directory which is "/" as show in the above image is the starting of the file system. More than that "/" is used to seperate the directories like "/etc/passwd  and /etc/group". Below will describe one by one the directories under root.

/boot : The files which needs to start the boot process
/etc : System configuration files.
/home : All the user's home directories are here. In simple words, users home folder.
/root : Home directory of the root user
/bin : User commands
/sbin : Administrative commands
/var : Files which changes by time. Persistence between boot. Dynamically change by time. eg - log files, databases
/dev : Special files which system needs to access hardware.
/proc : contains files which gives system information like /proc/cpuinfo
/mnt : list mount points
/run : contains files which are non persistent data means looses data within boots.


Comments

Popular posts from this blog

Different types of users in linux

Understanding Linux File Permissions and Ownerships

How to manage Linux Users and Groups