Cd cmd command - GeeksforGeeks

30 Sep, 2020
Cd is the abbreviation or synonym for chdir. It is a command found inside the Windows Command Processor (cmd) that allows for change of the current working directory of a shell instance. The CWD (Current Working Directory) is a path (of a directory) inside the file system, where the shell is currently working. The current working directory is essential for resolving relative paths. Cd is a generic command found in the Command Interpreter of most operating systems.
Description of the Command :Displays the name of or changes the current directory.
CHDIR [/D] [drive:][path]
CHDIR [..]
CD [/D] [drive:][path]
CD [..]

..   Specifies that you want to change to the parent directory.
Type CD drive: to display the current directory in the specified drive.Type CD without parameters to display the current drive and directory.Use the /D switch to change the current drive in addition to changing the current directory for a drive.
Some of the output is truncated due to its large length.
In order to obtain the above text execute the cd /? command on cmd.
It should be noted that chdir is an alias for cd, and therefore can be replaced for all of its occurrences.
Using the Command :
Displaying the Current Working Directory :Displaying the current working directory is not generally not required on cmd. This is because the default prompt in cmd displays the Current drive and path (CWD) along with the greater than sign ( > ) at all times ($P$G code). But for the sake of completeness, we would be describing it as well. To display the Current Working Directory, execute the cd command without any arguments.Syntax :cdApparent from the above output, it is not necessary for us to print the cwd as it is already being displayed by the prompt. Throughout the article, we will be using C:\Users as our CWD.Changing the CWD :We can change the Current Working Directory to different paths in the system. The following are the options –1. To a Directory of Current Drive :To change the working directory, execute command cd followed by an absolute or relative path of the directory you are wanting to become the CWD. Where the path should qualify the following criteria –The Path should be of a Directory.The Directory should be existing.Path can be absolute or relative. If a relative path is used, then the path should be relative to the CWD.Syntax :cd [Path]2. To a Directory of Another Drive :To change the working directory to another drive, execute command cd /D followed by a path to a directory. The path should qualify the following criteria –The path should be absolute.The path should contain the drive letter followed by a drive qualifier (DRIVE_LETTER & COLON).Syntax :cd /d [Path]3. An additional way to change the CWD to another drive without the usage of the cd command is to execute the drive letter followed by a colon.Syntax :(Drive_Letter):
Displaying the Current Working Directory :Displaying the current working directory is not generally not required on cmd. This is because the default prompt in cmd displays the Current drive and path (CWD) along with the greater than sign ( > ) at all times ($P$G code). But for the sake of completeness, we would be describing it as well. To display the Current Working Directory, execute the cd command without any arguments.Syntax :cdApparent from the above output, it is not necessary for us to print the cwd as it is already being displayed by the prompt. Throughout the article, we will be using C:\Users as our CWD.
Syntax :
cd
Apparent from the above output, it is not necessary for us to print the cwd as it is already being displayed by the prompt. Throughout the article, we will be using C:\Users as our CWD.
Changing the CWD :We can change the Current Working Directory to different paths in the system. The following are the options –1. To a Directory of Current Drive :To change the working directory, execute command cd followed by an absolute or relative path of the directory you are wanting to become the CWD. Where the path should qualify the following criteria –The Path should be of a Directory.The Directory should be existing.Path can be absolute or relative. If a relative path is used, then the path should be relative to the CWD.Syntax :cd [Path]2. To a Directory of Another Drive :To change the working directory to another drive, execute command cd /D followed by a path to a directory. The path should qualify the following criteria –The path should be absolute.The path should contain the drive letter followed by a drive qualifier (DRIVE_LETTER & COLON).Syntax :cd /d [Path]3. An additional way to change the CWD to another drive without the usage of the cd command is to execute the drive letter followed by a colon.Syntax :(Drive_Letter):
1. To a Directory of Current Drive :To change the working directory, execute command cd followed by an absolute or relative path of the directory you are wanting to become the CWD. Where the path should qualify the following criteria –
The Path should be of a Directory.
The Directory should be existing.
Path can be absolute or relative. If a relative path is used, then the path should be relative to the CWD.
Syntax :
cd [Path]
2. To a Directory of Another Drive :To change the working directory to another drive, execute command cd /D followed by a path to a directory. The path should qualify the following criteria –
The path should be absolute.
The path should contain the drive letter followed by a drive qualifier (DRIVE_LETTER & COLON).
Syntax :
cd /d [Path]
3. An additional way to change the CWD to another drive without the usage of the cd command is to execute the drive letter followed by a colon.
Syntax :
(Drive_Letter):
Operating Systems
Operating Systems
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Page Replacement Algorithms in Operating Systems
Program for FCFS CPU Scheduling | Set 1
Program for Round Robin scheduling | Set 1
Introduction of Deadlock in Operating System
Inter Process Communication (IPC)
Introduction of Operating System - Set 1
Difference between Process and Thread
CPU Scheduling in Operating Systems
Paging in Operating System
Semaphores in Process Synchronization