31 Mayıs 2012 Perşembe

Unix komutları -7


Log Files

Solaris
Red Hat
Ubuntu/Debian
HP
AIX
messages
/var/adm/messages
/var/log/messages
/var/log/messages
/var/adm/syslog/syslog.log
/var/adm/ras
syslog
/var/log/syslog
/var/log/syslog
/var/log/syslog
/var/adm/syslog/syslog.log
/var/adm/ras
mail

/var/log/mail
/var/log/mail.*
/var/adm/syslog/mail.log
/usr/spool/mqueue/syslog
cron
/var/cron/log
/var/log/cron
/var/log/cron.log
/var/adm/cron/log
/var/adm/cron/log
boot
/var/adm/messages
dmesg
/var/log/boot
dmesg
/var/log/boot
dmesg
/var/adm/syslog/syslog.log
dmesg
/var/adm/ras

alog -o -t boot
alog -o -t console
alog -L  (list all the logs available)
Error logging
logger
logger
logger
logger
/usr/lib/errdemon -l (display attributes) 
/usr/lib/errdemon (start error logging)
 
/usr/lib/errstop (stop error logging)
# use with above errorlog file 
errpt (summary errorlog report)
errpt -a (detailed errorlog report)
errpt -j <identifier> (single errorlog report)

errclear (clears errorlog)
errclear -d <class><days> (clears class errors)

errlogger "message upto 230 chars"
 
Security

Solaris
Red Hat
Ubuntu/Debian
HP
AIX
Checking the passwd file
pwck
pwck
pwck
pwck
pwdck -t ALL 
usrck -t ALL
checking the group file
grpck
grpck
grpck
grpck
grpck
console login (allow/deny)
# No reboot required 
/etc/default/login
# No reboot required 
/etc/securetty
# No reboot required 
/etc/securetty
# No reboot required 
/etc/securetty

Note: you may need to create this file if it does not exist
# No reboot required
/etc/security/user

chsec -f /etc/security/user -s root
Misc

Solaris
Red Hat
Ubuntu/Debian
HP
AIX
startup
eeprom
setenv boot-device
grub (GUI)
lilo (text based)
grub (GUI)
setboot -p <primary path>
setboot -a <alternate path>

# autoboot sequnce
 
setboot -b [on|off]
bootlist -m normal hdisk0 hdisk1
shutdown
shutdown -i5 -g0 -y (power down)
shutdown -i6 -g0 -y (reboot)
shutdown -i0 -g0 -y (OK prompt)
reboot -- -r (reboot/reconfigure)

touch /reconfigure
shutdown -h (halt)
shutdown -r (reboot)
shutdown -f (fast reboot no fsck)
shutdown -F (force fsck)
shutdown -h (halt)
shutdown -r (reboot)
shutdown -P (power off)
touch /forcefsck
# edit /etc/default/rcS change below so 
# you dont have to hang around
 
FSCKFIX=yes
shutdown -h now (halt)
shutdown -r now(reboot)
shutdown -F (fast shutdown) 
shutdown -Fr (fast shutdown and reboot)
Change run level
halt
init
poweroff
reboot
shutdown
telinit
uadmin
halt
init
poweroff
reboot
shutdown
telinit
halt
init
poweroff
reboot
shutdown
telinit
init
reboot
shutdown
init
shutdown
reboot
 
telinit
halt
init status
0
1
2
3
4
5
6

0 - shutdown
1 - single user
2 - n/a
3 - Multi-user
4 - n/a
5 - power off
6 - reboot

# change default
vi /etc/inittab

0 - halt
1 - single user
2 - multiuser (no networking)
3 - multiuser (networking)
4 - unused
5 - GUI
6 - reboot

# change default
vi /etc/inittab

0 - halt
1 - single user
2 - multiuser (default)
3 - same as 2
 
4 - same as 2
 
5 - same as 2
 
6 - reboot
 



# change default - change all the telinit
 
vi /etc/event.d/rc-default

0 - halt
1 - single users
2 - multiuser (networking)
3 - multiuser (networking, NFS, and CDE GUI) (default)
 
4 - multiuser (netwrking, NFS, and VUE GUI)
5 - n/a
6 - n/a

# change default - change the initdefault line 
vi /etc/inittab

0 - reserved
 
1 - reserved
 
