7 Command Prompt Tricks that You Should Know

7 Command Prompt Tricks that You Should Know

In computer science, a Command-line interpreter (CLI) refers to a program that allows users to enter a command; it then reads and interprets the input and executes the input in the operating system. CLI accepts commands from a keyboard in the form of a text line. It is a powerful tool used by developers, system administrators, and power users to interact with the computer system directly through textual commands, bypassing the need for graphical user interfaces (GUIs).

Here we will be sharing with you 7 Command Prompt tricks that you should definitely know. Mastering these tricks can significantly improve your productivity and efficiency when working with the Command Prompt. Let’s dive in and explore these useful techniques to enhance your command-line experience.

Command Prompt Tricks that You Should Know

In this section, we will explore 7 Command Prompt tricks that are essential for improving your productivity and efficiency in navigating and managing your system.

1. Listing Files and Directories

If you want to list all your files and directories, you can do so with a few Command Prompt commands.

To view all the files and folders in a particular directory, use the “dir” command. This “dir” command will list all the directories available on your Windows computer.

Additionally, you can list all the hidden files and directories. If somebody has hidden some files and directories on your computer, you can view them with a Command Prompt command. For that, use the “dir /a” command.

Note: There’s a reason why system files and folders are hidden, so don’t tamper with these hidden files and folders as it can affect your computer.

2. Opening Files using Command Prompt

Do you know you can open any files using the command prompt? Yes, you can open any images, audio, and video files using command prompts.

To view all the files and folders available in a particular directory, use the “dir” command.

Now, for example, if you want to view all the PNG files available in that directory, then you would use the command “dir *.png“.

To open a file, use the following command: “file_name_with_extension“.

3. Creating and Removing Directories

Creating and removing directories or folders on a Windows 10 computer is very easy using the command prompt. You don’t need to select multiple options for that; just write one Command Prompt command.

To create directories, use this command: mkdir (make directory) mkdir New

This command will create a directory called “New“.

To remove directories, use this command: rmdir (remove directory) rmdir New

This command will delete the “New” directory. If you have other directories inside this directory, then you have to use rmdir /s New.

This command will delete all the directories available inside this directory along with the “New” directory.

4. Change Drives and Directories

By default, C:\Windows\System32 or C:\Users<username> is your default Command Prompt directory. Now, if you want to work on different drives and directories, you have to use the “change directory” command.

Before that, let us learn how to check the drives available on our computer. For that, use this command: wmic logicaldisk get name

To change the drive, use the drive name with a colon (E:). This will change the directory to the E drive.

To change the directory, use this command: cd folder_name. For example: cd desktop

Note: To return to the default directory or previous directory, use this command: cd ..

5. Changing Colors of Command Prompt

If you want a matrix look in your command prompt, you can change its colors. Here, we will learn how to change the text color and background color of the command prompt.

To change the text and background color, use the “color” command followed by the desired color code, for example: color 08

Here, 0 represents the background color, and 8 represents the text color. If you need more help with the “color” command, use either “color /?” or “help color”.

Note: Numbers 0-7 represent background colors, while 8, 9, and A-F represent text colors. To revert to the default settings, simply use the “color” command.

6. Opening and Deleting Files

Here, we are going to discuss Deleting and Appending to Files. Here, we will learn how to open and delete files using the command prompt.

Let’s see how we can open the file:

Use this command to open files with the default software. For example, if your text editor is Notepad, then when you open the file using the command prompt, it will open in Notepad.

Here’s the command: Navigate to the directory and type the file_name_with_extension (note.txt)

Now, to open the note.txt on the command prompt itself, use the command: type note.txt

Now, to delete the file, use the following command: del note.txt

7. File Attributes in Command Prompt

If you want to change the file attributes, use the following command.

Note: If you need help with file attributes, use this command: “attrib /?

To hide files, use “attrib +h file_name_with_extension”. For example, if I want to hide the note.txt file, I’ll use: attrib +h note.txt

To add the read-only attribute, use: attrib +r note.txt

To unhide the file, use this command: attrib -h note.txt

Conclusion

That’s it! These are a few useful Command Prompt tricks that you should know. I hope you found them helpful. However, if you have any doubts or suggestions, don’t hesitate to leave them in the comment section.

Posted by
Ajoy Kumar

He is a Computer Science graduate dedicated to empowering individuals to forge successful careers in programming and the dynamic world of technology and industry.

Leave a Reply

Your email address will not be published. Required fields are marked *