31 Mayıs 2012 Perşembe

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

Unix komutları -5


Crash Dump

Solaris
Red Hat
Ubuntu/Debian
HP
AIX
Crash Dump
dumpadm -d <device>
crash (used to analyse crash dumps)
adb (used to analyse crash dumps)
diskdump
netdump
kdump (part of kexec rpm)
/etc/kdump.conf (select where you want the dump to go) 
service kdump start
chkconfig kdump on

## to crash the system
echo "c" > /proc/sysrq-trigger
crash (used to analyse crash dumps)
diskdump
netdump
kdump (part of kexec rpm)
/etc/kdump.conf (select where you want the dump to go) 
service kdump start
chkconfig kdump on

## to crash the system
echo "c" > /proc/sysrq-trigger
crash (used to analyse crash dumps)
edit /stand/system
add either:
dump
 2/0/1.5.0
dump lvol
dump none
# crash config file
/etc/rc.config.d/savecrash

sysdumpdev -l (list dump destination)
sysdumpdev -e (estimates dumpsize)
sysdumpdev -L (info)
sysdumpstart -p (start dump primary)
sysdumpstart -s (start dump secondary)

# set the dump device permanently
 
sysdumpdev -p <dump device> -P
 

# analyse dump file
echo "stat\n status\n t -m" | crash /var/adm/ras/vmcore.0
Performance Monitoring and Diagnostics

Solaris
Red Hat
Ubuntu/Debian
HP
AIX
CPU
top (sunfreeware)
prstat
 
sar
mpstat
w          (load average)
uptime   (load average)
 
ps
vmstat
top
sar
mpstat
w          (load average)
uptime   (load average)
 
ps
vmstat
procinfo
oprofile
cat /proc/cpuinfo
top
sar
mpstat
w          (load average)
uptime   (load average)
 
ps
vmstat
procinfo
cat /proc/cpuinfo
top
sar
w          (load average)
uptime   (load average)
 
ps
vmstat
glance
sam
topas -P
topas -L  (logical partitions)
 
mpstat
sar -c
 
w          (load average)
uptime   (load average)
 
lparstat
ps
iostat -tT 1
tprof
curt
 
Memory
prstat
vmstat
top
sar
free
vmstat
top
procinfo
slabtop
sar
cat /proc/meminfo
 
free
vmstat
top
procinfo
slabtop
sar
cat /proc/meminfo
top
vmstat
sar
sam
glance
topas
vmstat
sar -b
svmon
ps
ipcs -a
lockstat (version 4)
 
rmss
 
Network I/O
ndd
netstat
lsof
snoop
route
ethtool
mii-tool
netstat
lsof
tcpdump
 
ip
iptraf
ethtool
mii-tool
netstat
lsof
tcpdump
 
ip
iptraf
netstat
lanadmin
sam
glance
 
[ent|tok|fddi|atm]stat
netstat
netpmon (trcstop to stop trace)
Disk I/O
sar -d
iostat
vmstat
lsof
sar -d
iostat
vmstat
lsof
sar -d
iostat
vmstat
lsof
iostat
sar
sam
 
glance
topas -D   (disk)
topas -F   (filesystem)
 
iostat
sar -D
 
fcstat (fibre)
lvmstat
filemon (trcstop to stop)
 
fileplace

# disk stat history
 
chdev -l sys0 -a iostat=true
lsattr -HEl sys0 -a iostat
Application
truss -p <pid>
strace -p <pid>
strace -p <pid>
download and install tusc
tusc -p <pid>
topas
truss
sar
 
probevue
tprof
svmon -P <pid>
NFS
nfsstat
nfsstat
nfsstat
nfsstat
nfsstat
Kernel Modules and Parameters

Solaris
Red Hat
Ubuntu/Debian
HP
AIX
display loaded modules
modinfo
cat /proc/modules (more detailed) 
lsmod
Location: 
/lib/modules/`uname -r`/kernel/drivers

Config:
/etc/modprobe.conf
/etc/modprobe.d
cat /proc/modules (more detailed) 
lsmod
Location: 
/lib/modules/`uname -r`/kernel/drivers

Config:
/etc/modprobe.d/options
/etc/modprobe.d
kmadmin -k 
genkex
load modules
modload -p drv/<module name> 
modprobe <module>
insmod
modprobe <module>
insmod
kmadmin -L <module name>
n/a
unload modules
modunload -i <module number>
modprobe -r <module>
rmmod
modprobe -r <module>
rmmod
kmadmin -U <module name> 
kmadmin -u <module id>
n/a
set kernel parameters (tuning)
/etc/system (edit and reboot)
/etc/sysctl.conf (edit and update then reboot)
sysctl -p <filename>
sysctl -w param=value 

No reboot (dynamically):
echo "250 32000 100 28" > /proc/sys/kernel/sem
echo "536870912" > /proc/sys/kernel/shmmax
echo "4096" > /proc/sys/kernel/shmmni
echo "2097152" > /proc/sys/kernel/shmall
etc.............................................
/etc/sysctl.conf (edit and update then reboot)
sysctl -p <filename>
sysctl -w param=value 

No reboot (dynamically):
echo "250 32000 100 28" > /proc/sys/kernel/sem
echo "536870912" > /proc/sys/kernel/shmmax
echo "4096" > /proc/sys/kernel/shmmni
echo "2097152" > /proc/sys/kernel/shmall
etc.............................................
kcweb (11i) 
kctune (11i only)
rebuild kernel (< 11i see below)
chdev -l sys0 -a <parameter>=<value>
no -a          (network)
vmo -a        (virtual memory)
 
nfso -a        (NFS)
ioo -a         (Input/Ouput)
raso -a        (reliability, availability, serviceability)
 
