Home  >  Article  >  Operation and Maintenance  >  What is the working directory in linux

What is the working directory in linux

青灯夜游
青灯夜游Original
2022-07-01 18:41:5110589browse

In Linux, the working directory is also called the "current directory". It is the directory where the user currently resides in the file system after logging into the Linux system; a series of operations performed by the user in this directory are equivalent to the user's current directory in the file system. Work under it, so it is called the "working" directory. The working directory can be changed at any time. Use the cd command to switch the working directory. The syntax is "cd [relative path or absolute path]".

What is the working directory in linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

#What is the Linux working directory

After the user logs in to the Linux system, he is in a certain directory at all times , this directory is called the working directory or current directory (Working Directory).

To put it simply: the working directory is the directory you are currently in; this directory is your working directory, and a series of operations you perform in this directory are equivalent to working in this directory, so it is called "work" Directory

When a user initially logs into the system, his home directory (Home Directory) becomes his working directory. The working directory is represented by "." and its parent directory is represented by "..".

The working directory can be changed at any time, just use the cd command.

linux cd command

cd command is the abbreviation of Change Directory, used to switch the working directory.

Linux commands can be divided into two types according to their source, namely Shell built-in commands and external commands. The so-called Shell built-in commands are the commands that come with the Shell. These commands do not have executable files; external commands are developed independently by programmers, so there will be executable files for the commands. Most commands in Linux are external commands, and the cd command is a typical Shell built-in command, so the cd command does not execute the path of the file.

The basic format of the cd command is as follows:

[root@localhost ~]# cd [相对路径或绝对路径]

In addition, the cd command can be followed by some special symbols to express fixed meanings, as shown in Table 1:

Table 1 Special symbols of the cd command
Special symbols Function
~ Represents the home directory of the currently logged in user
~Username Represents switching to the home directory of the specified user
- represents the last directory
. represents the current directory
.. represents the upper-level directory

Their usage is:

[root@localhost vbird]# cd ~
#表示回到自己的主目录,对于 root 用户,其主目录为 /root
[root@localhost ~]# cd
#没有加上任何路径,也代表回到当前登录用户的主目录
[root@localhost ~]# cd ~vbird
#代表切换到 vbird 这个用户的主目录,亦即 /home/vbird
[root@localhost ~]# cd ..
#表示切换到目前的上一级目录,亦即是 /root 的上一级目录的意思;

It should be noted that in the Linux system, the root directory is indeed There are two directories. (current directory) and .. (parent directory of the current directory), but since the root directory is the top-level directory, the attributes and permissions of .. and . of the root directory are exactly the same, that is to say, the root directory The parent directory is itself.

[root@localhost /]# cd -
#表示回到刚刚的那个目录

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of What is the working directory in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn