Javatpoint Logo
Javatpoint Logo

Linux Home Directory

The Linux home directory is a directory for a particular user of the system and consists of individual files. It is also referred to as the login directory. This is the first place that occurs after logging into a Linux system. It is automatically created as "/home" for each user in the directory'. It is a standard subdirectory of the root directory. The root directory contains all other directories, subdirectories, and files on the system. It is denoted by a forward slash (/).

The home directory can be said as a personal working space for all the users except root. There is a separate directory for every user. For example, two users 'jtp1' and 'jtp2' will have directories like "/home/jtp1" and "/home/jtp2". These users will have all the rights under their directory files.

The root (administrative) user is the only user who has its home directory in a different location by default. The path of the root user is '/root/', where it has control under all the directories and files.

How to find the Home Directory?

There are multiple ways to access and return to the home directory. Some commands are very helpful for the directories such as cd, pwd, mkdir, pwd, ls, and rmdir. To access the home directory graphically, open the files application, and click on the Home option from the left side menu. Consider the below image:

Linux Home Directory

Here, we can explore our home directory.

Generally, our terminal opens with the user's particular directory. To change directory to home directory, execute the cd command as follows:

The above command will change the directory to home. To list the home directory, execute the ls command as follows:

Consider the below output:

Linux Home Directory

We can get back to our home directory by executing the cd command without any argument. It will back to our home directory from any directory we are working on. Execute it as follows:

Consider the below output:

Linux Home Directory

From the above output, we were in /Directory/files, by executing only cd command, we reached to our home directory. We can use the "cd ~ or cd $HOME" commands as well, to do the same. Consider the below commands:

To display the current working directory, execute the pwd command as follows:

Consider the below output:

Linux Home Directory

To create a directory under a directory, execute the mkdir command as follows:

Consider the below output:

Linux Home Directory

From the above output, we have created a directory as 'new_dir', and displayed it by executing the ls command.

We can remove a directory as well. To remove a directory, execute the rmdir command as follows:

Consider the below output:

Linux Home Directory

From the above output, we have removed the 'new_dir' directory.

Difference between Root and Home Directory

Some key differences between root and home directory are as following:

Root Directory Home Directory
The root directory is the topmost level of the system drive. The home directory is a subdirectory of the root directory.
It is denoted by a slash '/'. It is denoted by '~' and has path "/users/username".
The admin has access to make any changes in the files and settings. No user other than the root user can change the settings of the entire system.
The admin can create a user. Any user having a home directory cannot create a user.
In the Linux file system, everything comes under the root directory. The home directory contains a particular user's data.

Next TopicLinux PWD





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA