The following applies to commands entered in the terminal. You can find and open the terminal by going (in the finder) to your root Mac Hard Drive folder, select Applications, usually it is located in Utilities: click 'terminal'. Generally the terminal is an interface where, instead of clicking icons and menus with your mouse, you enter and send keyboard-typed commands to your computer. The commands you type are typically formed of abbreviations (of the word characterizing what the command accomplishes) with a special form of punctuation that allows combinations of commands and options to be pieced together.
The terminal area where the command is typed is generically referred to as the command line or shell. The prompt is the group of typographic symbols to the left and its contents indicate a number of important details. The area to the right of the prompt is where your keyboard-typed commands are displayed.
prompt_% commandSometimes the prompt is indicated by a single character (any of $ # %) and then is followed by the actual command you would enter. Once the command is entered you must press the 'return' key to send the command and have it execute. Here is an example of how my terminal window and prompt appear:
You can see I have customized my terminal. The prompt indicates the folder I am currently working from, when I open the terminal it has extra text at the top giving me information about my computer, the window is a specific size, has a specific title, and the colors for the window are set to black and white with a range of values. For information on how to configure your terminal sessions (and environment) see the parallel section on customization.
As you use the terminal you usually need to know 2 things: what you want to do, and where something is located. Knowing where you are in the folder structure is the first step in understanding where items are located. There are a few commands commonly available for determining this (pwd, cwd) but you must understand the terms:
path A synonym for location. The location of a file or folder. relative path The path relative to your current location (go up, down, look here). absolute path The path from the top-most folder (called root).and typographic conventions:
~ Home directory: can use '~username' as well. / Root directory: all folders are located within or below this one. . Current working directory: your current relative location. ./ Same as above. .. Directory above your current relative location. ../ Same as above. ../../path/file Path to a file named 'file' 2 folders up, in folder 'path'.
cd /To move to the Home directory:
cd ~To move into the subfolder Desktop:
cd ./Desktop/To look at the contents of a folder use the list command 'ls':
ls ./By default special files and their size are not listed, and there is no indication of what the file type is. You can list these extra files and attributes (respectively) using the options all (a), long format (l), flag (F):
ls -laF ./Desktop/Often this list of files and folders will scroll up the terminal screen too fast to read. If you want to you can send, or pipe (pipe is represented by the vertical bar character "|" on the keyboard), this list to the command less and then scroll through, or even search the listing:
ls -laF | lessTo search type /pattern and to quit the listing type q. Scroll using the arrow keys, gg takes you to the top and G to the bottom of the list.
which command man command apropos commandCommand line use is relatively consistent across the various UNIX-like operating systems and applications, can be a very powerful and efficient production tool, and often translates to better general understanding of computing and networking. Having spent 3+ years learning to use the command line I can say it is well worth the effort to learn this alternate way of interacting with your computer: it provides greater control and potential productivity.
unzip filename.zip
gunzip filename.gzIf the resulting file ends with .tar you'll need to untar it next.
tar -xvf ./Desktop/filename.tarHere I first invoked tar, gave it the options -xvf which are respectively extract, verbose, file, then state the file name. To create the tarball 'filename.tar' of the Desktop folder I change the x to c (to create instead of extract) followed by the file name and the contents to add to the tarball:
tar -cvf filename.tar ./Desktop/To create a tarball 'filename.tar' of the Desktop folder and .cshrc file just list the files separating each one with a space:
tar -cvf filename.tar ./Desktop/ .cshrcFor more info I have a page on quickly creating (and using) backups for project files. It provides details useful for automating most of the archive creation; one could write a perl script to do the whole thing and schedule it with cron... The nice thing about tar is that it preserves the directory structure so that if unpacked from the right point it will recursively replace existing files with the archived files.