There are some things you can only do from the command line, even on Windows. Some of these tools don’t have graphical equivalents, while others are just plain faster to use than their graphical interfaces.
We can’t possibly cover all the useful commands you can use in the Command Prompt or PowerShell here. We’ll be focusing on commands that should be useful even if you’re not a command-line person.
1. Change DirectoryOften you will have to navigate through directories. Terminal and Command Prompts both use the same cd command to change your current directory to the destination specified within the command. Say you want to go to a folder namedtech, you type:
You can navigate directly to the sub-directory of foo, like so:
To head back to the previous directory or go one level up of the current directory, type:
Another command that you may find in need often is mkdir. This command creates a new directory with the specified name. The following command, for example, will create a new directory named tech.
We can also create multiple folders at once. This example below will create three directories named foo, hello, andworld all together at once.
The mkdir command is compatible both in Terminal and Command Prompt.
3. Creating New FileUse thetouch command to create an empty file. For example:
You can specify more filenames, as follows, to create multiple files at once.
Use the mv command to move a particular file to a folder. This example below moves the tech.css to a folder named/sid.
You can also make use of the mv command to rename files and folders. This example below will rename theindex.html into about.html.
Type cp command or copy, if you want to copy a file or folder. Below is an example where we copy index.html and name the new file to about.html.
If you are running on Windows, use the copy command instead.
6. List Directory ContentThis is one of the commands that I personally use often, List Directory or known as ls. With this command, you can list the content of a directory. Specifying a folder name ahead of the ls command will list the content of the folder specified.
The ls command, however, will only work in a UNIX shell. You can run lscommand in Ubuntu and OS X, but not in Windows. In Windows, type dircommand instead.
7. Open FilesThe open command will open files of folders in the default app. This command below will open the folder Desktop in Finder.
The following command will open a .txt folder in TextEdit, which is the default app in OS X to edit plain text file.
Windows users should use edit. Given the same example, you can run:
Additionally:
- You can use exit command to exit from command prompt in windows.
- You can use ipconfig to quickly find your ip address.
These are only some of the the command lines but they are basic commands everyone must know.