Baitap Linux CoBan

download Baitap Linux CoBan

of 18

  • date post

    18-Jul-2015
  • Category

    Documents

  • view

    263
  • download

    1

Embed Size (px)

Transcript of Baitap Linux CoBan

Hng dn thc hnh - Lp trnh M ngun m

Hng Dn Thc Hnh

Chng: Linux C BnKhi: i hc Lin thng. 2011-2012

Hng dn: Bi tp thc hnh da trn gio trnh: CompTIA Linux Plus Certification Study Guide Bi tp thc hnh c chia theo lm nhiu Module Mi Modu le c thit k cho thi lng 3 tit thc hnh ti lp vi s hng dn ca ging vin. Ty theo s tit phn b, mi tun hc c th thc hin nhiu Module. Sinh vin phi lm tt c cc bi tp trong cc Module tun tng ng . Nhng sinh vin cha han tt phn bi tp ti lp c trc h nhim t lm tip tc nh. Cc bi c du (*) l cc bi tp nng cao dnh cho sinh vin kh gii.

Trang 1/18

Hng dn thc hnh - Lp trnh M ngun m

Module 1: Ci t H iu hnh Fedora Core (FC 10)Ni dung kin thc thc hnh: + Ci t HH Fedora Core (FC 10) song song vi HH Windows. Sau khi ci t xong, SV c th boot ng thi 2 HH.

Bc 1. Chun bChun b: - SV ci t HH Windows vo phn vng a cng C trc khi ci t HH Fedora Core 10, dnh 1 phn vng a cng dng ci t FC ( a D, dung lng khong 10GB) + 1 phn vng dng lm SWAP (dung lng bng 2 ln RAM gi a E ).

Yu cu phn cng:- SV tham kho trn website. - Ring i vi FC 10: cu hnh ti thiu dng ha v chy cc ng dng. - i vi CPU x86 + CPU Intel Pentium, ti u nu dng Pentium 4 hoc Dual Core + RAM: 256 MB + HDD: 9 GB - i vi CPU x86_64 yu cu ca RAM l 512 MB

Bc 2. Ci tKhi ng li my tnh, cho a CD (hoc DVD) thc hin cc bc sau y (SV c cc hng dn trn mn hnh lc ci t).

ci ny lm sau

Trang 2/18

Hng dn thc hnh - Lp trnh M ngun m

Module 2: Cc lnh v file-directoryNi dung kin thc thc hnh : + Nm vng h thng cy th mc trong linux + Nm vng - vn dng 2 khi nim c bn ng dn tuyt i + Mt s lnh c bn v file-directory

ng dn tng i

v

Cy th mc trong linuxLu : Cy th mc bt u bng du: / (root directory)

/

bin boot

dev

etc

home

media

var

root

sbin

User1

User2

Desktop

ng dn tuyt i ng dn tng i

Trang 3/18

Hng dn thc hnh - Lp trnh M ngun m

- ng dn tuyt i ca mt tp tin hay th mc lun bt u bi / (root directory) v tip theo sau l chui cc th mc m n i xuyn qua cho n khi ti ch. Tm li, mt ng dn tuyt i l ng dn bt u bi / . V d: 1. Khi bn ang ng trong th mc tuantub, th mc con ca home hay cn c th ni home l th mc m ca tuantub th ng dn tuyt i ca ca th mc tuantub s l /home/tuantub. 2. ng dn tuyt i ca tp tin abc l: /home/tuantub/Desktop/abc - ng dn tng i i vi ng dn tng i th ngi s dng khng i hi phi bt u t / m c th tip cn c vi cc th mc hay tp tin bn trong th mc hin hnh (working directory). Mt ng dn tng i thng bt u vi : -Tn ca mt th mc hoc tp tin -Mt du . (du chm) biu th cho working -Mt du .. (hai chm) biu th cho th mc m ca th mc hin thi. 1.Gi s l bn ang ng trong th mc /home/tuantub trong cy th mc, t y th ng dn Desktop/abc s l ng dn tng i ca tp tin abc. 2.T /home/tuantub th ng dn tng i n th mc /lib s l ../../lib (th mc lib l th mc con ca th mc m ca th mc m ca /home/tuantub) 3.T /home/tuantub, nu mun di chuyn n /lib th ta dng lnh cd vi : ng dn tuyt i : cd /lib ng dn tng i: cd ../../lib

Trang 4/18

Hng dn thc hnh - Lp trnh M ngun m

