Here are a few UNIX commands. I made this a long time ago while I was learing UNIX for the first time. This was my cheet sheet of notes for when i forgot some commands. Not all of the will work for OS X (some or system V commands) but it will get you started. As the other guys said... you can mess things up pretty bad using the terminal... so dont do it unless your prepared for it. And dont do it as root... unless you think you can handle it.
-evildead
#man <command> - gives you full manual of a command
# df -k - lists mountted drives and partitions. gives space uesed/avalable
# su <userName> swithch to a new user ( use "-" for root user)
# sudo <command> run a command as root, if user has sudo privleges
# rm = removes file
rm [file name]
rm -r [file name] = removes sub tree
rm r* = removes all files under current directory
rm fr [file name] = removes full directory
# cp = copy file
cp [file name1] [file name2]
# pwd = displays current directory
# mkdir [directory name] = makes directory
# ls = lists directories/ files
-a = lists all
-c = lists in columns
-l = long list
# df = displays number of free blocks and files
-b = kb free
-k = prints allocation
# cd = change directory
# cd .. = change to parent directory
# rmdir [directory Name] = removes directory (empty)
# mv [file name1] [file name2] if file 2 exists file1 will be moved to. If not, rename
# who = who is logged in to server
# finger [user name] = info about user
# tty = displays name of terminal
# uptime = displays how long the server has bee up and # of users
# s = save
# man = online manual
# man [command name] = info on a command
# w [user name] = displays what user is doing
[command] > [file name] = puts output of command to a file
[command] >> [file name] = appends output of a command to a file
[command] < [file name] = using a file as input to a command
# cat [file name] = filter that puts contents of a file to the screen
cat n = w/ line numbers
cat b = blank
cat s = squeeze: cuts double blank lines
cat c
- [file name] = cuts data and displays it to screen
list = -8 or 8-10 or 13-30
# colrm [start column] [end column] = deletes columns of data
# sort = sorting
-d = (dictionary) consists only of letters/ numbers/ spaces
-f = (fold) treats upper case as lower case
-r = (reverse)
# spell b [file name] = displays miss spelled words
# wc [file name] = word count
# head [file name] = displays first 10 lines
head [-count] [file name] = displays first count lines
# tail [file name] = displays last 10 lines
tail [-count] [file name] = last count lines
tail [+count] [file name] = displays line count down to EOF
# more [file name] = displays one page of a file at a time
-s = squeeze
# pg [file name] = displays one page at a time
# lp [file name] = prints file
# chmod = change file permissions
chmod [mode] [file name] (page 621)
chmod [ugoa][+-][rwx]
+ = give
- = take
w = write permission
r = read permission
x = execute permission
u = Applies to user
g = Applies to group
o = Applies to other (world)
a = Applies to all
# ln [file name] [new link name] = creating a new link
# [command] & = runs program in background
# ^z = suspend a program
# fg = (foreground) brings suspended program to front
# bg = (background) move current job to background.
Notifying local and remote users
# wall
# rwall [mars] [Pluto] [Orion]
the system
..
Press Control-d
Shutdown/ Boot Command
# shutdown
-y = continue shutdown, no intervention
-g = time, in seconds, till shutdown
-i = bring the system to a different run level
[-i run_level] (0,1,S, 6)
# init 0
# init 6 = reboot
# reboot
# boot
-r = reconfigure (find devices)
-rv = verbose (long list dump)
Identify system Disks
Ok probel-scsi, probe-scsi-all, or probe-ipi
Interrupting the system
-do only if system hangs and remote log fails
Do a Stop-a
>n
(at ok, sync)
Identifying disk devices
# dmesg
# partconf = displays systems config information, memory and peripherals
Volume Manager
# volcheck = looks for volumes
# eject floppy
# eject cdrom
# ufsdump [options] [arguments] [files_to_dump]
Options
0-9 -Specify the dump level. Level 0, lowest (full dump). Level 9 is highest
a -Create an on-line archive of the file names dumped to tape
f -Specify the device to which the files are written requires and argument
of device name.
u -Update the dump record (/etc/dumpdates
c -Set the blocking factor to 126 for all tape devices
files_to_dump
Can be raw or block file-system device names (/dev/(r)disk/c0t0d0s0)
The file-system name (/export/home)
A file for directory name (/export/home/lister)
example:
# usfdump 0ufc /dev/rmt/0 /export/home
-when default tape device (/dev/rmt/0) is used, not necessary to use option
do: # usfdump 0ufc /export/home
# ufsrestore [option] [arguments] [file_name]
Options
i -Perform interactive restore
r -Restore the entire backup
t -List the table of contents of the backup
x -Restore only the files named on the command line
a[archive_file] -Take the table of contents info from the archive_file rather than the tape
f[dump_file] -Use dump_file instead of /dev/rmt/0 as the file to restore from
v -Display path names as they are being restored
Using the command
1. Insert tape
2. Become supper user
3. display & verify right tape
# ufsrestore tuf /dev/rmt/0
4. Once verified, extract the individual file you want to restore
# cd /var/temp
# ufsrestore xvf /dev/rmt/0 ./etc/password
Using the command #2
1. cd to a temp directory
2. # ufsrestore i ( use if /dev/rmt/0 if cant find device)
3. ufsrestor> cd to some directory (can cd in the tape)
4. ufsrestor> add file_name
5. ufsrestor> ex or extract
6. ufsrestor> quit
Configuring the NFS Environment
The NFS Server
1. Edit the /etc/dfs/dfstab file to enable automatic sharing of resources
share F nfs /user
2. Start the NFS Server daemons by executing the script /ect/dfs/dftab
# /etc/init.d/nfs.server start
3. Use the dfshares command to verify the resource is available
# dfshares
4. To identify clients
# dfmounts
The NFS Client
1. Use the /usr/sbin/dfshares command to display a servers available resources
#dfshares [server_name]
2. Use the /sbin/mount command to access the remote file resource.
# mount [server_name]: /usr/share/man /usr/share/man
The /usr/share/man is the mount point on the client.
3. Edit the /etc/vfstab file to add and entry for the remote resources that will be
automatically mounted.
# [server_name]: /usr/share/man - /usr/share/man - yes
Other commands
# unmount /usr/share/man = un-mount
# mountall r = mounts all file resources
# unmounall r = un-mounts all currently mounted resources
Software Package Admin Commands
# pkginfo = display software package information
# pkginfo | more = using more to display info
Adding a software package
Pkgadd [-d device | path_name] pkg_name
# pkgadd d /cdrom/cdrom0/s0/solaris_2.4 SUNWando
Verifying Package Installation
# pkgchk [package_name]
# pkgchk p [path]
Removing Software Packages
# pkgrm [package_name]
Spooling Packages for Install on Client from Server
Server Side
# pkgadd d /cdrom/cdrom0/s0/solaris_2.4 s spool [package_name]
Client Side
1. # mount [server_name]: /export/pkgs /export/pkgs
2. # pkgadd d /export/pkgs [package_name]
Removing Spooled Packages
# pkgrm s /export/pkgs [package_name]
# ps ef displays current running processes
- can pipe it to grep for better results
# find / -name csh print
/ = the directory to start searching in
-print = prints full path name
# file [file name]
# set = displays environmental variables
# hostname = displays what host you are logged into
# grep [string] [filename] = searching for a string in a file
-i = Ignores case
-n = prints line number
-v = prints all lines except those that match
-c = prints only a count of the number of lines that match
# touch = sets the last modified date for the files specified to the current date
echo e [message] [escape option]
\a = alert (bell)
\b = backspace
\c suppress trailing new line
\f from feed (new page)
\n new line (line feed)
\r carriage return
\t tab
\\ another \
ex: echo e wake up! \a
-Formatting drives
newfs /dev/rdsk/c0t0d0s0
= full device name
# newfs = formatting drives
# newfs /dev/rdsk/c0t0d0s0
- note
must partition first (run format)
# cal = calendar program
cal [12] [2001] = displays a month
cal = displays this month
cal [2001] = displays a year
# passwd = password program. Use to change password
# vi = text editor
vi R [file name] = read only
vi r [file name] = recovery mode after system crash
vi r = =
vi command mode
zz = save and quit
:q! = quit no save
I = start inserting text at beginning of current line
A = start inserting text at end of line
:set show mode = displays what mode your in
w = moves cursor to next word
0 = moves cursor to begging of current line
:set number = displays line numbers
:set nonumber = removes line numbers
p = pasts last deleted item
dw = deletes word
:e [file name] open new file for editing
:x! = save and quit
vi input mode
^v then any control key
~ change to upper case of a letter that cursor is on.