Print service provided by iDogiCat: http://www.idogicat.com/
home logo





Home > IT > System Administration > Frequently Used Commands

Frequently Used Commands

iDog

  • ntsysv - change auto loaded services

System status check

Listed here are a few system monitoring commands which should give you a rough idea of how the server is running.

# server information
uname -a

# server config information
prtconf
sysdef -i

# server up time
uptime

# free disk
df -h

# mounted devices
mount

# network status
netstat -rn

# network configuration info
ifconfig -a

# processes currently running
ps -elf

# user processes
w
whodo
who am i
finger
ps

# virtual memory statistics
vmstat 5 5

# system activity reporter (Solaris/AIX)
sar 5 5

# report per processor statistics (Solaris)
mpstat 5 5
psrinfo

# swap disk status (Solaris)
swap -l

# shared memory
ipcs -b

Starting a process

Brief description on how to start a process from the command line.

Glossary:

& - run in background
nohup (No Hang Up) - lets process continue, even if session is disconnected

Examples:

# run a script, in the background
runbackup &

# run a script, allow it to continue after logging off
nohup runbackup &

# Here nohup.out will still be created, but any output will
# show up in my.log.  Errors will appear in nohup.out.
nohup /path/to/my_script > my.log &

# Here nohup.out will not be created; any output will
# show up in test70.log.  Errors will appear test70.log also !
nohup /path/to/my_script > my.log 2>&1  &

Cron table memo

Format:

MM hh dd mm weekday_range command_line

Examples:

30 03 * * 3,6 /xxx/xxx/xxx
00 11 * * 1-5 /yyy/yyy/yyy

Use of find

Example: there are a lot of files in src_dir, we want to move them to dest_dir, but 'mv srcdir/* dest_dir/' won't work since the '*' expands to too long a command line.

# '-l' specifies number of files in a batch; -i makes file to replace '{}'
find src_dir -type f | xargs -l20 -i mv {} dest_dir

# in batch
find src_dir -type f -exec mv --target-directory=dest_dir {}+

# one by one
find src_dir -type f -exec mv --target-directory=dest_dir {}\;

# or (one by one)
find src_dir -type f -exec mv {} dest_dir/ \;

# when file name contains space
find src_dir -type f -exec mv '{}' dest_dir/ \;