2 - multiuser mode with NFS
 
3 - user defined
 
4 - user defined
 
5 - user defined
 
6 - user defined
 
7-9 - user defined
# change default - change the initdefault line 
vi /etc/inittab
Startup options
-s single user
-a interactive
-x no device drivers (used in clustering)
 
-r reconfigure devices
-m milestone
single  - use grub to edit kernel line 
emergency - use grub to edit kernel line
 
linux rescue - use at the boot prompt
single: runlevel1, local fs mounted, no network
emergency: root fs read-only, no init files run
 
rescue: use cd-rom/network, root mounted as /mnt/sysimage
single  - use grub to edit kernel line 
emergency - use grub to edit kernel line
 
linux rescue - use at the boot prompt
single: runlevel1, local fs mounted, no network
emergency: root fs read-only, no init files run
 
rescue: use cd-rom/network, root mounted as /mnt/sysimage
interact with IPL? Y

# single user
 
ISL> hpux -is
# Logical volume maintanence mode 
ISL> hpux -lm

# No quroum check
ISL> hpux -lq
Based on 9114-275 workstation
1. switch off the machine

2. power on and enter the SMS menu

Note: to enter the SMS menu press numeric 1 after the word keyboard but before the word speaker
 


startup scripts
/etc/init.d

/etc/rc0.d - /etc/rc6.d
/etc/init.d

/etc/rc0.d - /etc/rc6.d
/etc/init.d

/etc/rc0.d - /etc/rc6.d
/sbin/init.d
/etc/rc.config.d (startup config files)
 

/sbin/rc0.d - /sbin/rc6.d
/etc/rc.d
/etc/rc.d/init.d

/etc/rc.d/rc2.d - rc9.d

/etc/rc.* (config files for auto-starting)
also uses the System Resource Controller
boot prompt commands
boot
printenv
setenv
banner
devalias
show-devs
show-pci-devs-all
 
probe-scsi-all
probe-fcal-all
probe-pci
 
watch-net-all
reset-all
F10 or F12
F10 or F12
interact with IPL? Y
Based on a 9114-275 workstation
1. switch off the machine

2. power on and enter the SMS menu

Note: to enter the SMS menu press numeric 1 after the word keyboard but before the word speaker
Boot process
Phases:
  • Boot PROM: displays system information, run POST, load bootblk, locate ufsboot
  • Boot Programs: bootblk loads and executes the ufsboot
  • Kernel Initialization: ufsboot loads and executes the core kernel, initializes core kernel data structures, loads other kernel modules based on the/etc/system file, starts/sbin/init program
  • init: starts other processes based on the /etc/inittab file
