Basic OS X UNIX Commands
There are lots of OS X and UNIX tutorials on the web, but here is a collection of some basic commands which you might find usefull when working in Terminal on your Mac. A bigger list of OS X commands is here.
➤ The following commands will allow you to navigate between directories:
ls- list contents of current directory
pwd- display the working directory
cd ~- go to the home directory
cd Desktop- change directory to the desktop
cd ..- go back up a directory
cd /- go to the ROOT (top) directory
mkdir myfolder- creates a directory
rmdir myfolder- removes an empty directory
You can redirect the output of a command to a text file.
ls > mydirectorylist.txt and press Return. A text file named mydirectorylist.txt appears containing the ouput from the ls command.
➤ The following commands will allow you to work with files:
cp myfile1 myfile2- copies file 'myfile1' to 'myfile2'
mv myfile1 myfile2- moves file 'myfile1' to 'myfile2'
rm myfile1- removes (deletes) file 'myfile1'
more myfile1- displays a text file one page at a time. Press the spacebar to see the next page; press Q to quit.
nano- A simple UNIX text editor. Use nano to edit your hosts file
➤ The following commands are useful Miscellaneous Commands:
top- List running processes (and memory usage) in sorted order; press Q to quit.
Control+C- Terminates most operations.
date- Displays the current date and time.
help- Displays a partial list of bash commands.
history- Displays the last commands you typed. You can redo a command by typing an exclamation point (!) followed immediately (no space) by the number of that command in the history list. To repeat the last command, type !!. To repeat the last filename, type !*.
sudo- Lets you carry out commands for which the account you are using lacks authority. You will be asked for an administrator’s password. BE CAREFUL!
When you’re working in Terminal, you don’t have a Trash Can to which deleted files are moved pending ultimate disposal. Delete it, and it’s gone. In general, UNIX has no Undo function.