试验2熟悉Linux环境试验_第1页
试验2熟悉Linux环境试验_第2页
试验2熟悉Linux环境试验_第3页
试验2熟悉Linux环境试验_第4页
试验2熟悉Linux环境试验_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、湖北汽车工业学院实验报告班 号 学 号 姓 名选课班中的序号 完成日期 年_月_日_至_节实验二 熟悉Linux环境实验一、实验目的. 了解Ubuntu系统基本操作方法,学会独立使用该系统。.练习常用的shell命令。.熟悉简单的脚本程序。.掌握Ubuntu下如何编辑、编译和运行一个C语言程序。.学会利用gcc、gdb编译、调试 C程序。二、实验内容1、登陆 Linux2、熟悉Ubuntu图形桌面环境 3、练习常用的Shell命令(必做)(6分) 1)目录操作#创建一个目录 abc将工作目录改变到abc改变当前目录到主目录 列出当前目录的内容mkdir abc cd abc #cd#ls#显示

2、:nnyOnnyvirtual-nachine:nkdtr otx nny(jny-virtual-narhire :Cd abennyflnny-vtrtualRachine:cd nnyijiiRy-vtrtual-nachtne:- Isbc examples. desktop snap公共的模板fflM 片文档下音乐ls -l #输出当前目录内容的长列表,每个目录或文件占一行显示:nnynmy-vtrtual-nachtrie: 总用量52drwxr-xr-x 2-rw - r - r 1 drwxr-xr-x 3 drvxr*xr-x 2 drwxr-xr-x 2 drwxr-xr-

3、x 2 drwxr-xr-x 2 drwxr*xr-x 2 drwxr*xr*x 2 drwxr-xr-x 2 drwxr-xr-x 2ney nny 4096 nny nmy 8986 nny nmy 4896 nny nmy 4096 nmy nmy 4696 nrny nny 4895 nmy nm/ 4&96 npy nmy 4096 nmy nmy 4096 ny nmy 4696 nrny nrty 4096Is月月月月月月月月月月月 5444444444 4 $P1的C翼板频片档载乐面 ”sn公模视图文下音桌.desktoppwd显示当前目录的全路径显示:nnyQcmy*vlrt

4、ual-ffiachlne:pwd /hone/nmy2)文件管理实用程序cp /etc/manpath.config filel #将 etc 目录下 manpath.config复制至U filelmv filel file2将 filel 重命名为 file2: $ cp /hone/nny/snap/gnone-system rwnttor/iZ7 .cp: *r not specified; onttting directory /卜。鹏/口杓V/5n3,。何,-53匕n训。力(0/1 27,nnyftnyvlrtual-nachtneIs*bc exampUs. desktop m

5、ftp公共的 横板 视,工 图片 文档 下注 音乐 桌面nnyrtny-virtual-Hichlne;nv snjp filehfiyirtny-vlrtual-fiachtne Isebc examples.desktop file公共的模板视频图片文档下载安乐桌面nnydnny-vlrtual-ndchln:=$显示file2 文件内容分屏显示file2 内容显示file2 后几行显示文件file2 的开始10行3)文件显示实用程序cat file2more file2tail file2head file2结果:nnynmy-vlrtual-riichtne: -$ ct my sc

6、tipt 书I/bin/bash pwd S -I nkdir nydir cd nydir cp /etc/nanpath*config .nv manpath .config m”anpath*Ecinftg noi e myTidiipdLhconfly rPi -1 nynarpath. config cd _ _ rrdir ,n)/dtrriFiyianm/-vtrtual-nachtne; -S no re nyscttpt #!/bin/bash pd Is nkdtr mj/dlr cd mydLr cp /etc/narpath*config * rnv nanpath,c

7、onflg nranpath.conftg more n/nanpath*canflrj r m -I mynaripath*conftq cd - rFidir pydinnyn*iy-virtual-rusehtne:tall rtysetiptp3dIs ankdlr nydlr cd nydic cp /etc/nanpath.config .nv manpath.config mymanpath.conftg nore fiynanpathiconfig rn -I nynarpath.config cd 一 rmdir rnydirnmytanFiy-vlrtual-nachine

8、: -5 head nyscttpT ffl/bln/bash pd 1S -I nkdir nydtr cd t*iydLr cp /etc/narpath.config .nv manpath.config mynanpath.config nore nynnpath,config 囚-I HYRanpath.ccnftgwc file2统计文件file2中的行数、单词数和字符数结果:nnynn/-virtual -njchinc:-$ * CySCtipt11 23 160 mys匚tlptrm -i file2请求用户确认删除file2 文件查看file2文件删除没有:nmydn用y-

9、vlrtud5 rm -x rm:是否删除普通文件,mysctlpt? nFanny-vtrtuat-pidchtne:*$ ls-l ls-1:未找到命令nnynm/-virtual-nachine;-*$ Is -1 总用量56Tiysctxptdrxr-xr-x2mynny40965月1-rw - r -,1nmynny89304月29drwxr 3nmynrty伯955月2drwxr-xr-x3nmynmy40964月29drvsxr-xr-x2nnynny409D4月29drwxr *Kr,x2nrnynny40904月29driflxr -kt - x2nmynmy40964月29

