Since you can directly control the computer by typing, many tasks can be performed more quickly, and some tasks can be automated with special commands that loop through and perform the same action on many filessaving you, potentially, loads of time in the process. The application or user interface that accepts your typed responses and displays the data on the screen is called a shell, and there are many different varieties that you can choose from, but the most common these days is the Bash shell, which is the default on Linux and Mac systems in the Terminal application. By default, Windows systems only include the anemic Command Prompt application, which has nowhere near the power of Bash, so for the purposes of this article were going to suggest you use the open source Cygwin tool as your Windows command line, since its quite a bit more powerful. Youll also at some point want to read parts one, two, and three of our series on using the Bash shell under Cygwinthe tips apply to Linux and OS X as well. Introduction to whoA getting started guide for the Command Prompt on Windows. Brien takes a look at whats new with Microsofts next Command Prompt and explains why you should be excited. Below are the steps on how to get to an MSDOS prompt or into the Windows command line in all versions of Microsoft operating systems. Notice For some commands and. An AZ Index of the Windows CMD command line ADDUSERS Add or list users tofrom a CSV file ADmodcmd Active Directory Bulk Modify ARP Address Resolution Protocol. If thats what you thought when you saw the title of this article, thenRead more Basic Command Line Usage. To get started with the command line, youll need to open up a terminal window and get ready to start typing commands. Heres a list of basic commands you can use, organized by the type of activity that you might want to perform. When you run your terminal application Cygwin on Windows, Terminal on Mac and Linux, your command prompt will start up pointing to a specific folder on your hard drive. You can navigate between folders, act on files inside those folders, or perform other actions. List Files. First, lets display a list of files inside the active folder. For this task, youll need to use the ls command. You can pass a number of parameters to the command to display extra details or change the sorting. For instance, if I add l to the end of my ls command, Ill see a detailed listing t will sort the results by file time S will sort by file size and r will reverse the sorting. You could use a combination of these together, like this command, which will show all files sorted by file size with the largest files at the bottom ls l. Sr. If you use the a option, you can see hidden files, and youll also notice something else in the listing there are two entries for. These represent the current folderthe. Change Directories. You can change between directories using the cd command, and using what we just learned about the. You can navigate to either full or relative paths. For example, the command above navigates to a relative pathone above the current folder. If youre in pathto and you want to navigate to the folder stuff inside that folder, you can simply type cd stuff. You can also navigate to absolute paths. Again, if I were in pathto and I want to navigate to anotherpath, I would simply type cd anotherpath. To swap directories to the previous working directory, the hyphen shortcut is handy to have on hand. For example, if you were in the firstfolderpath directory and then switched over to etc to make a configuration change, you might not want to type in the full path to switch back. You can quickly switch back to the previous working directory with this command cd Creating or Removing Folders. To create a new folder, you can simply use the mkdir lt foldername command. You can then remove any folder with the rmdir lt foldername commandas long as the folder is empty. If there are files in the folder, youll have to delete those files before you can remove the folder. Creating and Removing Files. You can use the touch lt filename command to create a new, blank file, and then use the rm lt filename command to delete files rm filename. You can quickly remove all files in a directory by using the asterisk wildcardanother simple tool that will come in very handy during your time in the command line. For example, if youre in a folder and want to delete every file inside that folder, just type rm f you want to delete a list of files and folders, including all files from subdirectories, without prompting you for every single entry, you can use the r option for recursive, and the f option for force. This command will wipe out every instance of a matching filename pattern note the slightly different use of the wildcard from the current directory and below rm rf filename. Plain Text Files. The command that you use to edit text files will be different based on the platform youre using and the application you prefer to use. If youre using Ubuntu Linux, you can use the nano editor to quickly edit files, which might be more suitable for beginners. Otherwise, the vim editor is available on just about any system and can be invoked with the vi lt filename syntax. Designing Engineers An Introductory Textbook Pdf more. Displaying Files. You can display the file contents directly on the screen with the cat command, but the results will probably go flying past you on most large files, so its usually better to use the more or less commands. For instance more lt filename This will display the contents of a file on the screen, and prompt you to scroll through the file a screen at a time. Command Redirection. Each command line application can accept standard input and writes to standard output, and you can use the or operators to redirect output from one command into another, which lets you chain commands together into much more powerful commands. For instance, if you want to use ls l to display a list of files but it keeps scrolling off the screen, you can pipe the output from the ls l command into the input of the more command by using the character ls l more. If you wanted to save the output of that list directly into a file instead of displaying on the console, you could use the operator to redirect the output into a file instead ls l filename. You could then use the cat command to display the contents of that file, pipe that into the grep command detailed further below, and then redirect that output into a separate file cat filename. Running a Script in the Current Folder. If you have an application or shell script in the current folder, you cant simply type the name of the command and expect it to start. Youll need to add a. Why Because in the Bash shell, the current directory, or. So to launch scriptname. Using History. You can use the history command to show a list of all the recently used commands, or the updown arrows to loop through them. The CtrlR shortcut key will start a search mode where you can type the first few characters of a command to search through your recent history. Looping Over a Set of Files. If you want to loop through a set of filenames and perform an action on each one, you can use the for command to loop through a set of files. For instance, to loop through all the.