Unix, Linux, and Max OS X Commands
Unix, Linux, and Max OS X Commands
Common Filesystem Commands
Search Commands
Configuration Files
change directory
cd
find files and directories
bash run commands
find
~/.bashrc
cd foo
bash config file (linux)
find .
~/.bash_profile
cd ../..
bash config file (mac)
find . –type f –name “*.java”
~/.profile
copy files and directories
cp
search for text in files
vi/vim config file
grep
~/.vimrc
cp /tmp/foo.txt .
grep ‘foo’ *
Sample Aliases
cp f1 f2 f3 dir1
find files on the entire system
locate
compress a file
gzip
locate java
alias l=“ls –alF”
gzip bigfile.tar
(like locate; mac os x only)
mdfind
alias h=history
list files and directories
ls
alias cd..=“cd ..”
Less-Common Commands
ls –alF
alias html=“cd /usr/local/html”
ls -aCF
concatenate files
cat
Common Network Commands
make a directory
mkdir
change group owner
chgrp
mkdir dir1 dir2 dir3
change file mode
file transfer protocol
chmod
ftp
mkdir –p a/b/c/d
change file owner
ping
ping a remote system
chown
scroll through a file
more
show free disk space
secure copy
df
scp
more bigfile.txt
differences between files
secure shell
diff
ssh
show running processes
ps
directory usage (du –s *)
du
ps auxwww
Command Mashups
display the beginning of a file
head
move files and directories
mv
show history of commands
history
grep foo *txt | wc -l
mv f1 f2 f3 dir1
show last user login times
last
history | grep ssh
remove a file or directory
rm
ln
link files and directories
ls –al | more
rm oldfile
list of open files
lsof
ls –al | grep Jul | grep –v 2006
rm –r olddir
man
man pages (help)
ls –al | grep ’^d’
archive command
tar
streamline editor
sed
ps auxwww | grep –i java
tar czvf all.tgz *
sort
sort input
ps aux | wc –l
tar xzvf all.tgz
strings
search for text in binary files
who | wc -l
word count
wc
display the end of a file
tail
wc –l file1 file2
who
who is on the system