(with emphasis on Solaris)
1 job scheduling
crontab -e edit
-l list
-r remove
min hrs day-of-month month day-of-week command
0-59 0-23 1-31 1-12 0-6
Example:
0 12 8-14 5 * sendMailToMom
Note: execute sendMailToMom in home directory at 12:00PM during the 8th to 14th of May.
2 system concepts
2.1 Program and processes
to view processes on a system
/bin/ps -ef
/usr/ucb/ps -aux
-e list information about every process now running
-f generate a full listing
2.2 to dynamically display process statistics
prstat
top
2.3 signals
Numeric description
1 Hangup (HUP)
2 Interrupt (INT)
9 Kill (KILL)
15 Terminate (TERM [default])
2.4 to send a signal to a process
kill [options] processid
Example: kill -9 123
kill -KILL 123
kill -INT 123
pkill -9 netscape [no need to lookup pid with pkill]
pkill -9 -U uidlist [kill someone else's process]
2.5 to display process numbers only
pgrep netscape
or ps -ef | grep netscape
Daemon processes run quietly in the background
Example: sendmail, in.named, nfsd
3 getting help
man [options] name
-a display all available sections
-l list all available sections
-s display a single section
-k keyword search
-M specify path to man page
Example: man -s1b shutdown
man -l shutdown
man -M /usr/man -s1b shutdown
4 installation
4.1 installing software packages
to install software packages on a system
pkgadd [options] [pkgid...]
-d device install or copy a package from device or directory
4.2 to display a list of installed packages on a system
pkginfo [options]
-l long format
-x designate an extracted listing of package information
Example: pkginfo -l SUNWaccu
4.3 to remove one or more installed packages from the system
pkgrm [options] [pkgid ...]
Example: pkgrm SUNW1251f
4.4 installing patches
patchadd
-M path_dir patch_id
Example: patchadd -M /ver/temp 11943301
-p display a list of the patches currently applied
or showrev -p
Example: showrev -p | wc -l
counts number of patches
show version number of patch 119891
patchadd -p | grep 119891
4.5 to remove patches
patchrm [options] patch_id
Example: patchrm 119433
5 the boot PROM
5.1 Overview of the boot PROM (programmable read-only memory) main functions:
1 test and initializes the system hardware
2 determines the system's hardware configuration
3 boots the operating system from the disk or the network
4 contains debug facilities for testing hardware and software
5.2 Entering boot PROM with
stop + A or control + pause
5.3 Boot PROM commands
boot an operating system image from hard disk, CD-ROM, or from a boot server over the network
boot
-s boot only to init level "s"
-r reconfiguration boot
banner
display PROM revision number
printenv
display the values of all boot PROM configuration variables
Example: printenv auto-boot?
setenv
set the value of boot PROM configuration variable
Example: ok setenv auto-boot? true
5.4 Accessing boot PROM configuration variables from UNIX
eeprom [variable[=value]]
Example: # eeprom auto-boot?=true
(# is the root prompt)
6 initialization and shutdown
system run levels
run level init state description
s or S single user mode
0 ok prompt
1 single user administrator
2 multiuser, no network
3 multiuser, with network
5 power off
6 reboot
6.1 show system run level
who -r
6.2 change system run level
# init n
where n is the new run level
Example: # init 6
6.3 shutdown [options] [message]
-i init-state (Default s)
-g grace-period (default 60 second)
-y preanswer the confirmation question
Example: # shutdown -i0 -g0 "maintenance"
# shutdown -i1 -g600 -y "Disk maintenance"
6.4 reboot [options]
Example: # reboot -- -r
the option -r is passed through to the boot program (this is signified by the "--" delimiter).
# reboot -- "net -install"
send "net -install" to boot
i.e. ok boot net -install
6.5 # halt [options]
# poweroff
7 User administration
7.1 account configuration files
7.1.1 the password file
location
/etc/passwd
format
login:encrypted passwd: uid: gid: gecos comment field:path to home directory:path to shell
(suggested) convention about these fields
login: maximum 8 alpha / numeric characters, must begin with an alphabet, must be unique
uid: max 6 numbers, must be unique
gid: must exist in /etc/group
path to home directory: /export/home/
path to shell: /bin/sh, /bin/csh or /bin/ksh
Example: root:x:0:1:/super-user:/:/sbin/sh
froomin:x:101:70:Marty Froomin:/export/home/froomin:/bin/sh
7.1.2 the shadow file
location
/etc/shadow
format
username:password:lastchg:min:max:warn:inactive:expires:flag
7.1.3 the group file
location
/etc/group
format
groupname:encrypted password:gid:comma-separated list of users
Example
root::0:root
sales::101:froomin, ross, f4032
7.1.4 An example script used to generate user accounts automatically
#!/bin/csh
###############################################
# Purpose : The purpose of this script is to creates a block of accounts
# with the initial password of "foobar". The script accepts three parameters:
# a letter, a starting number, and an ending number.
# Usage : # /home/f4014/acctgen letter startNumber endNumber
# Example: # /home/f4014/acctgen f 101 120
###############################################
# initiate control parameters
set letter = $1
@ startNumber = $2
@ endNumber = $3
while ($startNumber <= $endNumber)
set login = $letter$startNumber
# add new account information to /etc/passwd file
echo $login':'TIC5DnZB/dQgs:$startNumber':'10:$login':'/export/home/$login':'/bin/sh >> /etc/passwd
# synchronize /etc/shadow with /etc/passwd
pwconv
# create home directories and profiles for new users
mkdir /export/home/$login
cp /etc/skel/local.login /export/home/$login/.login
cp /etc/skel/local.profile /export/home/$login/.profile
cp /etc/skel/local.cshrc /export/home/$login/.cshrc
# change ownerships of home directories to new users
chown -R $login':'10 /export/home/$login
@ startNumber++
end
7.2 User administration shell commands
7.2.1 to add a user account to the system
useradd [options] userid
-u uid login
-g primary gid
-G secondary gid
-c "comment field"
-m -d path to home directory
-s path to shell
Example
useradd -u 101 -g 101 -c "Marty Froomin" -m -d /export/home/froomin -s /bin/sh froomin
to create / change password
passwd
7.2.2 to modify account settings for existing userids on the system
usermod [options] login
-same options as useradd
-l newlogin login
Example
usermod -G 102 froomin
usermod -l shammer sgilbery
7.2.3 to remove a userid from the system
userdel [-r] login
-r remove home directory
7.2.4 to add groups to the system
groupadd [options] groupname
-g gid
Example
groupadd -g 300 backupadmins
7.2.5 to modify existing groups
groupmod [options] groupname
-n newgroupname
Example
groupmod -n sysadmins admins
7.2.6 to remove a group from the system
groupdel groupname
Example
# groupdel admins
7.3 user account commands
7.3.1 find directory expression
user username
type x
7.3.2 what users are logged in
# who
# rwho
# rusers -l
# finger [options] [username]...
7.3.3 change password
passwd username options
# passwd -f mark
$ passwd
8 files and directories
paths
../ go up one directory
./ this directory
8.1 file system navigation
display current working directory
pwd
change directory
cd
Example
cd /local/bin
cd ../
8.2 listing the contents of directories
ls [options] [files]
-l long format, showing the following: permission links owner group size last-modified filename
-a list all entries, including those begin with a dot (.)
-F Marks directories with /, doors >, executable files *, FIFO |, symbolic links @, and AF_UNIX address family sockets with =.
-i print inode number in first column
-d if directory, list name only (not its content)
-t sort by time stamp (latest first)
-r reverse order of sort to get reverse alphabetic or oldest first
-R recursively list subdirectory encountered
Example: # ls -l
drwxr-xr-x 3 pete adm 1536 May 23 13:23 bin
8.3 to determine the type of a file
the file command
# file /temp
/temp: directory
8.4 creating files using the touch command
# touch filename
8.5 creating files using output redirection
>, <, >>, |
Example:
# ps -ef > /temp/proc.txt
8.6 creating files using copy
cp [options] source target
-i interactive
-r recursive, copy directory & its files
-p preserve owner, group and permission settings
Example:
# cp -r /etc/inet /etc/inetsave
8.7 moving file or rename
mv [options] source destination
-i prompt for confirmation to overwrite target
Example:
# mv -i hostname /tmp
# mv .profile .profileold
(rename file)
8.8 removing files
rm [options] file or dirname
-i interactive
-r recursively remove directories and its contents
-f remove all without prompt
Example:
# rm -rf /tmp/logs
8.9 Displaying the context of text files
Example:
# cat /tmp/names.txt
# more services
Advanced use of cat command
# cat volume[1-9] volume[1-9][0-9] volume1[01][0-9] >> encyclopedia
8.10 searching for text within files
grep [options] pattern [filename]
Example:
# grep uucp passwd
8.11 working with directories
8.11.1 creating subdirectories
mkdir [options] directory
-p create nonexisting parent directories
Example:
mkdir -p /tmp/apps/ar/bin
8.11.2 removing directories
rmdir [options] directory
-p remove empty parent directories
-r remove directories with their contents
Example:
# rm -r /tmp/libs