Many of us underestimate Windows Command Prompt. We just think of it as, black screen where we write commands. But this little black screen windows possesses power that Windows GUI doesn’t. The things you can do in GUI can be done in command prompt too, plus cmd has more commands that your GUI can’t do.
- You can create viruses using cmd, viruses that can be for fun, or viruses that can destroy your machine.
3 lines in cmd can crash your windows and delete its kernel. - You can set a timer to shut down or restart your machine, you can change a file’s extension.
- You can see how a data packet travels, from which routers and takes how much time to do so.
- You can add users, delete users, change passwords of users.
- You can check active connections, or see if server is up or down.
So ‘With Great Power comes Great Responsibilities.’ Use it carefully 🙂
In short Windows cmd is a Powerful tool, and if you’re planning to work in Windows, you should at least now the basic commands of Command Prompt. If you want to use cmd for normal purpose, you can select it from
‘Start –> Accessories –> Command Prompt’ or ‘Windows key+r (Run) and type cmd’.
In this post we will be looking at
Few Normal commands like cls, cd , dir, ren, md, del, rd, tree, attrib.
Few Network commands like ping, netstat, nslookup,ipconfig.
Few Advance commands like chkdsk, net user, sfc, sigverify, driveryquery, diskpart and tasklist.
Some commands need administrative privileges. If you want to run these commands
For Windows 7
Start –> search –> cmd (Right click and “RUN AS ADMINISTRATOR”)
For Windows 8
”Start –> Accessories –> Command Prompt (Right click and “RUN AS ADMINISTRATOR”)
When you run cmd as Administrator, at the title you will find ‘Administrator: Command Prompt‘
So lets start with the basic windows commands. One that you can run as normal user.
- cls
To clear the current screen use ‘cls‘.
- cd
– To change the current location, we use cd. You can either go in some folder of current location, or go a directory up or you can go into some other drive’s location.
– To change directory in current location use ‘cd [ folder name ]‘
– To go one level up use ‘cd ..‘
– To go in some other drive enter ‘cd [ Drive letter ]‘
NOTE : Here the destination will change to that drive, but you’ll still be in your current location.
When you enter only the drive letter, you’ll go that destination directly. - dir
– To see the current contents of a folder you can enter ‘dir‘.
It will show you Number of files, Number of Directories and their details. - ren
– If you wish to rename a file or even change its extension, you can use the ‘ren’ command. It stands for rename.
– To rename a file which is present is current directory, simply write :
ren [ filename ] [ new filename ]
If you want to rename a file, which is present in some other place, write
ren [ location of file ] [ location and new filename].
- md
– ‘md‘ is used to make a new directory.
– NOTE : if you want to make a new directory with name which has spaces,
example : ‘New folder‘ , ‘English Movies‘ , ‘Michael Jackson‘
please enter the folder name inside ” ”
– md “English Movies”– This will tell Windows to create ONE folder named ‘English Movies’.
Else it will make two different folders English folder and Movies folder.
See the image you’ll understand.
- del and rd
– ‘delete‘ is used to delete a file.
– ‘rd‘ is used to remove a directory.
– If you wish to delete all files in some directory use : ‘del Users/*‘– NOTE del *.* will delete all files with all extensions in current location. The ‘*’ before ‘.’ means all files and ‘*’ after ‘.’ means all extensions ( jpg, png, txt, mp3). - attrib
– If you want to change Attributes of a folder or file use ‘attrib‘ command.
– To make a file read only append ‘+r‘ . To remove read only append ‘-r‘ .
– To make a file hidden append ‘+h‘ . To remove hidden append ‘-h‘ .
– To make a file System file append ‘+s‘ . To remove System file property append ‘-s‘.
attrib [ filename ] +r +h — (To make ‘Read only’ and ‘Hidden’ ).
attrib “New Folder” +s +h +r — (To make a folder ‘System file’, ‘Hidden file’ and ‘Read only’ ). - tree
This command shows the contents of directory in a tree like structure.
Now you know basic commands that you can run in your machine to change or alter the properties of files.
Now lets look at some of the commands related to your network.
- ipconfig
This command is used to see the IP details in brief of all the active network devices.
You can also user ‘ipconfig /all‘ to see the IP and MAC details of every device present on your machine. - ping
ping is used to check if a server is up or down. Ping can also be used to check your internet connection.
If you try to ping google and you don’t get a response, it doesn’t mean Google is down 😛 It means your net is not working!
A normal ping request sends only 4 packets.
If you want to send more packets use ‘-t’ switch, which is used to send packets infinite times. It will only stop when you’ll stop it.
Append a IP address or website’s url after ping to check your connection. - nslookup
– ‘nslookup‘ is used to see the details of DNS server. - netstat
– ‘netstat‘ is a very useful command to see the incoming and outgoing connections in your machine.
These were few network connections you should know.
Now let us look at some of the system commands that can be used to view the system properties, or change them.
- chkdsk
– If you think some files are corrupt or you want to check all the files for error, just run ‘chkdsk’.
– You can use ‘/f‘ switch after ‘chkdsk‘ to fix the errors if found. - net user
– To alter the user accounts you can use ‘net user‘ command.
– With ‘net user‘
You can add new users and create their passwords,
Delete existing users,,
Change a password of any current user.
The good thing about ‘net user‘ is it doesn’t ask you current password before changing the password of existing user.
– So you can hack anybody’s local account using ‘net user’ 😀
– When you enter ‘net user‘ you will get a list of all usernames.
To change password enter ‘net user [ username ] *‘ - sfc /scannow
– ‘sfc’ stands for System File Checker. It is used to check the integrity of system files.
– If there are corrupt or missing files, it will find them and replace them. - sigverify
– This command is used to check the signatures of the existing drivers.
– It checks for digital signature of all the system files. - tasklist
– ‘tasklist‘ is used to view all the processes running in the system, in command prompt.
– It is useful if your task manager is disabled. - driverquery
– ‘driverquery‘ gives you a list of all the drivers that are installed, and their details like publisher, time and type. - diskpart
– Diskpart is one of the most useful and powerful commands in cmd. When you enter ‘diskpart‘ , it will open a new command prompt of Diskpart (In Windows 7).
– You can only run ‘diskpart‘ as Administrator.
– In Diskpart you can view disks, partitions, edit them, make some other partition active, or create new ones.
– If you don’t know how to use ‘diskpart’ just enter help, it will give you a list of commands
NOTE : Don’t try this for fun ! It can seriously mess up your system, you’ll lose all the data and if you delete the wrong partition, your system won’t boot 😛
There are many more commands like :
Format [ Drive letter ] like Format H:
or
‘Shutdown -s -t‘
to shut down the computer. You can set a time too. Just append the number of seconds after ‘-t’.
‘Shutdown -s -t 3600‘ will shutdown the machine after 1 hour.