ppid : 부모프로세스 id
swap memory : 메모리 부족하면 swap 영역으로 내려가서 다른 process 실행
top 커맨드 : 현재 process 및 system 정보를 실시간으로 보여줌
[root@station14 home]# top
top - 15:20:40 up 5:40, 3 users, load average: 0.08, 0.05, 0.05
Tasks: 238 total, 1 running, 237 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.4 us, 0.2 sy, 0.0 ni, 99.4 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
-- cpu 사용률 sy(커널,시스템) ni(nice value) id(idel) wa(waiting) hi(h/w interrupt를 하면서 소모된 cpu사용량) si (s/w interrupt를 하면서 소모된 cpu사용량)
interrupt가 높다는 것: cpu가 하던일을 멈추고 딴 일을 많이 한다.
KiB Mem : 16305016 total, 14298772 free, 1183132 used, 823112 buff/cache
KiB Swap: 524284 total, 524284 free, 0 used. 14621136 avail Mem
-- swap이 많이 사용된다 : 물리적 메모리가 부족하다.
메모리 부족 -> 프로그램 실행 못함.
swap 사용하기 위해 메모리에서 hdd swap 에 내려야하고, 나중엔 다시 올려야함.
=> 즉 빈번한 swap 읽고 쓰기는 시스템 성능을 저하시킴.
<아래 컬럼 의미>
PID프로세스번호
USER 유저
PR 우선순위(낮을수록 속도 빨라짐)
NI (nice value) -> PR값 에 영향
VIRT 물리적 메모리 + swap
RES 실제 프로세스가 사용하는 물리적 메모리
SHR 공유 메모리(shared memory)
%CPU cpu 사용량
TIME+ 실행되고나서 누적 cpu사용시간
<단축키>
shift + P : cpu많이 사용하는 순 정렬
shift + M : 물리적 메모리 많이 사용하는순 정렬
K : 특정 프로세스 종료하고자 할 때 pid 입력
shift + ? : 명령어들의 단축키
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2108 root 20 0 2356848 317392 86424 S 2.0 1.9 6:28.19 firefox
1246 root 20 0 464016 43724 33924 S 1.7 0.3 1:36.79 Xorg
2218 root 20 0 2393560 425356 64516 S 1.3 2.6 16:42.25 Web Content
1770 root 20 0 1803332 142320 38704 S 0.3 0.9 1:43.55 gnome-shell
2018 root 20 0 711340 21652 12788 S 0.3 0.1 0:27.63 gnome-terminal-
5699 root 20 0 159896 2384 1560 R 0.3 0.0 0:00.60 top
1 root 20 0 195816 6952 3976 S 0.0 0.0 0:02.16 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:00.07 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
7 root rt 0 0 0 0 S 0.0 0.0 0:00.01 migration/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
9 root 20 0 0 0 0 S 0.0 0.0 0:02.14 rcu_sched
10 root rt 0 0 0 0 S 0.0 0.0 0:00.05 watchdog/0
> /proc/cpuinfo == lscpu (cpu에 대한 정보)
[root@station14 /home]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 58
Model name: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
Stepping: 9
CPU MHz: 2385.976
BogoMIPS: 6784.77
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 8192K
NUMA node0 CPU(s): 0-7
> mpstat
[root@station14 /home]# mpstat
Linux 3.10.0-514.26.1.el7.x86_64 (station14.example.com) 04/12/2023 _x86_64_ (8 CPU)
03:52:32 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
03:52:32 PM all 0.93 0.00 0.16 0.05 0.00 0.00 0.00 0.00 0.00 98.86
> mpstat -P ALL 하면 너무 많음
[root@station14 /home]# mpstat -P ALL
Linux 3.10.0-514.26.1.el7.x86_64 (station14.example.com) 04/12/2023 _x86_64_ (8 CPU)
03:53:43 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
03:53:43 PM all 0.94 0.00 0.16 0.05 0.00 0.00 0.00 0.00 0.00 98.85
03:53:43 PM 0 1.18 0.00 0.22 0.06 0.00 0.00 0.00 0.00 0.00 98.53
03:53:43 PM 1 1.24 0.00 0.19 0.18 0.00 0.00 0.00 0.00 0.00 98.38
03:53:43 PM 2 1.22 0.00 0.19 0.03 0.00 0.00 0.00 0.00 0.00 98.56
03:53:43 PM 3 1.18 0.00 0.23 0.03 0.00 0.00 0.00 0.00 0.00 98.55
03:53:43 PM 4 0.73 0.00 0.10 0.02 0.00 0.00 0.00 0.00 0.00 99.14
03:53:43 PM 5 0.75 0.00 0.10 0.02 0.00 0.00 0.00 0.00 0.00 99.13
03:53:43 PM 6 0.50 0.00 0.15 0.03 0.00 0.00 0.00 0.00 0.00 99.31
03:53:43 PM 7 0.67 0.00 0.09 0.01 0.00 0.00 0.00 0.00 0.00 99.22
> 10초 간격으로 2번 mpstat를 실행
[root@station14 /home]# mpstat 10 2 -P ALL
Linux 3.10.0-514.26.1.el7.x86_64 (station14.example.com) 04/12/2023 _x86_64_ (8 CPU)
--첫번째는 부팅후 현재까지 누적치이므로 버리는값
03:54:43 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
03:54:53 PM all 4.20 0.05 0.55 0.04 0.00 0.00 0.00 0.00 0.00 95.16
03:54:53 PM 0 2.52 0.00 0.60 0.00 0.00 0.00 0.00 0.00 0.00 96.88
03:54:53 PM 1 2.70 0.20 0.50 0.10 0.00 0.00 0.00 0.00 0.00 96.50
03:54:53 PM 2 4.60 0.00 0.50 0.00 0.00 0.00 0.00 0.00 0.00 94.90
03:54:53 PM 3 6.22 0.00 0.80 0.10 0.00 0.00 0.00 0.00 0.00 92.88
03:54:53 PM 4 1.40 0.00 0.30 0.00 0.00 0.00 0.00 0.00 0.00 98.29
03:54:53 PM 5 14.01 0.00 0.80 0.00 0.00 0.00 0.00 0.00 0.00 85.19
03:54:53 PM 6 1.41 0.00 0.60 0.00 0.00 0.00 0.00 0.00 0.00 97.99
03:54:53 PM 7 0.80 0.30 0.30 0.00 0.00 0.00 0.00 0.00 0.00 98.60
03:54:53 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
03:55:03 PM all 6.86 0.05 0.95 0.05 0.00 0.00 0.00 0.00 0.00 92.09
03:55:03 PM 0 9.46 0.10 1.89 0.10 0.00 0.00 0.00 0.00 0.00 88.45
03:55:03 PM 1 7.82 0.00 0.70 0.20 0.00 0.00 0.00 0.00 0.00 91.27
03:55:03 PM 2 15.72 0.10 1.20 0.00 0.00 0.00 0.00 0.00 0.00 82.98
03:55:03 PM 3 6.39 0.00 1.10 0.10 0.00 0.00 0.00 0.00 0.00 92.41
03:55:03 PM 4 11.29 0.00 1.00 0.10 0.00 0.00 0.00 0.00 0.00 87.61
03:55:03 PM 5 1.30 0.10 0.30 0.00 0.00 0.00 0.00 0.00 0.00 98.30
03:55:03 PM 6 1.91 0.10 0.90 0.00 0.00 0.00 0.00 0.00 0.00 97.09
03:55:03 PM 7 1.00 0.20 0.40 0.00 0.00 0.00 0.00 0.00 0.00 98.40
Average: CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
Average: all 5.53 0.05 0.75 0.04 0.00 0.00 0.00 0.00 0.00 93.63
Average: 0 6.01 0.05 1.25 0.05 0.00 0.00 0.00 0.00 0.00 92.64
Average: 1 5.26 0.10 0.60 0.15 0.00 0.00 0.00 0.00 0.00 93.89
Average: 2 10.16 0.05 0.85 0.00 0.00 0.00 0.00 0.00 0.00 88.94
Average: 3 6.31 0.00 0.95 0.10 0.00 0.00 0.00 0.00 0.00 92.64
Average: 4 6.36 0.00 0.65 0.05 0.00 0.00 0.00 0.00 0.00 92.94
Average: 5 7.66 0.05 0.55 0.00 0.00 0.00 0.00 0.00 0.00 91.74
Average: 6 1.66 0.05 0.75 0.00 0.00 0.00 0.00 0.00 0.00 97.54
Average: 7 0.90 0.25 0.35 0.00 0.00 0.00 0.00 0.00 0.00 98.50
[root@station14 /home]# free -h
total used free shared buff/cache available
Mem: 15G 1.6G 13G 250M 944M 13G
Swap: 511M 0B 511M
[root@station14 /home]# cat /proc/meminfo
MemTotal: 16305016 kB
MemFree: 13722620 kB
MemAvailable: 14102220 kB
Buffers: 1008 kB
Cached: 839104 kB
SwapCached: 0 kB
Active: 1593648 kB
Inactive: 693744 kB
Active(anon): 1451108 kB
Inactive(anon): 229928 kB
Active(file): 142540 kB
Inactive(file): 463816 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 524284 kB
SwapFree: 524284 kB
Dirty: 1052 kB
Writeback: 0 kB
AnonPages: 1447180 kB
Mapped: 264116 kB
Shmem: 233756 kB
Slab: 104316 kB
SReclaimable: 49968 kB
SUnreclaim: 54348 kB
KernelStack: 8240 kB
PageTables: 27792 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 8676792 kB
Committed_AS: 4917936 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 376780 kB
VmallocChunk: 34358947836 kB
HardwareCorrupted: 0 kB
AnonHugePages: 264192 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 124240 kB
DirectMap2M: 16525312 kB
[root@station14 /home]# cat /proc/swaps
Filename Type Size Used Priority
/dev/dm-1 partition 524284 0 -1
특정 프로그램 뒤에 & 붙이면 background process로 실행
> sleep -> foreground
> fg: background process -> foreground process
bg: foreground process -> background process
jobs : job id 확인
> ctrl + z: running중인 프로그램 일시 정지
[root@station14 /home]# sleep 30
[root@station14 /home]# sleep 3000 &
[1] 6224
[root@station14 /home]# ps
PID TTY TIME CMD
5384 pts/1 00:00:00 bash
5996 pts/1 00:00:00 csh
6224 pts/1 00:00:00 sleep
6225 pts/1 00:00:00 ps
[root@station14 /home]# jobs
[1] + Running sleep 3000
[root@station14 /home]# fg %1
sleep 3000 -- foreground 명령어가 실행 중이라 다른 커맨함(jobs) 입력못함
^Z
Suspended
[root@station14 /home]# ps
PID TTY TIME CMD
5384 pts/1 00:00:00 bash
5996 pts/1 00:00:00 csh
6224 pts/1 00:00:00 sleep -- 아직 메모리에 있는데 cpu에 접근 안되는걸 알 수 있다.
6270 pts/1 00:00:00 ps
[root@station14 /home]# jobs
[1] + Suspended sleep 3000 --[1]: job id
[root@station14 /home]# bg %1 -- background로 전환
[1] sleep 3000 &
[root@station14 /home]# jobs
[1] Running sleep 3000 -- 다시 running이 된 모습
ctrl + z ( or ctrl + c) 입력 > 일시정지
[root@station14 /home]# jobs
[1] Running sleep 3000 -- 정지 안되는 모습 (백그라운드이므로)
> signal 정지 확인
[root@station14 ~]$ kill -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR
31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3
38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8
43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7
58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2
63) SIGRTMAX-1 64) SIGRTMAX
> ps를 통해 pid확인
[root@station14 ~]# ps
PID TTY TIME CMD
5384 pts/1 00:00:00 bash
5996 pts/1 00:00:00 csh
6224 pts/1 00:00:00 sleep
6301 pts/1 00:00:00 ps
[root@station14 ~]# kill -19 6224
[1] + Suspended (signal) sleep 3000
> killall 사용시 pid 몰라도됨.
[root@station14 ~]# yum -y install httpd
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00:00
classRPMs | 2.5 kB 00:00:00
errataRPMs | 2.5 kB 00:00:00
mysql-connectors-community | 2.6 kB 00:00:00
mysql-tools-community | 2.6 kB 00:00:00
mysql80-community | 2.6 kB 00:00:00
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-45.el7.centos.4 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-45.el7.centos.4 for package: httpd-2.4.6-45.el7.centos.4.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-45.el7.centos.4.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-45.el7.centos.4.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-45.el7.centos.4 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================
Package Arch Version Repository Size
========================================================================================================
Installing:
httpd x86_64 2.4.6-45.el7.centos.4 base 2.7 M
Installing for dependencies:
apr x86_64 1.4.8-3.el7 base 103 k
apr-util x86_64 1.5.2-6.el7 base 92 k
httpd-tools x86_64 2.4.6-45.el7.centos.4 base 84 k
Transaction Summary
========================================================================================================
Install 1 Package (+3 Dependent packages)
Total download size: 3.0 M
Installed size: 9.9 M
Downloading packages:
--------------------------------------------------------------------------------------------------------
Total 10 MB/s | 3.0 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : apr-1.4.8-3.el7.x86_64 1/4
Installing : apr-util-1.5.2-6.el7.x86_64 2/4
Installing : httpd-tools-2.4.6-45.el7.centos.4.x86_64 3/4
Installing : httpd-2.4.6-45.el7.centos.4.x86_64 4/4
Verifying : httpd-tools-2.4.6-45.el7.centos.4.x86_64 1/4
Verifying : apr-1.4.8-3.el7.x86_64 2/4
Verifying : httpd-2.4.6-45.el7.centos.4.x86_64 3/4
Verifying : apr-util-1.5.2-6.el7.x86_64 4/4
Installed:
httpd.x86_64 0:2.4.6-45.el7.centos.4
Dependency Installed:
apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-45.el7.centos.4
[root@station14 ~]# systemctl start httpd
> 안보임
ps -f[root@station14 ~]# ps -f
UID PID PPID C STIME TTY TIME CMD
root 5384 2018 0 14:29 pts/1 00:00:00 bash
root 5996 5384 0 15:49 pts/1 00:00:00 -sh
root 6224 5996 0 16:09 pts/1 00:00:00 sleep 3000
root 6558 5996 0 16:41 pts/1 00:00:00 ps -f
[root@station14 ~]# ps -ef | grep httpd
root 6552 1 0 16:41 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 6553 6552 0 16:41 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 6554 6552 0 16:41 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 6555 6552 0 16:41 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 6556 6552 0 16:41 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 6557 6552 0 16:41 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 6591 5996 0 16:44 pts/1 00:00:00 grep --color=auto httpd
> killall 명령어 실행 (이름으로 kill)
[root@station14 ~]# killall httpd
[root@station14 ~]# ps -ef | grep httpd
root 6643 5996 0 16:47 pts/1 00:00:00 grep --color=auto httpd
[root@station14 ~]# systemctl start httpd --다시 재실행
[root@station14 ~]# ps -ef | grep httpd
root 6651 1 0 16:47 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 6652 6651 0 16:47 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 6653 6651 0 16:47 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 6654 6651 0 16:47 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 6655 6651 0 16:47 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache
> ND로 끝나는 것들 확인
[root@station14 ~]# ps -ef | grep ND$
root 6651 1 0 16:47 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 6652 6651 0 16:47 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 6653 6651 0 16:47 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 6654 6651 0 16:47 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 6655 6651 0 16:47 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 6656 6651 0 16:47 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
[root@station14 ~]# pkill pd[root@station14 ~]# pkill ND$
> guru user로 sleep 실행
[guru@station14 ~]$ sleep 4000 &
[2] 6749
[guru@station14 ~]$ exit
logout
There are stopped jobs.
[guru@station14 ~]$ pgrep sleep
6224
6749
[guru@station14 ~]$ ps -ef | grep sleep
root 6224 5996 0 16:09 pts/1 00:00:00 sleep 3000
guru 6748 6703 0 16:52 pts/1 00:00:00 sleep 4000
guru 6749 6703 0 16:52 pts/1 00:00:00 sleep 4000
guru 6761 6703 0 16:53 pts/1 00:00:00 grep --color=auto sleep
[guru@station14 ~]$ ps -ef | grep sleep
root 6224 5996 0 16:09 pts/1 00:00:00 sleep 3000
guru 6749 6703 0 16:52 pts/1 00:00:00 sleep 4000
guru 6764 6703 0 16:53 pts/1 00:00:00 grep --color=auto sleep
[guru@station14 ~]$ pgrep sleep
6224
6749
[guru@station14 ~]$ ps -ef | grep guru
root 5340 2025 0 14:28 pts/0 00:00:00 su - guru
guru 5341 5340 0 14:28 pts/0 00:00:00 -bash
root 6702 5996 0 16:51 pts/1 00:00:00 su - guru
guru 6703 6702 0 16:51 pts/1 00:00:00 -bash
guru 6749 6703 0 16:52 pts/1 00:00:00 sleep 4000
guru 6768 6703 0 16:54 pts/1 00:00:00 ps -ef
guru 6769 6703 0 16:54 pts/1 00:00:00 grep --color=auto guru
[guru@station14 ~]$ pkill -u guru
[2]+ Terminated sleep 4000
[guru@station14 ~]$ ps -ef | grep guru
root 5340 2025 0 14:28 pts/0 00:00:00 su - guru
guru 5341 5340 0 14:28 pts/0 00:00:00 -bash
root 6702 5996 0 16:51 pts/1 00:00:00 su - guru
guru 6703 6702 0 16:51 pts/1 00:00:00 -bash
guru 6816 6703 0 16:55 pts/1 00:00:00 ps -ef
guru 6817 6703 0 16:55 pts/1 00:00:00 grep --color=auto guru
[guru@station14 ~]$ sleep 100 &
[1] 6928
[guru@station14 ~]$ ps -f
UID PID PPID C STIME TTY TIME CMD
guru 6703 6702 0 16:51 pts/1 00:00:00 -bash
guru 6928 6703 0 17:03 pts/1 00:00:00 sleep 100
guru 6929 6703 0 17:03 pts/1 00:00:00 ps -f
[guru@station14 ~]$ ps -l -- 자세히 확인( nice value가 0)
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
4 S 1000 6703 6702 0 80 0 - 29521 wait pts/1 00:00:00 bash
0 S 1000 6928 6703 0 80 0 - 27485 hrtime pts/1 00:00:00 sleep
0 R 1000 6930 6703 0 80 0 - 37744 - pts/1 00:00:00 ps
[guru@station14 ~]$ killall sleep
sleep(6224): Operation not permitted
[1]+ Terminated sleep 100
[guru@station14 ~]$ nice -n 5 sleep 1000 & -- nice 값 5 만큼 올려서 sleep 1000을 background로 실행 (-> 속도도 5만큼 느려짐)
[1] 6939
.[guru@station14 ~]$ ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
4 S 1000 6703 6702 0 80 0 - 29521 wait pts/1 00:00:00 bash
0 S 1000 6939 6703 0 85 5 - 27485 hrtime pts/1 00:00:00 sleep
0 R 1000 6945 6703 0 80 0 - 37744 - pts/1 00:00:00 ps
[guru@station14 ~]$ renice -n -3 6939 -- nice값 3만큼 내림
> visitor에서 실행해보기
[root@station14 ~]# su - visitor
Last login: Mon Apr 10 10:54:08 KST 2023 on tty5
[visitor@station14 ~]$ ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
4 S 1001 7025 7024 0 80 0 - 29521 wait pts/1 00:00:00 bash
0 R 1001 7062 7025 0 80 0 - 37744 - pts/1 00:00:00 ps
[visitor@station14 ~]$ nice -n -5 sleep 300 &
[1] 7063
[visitor@station14 ~]$ nice: cannot set niceness: Permission denied
^C
[visitor@station14 ~]$ ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
4 S 1001 7025 7024 0 80 0 - 29521 wait pts/1 00:00:00 bash
0 S 1001 7063 7025 0 80 0 - 27485 hrtime pts/1 00:00:00 sleep
0 R 1001 7072 7025 0 80 0 - 37744 - pts/1 00:00:00 ps
[visitor@station14 ~]$ renice -n 7 7063
7063 (process ID) old priority 0, new priority 7
[visitor@station14 ~]$ ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
4 S 1001 7025 7024 0 80 0 - 29521 wait pts/1 00:00:00 bash
0 S 1001 7063 7025 0 87 7 - 27485 hrtime pts/1 00:00:00 sleep
0 R 1001 7075 7025 0 80 0 - 37744 - pts/1 00:00:00 ps
> priority가 올라가면 그만큼 속도가 느려짐.
일반 유저에서는 nice 한번 올린 값은 절대로 밑으로 못내림 (즉 일방통행, 같은 양수임에도 내려가는거 못함.)
따라서 root 에서만 실행한다.
nice -> 특정 process가 cpu를 너무 많이 사용할때, nice값을 올려서 priority값을 올리고 cpu의 접근을 막아서 다른 process를 처리하도록 할 때 사용한다.
[root@station14 ~]# su -c "yum install -y xterm"
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package xterm.x86_64 0:295-3.el7 will be installed
--> Processing Dependency: libXaw.so.7()(64bit) for package: xterm-295-3.el7.x86_64
--> Running transaction check
---> Package libXaw.x86_64 0:1.0.12-5.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================
Package Arch Version Repository Size
========================================================================================================
Installing:
xterm x86_64 295-3.el7 base 455 k
Installing for dependencies:
libXaw x86_64 1.0.12-5.el7 base 190 k
Transaction Summary
========================================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 645 k
Installed size: 1.7 M
Downloading packages:
--------------------------------------------------------------------------------------------------------
Total 4.3 MB/s | 645 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libXaw-1.0.12-5.el7.x86_64 1/2
Installing : xterm-295-3.el7.x86_64 2/2
Verifying : libXaw-1.0.12-5.el7.x86_64 1/2
Verifying : xterm-295-3.el7.x86_64 2/2
Installed:
xterm.x86_64 0:295-3.el7
Dependency Installed:
libXaw.x86_64 0:1.0.12-5.el7
Complete!
[root@station14 ~]# man bash
[root@station14 ~]# jobs -l
[root@station14 ~]# man bash
[root@station14 ~]# man bash
[1]+ Stopped man bash
[root@station14 ~]# jobs -l
[1]+ 7192 Stopped man bash
[root@station14 ~]# vim /etc/fstab
[2]+ Stopped vim /etc/fstab
[root@station14 ~]# vim /etc/pam.d/ &
[3] 7238
[root@station14 ~]# nautilus &
[4] 7240
[3]+ Stopped vim /etc/pam.d/
[root@station14 ~]#
(nautilus:7240): Gtk-WARNING **: cannot open display:
[4] Exit 1 nautilus
[root@station14 ~]# gedit &
[4] 7244
[root@station14 ~]#
(gedit:7244): Gtk-WARNING **: cannot open display:
[4] Exit 1 gedit
[root@station14 ~]# xterm &
[4] 7248
[root@station14 ~]# Warning: This program is an suid-root program or is being run by the root user.
The full text of the error or warning message cannot be safely formatted
in this environment. You may get a more descriptive message by running the
program as a non-root user or by removing the suid bit on the executable.
xterm: Xt error: Can't open display: %s
xterm: DISPLAY is not set
[4] Exit 1 xterm
[root@station14 ~]# jobs -l
[1] 7192 Stopped man bash
[2]- 7228 Stopped vim /etc/fstab
[3]+ 7238 Stopped (tty output) vim /etc/pam.d/
[root@station14 ~]# nautilus &
[4] 7249
[root@station14 ~]#
(nautilus:7249): Gtk-WARNING **: cannot open display:
^C
[4] Exit 1 nautilus
[root@station14 ~]# gedit &
[4] 7251
[root@station14 ~]#
(gedit:7251): Gtk-WARNING **: cannot open display:
^C
[4] Exit 1 gedit
[root@station14 ~]# xterm &
[4] 7255
[root@station14 ~]# Warning: This program is an suid-root program or is being run by the root user.
The full text of the error or warning message cannot be safely formatted
in this environment. You may get a more descriptive message by running the
program as a non-root user or by removing the suid bit on the executable.
xterm: Xt error: Can't open display: %s
xterm: DISPLAY is not set
[4] Exit 1 xterm
[root@station14 ~]# jobs -l
[1] 7192 Stopped man bash
[2]- 7228 Stopped vim /etc/fstab
[3]+ 7238 Stopped (tty output) vim /etc/pam.d/
[root@station14 ~]# ps f t
PID TTY STAT TIME COMMAND
5384 pts/1 Ss 0:00 bash
5996 pts/1 S 0:00 \_ -sh
6224 pts/1 T 0:00 \_ sleep 3000
6702 pts/1 S 0:00 \_ su - guru
6703 pts/1 S 0:00 \_ -bash
6939 pts/1 SN 0:00 \_ sleep 1000
6975 pts/1 S 0:00 \_ su -
6979 pts/1 S 0:00 \_ -bash
7024 pts/1 S 0:00 \_ su - visitor
7025 pts/1 S 0:00 \_ -bash
7096 pts/1 S 0:00 \_ su -
7100 pts/1 S 0:00 \_ -bash
7192 pts/1 T 0:00 \_ man bash
7203 pts/1 T 0:00 | \_ less -s
7228 pts/1 T 0:00 \_ vim /etc/fstab
7238 pts/1 T 0:00 \_ vim /etc/pam.d/
7257 pts/1 R+ 0:00 \_ ps f t
[root@station14 ~]# ps --ppid $$
PID TTY TIME CMD
7192 pts/1 00:00:00 man
7228 pts/1 00:00:00 vim
7238 pts/1 00:00:00 vim
7259 pts/1 00:00:00 ps
[root@station14 ~]# pstree
systemd─┬─NetworkManager─┬─dhclient
│ └─2*[{NetworkManager}]
├─2*[abrt-watch-log]
├─abrtd
├─accounts-daemon───2*[{accounts-daemon}]
├─acpid
├─at-spi-bus-laun─┬─dbus-daemon───{dbus-daemon}
│ └─3*[{at-spi-bus-laun}]
├─at-spi2-registr───2*[{at-spi2-registr}]
├─atd
├─auditd───{auditd}
├─automount───4*[{automount}]
├─avahi-daemon───avahi-daemon
├─caribou───2*[{caribou}]
├─chronyd
├─colord───2*[{colord}]
├─crond
├─cupsd
├─2*[dbus-daemon───{dbus-daemon}]
├─dbus-launch
├─evolution-calen───5*[{evolution-calen}]
├─evolution-sourc───2*[{evolution-sourc}]
├─gconfd-2
├─gdm─┬─Xorg───3*[{Xorg}]
│ ├─gdm-session-wor─┬─gnome-session─┬─abrt-applet───2*[{abrt-applet}]
│ │ │ ├─gnome-settings-───4*[{gnome-settings-}]
│ │ │ ├─gnome-shell─┬─firefox─┬─Web Content───37*[{Web Conten+
│ │ │ │ │ └─59*[{firefox}]
│ │ │ │ ├─ibus-daemon─┬─ibus-dconf───3*[{ibus-dco+
│ │ │ │ │ ├─ibus-engine-han───2*[{ibu+
│ │ │ │ │ └─2*[{ibus-daemon}]
│ │ │ │ ├─oosplash─┬─soffice.bin───6*[{soffice.bi+
│ │ │ │ │ └─2*[{oosplash}]
│ │ │ │ └─6*[{gnome-shell}]
│ │ │ ├─gnome-software───3*[{gnome-software}]
│ │ │ ├─nautilus───3*[{nautilus}]
│ │ │ ├─seapplet
│ │ │ ├─ssh-agent
│ │ │ ├─tracker-extract───13*[{tracker-extract}]
│ │ │ ├─tracker-miner-a───2*[{tracker-miner-a}]
│ │ │ ├─tracker-miner-f───3*[{tracker-miner-f}]
│ │ │ ├─tracker-miner-u───2*[{tracker-miner-u}]
│ │ │ └─3*[{gnome-session}]
│ │ └─2*[{gdm-session-wor}]
│ └─3*[{gdm}]
├─gnome-keyring-d───4*[{gnome-keyring-d}]
├─gnome-shell-cal───5*[{gnome-shell-cal}]
├─gnome-terminal-─┬─bash───su───bash
│ ├─bash───csh─┬─sleep
│ │ └─su───bash─┬─sleep
│ │ └─su───bash───su───bash───su───bash─┬─man───less
│ │ ├─pstree
│ │ └─2*[vim]
│ ├─gnome-pty-helpe
│ └─3*[{gnome-terminal-}]
├─goa-daemon───3*[{goa-daemon}]
├─goa-identity-se───3*[{goa-identity-se}]
├─gpm
├─gsd-printer───2*[{gsd-printer}]
├─gssproxy───5*[{gssproxy}]
├─gvfs-afc-volume───3*[{gvfs-afc-volume}]
├─gvfs-goa-volume───2*[{gvfs-goa-volume}]
├─gvfs-gphoto2-vo───2*[{gvfs-gphoto2-vo}]
├─gvfs-mtp-volume───2*[{gvfs-mtp-volume}]
├─gvfs-udisks2-vo───2*[{gvfs-udisks2-vo}]
├─gvfsd───2*[{gvfsd}]
├─gvfsd-fuse───5*[{gvfsd-fuse}]
├─gvfsd-trash───2*[{gvfsd-trash}]
├─ibus-x11───2*[{ibus-x11}]
├─irqbalance
├─lsmd
├─lvmetad
├─master─┬─pickup
│ └─qmgr
├─mcelog
├─mission-control───3*[{mission-control}]
├─packagekitd───2*[{packagekitd}]
├─polkitd───5*[{polkitd}]
├─rngd
├─rsyslogd───2*[{rsyslogd}]
├─rtkit-daemon───2*[{rtkit-daemon}]
├─smartd
├─sshd
├─systemd-journal
├─systemd-logind
├─systemd-udevd
├─tracker-store───7*[{tracker-store}]
├─tuned───4*[{tuned}]
├─udisksd───4*[{udisksd}]
├─upowerd───2*[{upowerd}]
├─wpa_supplicant
└─xinetd
[root@station14 ~]# fg
vim /etc/pam.d/
[3]+ Stopped vim /etc/pam.d/
[root@station14 ~]# fg 1
man bash
[1]+ Stopped man bash
[root@station14 ~]# find / > output.txt 2 > errors.txt &
[4] 7262
[root@station14 ~]# jobs
[1]+ Stopped man bash
[2] Stopped vim /etc/fstab
[3]- Stopped vim /etc/pam.d/
[4] Running find / 2 > output.txt > errors.txt &
[root@station14 ~]# find: ‘/net/server1/export/home/dsuser1’: Permission denied
find: ‘/net/server1/export/home/dsuser2’: Permission denied
find: ‘/net/server1/export/home/dsuser3’: Permission denied
find: ‘/net/server1/export/home/dsuser4’: Permission denied
find: ‘/net/server1/export/home/dsuser5’: Permission denied
find: ‘/net/server1/export/home/dsuser6’: Permission denied
find: ‘/net/server1/export/home/dsuser7’: Permission denied
find: ‘/net/server1/export/home/dsuser8’: Permission denied
find: ‘/net/server1/export/home/dsuser9’: Permission denied
find: ‘/net/server1/export/home/dsuser10’: Permission denied
find: ‘/net/server1/export/home/dsuser11’: Permission denied
find: ‘/net/server1/export/home/dsuser12’: Permission denied
find: ‘/net/server1/export/home/dsuser13’: Permission denied
find: ‘/net/server1/export/home/dsuser14’: Permission denied
find: ‘/net/server1/export/home/dsuser15’: Permission denied
find: ‘/net/server1/export/home/dsuser16’: Permission denied
find: ‘/net/server1/export/home/dsuser17’: Permission denied
find: ‘/net/server1/export/home/dsuser18’: Permission denied
find: ‘/net/server1/export/home/dsuser19’: Permission denied
find: ‘/net/server1/export/home/dsuser20’: Permission denied
find: ‘/net/server1/export/home/dsuser21’: Permission denied
find: ‘/net/server1/export/home/dsuser22’: Permission denied
find: ‘/net/server1/export/home/dsuser23’: Permission denied
find: ‘/net/server1/export/home/dsuser24’: Permission denied
find: ‘/net/server1/export/home/dsuser25’: Permission denied
find: ‘/net/server1/export/home/dsuser26’: Permission denied
find: ‘/net/server1/export/home/dsuser27’: Permission denied
find: ‘/net/server1/export/home/dsuser28’: Permission denied
find: ‘/net/server1/export/home/dsuser29’: Permission denied
find: ‘/net/server1/export/home/dsuser30’: Permission denied
find: ‘2’: No such file or directory
[4] Exit 1 find / 2 > output.txt > errors.txt
[root@station14 ~]# tail -f output.txt
^Z
[4]+ Stopped tail -f output.txt
[root@station14 ~]# jobs
[1]- Stopped man bash
[2] Stopped vim /etc/fstab
[3] Stopped vim /etc/pam.d/
[4]+ Stopped tail -f output.txt
[root@station14 ~]# find / &> stderrandstdout.txt
^Z
[5]+ Stopped find / &>stderrandstdout.txt
[root@station14 ~]# jobs
[1] Stopped man bash
[2] Stopped vim /etc/fstab
[3] Stopped vim /etc/pam.d/
[4]- Stopped tail -f output.txt
[5]+ Stopped find / &>stderrandstdout.txt
[root@station14 ~]# bg
[5]+ find / &>stderrandstdout.txt &
[root@station14 ~]# jobs -l
[1] 7192 Stopped man bash
[2] 7228 Stopped vim /etc/fstab
[3]- 7238 Stopped vim /etc/pam.d/
[4]+ 7294 Stopped tail -f output.txt
[5] 7303 Exit 1 find / &>stderrandstdout.txt
[root@station14 ~]# fg %2
vim /etc/fstab
[root@station14 ~]# fg %3
vim /etc/pam.d/
[root@station14 ~]# kill %man
[root@station14 ~]# jobs -l
[1]- 7192 Terminated man bash
[4]+ 7294 Stopped tail -f output.txt
[root@station14 ~]# kill %{4..6}
-bash: kill: %5: no such job
-bash: kill: %6: no such job
[4]+ Terminated tail -f output.txt
[root@station14 ~]# pkill file-roller
[root@station14 ~]# ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
4 S 0 5384 2018 0 80 0 - 29551 wait pts/1 00:00:00 bash
0 S 0 5996 5384 0 80 0 - 30385 sigsus pts/1 00:00:00 csh
0 T 0 6224 5996 0 80 0 - 27485 signal pts/1 00:00:00 sleep
4 S 0 6702 5996 0 80 0 - 47951 wait pts/1 00:00:00 su
4 S 0 6975 6703 0 80 0 - 47939 wait pts/1 00:00:00 su
4 S 0 6979 6975 0 80 0 - 29520 wait pts/1 00:00:00 bash
4 S 0 7024 6979 0 80 0 - 47951 wait pts/1 00:00:00 su
4 S 0 7096 7025 0 80 0 - 47939 wait pts/1 00:00:00 su
4 S 0 7100 7096 0 80 0 - 29553 wait pts/1 00:00:00 bash
0 R 0 7310 7100 0 80 0 - 37744 - pts/1 00:00:00 ps