1. Trang chủ
  2. » Luận Văn - Báo Cáo

Lab report lesson 1

16 0 0
Tài liệu được quét OCR, nội dung có thể không chính xác
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Lab Report Lesson 1
Tác giả Liờu Thành Lõm
Người hướng dẫn Vừ Cụng Minh
Trường học Trường Đại Học Cống Nghiệp Tp Hề Chí Minh
Chuyên ngành Cụng Nghệ Điện Tử
Thể loại lab report
Năm xuất bản 2022
Thành phố Tp Hề Chí Minh
Định dạng
Số trang 16
Dung lượng 12,46 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Sử dụng lệnh ps để xem thông tin về các tiến trình a... Mé mét terminal mdi tty2, login vao bang tài khoản userl.. Mở một terminal mới tty3, login vao bang tài khoản user2... cea root@li

Trang 1

NH0 nọ công nrươnG

TRƯỜNG ĐẠI HỌC CÔNG NGHIỆP TP HÒ CHÍ MINH

Khoa: Công Nghệ Thông Tin

qS\TY 0E

4® OF 45

VỆ a

ớ, 4,

LAB REPORT

LESSON 1:

StudentsName : Liêu Thành Lâm

Student ID > 21030951

Subject :Hệ thông máy tính

Instructor :Võ Công Minh

Faculty :Công Nghệ Điện Tử

Completed Date :23/9/2022

Trang 2

NHẬN XÉT CỦA GIÁO VIÊN HƯỚNG DÂN

Điểm lab report:

Trang 3

PHẢN BÀI LÀM THỰC HÀNH (SV chụp màn hình thực hành các bước của các yêu cầu và giải thích các hình ảnh)

LAB 4: QUAN LY TIEN TRINH TRONG LINUX

Quan ly tién trinh (Process Management)

Sử dụng lệnh top để xem thông tin về các tiến trình, và thông tin chung của hệ thống

Firefox Web Browser

top - 07:28:11 up 2 min, 1 user, load average: 4,28, 2,42, 0,96

178 total, 2 running, 175 sleeping, © stopped, 1 zombie

6,5 us, 6,1 sy, 10,9 ni, 45,7 id, 30,7 wa, 0,0 hi, 6,9 sỉ, 0,0 st 969,6 total, 60,8 free, 588,0 used, 320,8 buff/cache

448,5 total, 217,9 free, 230,6 used 234,7 avail Mem

lieulam@lieulam-VirtualBox: ~

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND LieuLlam 10 930884 157032 92828 S 16,3 15,8 update+ lieulam © 3449808 244400 61652 gnone-+ tLeutLam 9 264432 31732 14044 Xorg

RTT g 1 0 14732 3844 3324 top

root 167388 6920 4692 systend root 9 kthrea+ root -20 rcu_gp

root -20 rcu_pa+ root -20 netns

root kworke+

root kworke+

root kworke+ root kworke+ root mm_per+ root rcu_ ta+ root rcu_ ta+

root ksoftt+

root rcu_sc+ root migrat+ root idle_i+ root kworke+ root cpuhp/9

10]

9

9

9

9

9 10]

9

9

9

9 ) 10]

9 10]

Trang 4

2 Sử dụng lệnh ps để xem thông tin về các tiến trình

a Xem tât cả các process : (dạng cây)

ps -eljH | more pstree

lieulam@lieulam-VirtualBox: ~ ©) =

$ ps -eljH | more pstree

S uID PGID SID C PRI NI ADDR SZ

TIME CMD

) ® © 80 0

9 60 -20

rcu_gp

9 4 9 60 -20

rcu_par_gp

ey

0 r2 9 60 -20

netns

9 is r2 8 60 -20

kworker/0:0H-events_highpri

0 3) 2 8 80 Le)

kworker /u2:9-events_unbound

0 k r2 8 60 -20

kworker/0:1H-events_highpri

0 10 2 8 60

mm_percpu_wq

0 11 rÀ 8 80

rcu_tasks_rude_

0 12 ra 80

rcu_tasks_trace

0 5) 2 80

ksofttrqd/9

9 14 2 80

rcu_sched

0 se) -40

migration/9

=) ấy Gl] G & Right curt

"- [2P 9/23/2022

Trang 5

b Xem tiến trình cha (tô tiên) của lệnh ps vừa thực thi : xem cột PID, PPID

ps -elJH |more

