What is cwd in linux

WBOY
Release: 2022-07-12 15:05:33
Original
11063 people have browsed it

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.

What is cwd in linux

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

What is cwd in Linux

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

What is cwd in linux

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

What is cwd in linux

There are also some special FDs:

  1. rtd: root directory
  2. mem: memory mapped file
  3. mmap: memory mapped device

What is cwd in linux

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

  1. 0: stdout, standard output
  2. 1: stdin, standard input
  3. 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:

  1. u: read and write
  2. r: read only
  3. w: Just write

What is cwd in linux

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template