上机作业:
1、请用命令查出ifconfig命令程序的绝对路径
[root@localhost ~]# which ifconfig
/usr/sbin/ifconfig
2、请用命令展示以下命令哪些是内部命令,哪些是外部命令?(cd pwd ls ifconfig du)
[root@localhost ~]# type cd
cd 是 shell 内嵌 (由此可见该命令cd为内部命令)
[root@localhost ~]# type pwd
pwd 是 shell 内嵌 (由此可见该命令cd为内部命令)
[root@localhost ~]# type ls
ls 是 `ls --color=auto' 的别名(由此可见该命令ls为外部命令)
[root@localhost ~]# type ifconfig
ifconfig 是 /usr/sbin/ifconfig(由此可见该命令ifconfig为外部命令)
[root@localhost ~]# type du
du 是 /usr/bin/du(由此可见该命令du为外部命令)
3、请在/下创建目录abc
[root@localhost ~]# mkdir /abc
请在/下创建目录/liangjian/liyunlong/weiheshang/duanpeng
[root@localhost ~]# mkdir -pv /liangjian/liyunlong/weiheshang/duanpeng
mkdir: 已创建目录 "/liangjian"
mkdir: 已创建目录 "/liangjian/liyunlong"
mkdir: 已创建目录 "/liangjian/liyunlong/weiheshang"
mkdir: 已创建目录 "/liangjian/liyunlong/weiheshang/duanpeng"
请在/abc下一次创建1000个目录,名字自己拟定。
[root@localhost ~]# cd /abc
[root@localhost abc]# mkdir -pv a{1..1000}
mkdir: 已创建目录 "a1"
mkdir: 已创建目录 "a2"
mkdir: 已创建目录 "a3"
mkdir: 已创建目录 "a4"
mkdir: 已创建目录 "a5"
mkdir: 已创建目录 "a6"
4、请用绝对路径方式切换到/liangjian/liyunlong/weiheshang/duanpeng 目录下
并用pwd查看当前的路径,请用上级目录名".."方式切换到 /liangjian/liyunlong下
[root@localhost abc]# cd
[root@localhost ~]# cd /liangjian/liyunlong/weiheshang/duanpeng
[root@localhost duanpeng]# pwd
/liangjian/liyunlong/weiheshang/duanpeng
[root@localhost duanpeng]# cd ../..
[root@localhost liyunlong]#
5、请一次删除/abc下一次创建的1000个目录,请在/abc下用touch再创建20个以stu开头的普通可读文档,文档后缀为.txt
[root@localhost liyunlong]# cd /abc
[root@localhost abc]# rm -rf a{1..1000}
[root@localhost abc]# touch stu{1..20}.txt
[root@localhost abc]# ls
stu10.txt stu2.txt
stu11.txt stu3.txt
stu12.txt stu4.txt
stu13.txt stu5.txt
stu14.txt stu6.txt
stu15.txt stu7.txt
stu16.txt stu8.txt
stu17.txt stu9.txt
stu18.txt stu19.txt
stu1.txt stu20.txt
6、请用cp命令将/boot/目录下以vmlinuz开头的文件拷贝到/abc下,并以查看他们占磁盘的空间大小。
[root@localhost ~]# cp -fr /boot/vmlinuz* /abc
[root@localhost ~]# cd /abc
[root@localhost abc]# ls
stu10.txt stu2.txt
stu11.txt stu3.txt
stu12.txt stu4.txt
stu13.txt stu5.txt
stu14.txt stu6.txt
stu15.txt stu7.txt
stu16.txt stu8.txt
stu17.txt stu9.txt
stu18.txt vmlinuz
stu19.txt vmlinuz-0-rescue-1781126a035244acbfb57d3f9b9955cf
stu1.txt vmlinuz-3.10.0-229.el7.x86_64
stu20.txt
[root@localhost abc]# du -sh
9.6M .
7、将其中一个vmlinuz开头的文件改名为kgc,另外一个剪切到/tmp目录下。
[root@localhost abc]# mv vmlinuz-0-rescue-1781126a035244acbfb57d3f9b9955cf kgc
[root@localhost abc]# ls
kgc stu15.txt stu20.txt stu7.txt
stu10.txt stu16.txt stu2.txt stu8.txt
stu11.txt stu17.txt stu3.txt stu9.txt
stu12.txt stu18.txt stu4.txt vmlinuz
stu13.txt stu19.txt stu5.txt vmlinuz-3.10.0-229.el7.x86_64
stu14.txt stu1.txt stu6.txt
[root@localhost abc]# cd
[root@localhost ~]# mv /abc/vmlinuz-3.10.0-229.el7.x86_64 /tmp
[root@localhost ~]# cd /tmp
[root@localhost tmp]# ls
hsperfdata_root systemd-private-PBSqBr
ks-script-4BkH3y systemd-private-QWHDdE
ssh-6Mdsp0Wi2oLf systemd-private-rVPz0P
ssh-IZ3FITvrrrrS systemd-private-tpQOLh
ssh-jI1uHRAhmWSu systemd-private-x0D2yP
ssh-SRTlh3lLi9Yq systemd-private-Z2SRR1
systemd-private-6sN7gJ systemd-private-zqFTlU
systemd-private-8f5azw vmlinuz-3.10.0-229.el7.x86_64
systemd-private-GpNskW vmware-root
systemd-private-Ip1Y8f yum.log
systemd-private-KaqASR yum_save_tx.2019-07-23.19-03.Eoc23z.yumtx
8、查看/tmp/目录下以vmlinuz开头文件的详细状态信息。
[root@localhost tmp]# stat vmlinuz*
文件:"vmlinuz-3.10.0-229.el7.x86_64"
大小:5029136 块:9824 IO 块:4096 普通文件
设备:fd00h/64768d Inode:75476714 硬链接:1
权限:(0755/-rwxr-xr-x) Uid:( 0/ root) Gid:( 0/ root)
环境:unconfined_u:object_r:default_t:s0
最近访问:2019-07-23 20:59:48.467156144 +0800
最近更改:2019-07-23 20:59:48.480156188 +0800
最近改动:2019-07-23 21:08:06.843825517 +0800
创建时间:-
[root@localhost tmp]#
9、用find命令查找/tmp目录下以vmlinuz开头及大小超过1M的文件
[root@localhost tmp]# find -name "vmlinuz*" -a -size +1M
./vmlinuz-3.10.0-229.el7.x86_64