In lieulam@lieulam-VirtualBox: ~ Q =

:~$ ps -eLjH |more 2S UID PID PPID PGID SID C PRI NI ADDR SZ

TIME CMD

9 yA 9 Lo) 9 0 80 6

:00 kthreadd

9 ic) 60 -20

:00 rcu_gp

9 _ Le) 60 -20

:00 rcu_par_gp

9 5 9 68 -20

netns

8 rf r2 ở 9 60 -20

kworker/0:0H-events_highpri

9 8 r2 9 9 80 9

kworker/u2:0-ext4-rsv-conversion

8 kỷ r2 9 9 60 -20

kworker/0:1H-events_highpri

i] 10 r2 9 9 60

mm_percpu_wq

0 11 2 lo 80

rcu_tasks_rude_

8 12 r2 80

rcu_tasks_trace

8 lệ 2 80

ksoftirqd/0

0 14 80

rcu_sched

8 15 -40

migration/0

OS) BUG W& Riot cui

7:32 AM Tis 9/23/2022 oe)

c Kiểm tra một số dịch vụ đã chạy chưa ? ( như cron, atd, sshd, )

:~$ ps -e |grep cron 00:00:00 ana

5

9) (#} Right Ctrl 7:33 AM

A © de ENG

9/23/2022 bế

Trang 6

d Xem trạng thái của process (running, sleeping, ) : xem cot S

ps -elj]H |more

8

:09 rcu -‹

0

PID

gp

4

PPID io)

:00 rcu_par_gp

5

0

:00 netn

9

=}

7

F¿

lieulam@lieulam-VirtualBox: ~

PGI D

9

9

9

9 io)

:00 kworker/0:0H-events_highpri

2 8 F¿ 8

SID C PRI

9 96

9 96

9 96

9 9

:09 kworker/u2:0-events_power_efftctent

io) 9 F¿ 9

:00 kworker/0:1H-events_highpri

2) 10 F¿

:80 mm_percpu_wq

9 11 F¿

:00 rcu_tasks_rude_

9 12 F¿

:00 rcu_tasks_trace

io) si) F¿

:00 ksofttrqd/0

9 14

:00 rcu_sched

15

migration/0

9

9

Xem các process của user hiện hành

ps hoặc ps -l

PID TTY

2394 pts/0

2437 pts/0

PID

2394

TIME CM

$ oe

00:00:00 bash 00:00:00 PPID

2268 Phe

ny

c

$ BI aoe

9 80

8 80

si

a

9 6

9

80

60

60

60

60

80

60

60

80

80

80

80

40

NI

9 -29 -20 -20 -20

9 -20 ADDR SZ

NI ADDR SZ WCHAN TTY

3371 do_wai pts/0

e

e 3571 pts/Ð

T=

|

A 2 dy ENG

TIME CMD 00:00:00 bash

99:00:09 ps

^ #1dx„ ENG

9] GB Right cri IEl it £

i] @ B Right ctr

7:35 AM 9/23/2022 B

#37 AM 9/23/2022 B

Trang 7

f Mé mét terminal mdi (tty2), login vao bang tài khoản userl Chạy vi Mở một terminal mới (tty3), login vao bang tài khoản user2 Chạy top

(=) Terminal * Thg 9 23 08:28

fF lieulam2@lieulam-VirtualBox: /home/lieulam Q

root(@lieulam-Virtua lieulam2@lieulam-Vi lieulam3@lieulam-Vi

Thunderbird Mail

'tty2” [New File]

Bo a SO El @ GY) @ WRiatt cw

Coa

^ 1d; ENG

9/23/2022 E )

Trang 8

BI 00a Thg 9 23 08:29

lieulam3@lieulam-VirtualBox: /home/lieulam Q irtua lieulam2@lieulam-Vi lieulam3@lieulam-Vi

op - 08:29:35 up 32 min, 1 user, load average: 0,02, 0,25, 0,31

186 total, 1 running, 184 sleeping, © stopped, 1 zombie

1,4 us, 0,0 sy, 0,0 ni, 98,6 id, 0,0 wa, 0,0 hi, 06,0 si, 06,0 st 969,6 total, 58,7 free, 548,1 used, 362,7 buff/cache

448,5 total, 124,9 free, 323,6 used avail Mem

TIME+ COMMAND

gnome-+ Xorg gnome-+ systend kthrea+ rcu_gp rcu_pa+ netns kworke+ kworke+ kworke+ mm_per+

