中南大学Linux系统实验报告_第1页
中南大学Linux系统实验报告_第2页
中南大学Linux系统实验报告_第3页
中南大学Linux系统实验报告_第4页
中南大学Linux系统实验报告_第5页
已阅读5页,还剩29页未读 继续免费阅读

下载本文档

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

文档简介

1、Unix/Linux系统实验报告 学 院: 信息科学与工程学院 指导老师: 胡小龙 班 级: 信息安全1401班 学 号: 姓 名: 孙毅 时 间: 2016年12月 实验一 Linux的安装(课后)11、实验目的12、实验设备13、实验原理14、实验步逐1Linux安装过程:1实验2 Linux基本操作91、 实验目的92、实验内容93、实验记录15实验3 Linux系统管理191、实验目的192、实验内容193、实验记录20实验4 Linux Shell程序设计221、实验目的222、实验内容223、实验结果23实验5 Linux 高级程序设计251、实验目的252、 实验内容25实验6

2、Linux内核281、实验目的282、实验内容28心得体会31实验一 Linux的安装(课后)1、实验目的(1) 了解硬盘分区的概念和方法;(2) 掌握硬盘的分区规划;(3) 掌握Linux操作系统的安装和配置过程。2、实验设备一台pc机、RedHat Linux 7.2以上版本、VMware Workstation v5.53、实验原理Linux可以以多种方式安装在PC机上: (1)独立分区安装; (2)DOS分区安装; (3)虚拟机VMWare下安装。鉴于VMware下安装对原来系统影响较小且不影响本实验目的,因此采用VMWare下安装方式。4、实验步逐 (1) 在Windows XP下安

3、装VMware 5.5(2) 配置虚拟机(3) 启动虚拟机(4) 启动Linux安装过程(5) 安装过程配置(6) 安装后配置(7) 第1次启动 VMWare下Linux操作系统Linux安装过程:(1)语言选择:(2)键盘配置: (3)鼠标配置: (4)选择安装还是升级: (5)安装类型: (6)磁盘分区设置: (7)为系统分区: (8)添加分区: (9)引导装载程序配置: (10)网络配置: (11)防火墙配置: (12)语言支持的选择: (13)时区配置: (14)设置根口令(15)选择软件包组: (16)准备安装: 应该看到一个安装 Red Hat Linux 做准备的屏幕。 当你重新

4、引导系统后,一份完整的安装日志可在 /root/install.log 中找到,以备今后参考。要取消安装进程,按计算机的重新启动按钮,或者使用 Control-Alt-Delete 组合键来重启计算机。 (17)安装软件包: (18)创建引导盘: (19)视频卡配置: (20)配置显示器: (21)定制配置: (22)安装完成实验2 Linux基本操作1、 实验目的 (1)复习Linux基本命令 (2)掌握常用Linux命令2、实验内容 (1)练习命令行模式下的常用命令: man:命令帮助ALT-Fx:虚终端切换常用命令:cat、Ls、ps、chmod、kill、ln、cp、mv、rm、cd、

5、pwd、mkdir、chown、who、w、wc、whoami、date、uname等命令实例:rootsoamazing-desktop:# touch testrootsoamazing-desktop:# cat testaaaaarootsoamazing-desktop:# lstest 公共的 模板 视频 图片 文档 下载 音乐 桌面rootsoamazing-desktop:# ps man PID TTY STAT TIME COMMAND 753 tty7 - 0:10 /usr/bin/X :0 -nr -verbose -auth /var/run/gdm/auth-fo

6、 - - Ss+ 0:10 - 1081 pts/0 - 0:00 bash - - Ss 0:00 - 1138 pts/0 - 0:00 ps man - - R+ 0:00 -rootsoamazing-desktop:# ls -ltotal 36-rw-r-r- 1 root root 6 2011-04-12 22:20 testdrwxr-xr-x 2 root root 4096 2011-04-12 15:40 公共的drwxr-xr-x 2 root root 4096 2011-04-12 15:40 模板drwxr-xr-x 2 root root 4096 2011-

7、04-12 15:40 视频drwxr-xr-x 2 root root 4096 2011-04-12 15:40 图片drwxr-xr-x 2 root root 4096 2011-04-12 15:40 文档drwxr-xr-x 2 root root 4096 2011-04-12 15:40 下载drwxr-xr-x 2 root root 4096 2011-04-12 15:40 音乐drwxr-xr-x 2 root root 4096 2011-04-12 15:40 桌面rootsoamazing-desktop:# chmod 888 testchmod: invali