Bi 1.Mc ch: Khng s dng giao din ha, s dung command line thc hin cc lnh c bn v file-folder . 1. Login vo h thng . S dng lnh cho bit user hin ti l g? 2. M terminal. 3. Login vo Linux di quyn root s dng lnh su . 4. Cho bit th mc hin hnh . 5. Lit k danh sch file , folder trong th mc hin hnh 6. To cu trc cy th mc nh sau:

7. To file vi.txt folder tc1 c ni dung bi th Hng Thm. 8. Delete folder ncd2 9. Copy 3 file bt k trong folder /etc vo folder ncd1 10. Copy ton b folder ncd1 vo cb 11. Di chuyn file vi.txt (yu cu 7) vo th mc cd 12. Chuyn v tr th mc hin hnh v cd 13. Chuyn v tr th mc hin hnh v /root 14. Hin th n i dung file vi.txt s dng lnh more, less, cat 15. To file log_time rng trong th mc cd 16. Hin th ngy gi t o file log_time ni trn. 17. i tn file log_time thnh log_time.txt v cha trong tc2 18. To file my_friend.txt trong th mc tc1 ch a danh sch tn 2 sinh vin ngicnh trong lp. (s dng l nh cat tn_file , bm Ctrl+D kt thc 19. Log out. Bm thot . Gi : Thng xuyn s dng lnh pwd v ls kim tra. C th s dng nhiu tham s trong qu trnh to th mc. )

Trang 5/18

Hng dn thc hnh - Lp trnh M ngun m

Bi 2:Mc ch: S dung command line thc hin cc lnh c bn v xem thng tin h thng.

1. Login vo h thng. Dng lnh su chuyn sang root. 2. Cho bit tn ca h iu hnh ang s dng.3. Cho bit version ca kernel ca HH hin ti 4. Cho bit bao nhiu user ang login vo h thng 5. Cho bit ngy thng nm hin ti ca h thng 6. Hin th lch ca thng hin ti 7. Hin th lch ca nm 2009, lch ca thng 3 nm 2009 8. Cho bit ngy 1 thng 1 nm 1990 l th my? 9. Hin th thng tin chi tit v user hin ti 10. S dng lnh man h in th cc lnh m man page cha cc t kha: find, search, read, hostname, connect system calls 11. S dng lnh apropos hin th cc lnh cc trang cha ni dung lin quan n group

Bi 3:Mc ch: S dung command line thc hin cc lnh c bn v file. Thit lp b danh cho lnh. tm kim thng tin-

1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13.

Login vo h thng. Dng lnh su chuyn sang root. Hin th tn my tnh hin ti Hin th thng tin v lnh passwd Hin th cc lnh m man page cha cc t kha: passwd Hin th v tr ca file lnh, source, manual page ca lnh ifconfig, locate Hin th th mc/file no s thc thi khi dng ln passwd Tm tt c cc file c cha t passwd . Trc khi thc hin lnh ny, nn s dng updatedb mt ln. Thit lp lnh dir l b danh ca lnh ls la, lnh m l b danh ca lnh mkdir. S dng lnh m ny to cu trc th mc m t bi 1. S dng lnh find tm ton b v tr file my_friend.txt tnh t /root To command f l b danh ca lnh find, tm t /, tm theo tn file. S dng lnh f ny tm v tr file password.config Tm nhng hng trong ni du ng file /etc/passwd cha t root . Tm v hin th thng tin chi tit cc file trong /etc m tn file c cha t config Tm tt c nhng file trong h thng cha t root.

Bi 4:Mc ch: S dung command line thc hin cc lnh c bn v file permis sion.

1. Login vo h thng. Dng lnh su chuyn sang root. Trang 6/18

Hng dn thc hnh - Lp trnh M ngun m

2. To ti khon user1 vi password user1 3. Dng su Login vi ti khon user1. Hin th th mc lm vic hin hnh. 4. Chuyn v th mc ngi s dng. Lit k chi tit file-folder c trong th mchin ti.