10、drvkxr-)cr- x2nmym my46964月2gdriftxr-sx2n”nmy40965月2drwxr -及xZnniynpiy40904月29drwxr -xr - x2nmynny40964月29driftixr-xr-x2nmynny4096W月294)其他实用程序date输出系统日期和时间结果:exanplts ftlcl的黑八板频片档卷面 sn公模视图文工口更TdesktopnHy0nny-virtual*Hachine:$ date282。年 05月。2日 星期六 21:39:18 CSTcal结果:显示本月的日历。cal 2002 显示2002年的日历nmygnny*

11、 virtual-machinecal 五月2020日一二三四五六 TOC o 1-5 h z 3 45678916 11121314151617 18192621222324 25U1128293031clear清除终端屏幕history显示你以前执行过的命令的列表结果:nnynny-virtual-nachInehlstorIsIs-sU-Lnkdir dbccd ndtrcd& Unkdlr abccd nydircdIsrm-abcnkdlr dbccd nydtrednkdtr abccd nydircdIsIS -Ipwdman 显示实用程序的有用信息,并提供该实用程序的基本用法

12、结果:nnynny-virtual-ftachine 1 $ man 您需要H么手册页?echo Hello,Welcome to here!读取参数并把它写到输出结果:nnyanny-virtual-nachtne: $ echo Hella,Weicome to here! Hello/Welcome to here!4、熟悉简单的脚本编程(必做)(1分)编写Shell脚本文件,显示当前路径,列出当前路径下所有文件,建立 mydir子目录,进入该子目录,拷贝 /etc/manpath.config文件到当前目录中,把文件 manpath.config 改名为mymanpath.config

13、 ,分频显示该文件,用户确认删除该文件,回到上一级目录,删除 mydir子目录。1)进入文本编辑器,输入下列脚本程序:#!/bin/bashpwdIs - lmkdir mydlrcd mydlrcp /etc/manpath.conflg .mv manpath.config mymanpath.configmore mymanpath.configrm - i mymanpath.configcd .rmdir mydir2)保存文件并退出文本编辑器。(给文件命名myscript )3)执行该脚本文件(bash myscript)注意:使用rm命令一定格外小心,因为一旦删除了一个文件,就无

14、法恢复。nmynhy-virtual-notnine /bopw/nFynyscrtpt总用drwxr-xr-x -rw-r-r- -rw-rw-r- rw* rw-r- drwxr-xr-x d-x-xr-x1 11 32nmy fny nmy nny nny nnynny nmy nmy nny nmy nmy4096 89836S167 4U96 4896drwxr-xr-x drwxr-xr*x22nwy nmy nny nmy40964日96drwxr-xrx2nwy nmy469$drwxr-xr-x2nny nny4096drwxr-xrx2nny nmy4096drMxr-*r

15、- *2nwy nmyAa96dx7rx3n同y nmy4096nanpath.conftg百月月月月月月月月月月月月月s tec Ppl*rI的 canplloscr瞿八板频片档a乐面 abshe公模视图文下音桌.desktop# This file is used by the man -db package to configure the 再an and cat path # It Is also used to provide a manpath for those without 0n岩 by ex4ntning 莒 thetr path envtroftwnt vartabu.

16、For details see the Manpath(5) waft page.#(r Lines beginning wttti are comments and are ignoredi Any combtnatton of # tabs cr spaces nay be used as whitespace1 separators.ntt There are three mappings allowed in this file:HANDATORV rANPATHmanpath element# Range of terminal widths pernitted when displ

17、aying cat pages. If the 9 terninal falls outside this range, cat pages will not be created tif 。mis写Ing) or displayed.鼻MI肿CATWIDTH 30 AMAXCATIDTH 的#g If CATWIDTH is set to a non-zero number, cat peges will always be# fornatted for a terniflal of the given width, regardless of the width of # the tern

18、tnal actually beng used. This should generally be within the # range by MINCATWIDTH and KAXCATWIDTH.*#CATW1DTH 0 fl Flags.4 NOCACHE k?eps nan fron creating cat pages. flNOCACHErm:是否删除普通文件1 Rynanpthconfig? y int sum = 0; switch(month)(case 1:sum = day;break;case 2:sum = 31 + day;break;case 3:sum = 59

19、 + day;break;case 4:sum = 90 + day;break;case 5:sum = 120 + day;break;case 6:sum = 151 + day;break;case 7:sum = 181 + day;break;case 8:sum = 212 + day;break;case 9:sum = 243 + day;break;case 10:sum = 273 + day;break;case 11:sum = 304 + day;break;case 12:sum = 334 + day;break;default :printf(输入的月份有错误

20、n);break;return sum;int birthday(int month1,int day1)/生日距离第一天的天数(int sum1 = 0;switch(month1) (case 1:sum1 = day1;break;case 2:sum1 = 31 + day1;break;case 3:sum1 = 59 + day1;break;case 4:sum1 = 90 + dayl;break;case 5:sum1 = 120 + dayl;break;case 6:sum1 = 151 + dayl;break;case 7:sum1 = 181 + day1;brea

21、k;case 8:sum1 = 212 + day1;break;case 9:sum1 = 243 + day1;break;case 10:sum1 = 273 + day1;break;case 11:sum1 = 304 + day1;break;case 12:sum1 = 334 + day1;break;default :printf(输入的月份有错误n);break;return sum1;int main()int month1 ,day1, month ,day;int sum;printf(请输入生日月日(XX-XX) :);scanf(%d-%d,&month1,&day1);printf(”请输入今天月日(XX-XX) :);scanf(%d-%d,&month,&day);sum = birthday(month1, day1)-today(month, day);if(sumout birthdayc nny nny-virtual-m

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论