Command prompt (cmd) is a powerful tool that allows you to interact with your computer’s operating system. One of the most common tasks that you may need to perform in cmd is to navigate through the directory structure of your computer. This can be done using the “cd” command. However, if you need to go back to the previous directory, you can use the “cd..” command. In this article, we will show you how to go back directory in cmd using the “cd..” command.
The “cd..” command is a shortcut for the “cd ..” command. The “cd” command is used to change the current directory. The “..” represents the parent directory of the current directory. Therefore, the “cd..” command will change the current directory to the parent directory. For example, if you are currently in the “C:\Users\YourUsername\Desktop” directory, and you want to go back to the “C:\Users\YourUsername” directory, you can use the following command:
“`
cd..
“`
This will change the current directory to the “C:\Users\YourUsername” directory. You can use the “cd..” command to go back to the parent directory of any directory. This can be a useful shortcut when you need to navigate through the directory structure of your computer quickly and easily.
Navigate the File System
Navigating the file system is an essential skill for using the command prompt. The following are some basic commands for navigating the file system:
Current Directory
The current directory is the directory that is currently being displayed in the command prompt window. To get the current directory, use the “cd” command without any arguments. For example:
“`
C:\Users\User> cd
C:\Users\User\Documents
“`
Changing Directories
To change the current directory, use the “cd” command followed by the path to the new directory. For example, to change to the “Downloads” directory, you would use the following command:
“`
C:\Users\User\Documents> cd Downloads
“`
Listing Files and Directories
To list the files and directories in the current directory, use the “dir” command. For example:
“`
C:\Users\User\Downloads> dir
Volume in drive C is OSDisk
Volume Serial Number: 40ED-1E3A
Directory of C:\Users\User\Downloads
02/20/2023 02:47 PM
02/20/2023 02:47 PM
02/20/2023 02:47 PM 1,922 setup.exe
02/20/2023 02:47 PM 110,852 software_installer.exe
02/20/2023 02:47 PM 4,608 test1.txt
02/20/2023 02:47 PM 4,608 test2.txt
5 File(s) 121,988 bytes
2 Dir(s) 102,170,649,600 bytes free
“`
Moving Up a Directory
To move up one directory, use the “cd ..” command. For example, to move from the “Downloads” directory to the “User” directory, you would use the following command:
“`
C:\Users\User\Downloads> cd ..
C:\Users\User>
“`
Absolute and Relative Paths
An absolute path is a path that starts from the root directory of the drive. For example, the following is an absolute path to the “Downloads” directory:
“`
C:\Users\User\Downloads
“`
A relative path is a path that starts from the current directory. For example, the following is a relative path to the “Downloads” directory:
“`
Downloads
“`
Using the Command Prompt
The Command Prompt is a powerful tool that allows you to interact with your computer at a command-line level. One of the many commands you can use in the Command Prompt is cd
, which allows you to change directories. To go back one directory in the Command Prompt, you can use the following steps:
- Open the Command Prompt. To do this, you can type "cmd" into the Windows search bar and click on the Command Prompt icon that appears.
- Navigate to the directory you want to go back from. To do this, type the
cd
command followed by the path to the directory. For example, if you want to go back to the directoryC:\Users\John\Documents
, you would type the following command:
cd C:\Users\John\Documents
- Type the
cd..
command. This command will go back one directory from the current directory. - Press Enter. The Command Prompt will now go back one directory.
The “CD” Command
The “cd” command in Command Prompt (cmd) allows you to navigate through directories and folders in the file system. To go back a directory, use the following syntax:
cd ..
This will take you up one level in the directory structure. For example, if you are currently in the “C:\Users\Username\Documents” directory, running “cd ..” will take you to the “C:\Users\Username” directory.
Going Back Multiple Levels
You can also go back multiple levels in the directory structure using the “cd” command. To do this, use the following syntax:
cd ..\..\..\
This will take you back four levels in the directory structure. You can add or remove as many “\..”s as needed to go back the desired number of levels.
For example, the following command will take you back five levels in the directory structure:
cd ..\..\..\..\
It’s important to note that the “cd” command only works on directories. It cannot be used to navigate to files.
Example
Command | Result |
cd .. | Goes up one level in the directory structure |
cd ..\.. | Goes up two levels in the directory structure |
cd ..\..\.. | Goes up three levels in the directory structure |
Parent Directory with “..\”.
To go to the parent directory of the current directory in the Command Prompt, you can use the “cd..” command. This command will move you up one level in the directory structure. For example, if you are currently in the “My Documents” directory, and you want to go to the “C:” drive, you can use the following command:
“`
cd..
“`
This will move you to the “C:” drive. You can also use the “cd..” command to go to the parent directory of a specific directory. For example, if you are currently in the “My Documents\My Pictures” directory, and you want to go to the “My Documents” directory, you can use the following command:
“`
cd..\
“`
This will move you to the “My Documents” directory.
Here is a table summarizing the usage of the “cd..” command:
Command | Description |
---|---|
cd.. | Go to the parent directory of the current directory. |
cd..\directory | Go to the parent directory of the specified directory. |
Multiple Directory Levels
To go back multiple directory levels in cmd, use the cd ..
command with the desired number of periods. For example, cd ...
goes back three directories, while cd ....
goes back four directories.
Going Back One Directory
To go back one directory, use the cd ..
command. This command moves you up one level in the directory tree.
Going Back Two Directories
To go back two directories, use the cd ../..
command. This command moves you up two levels in the directory tree.
Going Back Three Directories
To go back three directories, use the cd ../../..
command. This command moves you up three levels in the directory tree.
Going Back Four Directories
To go back four directories, use the cd ../../../..
command. This command moves you up four levels in the directory tree.
Going Back Five Directories
To go back five directories, use the cd ../../../../..
command. This command moves you up five levels in the directory tree.
Going Back Six Directories
To go back six directories, use the cd ../../../../../..
command. This command moves you up six levels in the directory tree.
Going Back Seven Directories
To go back seven directories, use the cd ../../../../../../..
command. This command moves you up seven levels in the directory tree.
Number of Periods | Number of Directory Levels |
---|---|
1 | 1 |
2 | 2 |
3 | 3 |
4 | 4 |
5 | 5 |
6 | 6 |
7 | 7 |
Navigate Back to Root Directory
Navigate back to the root directory by following these simple steps:
- Open Command Prompt (CMD) by pressing the Windows key + R, typing “cmd”, and hitting Enter.
- Type “cd \” (without quotes) to go to the root directory.
- Press Enter.
Alternatively, use the table below for a quick reference to navigate back to the root directory and other common directories.
Command | Description |
---|---|
cd \ | Go to the root directory |
cd.. | Go to the parent directory |
cd Documents | Go to the Documents directory |
cd Desktop | Go to the Desktop directory |
cd Downloads | Go to the Downloads directory |
Automate with Batch Files
Batch files provide a convenient way to automate repeated tasks in the command prompt, including changing directories. Here’s how to use batch files for this purpose:
- Create a new batch file: Open Notepad or any other text editor and create a new file.
- Start with the @ECHO command: This command suppresses the display of commands in the command prompt when the batch file is executed.
- Use the CD command: Use the CD command followed by the directory path you want to change to. For example, to change to the “Documents” folder, use the following command:
@ECHO OFF CD Documents
- Add additional commands: You can add any other commands you need to execute after changing directories. For instance, you can use the DIR command to list the files in the current directory.
- Save the batch file: Save the file with a “.bat” extension, such as “ChangeDirectory.bat.”
- Run the batch file: Double-click the batch file to execute it. It will automatically perform the specified directory changes and any other commands included in the file.
Here’s an example of a batch file that navigates to the “C:\Users\username\Documents” folder and lists the files in that directory:
Batch File Code | Description |
---|---|
@ECHO OFF |
Suppress display of commands |
CD C:\Users\username\Documents |
Change directory to the specified path |
DIR |
List files in the current directory |
How To Go Back Directory In Cmd
To go back a directory in the Command Prompt (cmd), you can use the “cd..” command. This command will take you up one level in the directory tree. For example, if you are currently in the “C:\Users\YourUserName\Documents” directory, and you want to go back to the “C:\Users\YourUserName” directory, you would type “cd..” into the Command Prompt.
You can also use the “cd” command to go back to a specific directory. For example, if you want to go back to the “C:\Windows” directory, you would type “cd C:\Windows” into the Command Prompt.
People Also Ask About How To Go Back Directory In Cmd
How do I go back to the previous directory in cmd?
To go back to the previous directory in cmd, you can use the “cd..” command.
How do I go back to the root directory in cmd?
To go back to the root directory in cmd, you can use the “cd /” command.
How do I go back to the desktop in cmd?
To go back to the desktop in cmd, you can use the “cd %userprofile%\Desktop” command.