In Linux, cwd refers to the directory where a certain process is running; cwd is the abbreviation of "current working directory", that is, the current working directory. cwd is not a command that comes with the system, but is a property of the system. , you can see cwd in the "/proc/{id}" directory.
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
pwd, $PWD and cwd in Linux
Explanation in one sentence: They all refer to the directory where a certain process is running.
$PWD is a system variable
pwd is a command that comes with linux. Full name: pathname of the current working directory.
cwd: It is not a command that comes with the system, but it belongs to the system Property. Full name: current working directory. Not only can you see cwd in the directory /proc/{id}, but you can also see it in many other programming languages (such as grunt)
cwd refers to current work directory, which is the current working directory.
Extended knowledge
FD name (cwd, memory...\d[u|r|w])
When executing a process, There will be a cwd file descriptor.
cwd refers to the current work directory, which is the current working directory.
Why is there an FD specifying the current directory?
is because in the Linux system, both directories and files exist in the form of files. So when we execute a process, we need to specify which directory to execute it in. The system will open the specified execution directory. Then this process is also a process of opening system files, that is, FD will be created. So it can be understood that any process will have a cwd FD
When a process is executed, there will be a txt file descriptor.
txt can be understood as program code, such as the binary library of an application or a shared library, etc.
Why is there FD of txt?
Since it is an execution process, there must be a code file that specifies the execution content. The file content needs to be read during execution, so opening the code file will inevitably create an FD. So it can be understood that any process will have a txt FD
There are also some special FDs:
- rtd: root directory
- mem: memory mapped file
- mmap: memory mapped device
There are also some FDs that start with a numerical value , these represent some file descriptors that need to be opened when this process is executed. This value can also be understood as an integer returned when the file is opened. When each process is initially opened, there will be three FDs starting with values by default, namely 0, 1, and 2. It can also be regarded as built-in FD, because they represent special meanings by default
- 0: stdout, standard output
- 1: stdin, standard input
- 2: stder, error output
So when the application opens a file internally, the values start from 3, and the valid range is 0-OPEN_MAX
An identification of FD read and write permissions will be added after the value:
- u: read and write
- r: read only
- w: Just write
Recommended learning: Linux video tutorial
The above is the detailed content of What is cwd in linux. For more information, please follow other related articles on the PHP Chinese website!