Operating System/Solaris2007/07/22 20:41

5장. Accounting & Permission

5.1 User Accounts(command line에서)

2.x에서 의 user accounts

#groupadd -g 100 dct
#cat /etc/group

dct::100:

#useradd -u 115 -g 100 -c "hong seong-chan" -d /user/hong -m -s /bin/csh hong
; UID 115, GID 100의 hong seong chan이라는 사람의 계정을 만드는데, 그 유저의 Home Directory는 /user/hong(-d /user/hong)으로 생성(-m) 하고, 그 User가 사용하는 Shell은 C-shell(-s /bin/csh)이고, login명은 hong일 것이다.

1) passwd file 보면

hong:x:115:100:hong seong chan:/user/hong:/bin/csh

2)shadow file 보면

hong:*LK*:::::::

#passwd hong ---> User "hong"의 패스워드를 지정해준다.

4.1.3에서 의 user accounts

#vi /etc/passwd
추가: std99::999:20:student99:/home/std99:/bin/csh userID (8자 이하 소문자): password: UID: GID: full_name: home_dir:shell

#mkdir /home/std99; std99에 대한 Home Directory 작성
#cp .cshrc /home/std99 ; 다른 User의 .cshrc File을 복사하는 것이 유리.
#ls -alg
#chown std99 /home/std99
#chgrp 20 /home/std99
#passwd std99 ; root가 유저의 pass를 부여한다.

소유권 변경 (Super User 권한에서)

#ls -al /user

drwxr-xr-x kim dct 512 10월 6일 13:01 kim
drwxr-xr-x root other 512 10월 6일 12:55 kim2

#chown -f kim2 kim2
#chgrp -f dct kim2
#ls -al /user

drwxr-xr-x kim dct 512 10월 6일 13:01 kim
drwxr-xr-x kim2 dct 512 10월 6일 12:55 kim2

특정 User에게 Permission 제한 할 때

/usr/bin/getfacl --> Access Control List (ACL) 볼 때

#getfacl * --> 모든 파일 확인

/usr/bin/setfacl --> ACL 수정 및 추가

#setfacl -s ..... man_page 확인

* /tmp 는 일반 File System이 아니기 때문에 Permission 변경이 안됨.

5.2 BSD Accounting Utilities

- accounting system은 account command를 enable함으로서 가능하며

/etc/rc file에 다음을 comment out
/usr/lib/acct/accton /usr/adm/acct OR
/usr/lib/acct/startup

- /usr/acct가 있는 File System이 95%이하이면 accounting을 하고 95%가 넘으면 자동적으로 accounting을 stop 한다
- SunOS에서는 kernel에서 SYSACCT configuration option이 포함되어 있어야 한다
- sa command로 report할수 있으며 sa -s 로 /usr/adm/acct의 내용을 compress하고 savacct file로 merge시킨다


/usr/etc/sa

% sa

1027 18063.15re 17.11cp 4078avio 4696k
16 1537.32re 6.22cp 1057avio 6258k cmdtool
14 12.79re 3.14cp 265300avio 6377k cp
7 17.18re 1.47cp 618avio 5902k suntetri
51 5.47re 0.69cp 1avio 4373k rm
6 481.65re 0.63cp 0avio 586k update*
37 99.61re 0.56cp 276avio 3443k vi

- leftmost : Total number of times the command was execute
- re : Total real time spent excuting the command
- cp : Total CPU time ,, ,, ,,
- avio : Average number of I/O operations per invocation of the command
- k : Average physical memory usage, in Kbytes

관련 FILE

- /var/adm/pacct raw accounting
- /var/adm/savacct summary by command
- /var/adm/usracct summary by user ID

A Script to Collect Accounting Data

#!/bin/sh

filename=`date | awk '{print $2 $3 $6}' -`
sa=/usr/etc/sa
recorddir=/usr/adm/localacct

if [ ! -d $recorddir ]

then

mkdir $recorddir

fi

pathname=$recorddir/$filename
date > $pathname
echo "Day's Activity (command summary)" >> $pathname
$sa -i >> $pathname
echo "Total activity (command summary)" >> $pathname
$sa >> $pathname

# this time, also compress reports into savacct

echo "Per-user activity" >> $pathname
$sa -ms >> $pathname
Day-to-Day Management

- /usr/lib/acct/runacct

Generates a set of five daily reports
/usr/adm/acct/sum directory내에 rprtmmdd형의 file로 보관되 mm은 월, dd는 일을 나타냄

- /usr/lib/acct/dodisk

Gathers disk usage statistics, which are summarized by runacct

- /usr/lib/acct/ckpacct

System에 free block이 500 이하일 경우 main accounting file
(/usr/adm/acct/pacct)이 계속 증가못하게 함

- /usr/lib/acct/monacct

Convert all daily reports into a monthly report
/usr/adm/acct/fiscal directory내에 fiscrptnn의 file name으로 저장

- /usr/lib/acct/prdaily

Get the accounting statistics for the current date and repoprt

- /usr/lib/acct/shutacct

To disable accounting cleanly, execute the shell script ~/shutacct

Accounting Reports & Management

- login name별, application별 Accounting과 last login을 report

% /usr/lib/acct/prdaily mmdd (예, 0908)

- CPU(MINS) : total cpu time
- KCORE-MINS : 분당 사용되는 physical memory
- CONNECT : The total amount of time the user was logged in
- DISK BLOCKS: ,, ,, disk storage that the user is occupying
- #OF PROC : ,, ,, processes the user executed
- #OF SESS : The number of times the user logged in during the day
- NUMBER CMDS : report된 기간동안 수행된 횟수
- TOTAL KCOREMIN : 이 program에 의해 사용된 physical memory(KByte)
- TOTAL CPU : 이 program에 의해 사용된 total cpu time
- TOTAL REAL : 이 program이 invoke된후 경과된 시간의 합
- MEAN SIZE : 이 program에 의해 사용된 평균 memory의 량
- MEAN CPU : 이 program이 실행하는데 소요된 평균CPU time(분)
- HOG FACTOR : program의 CPU효율로 total CPU time을 total 수행시간 (TOTAL REAL)으로 나눈 값
- CHARS TRANSFD : 이 program에 의해 transfer된 total character 수
- BLOCKS READ : 이 command에 의해 read/write된 disk blocks

# generate daily accounting reports (1 a.m)

0 1 * * * /usr/lib/acct/runacct

# update disk usage statistics weekly (2 a.m. Monday)

0 2 * * 1 /usr/lib/acct/dodisk

# manage accounting file size hourly (on the half-hour)

30 * * * * /usr/lib/acct/ckpacct

# generate monthly summaries (2 a.m. on the 1st of the month)

0 2 1 * * /usr/lib/acct/monacct

Creative Commons License
Posted by BLUEDAY™