rcu_ta+

rcu_ta+ ksofti+ rcu_sc+ migrat+ idle_i+ cpuhp/0

lieulam 3684464

tLeuLam 261364

tLeuLam 817768

root 167372

root 9

root

root

root

Ubuntu Software

root

root

root

root

root

root

root

root

root ©Œœœ@ŒœGœGœCCCCSCCCCCCCC'

©œŒG@@ŒœŒœGœCGCGœCG€CG€CGCGœCGC©C©Ce¬iCœ ©œGœŒœG©G©CGCG©C©CCGCG©CGCG©CGCG©CGeeGeeGC

9/23/2022

Trên terminal của root, dùng lệnh:

ps -a /hién thi các process dang chay trén cac terminal hay

Trang 9

cea root(@lieulam-VirtualBox: /home/lieulam

root(@lieulam-Virtua CTT Teal tt:

‘/var/lib/private’: Permission denied

‘/var/lib/NetworkManager’: Permission denied

‘/var/lib/update-notifier/package-data-downloads/partial’: Permission den

weet: (one) [sudo] password for lLieulam:

root@lieuLam-VirtualBox: /home/lieulam# ps -a

PID TTY TIME CMD

Rhythmbex2 00:00:08 Xorg

tty2 :Ø0: gnome-session-b

pts/0 bao Los su

pts/9 :00: bash

pts/0 700: su

pts/0 700: bash

pts/9 :00: sudo

pts/0 clo} bash

pts/1 H2) SU

pts/1 Molo bash

pts/2 700: sudo

pts/2 :00: <0)

pts/2 700: su

pts/2 Ho bash

pts/1 bao Lo NẠI

pts/2 :00: top

pts/0 : ps

root@lieulam-VirtualBox: /home/lieulam# |

Bote CBB WG Wrintcu

o

ps -af //hién thị các process đang chạy trên các terminal va chu nhan

Trang 10

root@lieulam-Virtua

2938 pts/2

2972 pts/2 700: su

2973 pts/2 700: bash

2982 pts/1 700: vi

2986 pts/2 bolo top

2999 pts/0 :00: ps

root@lieulam-VirtualBox: /home/lieulam# ps -af

UID PID Cc TTY CMD

1Leutam 1192 tty2 700: /usr/lib/xorg/Xorg vt2 -dis tLeuLam 1208 tty2 H2) /usr/libexec/gnome-session- root 2764 pts/0 700: su Lieulam

pts/9 :00: bash pts/9 :09: su Lieulam pts/0 700: ey Eta) pts/0 bolo sudo -s pts/0 :00: /bin/bash pts/1 700: su Lieulam2 pts/1 :00: bash pts/2 700: sudo -s pts/2 :00: /btn/bash pts/2 :09: su Lieulam3 pts/2 :00: bash seta) pts/1 bao] es vi tty2

AG tg) pts/2 :00: top

root 9 : pts/9 :09: ps -af

root@lieuLam-VirtualBox: /home/lLieulLam# i

V

r LibreOffice Writer

TP 2774

root 2902

root 2903

root

LlieuLlam2

root

root

root

tLeuLam3

8:31 AM

2 ” E)

3 Sử dụng lệnh kill và killall

a Xem đanh sách các SIGNAL, của lệnh kill

kill -1

⁄ San a peer Lteulam2a bash

a /bin/bash

Lteulams

3e ~

> To eet

oe oS oe

SIGFPE

SIGPIPE

SIGCONT

SIGVTALRM

sicsvs

ca

3

ey

ct

nh

Lệ»)

ca

73 Ss 2> s 7> s 4) s

>

s5 5 oS)

eee wi Ái Dan mát fhome/lieulam#r

Trang 11

b Xem ý nghĩa của 4 SIGN AL thường dùng (đọc manual)

c Chạy lệnh sau và thực hiện theo yêu cầu

find / -name "cron

Khi lệnh đang thực thi, nhân Ctrl_Z đề dừng tiên trình

