Home > Article > Operation and Maintenance > What directory is linux home?
In Linux, home is the user's host directory, which is usually used to save the user's files; when a user logs in to the system, the location after entering is "/home". The home directory of the root user is "/root". The home directory is usually represented by a tilde "~". There are three ways to enter the home directory: 1. Use the "cd" command directly; 2. Use the "cd ~" command; 3. Use the absolute path and execute "cd / home/xxxuser" command.
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
What is home directory?
Linux’s home directory is the user’s home directory. When a user logs in to the system, his location is It is /home. The Linux home directory is usually used to save user files. The root user's home directory is /root.
Linux’s home directory is usually represented by a tilde “~”. For example, if the current user's home directory is /home/haicoder, then entering cd or cd ~ or cd /home/haicoder or cd $HOME are equivalent.
This habit originated from the popular Lear-Siegler ADM-3A terminal machine in the 1970s. On this machine, the tilde and "home" key (used to move the cursor to the far left) happened to be on the same key.
Instructions
In Linux, there are many ways to enter the user's home directory.
Enter the home directory
Command | Description |
---|---|
cd | Use the cd command directly to enter the current user's home directory. |
cd ~ | Use the cd ~ command to enter the current user's home directory. |
cd /home/xxxuser | Using the absolute path, you can also enter the user's home directory. |
The case of entering the home directory
We first use the cd command to enter the /tmp directory , the specific command is as follows:
cd /tmp
After running, the terminal output is as follows:
Now, we use the cd command again to enter the home directory of the current user, The specific command is as follows:
cd
After running, the terminal output is as follows:
Now, we use the pwd command to view the current directory. The specific command is as follows:
pwd
After running, the terminal output is as follows:
We see that the directory we are in at this time is /root, because we are now the root user, and its home The directory is /root, so we used the cd command to enter the home directory. Now, we use the cd command again to switch to the /tmp directory. The specific command is as follows:
cd /tmp
After running, the terminal output is as follows:
Now, we use the cd command again to enter the home directory of the current user. The specific command is as follows:
cd ~
After running, the terminal output is as follows:
Now, we use the pwd command to view the current directory. The specific command is as follows:
pwd
After running, the terminal output is as follows:
We see that the directory we are in at this time is /root.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of What directory is linux home?. For more information, please follow other related articles on the PHP Chinese website!