1
Solaris 10
2
Users and Groups Management
3
User and Group•User คื�อ ผู้��ใช้�งาน•Group คื�อ กลุ่��มที่��ใช้�แบ่�งแยก
ประเภที่ผู้��ใช้�งานตามลุ่�กษณะการที่!างาน
4
User•ข้�อม�ลุ่ข้องที่�ก user จะถู�กระบ่�ไว้�ที่�� ไฟลุ่( /etc/passwd
•สามารถูดู�ไดู�โดูยใช้�คื!าส� �ง more /etc/passwd
#more /etc/passwdroot:x:0:0:Super-User:/:/sbin/shdaemon:x:1:1::/:bin:x:2:2::/usr/bin:sys:x:3:3::/:adm:x:4:4:Admin:/var/adm:lp:x:71:8:Line Printer Admin:/usr/spool/lp:uucp:x:5:5:uucp Admin:/usr/lib/uucp:…
5
การเพิ่-�ม user•useradd login_name•login_name คื�อ ช้��อผู้��ใช้�ที่��ต�องการสร�าง
#useradd user1#grep user1 /etc/passwduser1:x:1001:1::/home/user1:/bin/sh
6
ก!าหนดู passwordให� user
•passwd login_name
#passwd –r files user1New Password:Re-enter new Password:Passwd: password successfully changed for user1
7
การยกเลุ่-ก user แบ่บ่ช้��ว้คืราว้
•passwd –l login_name•หลุ่�งจากยกเลุ่-กแลุ่�ว้ ถู�าต�องการใช้� user น�/
อ�กให�ใช้�คื!าส��ง passwd เพิ่��อก!าหนดู password ใหม�ให� user
#passwd –l user1passwd: password information changed for user1
8
การลุ่บ่ user แบ่บ่ถูาว้ร•userdel login_name
#userdel user1#grep user1 /etc/passwd#
9
Group•ข้�อม�ลุ่ข้องที่�ก group จะถู�กเก0บ่ไว้�ที่��
ไฟลุ่( /etc/group•สามารถูดู�ไดู�โดูยใช้�คื!าส��ง more /etc/group
#more /etc/grouproot::0:other::1:rootbin::2:root,daemonsys::3:root,bin,admadm::4:root,daemonuucp::5:rootmail::6:root…
10
การเพิ่-�ม group•groupadd group_name
#groupadd group1#grep group1 /etc/groupgroup1::1001:
11
การลุ่บ่ group•groupdel group_name
#groupdel group1#grep group1 /etc/group#
12
การเปลุ่��ยน group ให� user
•usermod –g group_name login_name
•user ใหม� จะถู�กจ�ดูให�ม� group เป1น other#grep group1 /etc/group
group1::1001:#usermod –g group1 user1#grep user1 /etc/passwduser1:x:1001:1001::/home/user1:/bin/sh
13
การลุ่บ่ group ให� user•ไม�ม�คื!าส��งเฉพิ่าะ•ลุ่บ่โดูยการแก�ไข้ไฟลุ่( /etc/group
14
การดู� user แลุ่ะ group ป3จจ�บ่�น
•id
#iduid=1001(user1) gid=1001(group1)
16
File and Directory Management
17
การดู�รายช้��อ file แลุ่ะ directory
•ls#cd /#lsDesktop export noautoshutdown usersDocuments home opt usrbin kernel platform varcdrom lib proc voldev lost+found sbin workspacedevices mnt systemetc net tmp#
18
การดู�รายลุ่ะเอ�ยดู file แลุ่ะ directory
•ls –l#ls -ltotal 606drwxr-xr-x 4 root root 512 Mar 20 2007 Desktopdrwxr-xr-x 2 root root 512 Mar 20 2007 Documentslrwxrwxrwx 1 root root 9 Oct 10 2006 bin -> ./usr/bindrwxr-xr-x 3 root root 512 Jun 10 15:37 cdromdrwxr-xr-x 248 root sys 4096 Apr 23 2007 devdrwxr-xr-x 2 root sys 512 Jun 10 15:36 devicesdrwxr-xr-x 85 root sys 4608 Jun 10 19:18 etc…
19
รายลุ่ะเอ�ยดูข้อง ls -l
• ระดู�บ่การเข้�าถู4งไฟลุ่(• ดู�ช้น�ข้องไฟลุ่(• user_name ข้องเจ�าข้องไฟลุ่(• group_name ข้องเจ�าข้องไฟลุ่(• ข้นาดูข้องไฟลุ่(• เว้ลุ่าแก�ไข้คืร�/งลุ่�าส�ดู• ช้��อไฟลุ่(
-rw-rw-r-- 1 user1 group1 0 Jun 11 12:55 test.txt
20
ระดู�บ่การเข้�าถู4ง file-rw-r--r--1 ประเภที่ข้องไฟลุ่( ( - = file, d = directory, l =
link)2-4 คืว้ามสามารถูข้องเจ�าข้องในการ อ�าน เข้�ยน ร�น
ตามลุ่!าดู�บ่5-7 คืว้ามสามารถูข้อง group ในการ อ�าน เข้�ยน ร�น
ตามลุ่!าดู�บ่8-10 คืว้ามสามารถูข้อง user ที่��ว้ไป ในการอ�าน เข้�ยน
ร�น ตามลุ่!าดู�บ่
21
การแก�ไข้ระดู�บ่การเข้�าถู4งไฟลุ่(
•chmod permission_level file_name
#ls –l test.txt-rw-r--r-- 1 user1 group1 0 Jun 11 12.55 test.txt#chmod g+w test.txt; ls -l-rw-rw-r-- 1 user1 group1 0 Jun 11 12:55 test.txt#chmod o+wx test.txt; ls –l-rw-rw-rwx 1 user1 group1 0 Jun 11 12:55 test.txt#chmod o-w test.txt; ls –l-rw-rw-rw- 1 user1 group1 0 Jun 11 12:55 test.txt
22
การ copy file•cp source_file destination_file
•cp source_file destination_directory
#touch test.txt#lstest.txt#cp test.txt copied_file.txt#lstest.txt copied_file.txt
23
การย�ายไฟลุ่(•mv source_file destination_file
•mv source_file destination_directory
#mkdir dir1#mv test.txt dir1#ls dir1test.txt
24
การลุ่บ่ไฟลุ่(•rm file_name•rm –r directory_name
#lstest.txt#rm test.txt#ls#
25
Process Management
26
Process•Process คื�อ งาน หร�อ
โปรแกรมต�างๆ ที่��ที่!างานอย��ในระบ่บ่
27
การแสดูง process ที่��ที่!างานอย��
•ps•แสดูง process ข้อง user
ป3จจ�บ่�นที่��ที่!างานอย��ในข้ณะน�/น#ps PID TTY TIME CMD 1303 pts/3 0:00 sh 1348 pts/3 0:00 ps
28
การแสดูง process ที่��ที่!างานอย��
•ps –ef•แสดูง process ที่�/งหมดูที่��
ที่!างานอย��ในข้ณะน�/น#ps –ef UID PID PPID C STIME TTY TIME CMD root 0 0 0 11:24:06 ? 0:10 sched root 1 0 0 11:24:06 ? 0:00 /sbin/init root 2 0 0 11:24:06 ? 0:00 pageout root 3 0 0 11:24:06 ? 0:13 fsflush…
29
ต�ว้อย�างผู้ลุ่ลุ่�พิ่ธ์(จาก ps -ef
•UID : user id•PID : process id•PPID : parent
process id•C : processor
utilization
UID PID PPID C STIME TTY TIME CMD root 0 0 0 12:18:38 ? 0:09 sched root 1 0 0 12:18:38 ? 0:00 /sbin/init root 2 0 0 12:18:38 ? 0:00 pageout
•STIME : start time
•TTY : terminal
•TIME : cpu time
•CMD : command
30
การตรว้จสอบ่ process ที่��สนใจ
•ps –ef | grep process_name
#ps –ef|grep inetd root 223 1 0 11:24:31 ? 0:01 /usr/lib/inetduser1 1349 1303 0 13:38:55 pts/3 0:00 grep inetd
31
การหย�ดู process•pkill -9 process_name
32
Monitor Server•vmstat
33
Virtual Directory for Web Application
34
Shell Script
35
Startup - Shutdown
36
การ shutdown•shutdown -y -i5 -g0•init 5•poweroff
37
การ restart• - - -6 0shutdown y i g•init 6•reboot
38
Backup and Recovery
39
การรว้มไฟลุ่(•tar cvf tar_file_name file_name
•tar cvf tar_file_name directory
#lstest.txt test2.txt#tar cvf test.tar test.txt test2.txt#lstest.txt test2.txt test.tar
40
การบ่�บ่อ�ดูไฟลุ่(•gzip file_name
#lstest.tar#gzip test.tar#lstest.tar.gz
41
การแตกไฟลุ่(ที่��บ่�บ่อ�ดู•gunzip file_name
#lstest.tar.gz#gunzip test.tar.gz#lstest.tar
42
การดู�ข้นาดูไฟลุ่(ก�อน backup
•ufsdump S file_to_dump
#iduid=1001(user1) gid=1001(group1)
43
การ backup file•ufsdump