5. To 3 th mc vd1, vd2, vd3 trong th mc hin ti. Dng lnh cat to file 6. 7. 8. 9. 10. 11. 12. 13. 14. 15.monhoc.txt trong th mc vd1 cha danh sch cc mn hc -tn gio vin ging dy (ang hc trong hc k hin ti ). c permissions ca folder vd1 Thay i permissions ca folder vd1 thnh dr-xr-xr-x Xa file monhoc.txt trong th mc vd1 ? To file monhoc1.txt trong th mc vd1 vi ni dung bt k ? Thay i permissions ca folder vd1 thnh drwxrwxrwx To file monhoc1.txt trong th mc vd1 vi ni dung bt k M thm 1 terminal. To ti khon user2 vi password user2. Dng su Login vi ti khon user2 . T ti khong user2, hin th c ni dung th mc ca user1 hay khng ? (/home/user1) Dng lnh locate tm v tr file monhoc.txt. Nu khng tm thy, hy gii thch ti sao v thc hin lnh g locate c th tm thy file ny. Thay i permissions ca folder /home/user1 cho php user2 c th truy xut vo folder ny. Kim tra bng lnh ls. To cu trc th mc cho h thng nh hnh sau (tnh t sau th mc home)

Trang 7/18

Hng dn thc hnh - Lp trnh M ngun m

Module 3: CC LNH V FILE DIRECTORY (TT)Ni dung kin thc thc hnh: + Cc lnh theo tc trn file, th mc: find, locate, grep + Nn-gii nn tp tin th mc , backup + Thay i u ra, vo, thng bo li

Bi 1:Mc ch:

- S dng lnh tm kim find v locate

Module 4: Bash Shell-Ci t phn mm-Qun tr ngi dngNi dung kin thc thc hnh: +K thut Ci t phn mm trn Linux +Nn-gii nn tp tin th mc +Qun l user-group v phn quyn : .rpm, .tar.gz, .tar.z2 , t source code

Bi 1:Mc ch: S dng Bash SHELL.

1. Login vo h thng. Dng lnh su chuyn sang root. 2. c thng tin cc file sau (nu tn ti): /etc/profile, ~/.profile, ~/.bashrc,3. 4. 5. 6. ~/.bash_profile, ~/.login, and ~/.cshrc. T cc thng tin ny xc nh gi tr shell environment variables: PATH, p ath, LINES, HOME, v home. Kim tra gi tr ni trn bng cch s dng echo $variable (PATH, path, LINES, HOME, home). Xc nh search path (dng cho default shell tm kim chng trnh). M rng ng dn ny vi folder: /sbin v /ttcntt1_hui Thay i du nhc (prompt) hin ti thnh --> Thay i du nhc (prompt) hin ti thnh 2 hng: Done Next command> Thay i du nhc (prompt) hin ti lun hin th th mc lm vic hin ti. M thm 1 terminal kim tra du nhc c thay i theo hay khng? Thc hin thay i PROMT thnh duongdanhientai> v PATH c m rng vi /sbin v /ttcntt c nh cho tt c cc shell c m. Thc hin restart my o Linux v kim tra s thay i ca cc thng s ny. To lnh m l b danh cho lnh mkdir, v dir cho lnh ls la. Thit lp cc lnh b danh ny s dng c ngay c khi khi ng li my.

7. 8.

9.

10. Cho bit cc shell no c ci t v sn sng s dng trn h thng.Chuyn qua mt shell khc t shell hin ti.

Trang 8/18

Hng dn thc hnh - Lp trnh M ngun m

Gi : S dng cc lnh (hoc bin): chsh, c hsh l, echo, $PATH, $PS1, ~/.bash_profile, ~/.bashrc PS1='type something! ' Mt s m s dng cho prompt l: \d the date (day-of-the-week month day) \h the hostname (without the domain) \n start a new line \u the current username \w the working dir ectory

Bi 2.Mc ch: Khng s dng giao din ha, s dung command line thc hin cc lnh c bn v file-folder. 1. Kim tra menu Applications/Game cha cc thnh phn no. S dng rpm c i t gi phn mm gnome-games-2.22.1.1-4.fc9.i386.rpm. Sau tm trong menu Games xem c chng trnh mi hay khng? Chy th 1 hay 2 chng trnh. Sau remove gi phn mm ny ra khi my o. Kim tra trong danh sch cc gi ci vo my s dng RPM c cha gi gnome-games khng? S dng rmp remove gi ny ra khi my o. Kim tra cn cc game trong my hay khng? 2. Kim tra menu Applications/Education cha cc thnh phn no. S dng rpm c i t gi phn mm kdeedu-4.0.3-3.fc9.i386.rpm. (vi kha chuyn --nodeps) Sau tm trong menu Education xem c chng trnh mi hay khng? Chy th 1 hay 2 chng trnh. Gii thch ti sao nu c chng trnh khng chy . Sau remove gi phn mm ny ra khi my o. 3.