Linux系统管理习题.docx

上传人:s****u 文档编号:12766829 上传时间:2020-05-23 格式:DOCX 页数:11 大小:75.68KB
返回 下载 相关 举报
Linux系统管理习题.docx_第1页
第1页 / 共11页
Linux系统管理习题.docx_第2页
第2页 / 共11页
Linux系统管理习题.docx_第3页
第3页 / 共11页
点击查看更多>>
资源描述
第四章 shell命令 1、启动linux系统,进入默认的目录,在当前路径下添加新用户student,并设置该用户的登录密码,再显示已登录的用户(只输出用户名和用户数) rootbogon # cd /home rootbogon home# useradd student 正在创建信箱文件: 文件已存在 rootbogon home# passwd student 更改用户 student 的密码 。 新的 密码: 重新输入新的 密码: passwd: 所有的身份验证令牌已经成功更新。 2、切换到student用户的用户主目录下;在student用户主目录下创建一个临时目录tmp;在临时目录下创建一个文件,文件名为a.txt;将a.txt复制成b.txt;将b.txt改名成c.txt;为c.txt创建符号链接,链接文件名为linkc.txt;使用gzip压缩创建/etc的归档,将文件另存为/home/student/tmp/etc.tar.gz;将压缩的归档文件解压到/backups目录;删除tmp目录 rootbogon home# cd student rootbogon student# mkdir tmp rootbogon student# ls tmp rootbogon student# cd tmp rootbogon tmp# touch a.txt rootbogon tmp# ls a.txt rootbogon tmp# cp a.txt b.txt rootbogon tmp# ls a.txt b.txt rootbogon tmp# mv b.txt c.txt rootbogon tmp# ls a.txt c.txt rootbogon tmp# ln -s c.txt linkc.txt rootbogon tmp# ls a.txt c.txt linkc.txt rootbogon tmp# tar -zcvf /home/student/tmp/etc.tar.gz /etc rootbogon tmp# cd /backups rootbogon tmp# tar -zxvf /home/student/tmp/etc.tar.gz rootbogon # ls /backups etc rootbogon # cd /home/student rootbogon student# rm -r tmp rm:是否进入目录tmp? y rm:是否删除符号链接 tmp/linkc.txt?y rm:是否删除普通空文件 tmp/c.txt?y rm:是否删除普通文件 tmp/etc.tar.gz?y rm:是否删除普通空文件 tmp/a.txt?y rm:是否删除目录 tmp?y rootbogon student# ls rootbogon student# 3、列出用户主目录下的所有目录文件;列出所有属主权限为rwx的文件; 打印 /etc/passwd 中冒号之间是三位数的行;列出 /usr/share/doc 中以数字4结尾的文件;列出 /etc/hosts 中包含数字的所有行 ;打印 /etc/hosts 中包含 127.0.0.1 的行 rootbogon # cd /home rootbogon home# ls guo liukang student rootbogon home# ls -l|grep rwx drwx-. 4 student student 4096 6月 6 04:34 guo drwx-. 30 liukang liukang 4096 6月 9 07:14 liukang drwx-. 4 student student 4096 6月 22 00:29 student rootbogon home# grep :0-90-90-9: /etc/passwd games:x:12:100:games:/usr/games:/sbin/nologin usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin rtkit:x:499:499:RealtimeKit:/proc:/sbin/nologin abrt:x:498:498:/etc/abrt:/sbin/nologin saslauth:x:497:495:Saslauthd user:/var/empty/saslauth:/sbin/nologin pulse:x:496:494:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin liukang:x:500:500:小康维尼:/home/liukang:/bin/bash student:x:501:501:/home/student:/bin/bash rootbogon home# ls /usr/share/doc | grep 4$ attr-2.4.44 audit-2.0.4 authconfig-6.1.4 coreutils-8.4 cronie-1.4.4 cups-pk-helper-0.0.4 dbus-1.2.24 desktop-effects-0.8.4 DeviceKit-power-014 dmz-cursor-themes-0.4 dracut-004 dracut-kernel-004 efibootmgr-0.5.4 enscript-1.6.4 file-5.04 foomatic-4.0.4 gcc-4.4.4 gdm-2.30.4 gedit-2.28.4 gnupg2-2.0.14 groff-1.18.1.4 gtk2-engines-2.18.4 hal-0.5.14 ibus-1.3.4 iwl4965-firmware-228.61.2.24 keyutils-libs-1.4 libcap-ng-0.6.4 libdaemon-0.14 libgcc-4.4.4 libglade2-2.6.4 libgomp-4.4.4 libiptcdata-1.0.4 libogg-1.1.4 libpng-1.2.44 libraw1394-2.0.4 libspectre-0.2.4 libtiff-3.9.4 libXfixes-4.0.4 libXres-1.0.4 libXvMC-1.0.4 lohit-gujarati-fonts-2.4.4 lohit-punjabi-fonts-2.4.4 lua-5.1.4 mailx-12.4 MAKEDEV-3.24 nautilus-2.28.4 openobex-1.4 pakchois-0.4 pbm2l2030-1.4 pciutils-3.1.4 pnm2ppa-1.04 poppler-0.12.4 portreserve-0.0.4 python-mako-0.3.4 rdate-1.4 redhat-logos-60.0.14 setup-2.8.14 smp_utils-0.94 sysstat-9.0.4 system-config-users-1.2.104 traceroute-2.0.14 unique-1.1.4 urw-fonts-2.4 ustr-1.0.4 xmlrpc-c-1.16.24 xorg-x11-drv-openchrome-0.2.904 zd1211-firmware-1.4 rootbogon home# grep 0-9 /etc/hosts 192.168.58.128bogon# Added by NetworkManager 127.0.0.1localhost.localdomainlocalhost :1bogonlocalhost6.localdomain6localhost6 rootbogon home# grep 127.0.0.1 /etc/hosts 127.0.0.1localhost.localdomainlocalhost 4、写出一条命令,统计memo文件的行数,将结果写入memo.size文件中;在当前目录下创建子目录test,而后进入test子目录,并在其下创建名为myfile.txt的文件,并通过键盘将“hello world”字符串输入到myfile.txt文件中,创建另一个文件file2,将myfile.txt 与file2 合并为分file3。 rootbogon # cd /home rootbogon home# touch memo rootbogon home# touch memo.size rootbogon home# ls guo liukang memo memo.size student rootbogon home# wc memo | cat memo.size rootbogon home# cat memo.size 0 0 0 memo rootbogon home# mkdir test rootbogon home# cd test rootbogon test# touch myfile.txt rootbogon test# cat myfile.txt hellow world C rootbogon test# cat myfile.txt hellow world rootbogon test# cat file2 C rootbogon test# cat file2 myfile.txt file3 rootbogon test# cat file3 hellow world 5、在/root目录下,创建一个以自己的姓的拼音命名的文件夹,复制文件/etc/fstab到该文件夹下,文件名字不变。查看文件/root/某文件夹/fstab的前4行;统计目录/root下,所有目录文件的个数 rootbogon test# cd /root rootbogon # mkdir liu rootbogon # cp /etc/fstab liu rootbogon # ls liu fstab rootbogon # head -4 liu/fstab # # /etc/fstab # Created by anaconda on Mon Apr 21 05:43:19 2014 rootbogon # ll 总用量 112 -rw-r-r-. 1 root root 0 4月 21 01:36 = -rw-r-r-. 1 root root 0 6月 15 23:42 :a.bin -rw-. 1 root root 2717 4月 21 08:57 anaconda-ks.cfg drwxr-xr-x. 2 root root 4096 6月 22 01:31 Desktop drwxr-xr-x. 2 root root 4096 4月 21 06:36 Documents drwxr-xr-x. 2 root root 4096 4月 21 06:36 Downloads -rw-r-r-. 1 root root 0 6月 15 08:54 echo -rw-r-r-. 1 root root 39335 4月 21 08:57 install.log -rw-r-r-. 1 root root 9180 4月 21 08:55 install.log.syslog drwxr-xr-x. 2 root root 4096 6月 22 01:09 liu drwxr-xr-x. 2 root root 4096 4月 21 06:36 Music drwxr-xr-x. 2 root root 4096 4月 21 06:36 Pictures drwxr-xr-x. 2 root root 4096 4月 21 06:36 Public -rw-r-r-. 1 root root 0 6月 15 08:54 read drwxr-xr-x. 3 root root 4096 4月 22 06:27 root -rw-r-r-. 1 root root 72 6月 16 04:52 shell drwxr-xr-x. 2 root root 4096 4月 21 06:36 Templates -rw-r-r-. 1 root root 0 6月 22 01:49 text -rw-r-r-. 1 root root 42 6月 22 01:55 text3 drwxr-xr-x. 2 root root 4096 4月 21 06:36 Videos drwxr-xr-x. 2 root root 4096 4月 21 01:36 桌面 rootbogon # ls -l |grep d | wc -l 11第五章 用户和组管理 1.现雇用一组顾问从事某一项目。为每位顾问创建用户帐户,并将这些帐户掭加到作为补充组,名为consultants、组id为40000的组中。 这些帐户应在90天后终止时过期,且每个月都必须更改密码。 以下是顾问姓名及其相应用户名的列表,帐户的初始密码均应为default): Sspade, bboop, dtracy rootbogon # groupadd -g 40000 consultants rootbogon # useradd -G consultants Sspade rootbogon # useradd -G consultants bboop rootbogon # useradd -G consultants dtracy rootbogon # date -d 91-day 2014年 09月 22日 星期一 04:42:25 EDT rootbogon # chage -E 2014-9-22 -M 30 Sspade rootbogon # chage -E 2014-9-22 -M 30 bboop rootbogon # chage -E 2014-9-22 -M 30 dtracy rootbogon # tail -4 /etc/passwd student:x:501:501:/home/student:/bin/bash Sspade:x:502:502:/home/Sspade:/bin/bash bboop:x:503:503:/home/bboop:/bin/bash dtracy:x:504:504:/home/dtracy:/bin/bash rootbogon # tail -4 /etc/shadow student:$1$t2nKWO0v$4A9pXJpMluKn4ruvMhqCE.:16243:0:99999:7: Sspade:!:16244:0:30:7:16335: bboop:!:16244:0:30:7:16335: dtracy:!:16244:0:30:7:16335: rootbogon # tail -4 /etc/gshadow consultants:!:Sspade,bboop,dtracy Sspade:!: bboop:!: dtracy:!: rootbogon # passwd Sspade 更改用户 Sspade 的密码 。 新的 密码: 无效的密码: 过于简单化/系统化 重新输入新的 密码: passwd: 所有的身份验证令牌已经成功更新。 rootbogon # tail -4 /etc/shadow student:$1$t2nKWO0v$4A9pXJpMluKn4ruvMhqCE.:16243:0:99999:7: Sspade:$1$PdpjkE2w$xzCPUaPK2I4wVQg99OPL90:16244:0:30:7:16335: bboop:!:16244:0:30:7:16335: dtracy:!:16244:0:30:7:16335: 2.先建manager组,创建两个用户natasha,harry附属组为manager,创建第三个用户strlt不充许login 。 rootbogon # groupadd manager rootbogon # useradd -G manager natasha rootbogon # useradd -G manager harry rootbogon # useradd -G manager strlt -d /home/login 3.建一个用户susa,指定UID号为4000 帐户的初始密码均应为default rootbogon # useradd -u 4000 susa 4.解释下列信息描述的文件类型和存取权限;若用数值形式表示该权限分别为多少?创建一个文件并将文件的权限修改如下。 (1)drwxr-x-x (2) -r-x-xr 7-5-1 4-1-5 rootbogon # ls -l text -rw-r-r-. 1 root root 0 6月 22 01:49 text rootbogon # chmod 751 text rootbogon # ls -l text -rwxr-x-x. 1 root root 0 6月 22 01:49 text第六章 磁盘与文件系统管理 挂载与卸载U盘 rootbogon # mkdir /mnt/usb rootbogon # fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000cf7d9 Device Boot Start End Blocks Id System /dev/sda1 * 1 39 307200 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 39 2101 16567296 83 Linux /dev/sda3 2101 2611 4096000 82 Linux swap / Solaris Disk /dev/sdb: 4009 MB, 4009754624 bytes 23 heads, 23 sectors/track, 14804 cylinders Units = cylinders of 529 * 512 = 270848 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xc3072e18 Device Boot Start End Blocks Id System /dev/sdb1 * 16 14805 3911744 c W95 FAT32 (LBA) rootbogon # mount /dev/sdb1 /mnt/usb rootbogon # umount /mnt/usb第八章 进程管理 1.查看和杀死进程 rootbogon # ps -aux 68 1806 0.0 0.2 26308 5228 ? Ss Jun30 0:00 hald root 1807 0.0 0.0 18020 1160 ? S Jun30 0:00 hald-runner root 1849 0.0 0.0 20136 1076 ? S Jun30 0:00 hald-addon-inpu rootbogon # kill 1807 rootbogon # ps -aux dbus 1702 0.0 0.1 98092 2084 ? Ssl Jun30 0:01 dbus-daemon -s root 1713 0.0 0.2 97280 5104 ? Ssl Jun30 0:00 NetworkManager 2.每周六的7:30时,重新启动httpd服务 rootbogon # service atd start atrootbogon # at 7:30 at restart httpd第九章 软件管理 rootbogon # yum grouplist Loaded plugins: refresh-packagekit, rhnplugin This system is not registered with RHN. RHN support will be disabled. Setting up Group Process Installed Groups: Perl 支持 SNMP 支持 X 窗口系统 万维网服务器 Done第十章 网络基础 1.查看当前计算机主机名 rootbogon # hostname bogon 2.使用ifconfig命令配置一个以太网接口的IP为192.168.0.20 rootbogon # ifconfig eth0 192.168.0.20 rootbogon # ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:0C:29:17:05:B7 inet addr:192.168.0.20 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80:20c:29ff:fe17:5b7/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:6237 errors:0 dropped:0 overruns:0 frame:0 TX packets:5011 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:5803581 (5.5 MiB) TX bytes:664023 (648.4 KiB) 3.将网卡的IP地址设置为192.168.0.20,子网掩码为255.255.255.128 rootbogon # ifconfig eth0 192.168.0.20 netmask 255.255.255.128 rootbogon # ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:0C:29:17:05:B7 inet addr:192.168.0.20 Bcast:192.168.0.127 Mask:255.255.255.128 inet6 addr: fe80:20c:29ff:fe17:5b7/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:6238 errors:0 dropped:0 overruns:0 frame:0 TX packets:5025 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:5803824 (5.5 MiB) TX bytes:667014 (651.3 KiB) 4.为路由表添加一默认网关,其IP地址为192.168.0.20 rootbogon # route add default gw 192.168.0.20 rootbogon # route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 * 255.255.255.128 U 0 0 0 eth0 default 192.168.0.20 0.0.0.0 UG 0 0 0 eth0shell程序设计 1、设计一个模拟台式计算器,从键盘输入两个数,再输入算术运算符,求其计算结果。要求输出结果为:第一个数 运算符 第二个数 = 运算结果。(运算符仅包含expr支持的+ - * / %) Shell程序 : echo input the first number read a echo input the second number read b echo input the caltor read caltor sum=0 case $caltor in +) echo sum=expr $a + $b; -) echo sum=expr $a - $b; *) echo sum=expr $a * $b; /) echo sum=expr $a / $b; %) echo sum=expr $a % $b; Esac 结果: rootbogon # sh shell脚本计算器 input the first number 3 input the second number 4 input the caltor + sum=7 rootbogon # sh shell脚本计算器 input the first number 3 input the second number 4 input the caltor - sum=-1 rootbogon # sh shell脚本计算器 input the first number 3 input the second number 4 input the caltor * sum=12 rootbogon # sh shell脚本计算器 input the first number 8 input the second number 4 input the caltor / sum=2 rootbogon # sh shell脚本计算器 input the first number 8 input the second number 4 input the caltor % sum=0 2、编写一个shell脚本,将用户主目录下的所有*.txt文件用for循环复制到mysoft子目录下并显示所复制文件的内容。
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 考试试卷


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!