This is our 6th post on understanding first level directories in /. Knowing these folders in detail or at least what each is meant for will help you understand Linux/Unix in whole. we already covered below directories, please have a look at those to understand them. In this post we will see two more directories ie /home and /root directory. These directories are meant for similar purpose. The /root is meant for just root user and /home is for all the remaining users.
A brief intro to /home directory in Linux/Unix
The /home directory is a place where by default all user home directories are created.
OK, what are user home directories for?
These directories are a kind of personal place(Working space) for all the users other than root. There will be a separate folder for each user in /home directory. For example if you have a user called ‘Tom’, then his default home directory is /home/tom. We can change this default folder when creating user in Linux. Our Tom user can do what ever he wants in /home/tom folder where he have full rights on the files he created and owned in that folder.
The properties of /home folder?
1) A separate sub folder ie /home/<user-name> is present for each user.
2) Only user who owns this sub folder can access it’s content other than root user. So, tom user can not access Barbi user home directory content which is located at /home/barbi.
3) All his terminal properties, command history file, application setting files(~/.vimrc, ~/.ssh) etc everything is located in this folder.
4) System admins when try to implement quota for users they will implement it on /home directory. This /home directory should be mounted on a separate partition.
Each user home directory is important and frequently used directory for that user, we have alias name for it. This alias is set to ~ so that when ever user wants to navigate to his home directory, he do not have to use /home/<username> but just use below short cuts.
Will take you to your home directory.
When you are in your home directory even our PS1 prompt will show user’s home directory with ~.
xyz@sanne-taggle:/home$ cd xyz@sanne-taggle:~$ pwd /home/xyz
Some of the important files which are present in /home/<user-name> or /root directory are as below.
1) Bash shell related configuration files.
If your shell is not bash then you should see other shell configuration files.
2) Default editor configuration files.
3) You secure shell configuration files are located in ~/.ssh which contain your ssh-keys, knownhosts etc.
How about /root directory in Linux?
This is root’s home directory. Do not get confused between / and /root. Both these are meant for different purpose.
/ is the main folder where your file system resides, where as /root is root user home directory. Similar to /home/<user-name>, root user saves his personal data, terminal configurations in /root directory.
Some FAQ on user home directories
Why is home directory of root is a separate folder?
Because of security reasons root’s home directory is separated from /home.
I see many users in /etc/passwd but I don’t see them in /home, why?
This can be of two reasons.
1) Either users are system defined users
2) Or users home directory resides some where else.
3) Or intentionally /home directory is not created. For this type of users / will be treated as their home directory. This is a nightmare as he can not do anything in / folder due to lack of permissions.
In our next post we will see lib folder.
Latest posts by Surendra Anne (see all)
- Docker: How to copy files to/from docker container - June 30, 2020
Anisble: ERROR! unexpected parameter type in action:
Fix- June 29, 2020
- FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018