root(@lieulam-Virtua

root@lieulam-VirtualBox: /home/lieulam# find / -name "cron*"

/run/crond.reboot

/run/crond.ptd

find: ‘/run/user/1000/doc’: Permission denied

find: ‘/run/user/1000/gvfs’: Permission denied

/etc/cron.monthtLy

/etc/cron.d

/etc/cron.hourly

/etc/pam.d/cron

/etc/cron.weekLy

/etc/cron.daily

/etc/crontab

/etc/systemd/system/multi-user.target.wants/cron.service

/etc/tntt.d/cron

/etc/defautt/cron

/sys/fs/cgroup/memory/system.slice/cron.service

/sys/fs/cgroup/devices/system.slice/cron.service

/sys/fs/cgroup/pids/system.slice/cron.service

/sys/fs/cgroup/systemd/system.slice/cron.service

/sys/fs/cgroup/unified/system.slice/cron.service

find: ‘/proc/641/task/641/net’: Invalid argument

find: ‘/proc/641/net’: Invalid argument

/usr/share/bash-completion/completions/crontab

/usr /share/bug/cron

/usr/share/doc/cron

are/doc/cron/examples/crontab2english.pl

l1 4~ i i oe eo tS iro =+?¬+~ ¬]

8:34 AM

+ 9/23/2022 ae

Kiém tra băng lệnh ps -I xem lệnh còn hoạt động không ? (Tiên trình ứng với lệnh find có PID nào? Ở trạng thái gì?)

root@Lieutam-VirtuatBox: /home/Lieutam# ps -L

Ss) UID PID PPID PRI NI ADDR SZ

bì 3009 2903 80 9 - 3571

oot@lieuLlam-VirtualBox: /home/lLieulam#

te? 2 >) 8 GG Britt cri

837 AM

aN Miter 9/23/2022 B

Trang 12

Tiên trình ứng với lệnh fnd có PID: 3006 Ở trạng thái T(dừng chạy)

Châm dứt hoạt động của tiền trình ñnd băng lệnh sau có được không?

kill -SIGTERM <PID_find>

(kiêm tra lại bằng lệnh ps)

root@Lteu Lam-Vtr tua LBox:

root@lieulam-VirtualBox: /home/lieulam# ps -1

F UID PID PPID NI ADDR SZ

2764 2662

2773 2765

2992 2774

2903 2902

3006 2903

3013 2903

root@lieulam-VirtualBox: /home/lieuLam#

OE eG] @ & Right cr

8:41 AM 9/23/2022 E

^ ƒ]dx„ ENG

Châm dứt hoạt động của tiền trình ñnd băng lệnh sau có được không?

kill -SIGINT <PID_find>

(kiêm tra lại bằng lệnh ps)

root@LLeutLam-VtrtuaLBox: /home/LtLeutLam# ktLL -STGNTT

bash: kill: SIGNIT: invalid signal specification

root@lieulam-VirtualBox: /home/lieulam# ps -l

FS UID PID PPID NI ADDR SZ WCHAN

2764 2662 9 3586 do_wat

2773 2765 0 3579 do _ wai

2902 2774 0 3739 do sys

0

0

S

S

S

S 2903 2992 3177 do_wat

T 3006 2903 3504 do_sig

R 2903 3571 -

00 i -Vi : i ps -l

S PPID ADDR SZ

S 2662 3580

S 2765 3579

S 3739

S 3177

T 3594

4

4

4

ry

ry

r

r

F

l4

l4

4

4

4

P

2 AM

1% ”

Châm dứt hoạt động của tiên trình ñnd , bằng lệnh sau có được không ?

kill -SIGKILL <PID_find>

(kiếm tra lai bang lệnh ps )

Trang 13

root@LteuLam-VtrtuaLBox: /home/1LeuLam# kill -SIGKILL 3006

root@lieulam-VirtualBox: /home/lLieulam# ps -L

FS UID PPID NI ADDR SZ WCHAN TTY

- 3580 do wai pts/0

- 3579 do wai pts/0

- 3739 do sys pts/0

- 3177 do wai pts/0 ic}

- 3571 - pts/0

j find / -name "cron*"

Show Applications

ae wih bz1r#t<sóki2w) tualBox: /home/LieuLam#

^ ƒ1dx ENG piper =

Dung kill huy terminal hién tai : Terminal hiện tại tương ứng với tiên trình bash, vậy nên huỷ terminal hign tại có nghĩa là hủy tiên trình bash >> ket qua là sẽ kết thúc bash, và quay lại tiên tinh login (thay xuất hiện dau nhac login)

Hãy viết lệnh hủy tiền trình bash bằng lệnh kill?

Lénh huy tién trinh bash : kill -SIGKILL <PID_bash>

