2023年Linu程序设计实验报告大作业.pdf
《2023年Linu程序设计实验报告大作业.pdf》由会员分享,可在线阅读,更多相关《2023年Linu程序设计实验报告大作业.pdf(37页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、实 验 报 告 课 程 名 称:_ LI N U X程 序 设 计 _学 院:计 算 机 学 院 _专 业:软 件 工 程 班 级:14 3姓 名:张 正 银 学 号:一 2 0 2 3 年 1 月 1 日 山 东 科 技 大 学 教 务 处 制 实 验 报 告组 别 姓 名 张 正 馄 同 组 实 验 者 实 验 项 目 名 称 实 验 一 熟 悉 L in u x命 令 实 验 日 期 第 1 1 周 周 四 9,10 节 教 师 评 语 实 验 成 绩 指 导 教 师 一、实 验 目 的 熟 悉 并 掌 握 Linux操 作 系 统 基 本 命 令 二、常 用 的 普 通 命 令 1.了
2、 解 系 统 的 u name,dat e,w命 令 kunvm:$uname-aLinux vn 4.4.0-31-generic#50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Ltnuxkunvm:-$date2016年 12月 28日 星 期 三 16:53:36 CSTkunvm:$w16:53:42 up 12 min,1 user,load average:0.06,0.21,0.28USER TTY FROM LOGIN IDLE JCPU PCPU WHATkun tty7:0 16:41
3、 12:35 4.91s 0.53s/sbin/upstart kunvn:$|2.了 解 文 献 的 Is和 f i Ie命 令 kunvn:-$IsDesktop Downloads Learn Pictures TemplatesDocuments examples.desktop Music Public Videoskunvm:-$file examples.desktopexamples.desktop:UTF-8 Unicode textkunvm:$3.ca t,1 e ss,head,t ail,nb wc 等 命 令 的 使 用kunvm:-$cat my.c#includ
4、e#include int main()printf(*ptd:%dnH,getpid();printf(ppid:%dnn,getppid();return 0;kunvm:-$tail-n 3 my.cp tntf(pptd:%dn,getppid();return 0;)kunvm:$head-n 3 my.c#include#include kunvn:$nl my.c1#Include 2/Include 34 int main()5 printf(,pid:%dnH,getpid();6 printf(pptd:%dn,getppid();7 return 0;8 kunvm:-$
5、wc my.c8 14 140 my.c4.文 本 内 容 查 找 gre p 命 令 kunvn:$cat my.c|grep include#include winclude 5.文 献 权 限 的 修 改 chm o d,ch o wn,uma s kcunvn:-$Is-I my.c-rw-r-r-1 kun kun 140 12月 28 17:01 ny.ccunvn:*$sudo chmod 777 my.c:sudo password for kun:unvn:$Is-I my.c rwxrwxrwx 1 kun kun 140 12月 28 17:01 ny.ccunvn:-$
6、sudo chown root:root my.ccunvm:-$Is-I my.c-rwxrwxrwx 1 root root 140 12月 28 17:01 my.ccunvn:-$|6.文 献 夹 操 作:mkd i r,rmd i rkunvm:5 IsDesktop Downloads Learn Pictures TemplatesDocuments examples.desktop Music Public Videoskunvm:$mkdtr dtrlkunvm:$IsDesktop 1 Documents examples.desktop)Music Public Vide
7、osdtrl 1 Downloads Learn Pictures Templateskunvm:5 rmdir dtrl/kunvm:5 IsDesktop Downloads Learn Pictures TemplatesDocuments examples.desktop Music Public Videoskunvm:*$三、用 户 和 组 的 管 理 管 理 1.探 究 用 户 配 置 文 献/e t c/passwd,/et c/s h adowkunvm:-*$sudo tail-n 5/etc/passwdpulse:x:117:124:PulseAudto daemon,
8、:/var/run/pulse:/btn/falsertkit:x:118:126:RealttmeKit,:/proc:/bin/falsesaned:x:119:127:/var/ltb/saned:/btn/falseusbmux:x:120:46:usbmux daemon,f:/var/ltb/usbmux:/btn/falsekun:x:1000:10OO:kun,:/home/kun:/bin/bashk u n 0 v m:sudo tail-n 5/etc/shadowpulse:*:17001:0:99999:7:rtkit:*:17001:0:99999:7:saned:
9、*:17001:0:99999:7:usbmux:*:17001:0:99999:7:kun:$6$/4hN636M$3yCKhbKmCQ23wNlF01Zh.mtkm3.R/Yxr3IXk2ehFoYsNUMR7w7ZldSnce75s6kbMVwidgP8r5IBLz.:17150:0:99999:7:::kunvn:$|/e tc/p a ssw d是 用 户 数 据 库,其 中 的 域 给 出 了 用 户 名、加 密 口 令 和 用 户 的 其 他 信 息./e tc/s h a d o w是 在 安 装 了 影 子(sh a dow)口 令 软 件 的 系 统 上 的 影 子 口 令
10、 文 献。影 子 口 令 文 献 将/etc/p a ssw d文 献 中 的 加 密 口 令 移 动 到/etc/shadow中,而 后 者 只 对 超 级 用 户(r o o t)可 读。这 使 破 译 口 令 更 困 难,以 此 增 长 系 统 的 安 全 性。2.探 究 组 配 置 文 献 组 的 配 置 文 献/etc/g roup,/e t c/gsh a d o wkunvm:-$sudo tail-n 5/etc/grouppulse-access:x:125:rtkit:x:126:saned:x:127:kun:x:1000:sambashare:x:128:kunkunv
11、m:-$sudo tail-npulse-access:!:rtkit:!:saned:!:kun:!:sambashare:!:kunkunvm:-$5/etc/gshadow3.i d,w h o,wh o ami,g r o u p s 等 命 令 kun(bvm:*$iduid=1000(kun)gid=1000(kun)groups=10O0(kun),4(adm),24(cdrom),27(sudo),3O(dip),46(plugdev),113(Ipadmtn),128(sambashare)kunvm:$whokun tty7 2016-12-29 10:05(:0)kun0
12、vm:$whoamtkunkunvm:-$groupskun adm cdrom sudo dip plugdev Ipadmtn sambasharekunVE:$四、文 献 打 包 与 压 缩 1.ta r压 缩 和 解 压 kunvm:-$IsDesktop Downloads Learn Pictures TemplatesDocuments examples.desktop Music Public Videoskunvn:-$tar-zcvf learn.tar.gz Learn/Learn/Learn/6-2.cLearn/6-4Learn/6-2.oLearn/6-3.oLea
13、rn/6-4.oLearn/6-l.cLearn/6-l.oLearn/6-4.cLearn/6-3.ckunvm:-$IsDesktopDocumentsDownloadsexamples.desktopLearnlearn.tar.gzMusic PublicPictures TemplatesVideos,IsDesktop Downloads Learn Music Public VideosDocuments examples.desktop learn.tar.gz Pictures Templateskunvm:$tar-zxvf learn.tar gzLearn/Learn/
14、6-2 cLearn/6-4Learn/6-2 0Learn/6-3 0Learn/6-4 0Learn/6-1 cLearn/6-1 0Learn/6-4 cLearn/6-3 c五、软 件 包 管 理 1.安 装 软 件 treekunvm:*$sudo apt-get install treeReading package lists.DoneBuilding dependency treeReading state information.DoneThe following NEW packages will be installed:tree0 upgraded,1 newly in
15、stalled,0 to remove and 11 not upgraded.Need to get 40.6 kB of archives.After this operation,138 kB of additional disk space will be used.Get:1 http:/xenial/universe amd64 tree amd64 1.7.0-3 40.6 kBFetched 40.6 kB in 2s(18.5 kB/s)Selecting previously unselected package tree.(Reading database 216049
16、files and directories currently installed.)Preparing to unpack./tree_1.7.0-3_amd64.deb,Unpacking tree(1.7.0-3).Processing triggers for man-db(2.7.5-1)Setting up tree(1.7.0-3).2.卸 载 软 件 treekunvn:-$sudo apt-get remove treeReading package lists.DoneBuilding dependency treeReading state information.Don
17、eThe following packages will be REMOVED:tree0 upgraded,0 newly installed,1 to remove and 11 not upgraded.After this operation,138 kB disk space will be freed.Do you want to continue?Y/n y(Reading database.216055 files and directories currently installed.)Removing tree(1.7.0-3)Processing triggers for
18、 man-db(2.7.5-1)kunvm:-$treeThe program tree is currently not installed.You can install it by typing:sudo apt install treekunvm:-$六、进 程 管 理 1.to p 命 令 动 态 显 示 进 程 状 态 top 10:30:18 up 25 min,1 user,load average:0.22,0.13,0.13Tasks:251 total,1 running,250 sleeping,0 stopped,0 zombie%Cpu(s):2.3 us,3.2
19、sy,0.8 nt,89.4 id,4.2 wa,0.0 hi,0.1 si,0.0 stKiB Men:2630628 total,188516 free,625036 used,1217076 buff/cacheKtB Swap:2694076 total,2096840 free,3236 used.1165776 avail MemPID USER PR NI VIRT RES SHR S%CPU%MEM TIME+COMMAND1 root 20 0 119620 5716 3928 S 0.0 0.3 0:03.22 systemd2 root 20 0 0 0 0 S 0.0
20、0.0 0:00.02 kthreadd3 root 20 0 0 0 0 S 0.0 0.0 0:00.08 ksoftirqd+5 root 0-26 0 0 0 S 0.0 0.0 0:60.00 kworker/0+7 root 20 0 0 0 0 S 6.0 0.0 0:01.70 rcu sched8 root 20 0 6 0 0 S 0.0 0.0 0:00.00 rcu bh9 root rt 0 0 0 0 S 0.0 0.0 0:00.12 migrattori2.p s命 令 显 示 瞬 时 进 程 状 态 USERrootrootrootrootrootrootro
21、otrootrootrootrootps-auxPID%CPU%MEM vsz RSS TTY119620 57160 00 0?0 070 070 076 0?0 00 00 00 Q7STAT STARTSs 10:04S 10:04S 10:0410:0410:0410:0410:0410:0410:0410:0410:045SSSSSSC.TIME COMMAND0:03/sbin/intt spl0:00 kthreadd0:00 ksoftirqd/00:00 kworker/0:0H0:01 rcu_sched0:00 rcu_bh0:00 mtgratton/O0:00 wat
22、chdog/00:00 watchdog/10:00 migration/10:0?rksoftirod/ll3.K i I I命 令 终 止 一 个 进 程 用 gedit打 开 一 个 文 献 a.c p p并 在 后 台 运 营,显 示 的 进 程 号 为 1 7 27 1,然 后 用 kill命 令 杀 死 这 个 进 程,观 测 到 g e d i t 关 闭 kunvn:$gedit a.cpp&1 17271kunvn:$sudo k i l l 17271kunvm:$七、实 验 总 结 通 过 本 次 实 验,熟 悉 了 好 多 Linux下 面 的 基 本 命 令,可 以
23、看 出 Lin u x 的 命 令 基 本 上 都 有 好 多 参 数 可 选,这 样 就 可 以 用 一 条 命 令 完 毕 好 多 任 务,大 大 提 高 效 率。此 外 还 学 会 了 当 命 令 不 会 使 用 的 时 候,可 以 调 用 man来 查 看 命 令 的 使 用 方 法。实 验 报 告 组 别 姓 名 张 正 银 同 组 实 验 者 实 验 项 目 名 称 实 验 二 Sh e II编 程 实 验 日 期 第 1 2 周 周 四 9,1 0 节 教 师 评 语 实 验 成 绩 指 导 教 师 一、实 验 目 的 掌 握 Shell命 行 的 运 营 掌 握 编 写 和 执
24、 行 S h e门 程 序 的 环 节 掌 握 在 S h e ll中 使 用 参 数 和 使 用 变 量 的 方 法 掌 握 表 达 式 比 较,循 环 结 构 语 句 和 条 件 结 构 语 句 的 写 法 掌 握 在 s h e 1 1脚 本 中 使 用 函 数 的 方 法 二、简 朴 b a s h 脚 本 1.编 写 b a s h 脚 本 kunvm:/Learn$cat ch2-l.sh#!/bin/bash#一 个 裔 单 例 子 whopwddate2.添 加 执 行 权 限 kunQvm:*/Learn$sudo chmod+x ch2-1.shsudo password
25、for kun:3.运 营 结 果 kunvm:*/Learn$./ch2-1.shkun tty7 2016-12-30 10:25(:6)/home/kun/Learn2016年 12月 30 0 星 期 五 10:47:48 CSTkunvm:/Learn$|三、计 算 器:变 量 读 入 和 输 出 1.编 辑 程 序 kunvn:/Learn$vim ch2-2.shkunvm:/Learn$cat ch2-2.shttl/btn/shread x yz=expr$x+$yecho The sum is$z2.添 加 可 执 行 权 限 k:/Leain$chmod+x ch2-2.
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2023 Linu 程序设计 实验 报告 作业
限制150内