Boot sequence
1.     BIOS
2.     POST
3.     Master Boot Record (MBR) - point to the bootloader GRUB or LILO
4.     GRUB (stage 1) - point to GRUB stage 1_5
5.     GRUB (stage 1_5) - deals with specific filesystem types look at /boot/grub/*1_5 files
6.     GRUB (stage 2) – reads /etc/grub.conf and displays the grub menu, it specifies the kernel and the initrd files
7.     KERNEL - control given to the kernel
8.     INIT - reads /etc/inittab and runs /etc/rc.d/rc.sysinit script
Boot sequence
1.     BIOS
2.     POST
3.     Master Boot Record (MBR) - point to the bootloader GRUB or LILO
4.     GRUB (stage 1) - point to GRUB stage 1_5
5.     GRUB (stage 1_5) - deals with specific filesystem types look at /boot/grub/*1_5 files
6.     GRUB (stage 2) – reads /boot/grub/menu.lst and displays the grub menu, it specifies the kernel and the initrd files
7.     KERNEL - control given to the kernel
8.     INIT - runs the /etc/event.d/rc-default script
Phases:
1.     PDC - processor-dependent code; executes and performs self-tests
2.     ISL - initial system loader; loads the secondary system loader hpux
3.     HPUX - is the secondary system loader and loads the kernel /stand/vmunix, then hands over to the kernel
4.     KERNEL - swapper processes are started by the kernel then starts the init process
5.     INIT - reads /etc/inittab
Phases:
  • Read Only Storage (ROS): check the system board, perform POST, locate and load boot image, begin system initialization and execute phase 1 of the /etc/rc.boot script
  • Base Device Configuration: start configuration manager to configue base devices
  • System Boot: start init process phase 2, switch to hard-disk root filesystem, start other processes defined by /etc/inittab and execute phase 3 of the /etc/rc.boot script
determine the run level
who -r
runlevel
who -r
runlevel
who -r
who -r
who -r
obtain default run level
cat /etc/inittab
cat /etc/inittab
/etc/event.d/rc-default
/etc/inittab
/etc/inittab
list locale
locale -a
locale -a
locale -a
locale -a
locale -a
start xwindows
n/a
startx (shorthand of below)
initx (lots of parms)

n/a
n/a
initialize system
sys-unconfig


set_parms [initial|hostname|ip_address|timezone]

Note: set_parms is in /sbin
install_assist
Timezone
/etc/TIMEZONE
/etc/default/init
/etc/sysconfig/clock
/usr/share/zoneinfo/zone.tab
/etc/timezone
/usr/share/zoneinfo/zone.tab
/etc/TIMEZONE
/etc/environment
/etc/profile


Unix komutları -6



Accounts cmmands


Solaris
Red Hat
Ubuntu/Debian
HP
AIX
display users
cat /etc/passwd

logins -x
cat /etc/passwd
system-config-users (GUI)
cat /etc/passwd
cat /etc/passwd
logins -x
cat /etc/passwd

lsuser -f ALL   (detailed)
create a user
useradd
useradd
system-config-users (GUI)
useradd
useradd
sam
mkuser
useradd
remove a user
userdel
userdel
system-config-users (GUI)
userdel
userdel
sam
rmuser
userdel
modify a user
usermod
usermod
system-config-users (GUI)
usermod
usermod
sam
chuser -a
usermod
 
passwd -f
passwd -s
chfn <username>
chfn <username><shell>
change user password
passwd
passwd
passwd
passwd
passwd
pwdadm
pwdck -t ALL
create a group
groupadd
groupadd
groupadd
groupadd
mkgroup <group name>
remove a group
groupdel
groupdel
groupdel
groupdel
rmgroup <group name>
modify a goup
groupmod
groupmod
groupmod
groupmod
chgroup <attribute><group name>
password files
/etc/passwd
/etc/shadow
/etc/passwd
/etc/shadow
/etc/passwd
/etc/shadow
/etc/passwd
/tcb/files/auth/r/root (trusted system)
/etc/security/passwd
useful user commands
id -a
whoami
who
w
finger
id -a
whoami
who
w
finger
id -a
whoami
who
w
finger
id
whoami
who
w
uptime (displays # of users logged in)
finger
id
whoami
who
w
uptime (displays # of users logged in)
finger
 

# License information
 
lslicense
chlicense

# Maximum number of processes for a user
 
lsattr -D -l sys0 -a maxuproc
chdev -l sys0 -a maxuproc=<number>
useful group commands
groups
setpgrp
newgrp
groups
groups
groups
setprivgrp
groups
setgroups
lsgroup ALL

NFS commands


Solaris
Red Hat
Ubuntu/Debian
HP
AIX
NFS Daemons
server: mountd, nfsd
client: statd, lockd
server: rpc.mountd,nfsd
client: rpc.statd, lockd
server: rpc.mountd,nfsd
client: rpc.statd, lockd
server: rpc.mountd, nfsd
client: rpc.statd, lockd
server: rpc.mountd, nfsd
client: rpc.statd, rpc.lockd
NFS files
/etc/dfs/dfstab
/etc/dfs/sharetab
/etc/rmtab
/etc/exports
/var/lib/nfs/etab
/var/lib/nfs/xtab
/etc/exports
/var/lib/nfs/etab
/var/lib/nfs/xtab
/etc/exports
/etc/xtab
/etc/exports
/etc/xtab
List nfs clients that have a remote mount
/etc/rmtab
/var/lib/nfs/rmtab
/var/lib/nfs/rmtab
/etc/rmtab
/etc/xtab
display nfs shares
dfshares
showmount -e localhost
showmount -e localhost
showmount -e localhost
showmount -e localhost
exportfs
showmount -e localhost
create nfs share
/etc/dfs/dfstab (edit and add share)
share <path>
 

## dfstab example
 
share -F nfs -d "jumpstart" /export/jumpstart
redhat-config-nfs (GUI)

/etc/exports (edit and add share)
/sbin/service nfs reload

## /etc/exports example
/export *(rw,fsid=0,insecure,no_root_squash,sync)
/etc/exports (edit and add share, see below example)
exportfs -rav (export the shares)
 

/etc/init.d/portmap restart
/etc/init.d/nfs-kernel-server restart

## /etc/exports example
/export *(rw,fsid=0,insecure,no_root_squash,sync)
 
/etc/rc.config.d/nfsconf (edit)
/etc/exports (edit and add share)
exportfs -a
mknfsexp -d <directory>
mknfsmnt

shareall
uncreate nfs share
unshare <path>
/etc/dfs/dfstab (edit and remove share)
 
/etc/exports (edit and remove share)
/sbin/service nfs reload
/etc/exports (edit and remove share)
exportfs -rav (export the shares)
 
/etc/rc.config.d/nfsconf (edit)
exportfs -au (unshare all)
exportfs -u /home/vallep
 
/etc/exports (edit and remove share)
rmnfsexp  -d <directory> (unshares and removes from file) 

exportfs -u <filesystem>
 
unshareall
start/change nfs daemons
/etc/init.d/nfs.server start 
/etc/init.d/nfs.client start
svcadm enable nfs/server
svcadm disable nfs/server
/sbin/service nfs start
/etc/init.d/portmap start
/etc/init.d/nfs-kernel-server start
/sbin/init.d/nfs.core start
/sbin/init.d/nfs.server start
/sbin/init.d/nfs.client start
mknfs
chnfs
 

startsrc -s nfsd
startsrc -s rpc.mountd
stop nfs daemons
/etc/init.d/nfs.server stop
/etc/init.d/nfs.client stop
/sbin/service nfs stop
/etc/init.d/portmap stop
/etc/init.d/nfs-kernel-server stop
/sbin/init.d/nfs.client stop
/sbin/init.d/nfs.server stop
 
/sbin/init.d/nfs.core stop
rmnfs

stopsrc -s nfsd
stopsrc -s rpc.mountd
nfs status
ps -ef|grep < nfs daemons>
/sbin/service nfs status
/etc/init.d/nfs-kernel-server status
ps -ef | grep <nfs daemons>
lssrc -a |grep -i nfs
nfs reload
shareall
/sbin/service nfs reload
exportfs -rav (export the shares)
exportfs -a
exportfs -av
nfs performanace
nfsstat
nfsstat
nfsstat
nfsstat
nfsstat
nfs Options
n/a
cat /var/lib/nfs/etab
cat /var/lib/nfs/etab
n/a
nfso -a
nfso -o <option>=<value>

exportfs (display options)
solaris/redhat mount problems (nfs v3 to v4)
## Make sure you use NFS version 3 
mount -F nfs -o vers=3 <mount> <mountpoint>
n/a
n/a
n/a
n/a

NTP commands


Solaris
Red Hat
Ubuntu/Debian
HP
AIX
Time daemons
xntpd
ntpd
ntpd
xntpd
xntpd
ntp setup
# Solaris 8 
/etc/ntp.conf
/etc/ntp.server
/etc/ntp.client
/etc/rc2.d/xntpd [start|stop]
# Solaris 10
/etc/inet/ntp.server
/etc/inet/ntp.client

svcadm enable ntpd
/etc/ntp.conf (edit with ntp servers)
dateconfig (GUI)
chkconfig --list ntpd
chkconfig --level 2345 ntpd on
 
/sbin/service ntpd start
 
/etc/default/ntp
/etc/ntp.conf
/etc/init.d/ntp [start|stop|restart]
/etc/rc.config.d/netdaemons (set XNTPD to 1) 
/etc/ntp.conf
/etc/ntp.conf
startsrc -s xntpd
stopsrc -s xntpd

lslpp -L all|grep xntpd
ntp daemon options
/lib/svc/method/xntp
/etc/sysconfig/ntpd
/etc/default/ntp
/etc/rc.config.d/netdaemons
startsrc -s xntpd -a "-x"
/etc/rc.tcpip
NTP Trace commands
ntpq -p
ntptrace
ntpq -p
ntptrace
ntpq -p
ntptrace
ntpq -p
ntpdate (set the date)
ntpq -p
ntptrace
ntpdate