schedo -a   (processor scheduler)
 

vi /etc/security/limits
cd /etc/tunables
tunchange, tundefault, tunsave, tunrestore, tuncheck 

Note: most parameters are dynamically changed in AIX , for example memory segments are dynamically adjusted
display kernel parameters
cat /etc/system
sysdef -i
sysctl -a
cat /etc/sysctl.conf

cat /proc/sys/kernel/sem
cat /proc/sys/kernel/shmmax
etc...................................
sysctl -a
cat /etc/sysctl.conf

cat /proc/sys/kernel/sem
cat /proc/sys/kernel/shmmax
etc...................................
kctune (11i only)
sysdef
kmtune
kmsystem
/usr/sam/lbin/getkinfo -f /stand/vmunix -o /tmp/kernel.data
lsattr -EHl sys0 

Note: only a few kernel parameters can be changed
build kernel
edit and update file then reboot:
/etc/system
cd /usr/src/linux-2.5
edit Makefile (change EXTRAVERSION)
make mrproper
backup .config
make xconfig
make dep
make bzImage
make modules
move new kernel
make modules_install
change lilo/grub config file
reboot

cd /stand/build
/usr/lbin/sysadm/system_prep -v -s system
edit system file
/usr/sbin/mk_kernel -s ./system
mv /stand/system /stand/system.old
mv /stand/vmunix /stand/vmunix.old
mv /stand/build/system /stand
mv /stand/build/vmunix_test /stand/vmunix
reboot
chdev -l sys0 -a <parameter>=<value>

Note: most parameters are dynamically changed in AIX , for example memory segments are dynamically adjusted
interprocess communication
ipcs -a
ipcs -a
ipcs -a
ipcs -a
ipcs -a
Services

Solaris 10
Red Hat
Ubuntu/Debian
HP
AIX
display services
svcs -a
inetadm -l
service --status-all
There is no services or chkconfig command use the old fashioned way /etc/init.d/<service>
There is no services or chkconfig command 
use the old fashioned way /sbin/init.d/<service>
lssrc -a
start services
svcadm enable nfs
service nfs start
startsrc -s <subsystem>
startsrc -g <group>
stop services
svcadm disable nfs
service nfs stop
stopsrc -s <subsystem>
stopsrc -g <group>
reload service
svcadm refresh nfs
service nfs reload
refresh -s <subsystem>
restart service
svcadm restart nfs
service nfs restart
stopsrc -s <subsystem> 
startsrc -s <subsystem>
service status
svcs nfs
service nfs staus
lssrc -a
service dependencies
svcs -d network
n/a
n/a
service dependants
svcs -D network
n/a
n/a
service logging, etc
/var/svc/log
/var/svc/manifest
/lib/svc/method
n/a
/var/adm/ras
/etc/syslog.conf
 
/etc/rc.tcpip
change service startup
n/a
chkconfig --levels 2345 nfs on
n/a
Add a new service
n/a
# Create your stop/start
# script in /etc/init.d

chkconfig --add <script>

Patching / Software

Solaris
Red Hat
Ubuntu/Debian
HP
AIX
display installed patches
showrev -p
patchadd -p


swlist -l bundle 
swlist -l product
swlist -l patch
instfix -ia
adding patch
patchadd
patchadd -M <dir> (multiple patches)
patch -p1 <patch>

zcat patch46.gz | patch -p1

Note: -p = # of path stripping


swcopy (install patch into depot)
swinstall (install patch from depot)
Note: the swagentd daemon must be running
instfix -k
removing patch
patchrm
patch -R -p1 <patch>

swremove
installp -r
display installed packages
pkginfo (all packages)
pkginfo -l (single package)
pkgchk -l -p <file> (file belongs)
rpm -qa (all packages)
rpm -q (single package)
rpm -qf (file belongs)
rpm -qi <package> (very detailed)
dpkg -l
dpkg -S <search string> (search)
dpkg -S <filename> (file belongs)
 
dpkg -s <package> (status)
dpkg -p <package> (detailed)
 
swlist -l bundle <bundle> 
swlist -l product <product>
 

## check a package
swlist -s <full_path/software>
lslpp -L all (all filesets)
lslpp -L <package> (single fileset)
 
lslpp -w <file> (file belongs)
lslpp -ha (history of filesets)
rpm -qa (all packages)
rpm -q (single package)
rpm -qf (file belongs)
rpm -qi <package> (very detailed)
 

oslevel -g (install packkages above os level)

whereis <filename>
 
which_fileset <filename>
adding package
pkgadd
rpm -Uhv (updates/installs if not already)
rpm -ihv (install)
dpkg -i <package>
swinstall
swinstall -s <full_path/software>
installp -a
installp -c (cleanup after failed install)
rpm -i
geninstall (generic installer: installp, RPM, etc)
removing packages
pkgrm
rpm -e <package>
dpkg -r <package> (do not remove config files)
dpkg -P <package> (remove config files)
swremove
installp -u (commited packages) 
installp -r (applied packages)

rpm -e <package>
geninstall -u <package>
verify package
pkginfo -l
pkginfo -p
rpm -V <package>
n/a
swverity <fileset> (see /var/adm/sw/swagent.log)
lppchk -v 

rpm -V <package>
List files in package
pkgchk -l <package> | grep -i pathname
rpm -ql <package>
dpkg -L <package> (list files)
swlist -l file <product>
lslpp -f <fileset>
rpm -ql <package>
Package directory
/var/sadm
/var/lib/rpm
/var/lib/dpkg/info
/var/adm/sw
/usr/lpp
/var/lib/rpm
List libraries required for binary program
ldd <file>
ldd <file>
ldd <file>
chatr <file>
ldd <file>