cd (command line command)

from Wikipedia, the free encyclopedia

cd , on some platforms also chdir (from English for ' ch ange dir ectory ' ), is a command line command for use in shells that enables the working directory to be changed. It is used with practically all common operating systems, including Unix , DOS , OS / 2 , AmigaOS , Windows and Linux . On UNIX version 5 and earlier, only the chdir command is known. The short name cd was introduced after the advent of 110 baud modems in order to increase the operating speed.

function

Most operating systems use the concept of the working directory. The working directory represents the current position in the directory hierarchy . This working directory can be changed with the cd command ; the user specifies the target directory as a parameter for cd, which should be the new working directory. This specification can be made absolutely (starting from the root directory) or relative to the current working directory.

POSIX

The corresponding system call for changing the working directory is after POSIX chdir (2) . The POSIX standard also specifies the few parameters of the implementations common under Unix and Linux.

  • -L (csh: -l ): Symbolic links are retained in the directory path
  • -P (csh: -p ): Symbolic links are resolved, so the directory path reflects the actual directory tree after cd is called
  • - (instead of a target directory): changes back to the last working directory

Most shells also allow the user to specify a list of directories in an environment variable (usually CDPATH ). This list is then searched for suitable subdirectories when cd is called with a relative path.

Without parameters cd changes to the user directory of the user who called the command, with cd .. it goes one level up. In some cases, additional parameters are added.

The chroot command is used to set another directory as the temporary root directory.

DOS / Windows

Under DOS-based operating systems with their drive letters , the command only changes within a drive; under MS-DOS, changing the drive itself requires another command; cd / D can be used under Windows . The other range of functions is clearly limited, as DOS knows neither user directories nor symbolic links. The shortcuts under Windows are just files at the DOS level.

Calling cd without arguments outputs the current directory, analogous to pwd on POSIX.

In addition, cd .. can be shortened to cd ... This does not work in the recovery console of the Windows CD, with Windows PowerShell and with many other operating systems.

Web links