In this article, you will learn both theoretical and practical information on the Linux Home directory, which stores all information related to the users.
After reading this tutorial, you will know what a Home Directory is, the permissions structure, and application scenarios. This is useful for Linux distributions and other Unix-based operating systems like BSD.
Practical instructions in this tutorial include screenshots, making it easy for any Linux user to follow them.
What Is the Linux Home Directory?
Contrary to Microsoft Windows, Linux was designed to be a multiuser and multitasking operating system. This means that Linux is optimized to be used by different users. This is also useful to interact within networks securely.
Linux systems include a universal directory named Home, whose parent directory is the root (/) directory as a multiuser operating system.
In other words, the Linux Home Directory or partition stores personal directories of each user, which is restricted only to the homeowner and root user.
Let’s say you have a user named linuxhint in your system and another user named systemuser, then the path for each user’s personal directory will be:
Where “/” is the root directory, home is the general directory or partition storing all personal account directories (e.g. linuxhint or systemuser).
The exception to this rule is the root personal directory, which is not located under the /home/ partition/directory but under the root system location (/root/).
Home Directories are followed by a tilde slash (~), as shown below:
Advantages of the Linux Home Directory or Partition:
As said previously, the Home of a user isolates or restricts access to user files. This includes customization settings. Here, you can store configuration files that will affect only the Homeowner.
As you can imagine, this includes executable files stored only under a user’s Home Directory, which can be executed only within the user environment specifically. This also prevents malicious code from infecting the entire system.
This is one of the main reasons Linux is a more secure operating system than Windows. Linux was natively created under the premise, while Windows, developed for personal use, patched its operating system to implement a similar feature. In contrast, Linux was developed to grant privacy and security to different users.
Like other operating systems, this directory is created automatically when installing your system. During the Linux installation process, you can assign the Home directory an exclusive partition. This will ease your backup and restoration tasks and just save them.
Enter Your Home Directory With Just a Command:
There are different commands to access your Home Directory immediately: cd, tile slash (~), and cd $Home.
A cd command example, where the user changes the current directory from the /usr to /home/username directory.
A cd $HOME command example, where the user changes the current directory from /boot to /home/username directory.
A cd ~ command example, where the user changes the current directory from /boot to /home/username directory.
You can use the pwd command example to show the current directory to learn if you are in your /home.
Note: you can move to other directories by typing cd /<directory>, such as cd /user and cd /boot. To access files and directories when the current path isn’t the /home directory, always add the /home/ path as the parent directory in the path.
The Home Directory Permissions:
Default permissions of the /home directory are drwxr-xr-x (755), allowing the user group to execute and read files and others to execute files within the Home Directory.
You can check your Home Directory permission as shown in the following image:
If you are looking for better security and privacy, you can change the default permissions to 750.
Below you can see the command execution and result:
As you can see, others can’t read or execute files now. The owner keeps full rights, and the group read and execution permissions.
The /home directory is a formidable way to manage the users’ files. This allows users to manage users’ privacy, to move an entire user dedicated directory storing one’s files, for example, for backup purposes.
The root user is the only one allowed to access all users’ Home Directories with full permissions. Use the privileged user (root) to change permissions globally in your system. Yet, other users have global rights when reading files. You can change specific directory permissions by running the last command explained in this tutorial. It is recommended to increase your privacy, changing permissions to a more private policy.
Learning Linux permissions will allow you to customize your file access, as shown previously. You can get additional information on changing Linux permissions here. Understanding the home directory theoretic is useful to deal with other operating systems aside from Linux, like the BSD-based systems. In Macintosh, users, the equivalent to the /home directory is /users/, where users directories are /users/username.
The Home Directory, as a separate component of your system filesystem, shows Linux as the superior structure of this operating system over others; even over other systems, which didn’t include the multiuser feature natively, patching it later. Learning Linux permissions will allow you to customize your file access, as shown previously.
Thank you for reading this Linux tutorial about the /home directory. I hope it was helpful for you to understand more about Linux. Keep following Linux Hint for more Linux professional articles.