实验一:熟悉linux命令

上传人:mg****85 文档编号:34796228 上传时间:2018-03-01 格式:DOC 页数:17 大小:489KB
返回 下载 相关 举报
实验一:熟悉linux命令_第1页
第1页 / 共17页
实验一:熟悉linux命令_第2页
第2页 / 共17页
实验一:熟悉linux命令_第3页
第3页 / 共17页
实验一:熟悉linux命令_第4页
第4页 / 共17页
实验一:熟悉linux命令_第5页
第5页 / 共17页
点击查看更多>>
资源描述

《实验一:熟悉linux命令》由会员分享,可在线阅读,更多相关《实验一:熟悉linux命令(17页珍藏版)》请在金锄头文库上搜索。

1、操作系统实验报告 实验一:熟悉Linux 命令 一、 实验目的 熟悉Linux 系统,掌握Linux 系统的登入、退出等操作; 熟悉Linux 命令及进程管理; 学会使用Linux 下C 语言编程的基本知识; 二、 实验内容 1、Linux 基本操作 2、文件与目录操作 3、进程查看及在线帮助 4、全屏幕文本编辑器 Vi 的熟悉 5、Linux 下 C 语言编程基础知识 三、 代码及运行结果分析 1、Linux 基本操作,Linux 系统的登入 1.文件与目录的基本操作 显示文件目录命令 ls 改变当前目录命令 cd 建立子目录 mkdir 删除子目录命令 rmdir 删除文件命令 rm 文件

2、改名命令 mv文件复制命令 cp 2、进程查看命令 进程查看 who 命令ps 命令top 命令 4、在线帮助 联机帮助 man 命令联机帮助 help 命令whereis 命令查看 ls 命令所在位置 5、全屏幕文本编辑器 Vi 及 Linux 下 C 语言基础编程 1) e06620208localhost e06620208$ vi sj.c #include int main() printf(“helloworld“); return 0; : “sj.c“ New 6L, 65C written e06620208localhost e06620208$ gcc sj.c -o s

3、j e06620208localhost e06620208$ ./sj helloworlde06620208localhost e06620208$ 2) e06620208localhost e06620208$ vi sjj.c #include main() printf(“The current process ID is %dn“,getpid(); “sjj.c“ New 5L, 83C written e06620208localhost e06620208$ gcc sjj.c -o sjj e06620208localhost e06620208$ ./sjj The c

4、urrent process ID is 24189 e06620208localhost e06620208$ vi 1.c #include #include main() pid_t pid; pid=fork(); if(pid main() printf(“this process will exit!n“); exit(0); printf(“never be displayed!n“); “jj.c“ New 7L, 114C written e06620208localhost e06620208$ gcc jj.c -o jj e06620208localhost e0662

5、0208$ ./jj this process will exit! 分析:程序运行到 exit(0);时将退出 printf(); 语句不执行,程序最终输出 this process will exit! 4) e06620208localhost e06620208$ vi jjj.c #include #include main() pid_t pid; pid=fork(); if(pid #include #include #include main() pid_t pc,pr; pc=fork(); if(pc main() int p1,p2; while(p1=fork()=-

6、1); if(p1=0) printf(“b.My process ID is %d“,getpid(); elsewhile(p2=fork()=-1); if(p2=0) printf(“c.My process ID is %d“,getpid(); 25225 25 25225 i=25225 i=0 进程号else printf(“a.My process ID is %d“,getpid(); “s2.c“ New 15L, 279C written e06620208localhost e06620208$ gcc s2.c -o s2 e06620208localhost e0

7、6620208$ ./s2 b.My process ID is 25425c.My process ID is 25426a.My process ID is 25424e066202 07localhost e06620208$ 分析:程序 2 运行,满足 p1=0,输出父进程 ID ,p1=fork(),p1 值发生改变, else 条件满足,之后再判断 p2 的值同样输出子进程的 ID,最后输出下级子进 程的 ID,运行结果如上。程序执行后其进程树如下: 3) e06620208localhost e06620208$ vi s3.c #include main() int m,n,k

8、; m=fork(); printf(“PID:%dt“,getpid(); printf(“The return value of fork():%dtt“,m); printf(“hen“); n=fork(); printf(“PID:%dt“,getpid(); printf(“The return value of fork():%dtt“,n); printf(“han“); k=fork(); printf(“PID:%dt“,getpid(); printf(“The return value of fork():%dtt“,k); printf(“hon“); “s3.c“

9、New 17L, 347C written e06620208localhost e06620208$ gcc s3.c -o s3 e06620208localhost e06620208$ ./s3 PID:25580 The return value of fork():0 he PID:25581 The return value of fork():0 ha PID:25582 The return value of fork():0 ho PID:25581 The return value of fork():25582 ho PID:25580 The return value of fork():25581 ha PID:25579 The return value of fork():25580 he PID:25584 The return value of fork():0 ha 25424 25425 25426 p1=25425,p2=25426 p1=25425,p2=0 p1=0,p2=0

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号