background image

MacOS X UNIX Terminal Commands

 

note: all commands are case sensitive!!! 

 

list information on a command ('man' is short for 'manual') 

man command 

 

---------

 

 
full directory listing [including hidden files] 

ls -alF 

 

---------

 

 
same as above, but for large directories 

ls -alF | more 

 

---------

 

 
when you use the 

-l

 flag w/ 

ls

, there will be a string of characters on the left for each file, 

which may look something like 

-rwxr-xr-x

 

the first character describes what the item is: 

-

 

= regular file 

d

 

= directory 

b

 

= special block file 

c

 

= special character file

 

= symbolic link 
p

 

= named pipe special file 

example: 

lrwxr-xr-x

 would be a symbolic link 

 

the next 9 characters are 3 groups of 3 characters each, which tell the 
read/write/execute permissions for user, group, and other respectively: 

r = read 
w = write 
x = execute 
using the above example of

 

lrwxr-xr-x

, you would have symbolic link file, where the

 user 

can 

read, write and execute

 (

rwx

), and the 

group

 and 

others

 can 

read

 and 

execute

 (

r-x

)

 

 
change the permissions for a file 

chmod flags filename 
description of flags: 
u = user 
g = group 
o = other 
a = all of the above 
example:

  

chmod u=rwx,go=rx

 

filename

 

this would make the file 

readable

writable

, and 

executable

 by the owner (

u

), and 

background image

readable/writable

 by everybody else (

go

 

---------

 

 
wildcard for any # of characters 

*

 

 
wildcard for a single character 

?

 

 

---------

 

 
current directory 

.

 

 
parent directory 

.. 

 
home directory 

~

 

 

---------

 

 
list command history 

history

 

 
re-run previously typed command (number can be found in 

history

 list) 

!number

 

 

---------

 

 
run a program in the background 

program

 

&

 

 

---------

 

 
clear the screen in the terminal 

clear

 

 

---------

 

 
see what directory you are currently in 

pwd

 

 

---------

 

 
information on available disk space for all mounted volumes 

df -k 

background image

 

summarize disk usage (list all files) from current directory on down 

du

 

 

---------

 

 
list of commands to control apache (web server) 

apachectl man 

 

---------

 

 
list of running processes 

ps aux | more 
 

 

kill running process (PID=# from the 

ps -aux | more

 list) 

 

kill

 PID 

 

 

list heap allocation for process 

 

heap

 PID 

 

 

put a program in the background 

 bg PID 
 

 

bring a program to the foreground 

 fg PID  

 

---------

 

 
list commands to use w/ Java 

java -help 
 

list commands to use w/ Java compiler 

javac -help 

 

---------

 

 
change aqua windows to nextstep & vice versa 

defaults write NSGlobalDomain NSInterfaceStyle nextstep 
defaults write NSGlobalDomain NSInterfaceStyle aqua 

 

--------- 

 
change the arrow for the foreground app in the dock from black to blue 

defaults write com.apple.dock showforeground -boolean YES 

 
---------

 

 
dim (make translucent) the icons of hidden apps in the dock 

background image

defaults write com.apple.dock showhidden -boolean YES 

 

---------

 

list of commands to use w/ gnutar 

gnutar -help | more 

 

---------

 

 
change the owner of a file 

chown

 newowner fileordirectory 

 

---------

 

 
rename a file 

mv

 filename newfilename 

 

move a file 

mv sourcefile destination/ 
 

copy a file 

cp

 

sourcefile destination/ 

 

delete a file 

rm 
 

delete a file w/o asking for verification 

rm -f 
 

delete a directory, and all the files in it 

rm -r 

or

 

rmdir 
 

create a directory 

mkdir 

 

---------

 

 
diplay the first few lines of a file (default=10 lines) 

head filename 
 

display the last few lines of a file (default=10 lines) 

tail filename 

 

---------

 

 
break (kill almost any running program or process) 

control c 

background image

 

pause screen output 

control s 
 

resume screen output 

control q 
 

erase entire line that was just typed 

control u 
 

suspend running process 

control z 

 

---------

 

 
gnu zip a file [zipped file will end w/ 

.gz

] 

gzip filename 
 

gnu unzip a file 

gunzip filename 

 

---------

 

 
display a calendar 

cal 

 

---------

 

 
list information on a server 

whois servername.com 
 

list information on current user 

whoami