In computer science, a Command-Line Interface (CLI) refers to a program that allows you to interact with the operating system by typing text-based commands. Instead of clicking through menus and windows, you enter instructions directly using your keyboard, and the system executes them instantly.
On Windows, the Command Prompt is one of the most widely used CLI tools. Developers, system administrators, and power users rely on it to perform tasks faster, automate workflows, and access system-level features that aren’t always available through graphical user interfaces (GUIs).
In this guide, we’ll walk you through 7 essential Command Prompt tricks you should definitely know. Mastering these commands can significantly improve your productivity and make working with Windows more efficient. Let’s get started.
Command Prompt Tricks You Should Know
Below are seven practical Command Prompt tricks that will help you navigate, manage files, and customize your command-line experience with ease.
Also, if you prefer a visual tutorial and want to learn more about the Command Prompt, you can watch the video mentioned below.
1. Listing Files and Directories
To view all files and folders in a directory, use the dir command. It displays a complete list of directories and files in your current location.
If you want to include hidden files and folders as well, use:
dir /a
This command reveals files that are normally hidden by the system.
Note
System files are hidden for a reason. Modifying or deleting them can cause system instability, so proceed carefully.
2. Opening Files Using Command Prompt
You can open files directly from the Command Prompt without navigating through File Explorer.
First, list the files in a directory using:
dir
To filter specific file types, such as PNG images, use:
dir *.png
To open a file, simply type its name along with the extension:
file_name_with_extension
The file will open using its default associated application.
3. Creating and Removing Directories
Creating and deleting folders is quick and easy with Command Prompt.
To create a new directory, use:
mkdir New
This creates a folder named New.
To remove an empty directory, use:
rmdir New
If the directory contains files or subfolders, use:
rmdir /s New
This deletes the directory along with everything inside it.
4. Changing Drives and Directories
By default, Command Prompt opens in a system directory such as C:\Windows\System32 or your user folder. You can switch drives and folders easily.
To list available drives on your system, run:
wmic logicaldisk get name
Now, to switch to another drive, type the drive letter followed by a colon:
E:
To change directories, use:
cd folder_name
For example:
cd Desktop
To move back to the previous directory, use:
cd ..
5. Changing Command Prompt Colors
You can customize the look of Command Prompt by changing its text and background colors.
Use the color command followed by a color code, for example:
color 08
Here, 0 represents the background color, and 8 represents the text color.
If you need help with color codes, use:
color /?
To revert to default colors, simply type:
color
6. Opening and Deleting Files
To open a file using its default application, navigate to its directory and type the file name:
note.txt
Now, to view the contents of a text file directly inside Command Prompt, use:
type note.txt
To delete a file, use:
del note.txt
Be cautious—deleted files do not go to the Recycle Bin.
7. Managing File Attributes
You can modify file attributes using the attrib command.
To view available options, use:
attrib /?
Now, to hide a file:
attrib +h note.txt
To make a file read-only:
attrib +r note.txt
To unhide a file:
attrib -h note.txt
Conclusion
That’s it! These Command Prompt tricks may seem simple, but once you start using them regularly, they can save you a lot of time and effort. Whether you’re managing files, navigating directories, or customizing your setup, Command Prompt gives you powerful control over your Windows system.
If you have any questions or additional tips to share, feel free to drop them in the comments, we’d love to hear from you.