8、d mode: 888Try chmod -help for more information.rootsoamazing-desktop:# chmod -helpUsage: chmod OPTION. MODE,MODE. FILE. or: chmod OPTION. OCTAL-MODE FILE. or: chmod OPTION. -reference=RFILE FILE.Change the mode of each FILE to MODE. -c, -changes like verbose but report only when a change is made -n

9、o-preserve-root do not treat / specially (the default) -preserve-root fail to operate recursively on / -f, -silent, -quiet suppress most error messages -v, -verbose output a diagnostic for every file processed -reference=RFILE use RFILEs mode instead of MODE values -R, -recursive change files and di

10、rectories recursively -help display this help and exit -version output version information and exitEach MODE is of the form ugoa*(-+=(rwxXst*|ugo)+.Report chmod bugs to GNU coreutils home page: General help using GNU software: Report chmod translation bugs to rootsoamazing-deskto

11、p:# ls -ltotal 36-rw-r-r- 1 root root 6 2011-04-12 22:20 testdrwxr-xr-x 2 root root 4096 2011-04-12 15:40 公共的drwxr-xr-x 2 root root 4096 2011-04-12 15:40 模板drwxr-xr-x 2 root root 4096 2011-04-12 15:40 视频drwxr-xr-x 2 root root 4096 2011-04-12 15:40 图片drwxr-xr-x 2 root root 4096 2011-04-12 15:40 文档drw

12、xr-xr-x 2 root root 4096 2011-04-12 15:40 下载drwxr-xr-x 2 root root 4096 2011-04-12 15:40 音乐drwxr-xr-x 2 root root 4096 2011-04-12 15:40 桌面rootsoamazing-desktop:# chmod u-w,g+w,o+w testrootsoamazing-desktop:# ls -ltotal 36-r-rw-rw- 1 root root 6 2011-04-12 22:20 testdrwxr-xr-x 2 root root 4096 2011-0

13、4-12 15:40 公共的drwxr-xr-x 2 root root 4096 2011-04-12 15:40 模板drwxr-xr-x 2 root root 4096 2011-04-12 15:40 视频drwxr-xr-x 2 root root 4096 2011-04-12 15:40 图片drwxr-xr-x 2 root root 4096 2011-04-12 15:40 文档drwxr-xr-x 2 root root 4096 2011-04-12 15:40 下载drwxr-xr-x 2 root root 4096 2011-04-12 15:40 音乐drwx

14、r-xr-x 2 root root 4096 2011-04-12 15:40 桌面rootsoamazing-desktop:# chmod u+w,g-w,o-w testrootsoamazing-desktop:# ls -ltotal 36-rw-r-r- 1 root root 6 2011-04-12 22:20 testdrwxr-xr-x 2 root root 4096 2011-04-12 15:40 公共的drwxr-xr-x 2 root root 4096 2011-04-12 15:40 模板drwxr-xr-x 2 root root 4096 2011-04

15、-12 15:40 视频drwxr-xr-x 2 root root 4096 2011-04-12 15:40 图片drwxr-xr-x 2 root root 4096 2011-04-12 15:40 文档drwxr-xr-x 2 root root 4096 2011-04-12 15:40 下载drwxr-xr-x 2 root root 4096 2011-04-12 15:40 音乐drwxr-xr-x 2 root root 4096 2011-04-12 15:40 桌面rootsoamazing-desktop:# lnln: missing file operandTry

16、 ln -help for more information.rootsoamazing-desktop:# ln -helpUsage: ln OPTION. -T TARGET LINK_NAME (1st form) or: ln OPTION. TARGET (2nd form) or: ln OPTION. TARGET. DIRECTORY (3rd form) or: ln OPTION. -t DIRECTORY TARGET. (4th form)In the 1st form, create a link to TARGET with the name LINK_NAME.

17、In the 2nd form, create a link to TARGET in the current directory.In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.Create hard links by default, symbolic links with -symbolic.When creating hard links, each TARGET must exist. Symbolic linkscan hold arbitrary text; if later resolved,

18、 a relative link isinterpreted in relation to its parent directory.Mandatory arguments to long options are mandatory for short options too. -backup=CONTROL make a backup of each existing destination file -b like -backup but does not accept an argument -d, -F, -directory allow the superuser to attemp

19、t to hard link directories (note: will probably fail due to system restrictions, even for the superuser) -f, -force remove existing destination files -n, -no-dereference treat destination that is a symlink to a directory as if it were a normal file -i, -interactive prompt whether to remove destinati

20、ons -s, -symbolic make symbolic links instead of hard links -S, -suffix=SUFFIX override the usual backup suffix -t, -target-directory=DIRECTORY specify the DIRECTORY in which to create the links -T, -no-target-directory treat LINK_NAME as a normal file -v, -verbose print name of each linked file -he

21、lp display this help and exit -version output version information and exitThe backup suffix is , unless set with -suffix or SIMPLE_BACKUP_SUFFIX.The version control method may be selected via the -backup option or throughthe VERSION_CONTROL environment variable. Here are the values: none, off never

22、make backups (even if -backup is given) numbered, t make numbered backups existing, nil numbered if numbered backups exist, simple otherwise simple, never always make simple backupsReport ln bugs to GNU coreutils home page: General help using GNU software: Report ln translation b

23、ugs to rootsoamazing-desktop:# whoroot tty7 2011-04-12 22:11 (:0)root pts/0 2011-04-12 22:12 (:0.0)rootsoamazing-desktop:# whoamirootrootsoamazing-desktop:# (2) 编辑器vi的使用:使用vi建立并修改一个文本文件rootsoamazing-desktop:# vi test(3) 档案管理:rpm、gzip、tar等命令(4) 网络命令: telnet、ftp、talk3、实验记录在实验过程中,记录到的实验现象: 系统启动1、 Man l

24、s按q退出2、 w、who、whoami命令 查看当前登录主机的所有用户3、 查看自己的bash相关进程:ps l4、 rpm命令Linux是否安装logrotate软件,并且列出属于该软件所提供的所有目录和文件5、 将/etc/man.config复制到/tmp中,并且以gzip压缩6、使用tar备份/etc/man.config目录 7、由于本机网络配置及其软件下载问题,导致网络设置命令无法成功实现实验3 Linux系统管理1、实验目的(1)掌握Linux基本系统管理命令 (2)掌握基本管理方法(3)初步了解Linux中与系统管理相关的有关配置文件2、实验内容 (1) 用户管理adduse

25、r、useradd、passwd等观察:/etc/passwd文件 (2) 文件系统管理df、du命令使用mount、umount命令使用:安装usb盘或者光盘,查看分析/etc/fstab文件 (3) 存储器free:了解存储器使用情况 (4) 关机halt、shutdown h、init 0reboot、shutdown -r now并比较它们之间的差别 (5) 网络配置netconfig的使用 (6)启动配置/etc/inittab:查看、修改并观察其响应3、实验记录在实验过程中,注意记录实验现象A、用户管理 建立新的用户:gang,并且设置密码B、文件系统管理 分别用df h将容量结果

26、以易读的容量格式显示出来,用du显示出了/etc/man.config的内容。 挂载了用来安装linux的原版光盘,用df查看后,解除了挂载C、存储器 Free命令 实验4 Linux Shell程序设计1、实验目的(1)掌握Linux shell程序运行方法 (2)掌握Linux Shell程序基本语法(3)了解Linux环境变量(3)编写简单Linux shell程序 2、实验内容(1) 查看/etc/.profile文件:相当于DOS下autoexe.bat(2) 通配符“*”、“?”、“”的使用$ls a-c* 和 $ls a,m,t*命令 (3)重定向和管道的使用ls | more

27、cat test.txt(4) 变量$lookup=/usr/mydir $echo $lookup $export lookup:让进程使用(5) 编辑并运行以下程序(shell程序控制结构)1 、fortest #!/bin/bash for a in x y zdo echo now a=$adone2 、fortest1 #!/bin/bash for ado echo now a=$adone3、 functest #!/bin/bashsetup()echo setupdo_date()datechgdir()cd $1do_datesetupchgdir4、 paramtest#

28、!/bin/bashecho filename:$0echo arguments:$*echo number arg:$#echo arg2:$2shiftecho number arg:$#echo arg2:$2set hello,everoneecho args:$*echo arg2:$25 、untiltest#!/bin/bashnumber=0until (test $number gt 5)doecho “ $number”number=expr $number + 1done3、实验结果程序调试及运行结果如下:实验5 Linux 高级程序设计1、实验目的(1)了解Linux操

29、作系统下应用程序开发流程(2)掌握gun工具链的使用(3)了解Linux高级编程技巧(例如IPC机制、系统调用等)2、 实验内容 (1)编写一个简单的C语言程序,编写Makefile文件。了解编译过程,并用gdb进行调试。#include int main(void)printf(Hello World!);调试: gcc helloworld.c a.out (2)以下任选其一:1、编写一个多进程通信程序,采用Message Queue或shared Memory或者Maped File机制进行通信2、编写一个多线程程序(pthread),实现2程同步互斥源代码:#include #incl

30、ude #define BUFFER_SIZE 16 struct prodcons/ 缓冲区相关数据结构int bufferBUFFER_SIZE; pthread_mutex_t lock; int readpos, writepos; pthread_cond_t notempty; pthread_cond_t notfull; ;void init(struct prodcons *b)pthread_mutex_init(&b-lock, NULL);pthread_cond_init(&b-notempty, NULL);pthread_cond_init(&b-notfull,

31、 NULL);b-readpos = 0;b-writepos = 0;void put(struct prodcons *b, int data)pthread_mutex_lock(&b-lock);if (b-writepos + 1) % BUFFER_SIZE = b-readpos)pthread_cond_wait(&b-notfull, &b-lock);b-bufferb-writepos = data;b-writepos+;if (b-writepos = BUFFER_SIZE)b-writepos = 0;pthread_cond_signal(&b-notempty

32、);pthread_mutex_unlock(&b-lock);int get(struct prodcons *b)int data;pthread_mutex_lock(&b-lock);if (b-writepos = b-readpos)pthread_cond_wait(&b-notempty, &b-lock);data = b-bufferb-readpos;b-readpos+;if (b-readpos = BUFFER_SIZE)b-readpos = 0;pthread_cond_signal(&b-notfull);pthread_mutex_unlock(&b-loc

33、k);return data;#define OVER ( - 1)struct prodcons buffer;void *producer(void *data)int n;for (n = 0; n n, n);put(&buffer, n); put(&buffer, OVER);return NULL;void *consumer(void *data)int d;while (1)d = get(&buffer);if (d = OVER)break;printf(-%d n, d);return NULL;int main(void)pthread_t th_a, th_b;vo

