CLI Navigating the Command Prompt
Navigating the Command Prompt in Windows CLI involves moving through directories, viewing directory contents, and understanding your current location within the file system. Here’s a guide to mastering navigation commands in the Command Prompt.
1. Opening the Command Prompt
- Press
Win + R
, typecmd
, and pressEnter
. - Alternatively, search for "Command Prompt" in the Start menu.
2. Checking Your Current Directory with cd
- The prompt shows the current directory by default, like this:
- To verify or display the current directory at any time, simply type:
3. Changing Directories with cd
To move into a directory:
Use thecd
command followed by the directory name.Example:
This moves you from the current directory to the
Documents
folder.To go back to the previous directory:
Usecd ..
to move up one level in the directory structure.To switch to a specific path:
Enter the full path to navigate directly to that folder.To change drives:
Use the drive letter followed by a colon (:
) to switch between drives.
4. Listing Directory Contents with dir
- Use the
dir
command to display files and folders in the current directory: - With options:
dir /p
: Displays results one page at a time (helpful for long lists).dir /s
: Shows all files and subdirectories in the current directory and its subdirectories.dir /a
: Shows hidden files and system files.
5. Creating Directories with mkdir
- To create a new directory (folder) within the current directory:
6. Moving Between Directories Quickly
- Use Tab Autocomplete: Start typing a directory or file name and press
Tab
to autocomplete names in the current directory.
7. Viewing Directory Path with echo %cd%
- The
echo %cd%
command outputs the full path of the current directory.
Examples of Navigation
Quick Tips
- Use
cd /d <drive>
: Changes directories and drives simultaneously. dir /b
: Lists files and folders in a bare format, without extra details.
Mastering these navigation commands will make it easier to work with files, directories, and drives directly from the Command Prompt, allowing for quicker and more efficient navigation throughout your file system.