The Linux user directory is a directory created by the system administrator when adding users. Each user has his own home directory. The home directories of different users are generally different from each other; when a user first logs in to the system, other The working directory is the user's home directory, usually the same as the user's login name; users can reference their home directory through a "~" character.
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
What does the linux user directory mean?
~ represents the user’s home directory in Linux
For general users, ~ represents /home/ (user name)
For root users, ~ represents /root
If you want to see the true appearance of ~, you can first enter the ~ directory, and then use the pwd -P command to view the absolute path of ~
cd ~ pwd -P
The user's home directory can be in /etc/passwd Item 6 finds
[root@www ~]# head -n 4 /etc/passwdroot:x:0:0:root:/root:/bin/bash <p> Home directory: <br> This is the user’s home directory. Taking the above example, root’s home directory is in /root, so when root logs in, it will immediately go to /root It’s in the catalog! hehe! If you have an account with a particularly large space, what should you do if you want to move the account's home directory to another hard drive? correct! You can make modifications in this field! The default user home directory is in The /home/yourIDname</p><p> directory is a special file for organizing files in the Linux system. To enable users to better use directories, we introduce some basic concepts about directories. </p><p>(1) Working directory and user home directory <br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">Logically speaking, after the user logs in to the Linux system, he is in a certain directory at all times. This directory <br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px"> The directory is called the working directory or current directory (Working Directory). The working directory can be changed at any time. When a user initially logs into the system, his home directory (Home<br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">Directory) becomes his working directory. The working directory is represented by "." and its parent directory is represented by "..". <br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">The user home directory is created by the system administrator when adding users (it can also be changed later). Each user has his own home directory. The home directories of different users are generally different from each other. <br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">When a user first logs in to the system, his working directory is the user's home directory, which is usually the same as the user's login name. <br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">Users can reference their home directory through a ~ character. <br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">For example, the command <br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">/home/WANG$ cat ~/class/software_1<br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px"> has the same meaning as the following command <br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">/home/WANG$ cat /home/WANG/class/software_1<br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">. The shell will replace the ~ character with the name of the user's home directory. After the directory hierarchy is created, users can put relevant files into the corresponding directories to organize the files. </p><p>(2)路径 <br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">顾名思义,路径是指从树型目录中的某个目录层次到某个文件的一条道路。此路径的主要构成是目录名称,中间用“/”分开。任一个文件在文件系统中的位置都是由相应的路径决定的。 <br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">用户在对文件进行访问时,要给出文件所在的路径。 路径又分相对路径和绝对路径。 绝对路径是指从“根”开始的路径,也称为完全路径;相对路径是从用户工作目录开始的路径。 <br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">应该注意到,在树型目录结构中到某个确定文件的绝对路径和相对路径均只有一条。绝对路径是确定不变的,而相对路径则随着用户工作目录的变化而不断变化。这一点对于我们以后使用某些命令如cp和tar等大有好处。 <br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">用户要访问一个文件时,可以通过路径名来引用,并且可以根据要访问的文件与用户工作<br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">目录的相对位置来引用它,而不需要列出这个文件的完整路径名。例如,用户WANG有一个名为class的目录,该目录中有两个文件:software_1<br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">和hardware_1。若用户WANG想显示出其class目录中的名为software_1的文件,可以使用下列命令: <br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">/home/WANG$ cat /home/WANG/class/software_1<br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px">用户也可以根据文件software_1与当前工作目录的相对位置来引用该文件。</p><p>这时命令为: <br style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px"></p><pre class='brush:php;toolbar:false;'> /home/WANG$ cat class/software_1
Linux中用 pwd 命令来查看”当前工作目录“的完整路径。 简单得说,每当你在终端进行操作时,你都会有一个当前工作目录。
在不太确定当前位置时,就会使用pwd来判定当前目录在文件系统内的确切位置。
命令格式:
pwd [选项]
命令功能:
查看”当前工作目录“的完整路径
常用参数:
一般情况下不带任何参数
如果目录是链接时:
格式:pwd -P 显示出实际路径,而非使用连接(link)路径。
常用实例:
1:用 pwd 命令查看默认工作目录的完整路径
[root@localhost ~]# pwd /root [root@localhost ~]#
实例2:
[root@localhost ~]# cd /opt/soft/ [root@localhost soft]# pwd /opt/soft [root@localhost soft]#
实例三:目录连接链接时,pwd -P 显示出实际路径,而非使用连接(link)路径;pwd显示的是连接路径
命令:
输出:
[root@localhost soft]# cd /etc/init.d [root@localhost init.d]# pwd /etc/init.d [root@localhost init.d]# pwd -P /etc/rc.d/init.d [root@localhost init.d]#
实例4:/bin/pwd
命令:
/bin/pwd [选项]
选项:
目录连接链接时,输出连接路径 输出物理路径输出:
[root@localhost init.d]# /bin/pwd /etc/rc.d/init.d [root@localhost init.d]# /bin/pwd --help [root@localhost init.d]# /bin/pwd -P /etc/rc.d/init.d [root@localhost init.d]# /bin/pwd -L /etc/init.d [root@localhost init.d]#
实例五:当前目录被删除了,而pwd命令仍然显示那个目录
输出:
[root@localhost init.d]# cd /opt/soft [root@localhost soft]# mkdir removed [root@localhost soft]# cd removed/ [root@localhost removed]# pwd /opt/soft/removed [root@localhost removed]# rm ../removed -rf [root@localhost removed]# pwd /opt/soft/removed [root@localhost removed]# /bin/pwd /bin/pwd: couldn't find directory entry in “..” with matching i-node [root@localhost removed]# cd [root@localhost ~]# pwd /root [root@localhost ~]#
推荐学习:《linux视频教程》
The above is the detailed content of What does linux user directory mean?. For more information, please follow other related articles on the PHP Chinese website!

