CMSI 186: Command Line Help

Introduction

For many of you, this is the first time [or nearly so] that you are actually typing in "real" commands to the computer. Usually, you boot your machine, wait for the windowing interface to appear, then use the mouse [and some typed commands or keypresses] to accomplish your tasks in the windows which get started by clicking on things. For this class, however, much of that familiarity will RAPIDLY disappear.

To help you with navigating the command window [Windows] or terminal window [Mac/UNIX/Linux], here is a handly table of some basic commands with explanations of what they mean and what they do. While it is most definitely not exhaustive, and not even really comprehensive, it will at least provide you with a reference of basic "stuff" to get you going.

Mac O/S — Linux — UNIX Commands…

You start the Mac/Linux/UNIX command line the finder, the launchpad, or the spotlight. From the Finder icon in the dock, click "Applications" in the favorites list, then find the "Utilities" folder and click to open it; locate "Terminal" and double-click the icon to open the program.

From the Launchpad, click the Launchpad icon to open the screen of application programs; find the "Other" icon and click to open it. The Mac displays a set of utility programs. Locate the icon for the Terminal program and click it. As an alternative, click the text area next to the magnifying glass icon in Launchpad and type "terminal". Launchpad locates and displays the Terminal icon -- a handy time-saver if your MacBook has many programs. Click the icon to open the program.

From Spotlight, click the "Spotlight" magnifying glass icon. In the text field that opens, type "terminal". Spotlight displays a list of matches for the word "terminal" including the program. Click the entry for Terminal to open it.

Once the terminal window is open, you can use the commands from the following table. Remember that in the following descriptions, the words "directory" and "folder" are treated as synonymous.

FREQUENTLY USED COMMANDS
ItemCommandMeaning/Action Performed [possible "switches"]
1pwd Output which directory is the current directory
2cd <directory or path> Change directory to that specified
3lsList the contents of the current directory
4ls <directory or path> List the contents of the named directory
5mkdir <directory or path> Make a new directory or subdirectory
6rmdir <directory or path> Remove a directory or subdirectory
7rm <file or directory> Delete a file
8cp <source file> <target file> Copy one file to another
9more <file> List out file contents, pause for each screen-full
10mv <source file> <target file> List out file contents, pause for each screen-full
11cat <file> List out file contents, but without pausing
12man <shell> List out the commands available for the shell
13man <command> Get the help page for <command>
OTHER INTERESTING COMMANDS
14alias lets you give your own name to a command or sequence of commands
15chmod Sets the file permissions flags on a file or folder
16chown change the owner and group owner of a file
17curl tool to retrieve information and files from URLs or internet addresses
18df shows the size, used space, and available space on the mounted filesystems
19curl tool to retrieve information and files from Uniform Resource Locators (URLs) or internet addresses
20diff or sdiff compares two text files and shows the differences between them
21echo echoes a string of text to the terminal window
22exit or cntl+d close a terminal window or log you out of a remote access session
23find track down files that you know exist if you can’t remember where you put them
24free gives you a summary of the memory usage with your computer
25grep searches for lines which contain a search pattern
26head [or tail] gives you a listing of the first [or last] 10 lines of a file
27history lists the commands you have previously issued on the command line
28ping verify that you have network connectivity with another network device
29ps lists the running processes
30tar create an archive file [like a zip file]
31top shows you a real-time display of computer status
32uname obtain some system information
33whoami find out who you are logged in as

Windows Commands…

You start the windows command line by either finding it in the programs list [by clicking through the following process: Start button -> All Programs -> Accessories -> Command Prompt] or by using the "Run Box" [by clicking through the following process: Start button -> Search box -> type "cmd" and press the ENTER key]. You'll see the command window appear.

Once the command window is open, you can use the commands from the following table. Remember that in the following descriptions, the words "directory" and "folder" are treated as synonymous.

FREQUENTLY USED COMMANDS
ItemCommandMeaning/Action Performed [possible "switches"]
1cd or chdir Output which directory is the current directory
2cd or chdir <directory or path> Change directory to that specified
3dir List the contents of the current directory
4dir <directory or path> List the contents of the named directory
5md or mkdir <directory or path> Make a new directory or subdirectory
6rd or rmdir <directory or path> Remove a directory or subdirectory
7del <file or directory> Delete a file
8erase <file or directory> Delete a file
9copy <source file> <target file> Copy one file to another
10more <file> List out file contents, pause for each screen-full
11type <file> List out file contents, but without pausing
12help List out the commands available
13ren or rename Renames a file or files
14<command> /? Get the help page for <command>
OTHER INTERESTING COMMANDS
15attrib Displays or changes file attributes.
16chkdsk Checks a disk and displays a status report.
17cls Clears the screen.
18cmd Starts a new instance of the Windows command interpreter.
19color Sets the default console foreground and background colors.
20comp Compares the contents of two files or sets of files.
21date Displays or sets the date.
22echo Displays messages, or turns command echoing on or off.
23exit Quits the CMD.EXE program (command interpreter).
24fc Compares two files or sets of files, and displays the differences between them.
25find Searches for a text string in a file or files.
26findstr Searches for strings in files.
27mklink Creates Symbolic Links and Hard Links
28move Moves one or more files from one directory to another directory.
29path Displays or sets a search path for executable files.
30popd Restores the previous value of the current directory saved by PUSHD.
31prompt Changes the Windows command prompt.
32pushd Saves the current directory then changes it.
33sort Sorts input.
34start Starts a separate window to run a specified program or command.
35systeminfo Displays machine specific properties and configuration.
36time Displays or sets the system time.
37title Sets the window title for a CMD.EXE session.
38tree Graphically displays the directory structure of a drive or path.
39ver Displays the Windows version.
40vol Displays a disk volume label and serial number.