A home directory, also called a login directory, is the directory on Linux and Unix-like operating systems that serve as the repository for a user’s files, directories, and programs. It is also the directory that a user is first in after logging into the system.
Whenever you create a new ordinary user, it creates a new directory into /home directory. In the below picture, you can see there is a directory (If you see with the command: ll -a /home then you can see few hidden directories) in /home. When I created a user with the name amit it created a directory with the name amit.
Generally, the name of the user’s directory is the name of the user. In the above example, I created a user with the name of amit the absolute path of the user amit will be /home/amit.
Note: You can also create a user in your defined location. You just have to give the absolute path while you are creating a user or while you are moving the existing users’ home directory. Read about useradd command to create the home directory in different locations.
There is only one user by default which will have a different location for the home directory is the root. The root directory, you can see in below picture with hidden files in it i.e. /root
Returning to the home directory
There are several easy ways for a user to return to its home directory.
The tilde is used to represent users’ home directories on Unix-like operating systems. A user could also return to its home directory by using the tilde as an argument.
The absolute pathname of a user’s home directory is stored in that user’s $HOME environmental variable.
In this tutorial, you learned about the home directory in Linux. I hope, you understand but if you have any questions, you can ask in the comment section.