The five core components of the Linux operating system are: 1. Kernel, 2. System libraries, 3. System tools, 4. System services, 5. File system. These components work together to ensure the stable and efficient operation of the system, and together form a powerful and flexible operating system.

The five core elements of Linux are: 1. Kernel, 2. Command line interface, 3. File system, 4. Package management, 5. Community and open source. Together, these elements define the nature and functionality of Linux.

Linux user management and security can be achieved through the following steps: 1. Create users and groups, using commands such as sudouseradd-m-gdevelopers-s/bin/bashjohn. 2. Bulkly create users and set password policies, using the for loop and chpasswd commands. 3. Check and fix common errors, home directory and shell settings. 4. Implement best practices such as strong cryptographic policies, regular audits and the principle of minimum authority. 5. Optimize performance, use sudo and adjust PAM module configuration. Through these methods, users can be effectively managed and system security can be improved.

The core operations of Linux file system and process management include file system management and process control. 1) File system operations include creating, deleting, copying and moving files or directories, using commands such as mkdir, rmdir, cp and mv. 2) Process management involves starting, monitoring and killing processes, using commands such as ./my_script.sh&, top and kill.

Shell scripts are powerful tools for automated execution of commands in Linux systems. 1) The shell script executes commands line by line through the interpreter to process variable substitution and conditional judgment. 2) The basic usage includes backup operations, such as using the tar command to back up the directory. 3) Advanced usage involves the use of functions and case statements to manage services. 4) Debugging skills include using set-x to enable debugging mode and set-e to exit when the command fails. 5) Performance optimization is recommended to avoid subshells, use arrays and optimization loops.

Linux is a Unix-based multi-user, multi-tasking operating system that emphasizes simplicity, modularity and openness. Its core functions include: file system: organized in a tree structure, supports multiple file systems such as ext4, XFS, Btrfs, and use df-T to view file system types. Process management: View the process through the ps command, manage the process using PID, involving priority settings and signal processing. Network configuration: Flexible setting of IP addresses and managing network services, and use sudoipaddradd to configure IP. These features are applied in real-life operations through basic commands and advanced script automation, improving efficiency and reducing errors.

The methods to enter Linux maintenance mode include: 1. Edit the GRUB configuration file, add "single" or "1" parameters and update the GRUB configuration; 2. Edit the startup parameters in the GRUB menu, add "single" or "1". Exit maintenance mode only requires restarting the system. With these steps, you can quickly enter maintenance mode when needed and exit safely, ensuring system stability and security.

The core components of Linux include kernel, shell, file system, process management and memory management. 1) Kernel management system resources, 2) shell provides user interaction interface, 3) file system supports multiple formats, 4) Process management is implemented through system calls such as fork, and 5) memory management uses virtual memory technology.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver Mac version
Visual web development tools
