Running Commands from Windows Operating System
Windows operating system provides a command-line interface (CLI) known as Command Prompt or PowerShell, which allows users to execute various commands and tasks. This blog post will cover some basic and essential commands you can use from the CLI in Windows OS.
Starting the Command Prompt
- Press
Win + R
keys together on your keyboard to open the Run dialog box. - Type
cmd
in the text field and hit Enter to launch the Command Prompt window. Alternatively, you can also search for "Command Prompt" or "PowerShell" within the Start menu.
Navigating Directories (Changing Directories)
To navigate between directories:
- Use the
cd
command followed by a space and then the directory name or path you want to move to. For example,cd C:\Users\YourName\Desktop
. You can also usecd ..
to go up one level in the directory hierarchy orcd ~
to return to your home directory.
Listing Directory Contents
To list the contents of a current directory, type dir
and press Enter. The command will display a list of files and directories along with their sizes and modification dates.
Creating New Directories
- To create a new directory, use the
mkdir
command followed by a space and then the name of the directory you want to create. For instance,mkdir myNewDirectory
.
Renaming Directories
To rename a directory, follow these steps:
- Navigate to the parent directory using the
cd
command. - Type
renamedir oldDirectoryName newDirectoryName
. ReplaceoldDirectoryName
andnewDirectoryName
with your actual directory names. For example,renamedir myOldDirectory myNewDirectory
.
Deleting Directories and Files
To delete an empty directory, type rmdir directoryName
. To remove a non-empty directory, use the rd /s directoryName
command to recursively delete all contents within the directory and then delete the directory itself. Be careful when using this command!
For deleting files, simply type del fileName.extension
, replacing fileName.extension
with the actual filename and file extension.
Closing the Command Prompt
To close the Command Prompt window, simply type exit
and press Enter on your keyboard.
These are just some basic commands you can use in the Windows Command Prompt or PowerShell interface. For more advanced usage, refer to Microsoft's official documentation or other relevant resources online.