e Dung killall huy tat cA cac bash shell hiện tại trong | terminal :

Trén terminal ttyl , login vao hé thong với user Ì

Bi

Termina’ Terminal File Edit View Search Terminal Help + En > @)) 21:06 o2

@ root@lieulam-VirtualBox: /home/lillamm

root@lieulam-VirtualBox: /home/Lillamm# sudo su Lieulami

` lieulami@lieuLam-VirtualBox:/home/lillamms fj

củ

=

5

E

B

Â

2

Ø6 ‹) øœ 9 v el là 2C ^A ar U

9/23/2022 a)

Trang 14

Dùng lệnh su, chuyển sang dùng quyền của user2

Pa

Termina! Terminal File Edit View Search Terminal Help + len] > @)) 21:18

LieuLami@lieulam-VirtualBox: /home/lillamm$ su Lieulam3

Password:

LieulLam3@lieuLam-VirtualBox: /home/lillamm$ su Lieulam4

Password:

lieulam4@lieulam-VirtualBox:/home/lillamms Jj

| e root @lieulam-VirtualBox: /home/lillamm

i | root@lieulam-VirtualBox: /home/lillamm# sudo su LieuLam1

Tiếp tục , dùng lệnh su, chuyên sang dùng quyên của user3

|

a\ Terminal File Edit View Search Terminal Help rt En | ỳ) 4)) 21:16

@ root@lieulam-VirtualBox: /home/lillamm

root@lieulam-VirtualBox: /home/Lillamm# sudo su Lieulami

LieuLami@lieuLam-VirtualBox:/home/lillamm$ su Lieulam3

Password:

Lieulam3@lieulam-VirtualBox: /home/lillamm$ su Lieulam4

Password:

Lieulam4@lieuLam-VirtualBox: /home/lLilLamm$

9%16 PM

Xem toàn bộ các tiến trình phát sinh sau chuỗi lệnh trên

ps -aljH | grep ttyl

Dé kill tat cả các bash shell hién tai (trong | terminal) , đùng lệnh

kill -SIGKILL <PID_cia shell gic trén cing>

Dé kill tat cả các bash shell hién tại trên tat cả các terminal, dung

killall -SIGKILL bash

Trang 15

ty BE] Em 4) 2120 +?

lilamm@lieulam-VirtualBox: ~

a a :~$ ps -aljH UID PID PPID PGID SID C PRI NI ADDR SZ WCHAN TTY TIME CM

R 1001 2448 2333 2448 rie 9 80 9 - 2248 - pts/1 00:00:00 ps

3 Heh}

= 920 PM eer 6:

L8

4 Tìm hiểu địch vụ lập lịch cron:

a Lập lịch để mỗi phút ghi một chuỗi vào file test, Thao tác như sau :

Dung quyén cua root, mé file /etc/crontab bang vi (sudo vỉ /efc/cronfab) hoặc nano Nhập vào cuối file dong sau :

** * * * root echo “hello” >> /test.txt

Kiểm tra bằng cách: chờ vài phút trôi qua, rồi mở file test.txt để xem Hoặc chỉnh lại đồng hồ hệ thong réi xem lai file

Trang 16

Terminat ty BE] & ©) 2128

root@lieulam-VirtualBox: /home/lillamm

GNU nano 2.5.3 File: /etc/crontab Modified /etc/crontab: system-wide crontab

Unlike any other crontab you don't have to run the `crontab'

command to install the new version when you edit this file

and files in /etc/cron.d These files also have username fields,

that none of the other crontabs do

SHELL=/btn/sh

PATH=/usr/local/sbin: /usr/local/bin:/sbin:/bin: /usr/sbin: /usr/bin

# mh dom mon dow user command

17 #82 root cd / && run-parts report /etc/cron.hourly

25 Là root test -x /usr/sbtn/anacron || ( cd / && run-parts repo$

ee 7 root test -x /usr/sbin/anacron || ( cd / && run-parts repoS 1** root test -x /usr/sbin/anacron || ( cd / && run-parts repo$

*

ie)

47 6

52 6

root echo "hello" >> /text.txt

me Get Help (@@) Write Out @f Where Is @M Cut Text (@) Justify we Cur Pos

i Exit aii Read File @i} Replace my Uncut Text@j To Spell Go To Line

9:28 PM

Ngày đăng: 27/12/2024, 12:26

🧩 Sản phẩm bạn có thể quan tâm

w