Saturday 27 June 2015

Command prompt secrets


20 command prompt secrets
Although it seems boring, but it’s true that command is also a most interesting feature provided by windows. Basically there are two types of commands namely Internal and External commands. You can do various of things if you know the commands.
Now come to the point regard this topic about command prompt secrets that are still not known to many people. These are as follows:-

1. Ctrl-C (To Abort a Command)
 
Every command can be stopped in between with the abort command: Ctrl-C.
If you just written the command but not executed it, then you can simply change the command by backspace. But sometimes there is a situation that you executed the command, then you came to know that you did something wrong in it and you want to abort the execution of that command. Here you can use Ctrl+C to abort the command.
Note: Ctrl-C can't undo things that are undoable, like a partially complete format command.

2. View a Command's Results One Page (or Line) at a Time
Did you ever run a command that produces so much information on the screen that it's almost not required.
You can get rid of this by allowing the output to be displayed in one line or page.
To do this, just type the command followed by the pipe redirection operator and then the more command.
For example:- executing dir /s | more will generate the thousands of lines of results but the more command will pause each page of results with -- More -- at the bottom of the page, indicating that the command has not completed the running.
Just press the space bar to jump to next page or press the Enter key to go to next one line at a time.
3. Allow to  Run Command Prompt as an Administrator Automatically
 There are many commands that require administrator privileges for running. For this, you can type cmd in start and then right click on it and choose run as administrator. But if you use the command prompt on daily basis, then it may waste lot of your time. So to get rid of this, you can do the following:-
Create a command prompt shortcut on desktop. Right click on it and choose properties. Then click on shortcut> go to advanced and check the run as administrator option and then save the changes.
Now this will automatically open this command prompt shortcut with administrator privileges. Hence it will save your time if you are a frequent prompt user.


4. Use of function keys to enhance your speed on command
It is also a secret that is not known to many users.
Just read the below to know this:-

F1: Pastes the last executed command (character by character)
F2: Pastes the last executed command (up to the entered character)
F3: Pastes the last executed command
F4: Deletes current prompt text up to the entered character
F5: Pastes recently executed commands (does not cycle)
F6: Pastes ^Z to the prompt
F7: Displays a selectable list of previously executed commands
F8: Pastes recently executed commands (cycles)
F9: Asks for the number of the command from the F7 list to paste.


 
5. Save a Command's Output to a notepad file (using redirection operator)
The method used here is to use redirection operator to redirect the output to a specific file.
Syntax: ‘command’>>’filename’

Sometimes there is a situation that you need to save the output of command so that you could review it in future.
Let’s say for example:- You want to upload your file into a forum on web, then the best way is to save the output in file so that you can use it in future.
For this purpose, we use the redirection operator(> or >>) which store the output in a file.

Example of such command:-
systeminfo>>c:\file.txt
This command will give system info as output and redirection operator used in this will store the output in a notepad file named file.txt

 6. Get Help for Any Command
Well, you may know that there is a help command (syntax: help ‘Your-command’) with which you can find out the work of your command. But this command doesn’t provide help for various commands.
There is another way with which you can know the syntax of the any command.
For this purpose, just type /? After writing your command and it will display and explain the complete syntax of that command and how to use it.

7. View Your Hard Drive's Entire Directory Structure (tree command)
The tree command will give you entire directory structure. You can view the entire structure of a particular directory by using tree. Execute tree from any directory to see the folder structure under that directory.
Tip: As if a directory has so many folders in it, then the tree command may produce a lot of information which may not be visible at a time. So you can either use the redirection operator to save the output in a file (trick 5) or you can use trick #2 to view the result page by page or line by line in prompt.

Also read:- what is cloud computing


8. Customize the Command Prompt Title Bar Text                                                 

 
Are you tired of the command prompt title bar text. Don’t worry, because now you can get rid of it by using title command.
Syntax: Title ‘titlename’
Example: title khushkirat singh
The disadvantage of this is that the changes will not stick and are not permanent. So when you executed the prompt again after closing it, then the previous default title will be back.
But the advantage is that that this will help you to customize the prompt. i.e if you take a screenshot of a prompt for your project, then the title will prove that you actually used that command. And your project is not copied from anywhere else.


9. Copy From the Command Prompt
As you may or may not know, copying from the Command Prompt is not as easy as copying from other programs. Due to this reason, the outputs are first saved to a file.
But what if you do just want to copy a short section of text to the clipboard? Yes we can do this. Read the following steps to know how!
Right-click anywhere in the Command Prompt window and choose Mark. Now, highlight the text which you want to copy with your left mouse button. Once your selection is made, press Enter.
Now text is copied to your clipboard and hence you can paste that information anywhere you want.

