Pages

Friday 27 December 2013

Solaris 9 Command (Basic)

############Cac lenh thuong dung :
/usr/platform/`uname –i`/sbin/prtconfig –v
du -sh // xem current capacity cua thu muc (phai cd vao thu muc, dung tai thu muc do va go du -sh)
(ls -li // )
vi /etc/profile
PATH=/usr/sbin:/usr/bin://bin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/usr/ccs/bin:/usr/local/mysql/bin/:/usr/local/ssl/bin
CPPFLAGS="-I/usr/include -I/usr/local/include -I/usr/local/ssl/include -I/usr/local/BerkeleyDB.4.2/include -I/usr/java/include -I/usr/sfw/include"

#cat /var/sadm/system/admin/CLUSTER //xem coi He dieu hanh nay cai dat loai package na`o
//CLUSTER=SUNWCXall

######
Cac cau lenh search ky tu trong file
grep -c <ky tu> <file> // tra ve so luong ky tu co trong file
grep -l <ky tu> <file> // tra ve ten file

crle -u -v -l /usr/lib:/lib:/etc/lib:/usr/local/lib:/usr/local/ssl/lib:/usr/local/BerkeleyDB.4.2/lib:/usr/share/lib:/usr/xpg4/lib:/usr/sfw/lib:/usr/java/lib:/usr/ccs/lib:/usr/sadm/lib:/etc/security/lib:/opt/csw/lib
export LD_LIBRARY_PATH=/usr/local/lib
ln -s /usr/local/bin/gcc /usr/ccs/bin/cc

uname -r //show version
df -lk //disk space
prtconf //avalaible memory
which <command> //locate position of command
netstat -an | grep LISTEN

Lenh xem cac dia trong he thong : iostat -En
Lenh xem route : route get <net or host>
Set che do graphic cho Solaris :#eeprom console=graphics
#/usr/dt/bin/dtlogin -e
#reboot
##############Cau hinh FTP server voi folder retriction user :
# <tao user, pass>
# useradd -d /export/home/<folder-name> -s /bin/sh <user-name>
# passwd <name>
# cd /etc/ftpd
# vi ftpaccess
# <Them dong sau vao file tren>
# guestuser <name>
# <Update thu muc>
# /usr/sbin/ftpconfig -d /export/home/<foder-name>
# chmod lai thu muc home cua user do'
(<folder-name> va <user-name> ta nen tao giong nhau)
bash-2.05# more /etc/release //show version
#cd var/sadm/patch : show patch
#showrev -p : show patch
#cd /var/sadm/pkg
## /usr/sbin/psrinfo -v : determine the speed of your processor(s)
# /usr/sbin/pkgadd -d /cdrom/cdrom0/directory/Product package_names : add o individual package
in Solaris CD Software
#sys-unconfig // System Undo Config



#####################Change Host Name
For Solaris versions prior to 7, check/edit:
/etc/inet/hosts
/etc/nodename
/etc/hostname.<interface>
where <interface> is the name of the primary interface, e.g. bge0.
/etc/net/ticlts/hosts
/etc/net/ticots/hosts
/etc/net/ticotsord/hosts
Then reboot the system.
For Solaris versions 7 to 9, check/edit:
/etc/inet/hosts
/etc/nodename
/etc/hostname.<interface>
where <interface> is the name of the primary interface, e.g. bge0.
/etc/net/ticlts/hosts
/etc/net/ticots/hosts
/etc/net/ticotsord/hosts
/etc/inet/ipnodes
Then reboot the system.
For Solaris version 10, check/edit:
/etc/inet/hosts
/etc/nodename
/etc/hostname.<interface>
where <interface> is the name of the primary interface, e.g. bge0.
/etc/inet/ipnodes
Then reboot the system.





#################Change IP Address
For Solaris versions prior to 7, check/edit:
/etc/inet/hosts
/etc/hostname.<interfaces>
where <interfaces> are the names of the interfaces, e.g. bge0, bge1, eri0.
/etc/net/ticlts/hosts
/etc/net/ticots/hosts
/etc/net/ticotsord/hosts
If you are moving to a new subnet, check/edit:
/etc/inet/netmasks
/etc/defaultrouter
/etc/resolv.conf
Then reboot the system.
For Solaris versions 7 to 9, check/edit:
/etc/inet/hosts
/etc/hostname.<interfaces>
where <interfaces> are the names of the interface, e.g. bge0, bge1, eri0.
/etc/net/ticlts/hosts
/etc/net/ticots/hosts
/etc/net/ticotsord/hosts
/etc/inet/ipnodes
If you are moving to a new subnet, check/edit:
/etc/inet/netmasks
/etc/defaultrouter
/etc/resolv.conf
Then reboot the system.
For Solaris version 10, check/edit:
/etc/inet/hosts
/etc/hostname.<interfaces>
where <interfaces> are the names of the interface, e.g. bge0, bge1, eri0.
/etc/inet/ipnodes
If you are moving to a new subnet, check/edit:
/etc/inet/netmasks
/etc/defaultrouter
/etc/resolv.conf
Then reboot the system.
########### Change domainname
domainname <domain>
domainname > /etc/defaultdomain

#########################In the ssh configuration files, allow root logins as follows:
# vi /etc/ssh/sshd_config
PermitRootLogin yes
Restart sshd by stopping and starting it.
# /etc/init.d/sshd stop
# /etc/init.d/sshd start


#########################
#ifconfig hme0 plumb



##################################################################################
##Do not connect a keyboard to the Sun machine if you want to use serial console##
##Do not connect a keyboard to the Sun machine if you want to use serial console##
##Do not connect a keyboard to the Sun machine if you want to use serial console##
##Do not connect a keyboard to the Sun machine if you want to use serial console##
##Do not connect a keyboard to the Sun machine if you want to use serial console##
##Do not connect a keyboard to the Sun machine if you want to use serial console##
##################################################################################
To connect to the system console, in the ALOM system controller window, type
sc> console
To return to the ALOM shell prompt (sc>) type #. (pound period).
The chassis serial number is 0547AE81D0 then the default password is:
47AE81D0


###########################
Xem log, config log
#/etc/logadm.conf


###################################################################################
pkggadd -R <installed directory> -a <create admin file> -d <source folder>

pkgadd -R /export/opt/software -d pkg
pkginfo -l <package>

###################################################################################
Error on pkginfo:
bash-2.05# pkginfo -l SUNWxwman
pkginfo: ERROR: bad entry read in contents file
pathname: /platform/SUNW,Sun-Fire-880/kernel/misc/sparcv9/sbdp
problem: unable to read mode/owner/group

Error o pathname nao thi check cai do'.Nhu VD tren thi error tai
/platform/SUNW,Sun-Fire-880/kernel/misc/sparcv9/sbdp , thu hien nhu sau :
Open file :
#cd /var/sadm/install/contents
Vao den do`ng do'
kiem tra loi nhu the nao
Luu lai va reboot

Nho backup lai file nhe'



#############Cac lenh tim kiem ps:
ps - U <user> // tim session cua user
ps -U qmails | grep qmail-se | awk "{print \$4;}" // lenh nay se in ra paramenter thu 4 cua
ket qua 2 lenh truoc

##############Manage command history:
history se duoc luu trong file ~/.bash_history
Neu ta muon sau moi lan logout, may tinh se xoa tat ca history command thi lam nhu sau :
#cd ~
#vi ~/.bash_logout

/bin/rm -f $HOME/.bash_history
clear
wq!
#env
# //logout ra la duoc

Multipathing Command

#if_mpadm -d ce0 //lenh nay dung de deactive card ce0 ra khoi nhom IPMP
#if_mpadm -r ce0 //reactive lai card ce0

######### kiem tra tinh trang he thong
who // xem current user login [-p : hien thi system last reboot] [-m hien thi concurrent reminal] [-r hien thi current system run-level]
prtdiag -v
who -b // he thong duoc boot lai khi nao
who -q // current user login
who -u // giong -q, nhung chi tiet hon.
grep dump /var/adm/m* //tim kiem loi "dump" trong cac file message* (don gian chi la tim
ky tu trong file)
cat /var/adm/messages | grep dump
last <username> //hien thi "history login" ma username nay da login
last reboot //hien thi log cac lan boot
last // neu chi co lenh last khong, he thong se hien thi log cac user da login va cac lan reboot


######### Cac File Log cua he thong
more /etc/syslog.conf



######### Su dung Crontab
crontab -l // de biet cac jobs cua users hien tai
crontab -e // de tao jobs
Cu phap nhu sau
Minute(0-59) Hour (0-23) Day of Month (1-31) Month (1-12 or Jan-Dec) Day of Week (0-6 or Sun-Sat) Command
VD
0 2 12 * 0,6 /usr/bin/find

su dung nhu sau:
export EDITOR=vi
crontab -e //sau do soan thao nhu file vi binh thuong





===========================================
Loi xay ra tren lenh route add

bash-2.05# netstat -rn
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- -------------------- ----- ----- ------ ---------
202.78.224.129 202.78.224.88 UGH 1 16286
202.78.224.130 202.78.224.88 UGH 1 0
10.254.0.68 10.20.4.254 UGH 1 16047
10.254.0.67 10.20.4.254 UGH 1 14745
192.168.1.209 202.78.224.88 UGH 1 0
202.78.224.64 202.78.224.68 U 1 286104 eri0
202.78.224.128 202.78.224.88 UG 1 1
10.20.254.0 202.78.224.88 UG 1 208544
192.0.2.0 10.20.4.254 UG 1 115384
224.0.0.0 202.78.224.68 U 1 0 eri0
default 202.78.224.90 UG 1 144721
127.0.0.1 127.0.0.1 UH 5929976173 lo0
bash-2.05#
bash-2.05#
bash-2.05#
bash-2.05# route add 10.20.4.0 -netmask 255.255.255.0 10.20.4.31
add net 10.20.4.0: gateway 10.20.4.31: Network is unreachable
Trong khi ping van thay 10.20.4.1 ma` no lai bao loi unreachable
bash-2.05# route add 10.20.4.0 -netmask 255.255.255.0 10.20.4.31 -ifp eri1
add net 10.20.4.0: gateway 10.20.4.31: Network is unreachable
10.20.4.31 la IP cua card mang
bash-2.05# route add -net 10.20.4.0 netmask 255.255.255.0 10.20.4.31 -ifp eri1
netmask: bad value
Nhung no lai thanh cong khi thuc hien lenh sau:
bash-2.05# route add -net 10.20.4.0 -netmask 255.255.255.0 127.0.0.1 -ifp eri1
add net 10.20.4.0: gateway 127.0.0.1
bash-2.05# netstat -rn
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- -------------------- ----- ----- ------ ---------
202.78.224.129 202.78.224.88 UGH 1 16286
202.78.224.130 202.78.224.88 UGH 1 0
10.254.0.68 10.20.4.254 UGH 1 16047
10.254.0.67 10.20.4.254 UGH 1 14745
192.168.1.209 202.78.224.88 UGH 1 0
202.78.224.64 202.78.224.68 U 1 286104 eri0
202.78.224.128 202.78.224.88 UG 1 1
10.20.254.0 202.78.224.88 UG 1 208544
192.0.2.0 10.20.4.254 UG 1 115384
10.20.4.0 10.20.4.31 U 1 0 eri1
224.0.0.0 202.78.224.68 U 1 0 eri0
default 202.78.224.90 UG 1 144721
127.0.0.1 127.0.0.1 UH 5929976173 lo0


REAL TIME PROCESSES:
# priocntl -d -i class RT
// if realtime process is running, some application (backup fssnap, del file ...) can not
excutable
Xem lai file backup Snapshot
/usr/lib/fs/ufs/fssnap -i <file_system>

######### Tim kiem file
grep -i test /tmp/zone_out |wc -1 // tim kiem tu khoa test trong file /tmp/zone_out






















OpenSolaris Command ######################################
#svcadm enable <service>
Xem /etc/user_attr de hieu vai tro cua root // tren Open Solaris, vai tro cua root co su
thay doi, no se khong log truc tiep vao he thong ma se duoc su thong qua user khac
Do do' khi cai dat Webmin, ta se khong login = account root duoc. Day la cach khac phuc:
Step 1:
#su root
#/usr/sfw/lib/webmin/setup.sh //buoc nay co the khong can
Selected all the default options: //buoc nay co the khong can
Step 2:
Then while root
Edited /etc/webmin/miniserv.users and added them user nhu sau:
nhieu:x:101 (<user>:x:<userID>)
-This allows you to login to the server
Step 3:
And also edited /etc/webmin/webmin.acl //Edit file nay de cap quyen truy cap service cho user
Copy the existing entry for root and added a new line and changed root to nhieu (<user>) to give access to all the modules
Step 4:
Exit root shell and do //restart lai webmin
$ svcadm enable webmin //neu cai dat = .pkg thi lenh se khac
#/etc/init.d webmin stop
#/etc/init.d webmin start
Step 5:
http://localhost:10000


############### Upgrade Webmin
Often Solaris is not configured by default to allow the upgrading of packages.
To change this, edit the file /var/sadm/install/admin/default and change the line
instance=unique to instance=overwrite. This will allow you to install a new Solaris
package of Webmin over an older version.
Another method of upgrading is to use the following commands :
/etc/webmin/stop
cp -r /etc/webmin /etc/webmin.old
pkgrm WSwebmin
mv /etc/webmin.old /etc/webmin
gunzip webmin-1.430.pkg.gz
pkgadd -d webmin-1.430.pkg WSwebmin



##############################
ESTABLISHED có nghia là socket dang nh?n và g?i và di?u này có nghia là có 1 active connection dang ho?t d?ng
SYN_SENT Socket dang ti?n hành thi?t l?p k?t n?i và dang trong quá trình d?i ACK t? host khách
SYN_RECEIVED có nghia là k?t n?i dã du?c xác nh?n, AKA, sau khi dã vu?t qua bu?c SYN_SENT
FIN_WAIT_1 nghia là socket dã du?c l?nh dóng l?i, và dang trong quá trình ng?t k?t n?i.
FIN_WAIT_2 g?n gi?ng _1 ch? khác là dang ch? socket dóng và g?i dóng k?t n?i cho máy khách
CLOSED socket không s? d?ng
CLOSE_WAIT Nghia là remote dã ng?t r?i và dang ch? d? dóng
LAST_ACK có nghia socket dang trong quá trình ch?, phía remote dã k?t thúc và dã dóng và socket dã dóng r?i
LISTEN socket dang ch? 1 k?t n?i d?n.

###############################
Su dung lenh sar de ghi nhan thong tin
###############################
Go phim #. de vao che cho ALOM
Go:
sc>console de vao lai che do console
User va pass de vao ALOM la : admin qtsc


###############################
Auto FTP bang script
###############################
Cach 1: Khong dung Auto-login
~~~~~~~~~~~~~~~~~~~~~~~~~
ftp -n <<Ketthuc // option -n o day la no auto-login
open 202.78.227.54
user nhutnb 67ty)O // user va pass
bin // cac cau lenh sau khi da login thanh cong FTP server dat o day.
ls
by
Ketthuc
Cach 2 : Du`ng Auto-login
~~~~~~~~~~~~~~~~~~~~~
ftp 202.78.227.54 <<Ketthuc
bin
ls
by
Ketthuc
O cach 2 nay khong can khai bao Username va password. Username va password se duoc khai bao
tai file $HOME/.netrc (nen nho la file .netrc luon dat tai thu muc HOME cua user ma` thuc thi script na`y)
# more ~/.netrc
machine 202.78.227.54
login nhutnb
password 67ty)O

Cach khai bao file .netrc tai day : http://www.mavetju.org/unix/netrc.php
Phai set dung quyen cho .netrc la 600

############################
tao script gui mail: (chua test)
#!/bin/bash
# script to send simple email
# email subject
SUBJECT="SET-EMAIL-SUBJECT"
# Email To ?
EMAIL="admin@somewhere.com"
# Email text/message
EMAILMESSAGE="/tmp/emailmessage.txt"
echo "This is an email message test"> $EMAILMESSAGE
echo "This is email text" >>$EMAILMESSAGE
# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE

##############################
DNS Flush on Solaris
# ps -ef|grep nscd
#kill no' di
Sau do start lai
#/usr/sbin/nscd

date '+%y%m%d'




###################### Su dung Vi trong Console
TERM=vt100
export TERM


#####################Khong truy cap duoc solaris tu Xmanager
Trong solaris, X evironment tu khong start moi khi restart OS. Neu X khong tu dong start, thuc hien nhu sau:
#cd /etc/rc2.d
#S99dtlogin start
Neu van chua duoc thi :
#S99dtlogin reset

netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr
top -n 1 //top 1 lan

No comments:

Post a Comment