您的位置:首页 > 运维架构 > Linux

linux第二关练习题上部

2018-07-23 16:44 323 查看

第1章 PATH

1.1 PATH 存放的是linux下命令的路径(位置)

[root@oldboyedu50-lnb ~]# echo $PATH/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

1.2 linux启动过程

开机自检(BIOS)MBR引导GRUB菜单加载内核运行init进程读取/etc/inittab配置文件执行/etc/rc.d/rc.sysinit脚本执行/etc/rc.d/rc脚本启动mingetty进程

1.3 linux执行命令过程

1.是否是别名2.在PATH中找命令是否存在 1).提示 command not found 2).执行实例1-1 如何过滤出已知当前目录下oldboy中的所有一级目录(提示:不包含oldboy目录下面目录的子目录及隐藏目录,即只能是第一级目录)?mkdir /oldboy -pcd /oldboymkdir ext/oldboy test xiaodong xiaofan xingfujie -ptouch jeacen oldboy wodi.gz yingsui.gz方法1-tree [root@oldboyedu50-lnb /oldboy]# tree -dL 1.├── ext├── test├── xiaodong├── xiaofan└── xingfujie5 directories方法2-find [root@oldboyedu50-lnb /oldboy]# find -maxdepth 1 -type d../xiaodong./xiaofan./test./ext./xingfujie[root@oldboyedu50-lnb /oldboy]# find -maxdepth 1 -type d -name ".".[root@oldboyedu50-lnb /oldboy]# find -maxdepth 1 -type d ! -name "."./xiaodong./xiaofan./test./ext./xingfujie方法3 d开头的[root@oldboyedu50-lnb /oldboy]# ll |grep "^d"drwxr-xr-x 3 root root 4096 Jul 19 23:59 extdrwxr-xr-x. 2 root root 4096 Jul 16 19:24 testdrwxr-xr-x 2 root root 4096 Jul 19 23:59 xiaodongdrwxr-xr-x 2 root root 4096 Jul 19 23:59 xiaofandrwxr-xr-x 2 root root 4096 Jul 19 23:59 xingfujie方法4 第2列大于1 [root@oldboyedu50-lnb /oldboy]# ll |awk '$2>1'total 40drwxr-xr-x 3 root root 4096 Jul 19 23:59 extdrwxr-xr-x. 2 root root 4096 Jul 16 19:24 testdrwxr-xr-x 2 root root 4096 Jul 19 23:59 xiaodongdrwxr-xr-x 2 root root 4096 Jul 19 23:59 xiaofandrwxr-xr-x 2 root root 4096 Jul 19 23:59 xingfujie方法5 ls [root@oldboyedu50-lnb /oldboy]# ls -Falex.txt jeacen oldboy.txt test.sh t.sh.bak xiaodong/ xingfujie/ext/ oldboy test/ t.sh wodi.gz xiaofan/ yingsui.gz[root@oldboyedu50-lnb /oldboy]# #-F 不同类型的文件 加上不同的标记 目录/[root@oldboyedu50-lnb /oldboy]# ls -F |grep "/"ext/test/xiaodong/xiaofan/xingfujie/方法6 *目录标记[root@oldboyedu50-lnb /oldboy]# ls -ld */drwxr-xr-x 3 root root 4096 Jul 19 23:59 ext/drwxr-xr-x. 2 root root 4096 Jul 16 19:24 test/drwxr-xr-x 2 root root 4096 Jul 19 23:59 xiaodong/drwxr-xr-x 2 root root 4096 Jul 19 23:59 xiaofan/drwxr-xr-x 2 root root 4096 Jul 19 23:59 xingfujie/实例1-2 /etc/目录为linux系统的默认的配置文件及服务启动命令的目录a. 请用tar打包/etc整个目录(打包及压缩)。b. 请用tar打包/etc整个目录(打包及压缩,但需要排除/etc/services文件)。c. 请把a点命令的压缩包,解压到/tmp指定目录下(最好只用tar命令实现)。1.创建压缩包 tar zcvf /tmp/etc.tar.gz /etc/#z gzip 通过gzip 软件压缩#c create 创建包#v verbose 显示过程#f file 指定文件2.查看压缩包内容 tar ztf /tmp/etc.tar.gz#t list 显示压缩包内容3.解压 tar zxf etc.tar.gz#x extract 解压[root@oldboyedu50-lnb /tmp]# ll /tmp/etc.tar.gz-rw-r--r-- 1 root root 9734648 Jul 20 01:41 /tmp/etc.tar.gz解压到/opt[root@oldboyedu50-lnb /tmp]# tar xf /tmp/etc.tar.gz -C /opt/[root@oldboyedu50-lnb /tmp]# ll /opt/total 12drwxr-xr-x. 2 root root 4096 Jul 11 01:16 datadrwxr-xr-x 78 root root 4096 Jul 19 20:43 etcdrwxr-xr-x. 2 root root 4096 Mar 26 2015 rhb.请用tar打包/etc整个目录(打包及压缩,但需要排除/etc/services文件)。[root@oldboyedu50-lnb /tmp]# tar zcf /tmp/etc-pai.tar.gz /etc/ --exclude /etc/servicestar: Removing leading `/' from member names[root@oldboyedu50-lnb /tmp]# tar tf /tmp/etc-pai.tar.gz |grep servicesetc/init/readahead-disable-services.conf[root@oldboyedu50-lnb /tmp]# tar tf /tmp/etc.tar.gz |grep servicesetc/init/readahead-disable-services.confetc/servicestar zcf /tmp/etc-pai.tar.gz /etc/ --exclude /etc/servicestar命令经典故障Removing leading `/' from member names[root@oldboyedu50-lnb /oldboy]# tar zcf /tmp/etc.tar.gz /etc/tar: Removing leading `/' from member names把压缩包中的开头的/(根)删除掉背后过程:打包压缩过程中 文件或目录 绝对路径---->相对路径 打包的时候: /etc/host /etc/profile 压缩包中样子 etc/host etc/profile这个提示原因: 防止解压的时候覆盖源文件。实例1-3 假如当前目录是/etc/sysconfig/network-scripts/cd - 进入到上一次所在的位置An argument of - is equivalent to $OLDPWD.cd - === cd $OLDPWDcd . 进入当前目录cd .. 进入上一级目录cd ~ 进入当前目录的家目录实例1-4 按照时间顺序查看文件ls -lrt#-r 逆序#-t 按照修改时间调试系统服务时,希望能实时查看系统日志/var/log/secure的更新,如何做?-F == -f --try 如果文件不存在 会不断重试tail -f /var/log/secure[root@oldboy50-01 ~]# ll -ttotal 52-rw-r--r--. 1 root root 10 Jul 17 04:28 oldboy.log-rw-r--r--. 1 root root 56 Jul 16 18:42 *.shdrwxr-xr-x. 3 root root 4096 Jul 15 01:48 oldboy-rw-------. 1 root root 1160 Jul 14 23:41 anaconda-ks.cfg-rw-r--r--. 1 root root 21736 Jul 14 23:41 install.log-rw-r--r--. 1 root root 5890 Jul 14 23:38 install.log.syslog实例1-5 打印配置文件nginx.conf内容的行号及内容,该如何做?[root@oldboyedu50-lnb /oldboy]# #{1..5} 生成序列[root@oldboyedu50-lnb /oldboy]# echo {1..10}1 2 3 4 5 6 7 8 9 10[root@oldboyedu50-lnb /oldboy]# echo {01..10}01 02 03 04 05 06 07 08 09 10[root@oldboyedu50-lnb /oldboy]# echo stu{01..10} |xargs -n1stu01stu02stu03stu04stu05stu06stu07stu08stu09stu10[root@oldboyedu50-lnb /oldboy]# echo stu{01..10} |xargs -n1 >nginx.conf方法1 cat [root@oldboyedu50-lnb /oldboy]# cat -n nginx.conf 1 stu01 2 stu02 3 stu03 4 stu04 5 stu05 6 stu06 7 stu07 8 stu08 9 stu09 10 stu10方法2 vim :set nu #显示行号 :set nonu #取消显示行号

第2章 vmware 经典故障:

该虚拟机似乎正在使用中。如果该虚拟机未在使用,请按“获取所有权(T)”按钮获取它的所有权。否则,请按“取消(C)”按钮以防损坏。配置文件: G:\VMware\模板机01\老男孩教育50期-模板机01.vmx。方法1.重启计算机 方法2.通过everything 搜索 .lck 删除 虚拟机名称.lck 目录 重启vmware
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux 第二关 练习