




下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、unix-linux實驗報告-華北電力大學-閻蕾作者:日期:華比”*孑科技學院(2012實驗報告2013年度第1學期)稱:UNIX/LINUX 體系及編程系:信息工程系級:t=r.號:學生姓名: 指導教師:成 績:日期:2012年9月9日實驗正文.實驗目的和要求:1.2.3.4.5.1.掌握UNIX/Linux系統(tǒng)的目錄和文件管理命令。 掌握shell的輸入輸出重定向,編寫編寫C語言程序,使用 GCC編譯,使用 掌握make工具,撰寫 makefile 文件, 要求每人能獨立完成實驗。shell腳本文件。GDB調試。完成C程序的自動編譯。.實驗主要內容:1.用pwd命令顯示用戶主目錄的路徑名,
2、 命令查看當前登錄在系統(tǒng)中的用戶列表, 戶總數(shù)和系統(tǒng)啟動時間。比較whoami命令:pwd:查看當前工作路徑 命令:date :查看日期時間 命令who - a 查看登陸系統(tǒng)中的所有用戶,同時顯示啟動時間 命令:whoami和who am i 的區(qū)別:whoami只顯示當前用戶的名字用date命令查看當前日期和時間,用who利用who命令選項查看當前系統(tǒng)中的用和who am i 顯示的結果區(qū)別。費 1 G hyJ(ahyJ-VirtualBox; To run a command as administrator user root), use sudo . See *an sudo roof
3、for details*whoanihy jhyjhyjhyjhyj-VirtuaIBox:Shyjpts/0hy jhyj -/lrtualBox:Swho an i2012-10-21 16:42 :0) date2012年10月219星期日15:4氛25 CST hy jhyj -VlrtualBoM: -$ pv*d/hone/hy2. 用vi編輯器,先在用戶主目錄中創(chuàng)建文件,編輯文件。并作統(tǒng)計文件大小,重新 編輯文件。字符串替換等工作命令:創(chuàng)建qq文件:vi qq命令:統(tǒng)計創(chuàng)建文件大小:du - h qq 命令:字符串的替換:在命令模式下輸入cat qq 查看文件可以把文件中所有的h
4、uangjinlong 替換成Mk 1, $s/huangjiniong/Mk/g1表示第一行,$s表示最后一行。內容如下:hyjhyj-vtrtualBox:S hyj電hyj-Vi rtualBox:S 4.QK qq hyjhyj-Vi rtualBox: huangJlnlong :1 love you!vl qq du -h qqcat qqnieqifeng:sorryt dont love you! hyjhyj-Vi rtualBox-5 vi qq hyjhyj-VtrtuaIBox:S cat qq Mk :t love you!nteqT.fen9:sorry,i don
5、t love you!3.運用find 命令查找Passwd文件在/目錄下查找 passwd 文件:find / -name passwd rootRedhat 桌面# find / -name passed SGlinuxclass/p35v/d selinux/cVasE/passwd/permi/passwd usr/share/doc/pamldap-lB5/pam.dfpa5swd usr/bin/passwd etc/paffi.d/passzd etc/passwd homeZdeino/passed查找一天前所創(chuàng)建的文件: 查找一天前所訪問的文件:ToowKeanaTfind
6、/home/de no/ -atime +1find /home/de no/ -ctime +1臬 inTina/inome/aenioz -atime mMH耐前被創(chuàng)建的立件/home/deno/ -ctime 4i24小時?前戡訪間的交件find -user qqhome/demo/passwd home/denio/xd hofTie/demo/name home/demo/root.h home/demo/heno ,tar, g; home/demo/xd X home/demo/hello.txt home/denio/root .txt ;rootRedhaT 黛面# Tind
7、i home/demo/ home/demo/paswd (home/demo/買d hofne/demo/name home/demo/root .sh fhone/denio/hello .tar.gz home/demo/xd.c home/demo/helTo,txt home/denio/rooT. txt查找/home/demo目錄下屬主是 qq的文件:hy JhyJ - VI rt ualBo)c*S 11 總用量483drwxr-xrdrwxr-xr-rw-rw-r- -rw-r- - r drwx ” drwx - -rw-rw-r drwx *-rw-rw-r*rw*rw-
8、r-rw-rw-r-*rw*rw-r drwxdrwx -*rw*rw-rdr -x-rWrw-r*rw-rw-r-rwdrwxrwxrdrwx -drwx213111121213111114412111334-rW-rdrwx -rw-rWrWrhyj root hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyjhyj root hyj hyj hyj hyj hyj hyj hyj hyj hy) hyj hyj hyj hyj hyj
9、 hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj hyj409 & 409689Z23 3353 409640p &409678261617951 4096 4096183 01939S5O 4096 4096 4096675409 &256502012-10-21 2012-10-21 2012-10-21 Z012-10-21 2012-13-21 2012-10-21 Z012-10-21 2012-10-21 20121021 2012-10-21 2012-10-21 2012-10-21 2012-10-21 2012-10*21 2012-
10、10-21 2012-10-21 2012-10*21 2012-1O-Z1 2012-10-21 2012-10*21 2012-10-21 2012-10-21 2012-10*21 2012-10-21 2012-10-21 2012-10*21 2012-10-21 2012-10-211915IS1515161315161516161517161616161?15161616161516161934580558583505273124313158293131313120593131313658313134,bash_htstory .bashlogout .bashrc.cache/
11、.config/d.dbus/ dengshuat*dmrc,esd_auth examples.desktop flower.gconf/.gnoneZ/.gtk-bookmarks *gvfs/ hellohyj,工匸Eauthority.Local/.nlsston-control/ noztlia/,profile pulse/ ,pulse-cookte qq4.編寫flower腳本a .顯示用戶名。顯示用戶當前系統(tǒng)中的進程。b判斷當前用戶是否為root用戶:若是root 目錄下的某個文件的內容但保留其最后的 若不是root用戶,提示出錯。文件為/var/log/cron文件。利用n
12、,清除 /var/log用戶,則根據(jù)命令行參數(shù)n行的內容,若沒有參數(shù),則保留10行;cat - n查看文件一共65行。62 HOJ )port)*t63 HOJL 1)64 /flowL Uw fiaj t 1)08:23:330fii30:eioe:4o:eieie:5ei:fciiRedhatRedhatRfidhatKfidhatcrondlB121:CROWD2029:CR0ND2610il ;tR0NUZb34j:CROM)(root)(root)troot)腳本如下:INFO I ojrning with inotity suCHD Tr tiw-m- . -=_.二 p、二)-1
13、1 1- ij_ir#!/bin/ba;h-令-1 rifjecldre -i iwhoami/home/deiM/ 二;.tx t*_psJC-ivdi - -root JI lii-nI /var/;ogcron -/honic/dcuo/niin. IFL e 5ii ,w -$n - IE #15=.d_l -15 /var/Loq/cror /var/log/crartBakcat /var/Lciq/cror.tiak .- /var/log/cronI- c一九/vdryVog/troii /vdr/Tug/cian.bdk一 ciL /vsr/lag/cron.bdk /Vdi
14、ir/log/cran/home/dro/m111.1 yr-/Iloffnf/de/- - .rxt執(zhí)行:bash /home/demo/flower.sh查看 /var/log/cr onLroot(9Redhat 1 rjuv 忸五鋼 tJavrjQiv huv hav tlav fJoiv rm rjQv Lav (Jfiiv Nov rJov rjoiv12 3111Log J# cat -n 7var/Log/cron 33333333333333309:1&:Q1 09:10.01 Q9:1:G2 他:If)仙2 09:1&:03 09:1&.03 09;1&:14 09:1&:
15、14 09:1&:14 09:1&:14 09:1&:15 09:W:15 09:W:15 旳;I肌15 (39:1&715Kedhat Rtdhat Redhat K&dhat ftedhdt ftedhat Jedhat 耳已dht edlidt Redhat edhat Redhat =edhat =tdhat edhatrun-piris(zett/(.ron*dailyJ27201: finished rur-part5(/etc/cror.daily)2760: starting run-pa rts j/etc/cror,daily)2727J: rur-paris(/etc/c
16、rori daily) 270!3: ruii-pdrlst/eTt/troii.ddlly J 8461: run pirts(/etc/cror-daily)27G0J: ruri-p3rts(/at/cror .daily) 28571:finish&d starting Finished sta rting finishedrur-pFirts(/eT/cror,rtailyJ 127881: starting run-parls(/elt/croii.daily) 28051 : run-parts(/etc/cror.daily)2709): run-parts(/etc/cror
17、.daily)2E80 j: rur-pirTs(/eT/cror.rta1;yj27881:finished5ta rting finished startingrur-partstetc/crordaityj29131: finish&d anacron2634: Job cron,daily terrinat&d anacron26e4: NOnnal exit (1 job run Jtups logrotate logrotate makeuhsTis.cr nidkewlidlis.tr mtacate.cron mlDCate.cron preLirk preLink reada
18、head.crc readahead.crc Tmfjwatfh tmpAfatch5.十進制轉換為十六進制:代碼如下:文件(臼 編輯(日 查看但)搜素 勢端 幫駅A#irclude Bint indln()int n;prplea5.& input a numbsrir ; scarf (;Srintfxn,n);-t Lu f Til S ;編譯:gcc - Wall執(zhí)行:./xd-n xdroot(aRedhat pLea&e inputdemo# -/xd a number3c ge.c judge.h main.c Makefile makefile.bah output.c out
19、put.h 廠申tlRedhdt Ifclb# I*上*Makefile:M roGroot 回 RedlhaUhome/demo/lOIb cc =gccHEAD =judge.h output*hSRC =main.c judge.c output.iie5J;(OBjs =inain,o judge,o output,oTT = jinzhiCFLAGS +-LDFLAGS += -WallaU:S(TTStTT) : SfOBJS)S(CC) J (LDIFLAiGSl SfOBJSS -o 昶;電Sileanrc$(CC) $(CFLAGS)讓 $ 7 $rm -f So S(TT1主函數(shù):mai n.crootRedhat:/hofne/demo/10L6include #include output. hinclude judge,h int mainOint a;int jud;IPrinti(錯輸入+進制數(shù)導:Wl; gcanf d,&a);jud=jLdge(a);output(a 打 1 -嚴* pHntfr情擒入+ a
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 保密知識考試題庫帶答案(研優(yōu)卷)
- 2025年中國新消費行業(yè)市場規(guī)模調研及投資前景研究分析報告
- 東臺教師招聘試題及答案
- 安全操作規(guī)范試題及答案
- 醫(yī)療信息透明化與患者權益的保護
- 2025年鋼管帳篷項目市場調查研究報告
- 2025年鋼絲繩手扳項目市場調查研究報告
- 基于大數(shù)據(jù)的企業(yè)管理決策支持系統(tǒng)研究
- 2025年金絲格面料項目市場調查研究報告
- 2025年酸奶露項目市場調查研究報告
- 回轉窯回轉滾筒干燥機使用說明書
- 2023年四川省成都市中考歷史試卷附答案解析
- 第四節(jié) 石油資源與國家安全
- 2023年廣東初中學業(yè)水平考試生物試卷真題(含答案)
- 2023年全國統(tǒng)一高考政治試卷(新課標ⅰ)(含解析版)
- 新課程標準2022版綜合實踐
- 2023年浙江夏季世界少年思維研學“丁一杯”五年級數(shù)學模擬卷(一)含答案
- 260噸(t)吊車性能參數(shù)
- 超星學習通中華傳統(tǒng)文化之文學瑰寶(同濟大學)章節(jié)答案
- 國家電網(wǎng)(公共與行業(yè)知識)考試高分通關題庫資料800題(附答案)
- ISO50001-2018能源管理體系內審檢查表
評論
0/150
提交評論