34、id *retval;init(&buffer);pthread_create(&th_a, NULL, producer, 0);pthread_create(&th_b, NULL, consumer, 0);pthread_join(th_a, &retval);pthread_join(th_b, &retval);return 0;实验6 Linux内核1、实验目的(1)了解Linux操作系内核(2)掌握内核编译和内核升级方法(3)了解有关内核编程2、实验内容(1) 内核配置和编译(课后完成)(2) 察看/proc内存文件系统下的文件,写出每个目录内容(3) 编写一个简单的字符虚拟设

35、备程序(以模块方式编译、加载、使用)struct file_ operations status_ fops = NULL, /* seek */read_ status,write_ status,NULL, /* readdir */NULL, /* poll */NULL, /* ioctl */NULL, /* mmap */open_ status,NULL, /* flush */close_ status,NULL, /* fsync */NULL, /* fasync */NULL, /* check_ media_ change */NULL, /* revalidate *

36、/NULL, /* lock */;创建这个设备:mknod /dev/status c 0static int major_ number = 0; /* pass a major of 0 to register_ chrdev* for dynamic allocation*/int init_ module( void)major_ number = register_ chrdev( 0, status, &status_ fops);if (major_ number count) ? count : char_ count;copy_ to_ user( buffer, message, count_ to_ copy); /* write to the user- space buffer */return char_ count; 心得体会 之前都是用的Windows系统,突然用到linux系统,最开始是感觉很别扭很不习惯,到后来用了一段时间之后再去用windows发现很不习惯了,这才意识到原来linux系统这么好用,这么神奇,感觉会一点linux系统的人都是大神;在做此次试验的过程中,我也学到了linux的更多的知识: Linux是一套免费使用和自由传播的类Unix操作系统,是一个基于POSIX和UNIX的

温馨提示

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

评论

0/150

提交评论