Go forward : cd path\to\folder
Go backward : cd ../..
Show lists of files and directories : dir
Show lists of files and directories with hidden files also : dir /a
Clearing screen : cls
Show specific type of files: dir *.png | dir *.jpg
Help for a specific command: ipconfig /? | cls /?
Create a new directory : mkdir myDir | mkdir path\to
Remove or delete directories: if your directory is empty rmdir myDir else rmdir /S myDir
Changing drivers : C: | D:
Show path variables: path
Show available drive names: wmic logicaldisk get name
Change color: color 0B | color 90 or back to default just use color
Creating a file : echo somecontent > file.txt
Deleting file: del filename.ext
Reading contents of a file: type file.ext\
Override to a file : echo newcontent > samefile.ext
Appending to a file : echo appendingcontent >> samefile.ext
Copying files: copy test.txt mydir
Introduction to Command Prompt:
The command line in Windows is also known as Command Prompt or CMD.
On Mac and Linux systems, it's called Terminal.
To open Command Prompt, follow these steps: Open Start, search for 'Command Prompt', and select it.
Alternatively, you can click the keyboard shortcut (Windows + R), type 'cmd', and press Enter.
The first line will indicate the version we are using and the current file location by default.
Right-click on the top title bar, and the Properties screen will appear. From there,
To move from one directory to another, use the cd command followed by the folder name.
For example, to move to the 'Desktop' directory from C:\user\ranjith, type cd desktop.
C:\user> ranjith >
Cd space desktop
To go to the 'python' folder inside 'Desktop', type cd desktop\python.
C:\user> ranjith >
Cd desktop > python
To return to the parent directory, use cd ... For example, if you are in C:\user\ranjith\desktop\python and want to go back two levels to
C:\user\ranjith,
type cd ..\..
To navigate directly to a specific directory in one line, you can provide the full path.
For example, to go directly to C:\user\ranjith\desktop\python,
you can type cd
C:\user\ranjith\desktop\python.
To list files and directories :
use the dir command.
For example, C:\user\ranjith> dir
will show the files, folders, free space, and storage details in the current directory.
To view the contents of a specific folder, use dir followed by the folder path.
For example, C:\user\ranjith>dir
Desktop\Python will display all files and folders in the Python folder on the Desktop.
To view hidden or system files, you can use the dir /a command.
For example,
C:\user\ranjith>dir /a
will display all files, including hidden and system files.
To clear the command prompt screen, use the cls command.
For example,
C:\user\ranjith> cls
will clear the screen and remove previous command outputs.
Opening Files and Viewing History:
To list files of a specific type in a directory, use the dir command with a filter.
For example,
C:\user\ranjith>dir *.png will list all PNG
image files in the current directory.
To open a specific file, enter its filename.
For instance,
C:\user\ranjith\python>binary_search.png would open the binary_search.png file.
To navigate through your command history, use the Up and Down arrow keys. Pressing the Up arrow key will cycle through previous commands, while the Down arrow key will move forward through the commands.
To get help on a command, use the /? option.
For example,
C:\user\ranjith>ipconfig /? will show help for the ipconfig command.
Creating and Removing Folders:
To create a new folder, use the mkdir command followed by the folder name.
For example,
C:\user\ranjith>python>mkdir temp will create a folder named temp.
To remove a folder, use the rmdir command followed by the folder name.
For example,
C:\user\ranjith>python>rmdir temp will delete the temp folder.
Note that the rm command is used for files in some systems, but in Command Prompt, you use del for files and rmdir for directories.
Creating and removing directories:
To create a directory, use the command mkdir txt.
To remove a directory and its contents, use rmdir /s txt.
This will delete all files and subfolders in the directory as well as the directory itself.
Use Ctrl + Left Arrow to move the cursor to the beginning of the line and Ctrl + Right Arrow to move it to the end.
To check the version, use ver.
To start multiple command boxes, use Start.
To exit, use Exit.
Drives and Color Commands:
To list all drives, use: wmic logicaldisk get name. This will show all available drives.
c:\user> ranjith >
wmic logicaldisk get name
To switch to a different drive, type the drive letter followed by a colon (e.g., E:).
C:\user> ranjith > E:
To list files in the current drive, use: dir.
E :\> dir
To view hidden files, use: dir /a.
E :\> dir /a
To see a directory tree, use: tree.
E :\> tree
Changing Text and Background Colors:
E :\> color /?
To change the color of text and background, use: color /? to see help options.
For example, color a changes the text color to green.
E :\> color
E :\> color a
color fc sets a bright white background (if 'f' is not given, it defaults to black) and changes text color to bright red.
E :\> color fc
These commands help manage files and customize the appearance of your command prompt
File Attributes:
To view file attributes and get help, use: attrib /?.
C:\user> ranjith > YouTube > attrib /?
To see the attributes of a file, use: attrib sample.txt.
C:\user> ranjith > Desktop >youtube >
attrib sample. txt
Replace sample.txt with your file name.
To add the "hidden" attribute to a file, use: attrib +h sample.txt.
C:\user> ranjith > Desktop >youtube >
attrib +h sample. txt
To remove the "hidden" attribute, use: attrib -h sample.txt.
C:\user> ranjith > Desktop >youtube >
attrib +r - h sample. txt
Deleting and Creating Files:
To delete a file, use: del sample.txt.
C:\user> ranjith > Desktop >youtube >
del sample. txt
del - delete <FileName >
To create a new file, use: echo. > sample.txt. This creates an empty file.
C:\Users\mrkis\Desktop\Youtube>
echo > sample.txt
To write text to a file, use: echo Kishore > sample.txt. This writes "Kishore" to the file.
C:\Users\mrkis\Desktop\Youtube>
echo Kishore > sample.txt
C:\Users\mrkis\Desktop\Youtube>
type sample.txt
To view the contents of the file, use: type sample.txt.
Appending Text to Files:
C:\Users\mrkis\Desktop\Youtube>echo hello>sample.txt
To add text to the end of a file without overwriting existing content, use: echo world >> sample.txt.
C:\Users\mrkis\Desktop\Youtube>type sample.txt
This will add "world" to the end of sample.txt.
To see the updated content, use: type sample.txt.
Copying Files:
To copy a file to another location or with a new name, use: copy sample.txt test2.txt. This copies sample.txt to a new file named test2.txt in the same directory. If you want to specify a different directory, provide the path instead of just the filename.
C:\Users\mrkis\Desktop\Youtube>
copy sample.txt test2
This guide helps with managing file attributes, performing file operations, and
Copying Files Between Disks:
To copy a file from one disk to another, use: copy sample.txt E:. This copies sample.txt from the current location to the E: drive.
Using XCOPY for Copying Directories:
To copy files and directories, including subdirectories, use: xcopy test1 test2 /s. This copies test1 (which can be a file or directory) to test2, including all subfolders and files.
Moving Files:
C:\Users\mrkis\Desktop\Youtube>
copy sample.txt e:
E - another disk
To move files from one location to another, use: move test1 test2. This command moves test1 to test2. If test2 is a folder, test1 will be moved into it. If test2 is a file name, test1 will be renamed to test2.
In summary:
C:\Users\mrkis\Desktop\Youtube>
xcopy test1 test2 /s
copy sample.txt test2
Sample. txt - endha file ah copy seiya vendum.
S - sub files
copy source destination copies files.
xcopy source destination /s copies files and directories, including subdirectories.
move source destination moves files or renames them
Top comments (0)