10. Open the Command Prompt From Any Location (shift+rightclick)
If you've ever worked in the Command Prompt for very long, you know that it can be really frustrating executing the cd/chdir command over and over again to get to the right directory you want to work from.
Luckily, there's an easy Command Prompt trick that will let you open a Command Prompt window any directory or folder
For this purpose, just go to the directory or folder from where you want the prompt to open. Then from there, press Shift + right click mouse. When a new window pop-up, then click on open command prompt here  and you are done. Click it and you'll start a new instance of the Command Prompt ready at the right location!

12. Drag and Drop For Easy Path Name Entry


There are many commands that require you to enter the whole path in the command. This could be frustrating if the path is so long. Especially when sometime you entered wrong letters in hurry and now you would have to do it again.
For example, in Windows 7, the path to the Accessories group in my Start Menu is: C:\Users\Tim\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories. And nobody wants to type such a long path and also it wastes lot of time.
Luckily there's a Command Prompt trick that makes this much easier: drag and drop.
Just navigate to the folder you want the path for. Once reached there, drag the folder or file to the Command Prompt window. Like magic, the full path will get typed automatically in the prompt and thus saving your precious time.
13. Shut Down or Restart Another Computer

 
System administrators in a business environment do this all the time for lots of reasons, but you can also shut down or restart another computer on your network, all from your computer's Command Prompt i.e. remotely.
The easiest way to shut down a computer remotely is to execute shutdown /i from the Command Prompt This will open a Remote Shutdown Dialog popup, shown above. Just enter the name of the remote computer which you want to shutdown (which you can get by running the hostname command on the other PC, select the option (shutdown or restart) and click OK and you are done.


  14. Use Robocopy as a Backup Solution
 
Thanks to the robocopy command, you don't need to use Window's backup software or install a third party program to manage your backups.
Just execute robocopy c:\users\khushkirat\documents f:\backup\documents /copyall /e /r:0 /dcopy:t /mir, Just replace the source and destination folders according to your choice.
Note: Robocopy command will not be available if you are using windows XP or earlier.
 15. View Your Computer's Important Network Information


 
Sometime you need to troubleshoot the problem of your network connection. This information is somewhere stored in control panel. But instead of going so deep, there is a simple command that will help you to get the network related information easily.
The command for this purpose is ipconfig /all. For better results and to quickly view the results, combine this command with trick #6.

 
16. Access Previously Used Command with the Arrow Keys
Another great Command Prompt trick is the use of the keyboard arrow keys to go through previously executed commands. The up and down arrow keys cycle through the commands you've entered and the right arrow automatically enters, character by character, the last command you executed.
This might not sound that interesting, but there are several situations where the arrow keys become huge time savers.
Consider this example: You've typed out 25 characters of a command and then try to execute it, but suddenly you find that you forgot to add an option at the very end. No problem, just hit the up arrow and the entire command is automatically entered in the Command Prompt window. Now you can edit that command for whatever you want.

Also read: Windows 10 features

17. Automatically Complete Commands with Tab Completion
 
Tab completion is another Command Prompt trick that can save your lots of time.
To use tab completion in the Command Prompt, just enter the command and then the portion of the path that you know. Then press the tab key over and over to cycle through all of the available possibilities.
For example, let's say you want to change directories to some folder in the Windows directory but you're not sure about the name of that directory. Type cd c:\windows\ and then press tab until you see the folder you're looking for.

18. Find a Website's IP Address
 

Syntax:- nslookup ‘websitename’
Example:- nslookup facebook.com

 
Want to know the ip address of any website? It’s too simple. There are many situations where you need to know the ip address of a website. For ex. You want to go to a website through its ip address just because the dns of that website is blocked.
For this purpose, you can use the nslookup command.
Another way to find the ip address of a website is using the ping command
Syntax:- ping ‘Websitename’
Then look at the output you will get the ip address of the website there.

19. Copy & Paste Easier with QuickEdit Mode
Trick #9 is about copy paste in command prompt. But this is even easier than this.
Want to know how? Read the following lines

Just right-click on the Command Prompt title bar and select Properties.
On the Options tab, in the Edit Options section, check the QuickEdit Mode box and then click OK.
Enabling QuickEdit Mode is like having Mark enabled all the time so selecting text to copy is really easy.
Now to use this and perform the action live:-
To copy:- Just select the text to copy and then press enter. Now all that text is copied in clipboard to get pasted.
To paste:- right click once and whatever is in the clipboard is pasted in the Command Prompt window.

Also read: Rooting android device


20. Watch Star Wars Episode IV
Are you shocked? Am not joking! You can watch an ASCII version of the full Star Wars Episode IV movie in the Command Prompt window.
Just open Command Prompt and execute telnet towel.blinkenlights.nl and the movie will start immediately. This
Well, this is actually not a trick of the Command Prompt or any command, but it is fun.

Note: The telnet command is not enabled by default in Windows 7 or Windows Vista but can be turned on.
For this purpose, go to control panel>program and features>turn windows features on or off>check the telnet client feature.

For more tech stuff, like us on Facebook:- Technology fever
  
Note: If you have any query regarding above commands, comment below and i will surely help you

No comments:

Post a Comment