第1章 Linux的启动过程

第2章 PATH PATH 存放的是Linux下命令的路径(位置) echo $PATH $LANG $PS1 /bin/ /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin [root@oldboyedu50-lnb ~]# echo $PATH /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

第3章 Linux下执行命令的过程 3.1 是否是别名 3.2 在PATH中找命令是否存在 1) 提示 Command not found 2)执行 3.3 题: 1 如何过滤出已知当前目录下oldboy中的所有一级目录(提示:不包含oldboy目录下面目录的子目录及隐藏目录,即只能是第一级目录)? 粘贴以下内容: mkdir /oldboy -p cd /oldboy mkdir ext/oldboy test xiaodong xiaofan xingfujie -p touch jeacen oldboy wodi.gz yingsui.gz

方法一 tree [root@oldboyedu-50 oldboy]# tree -dL 1 . ├── ext ├── test ├── xiaodong ├── xiaofan └── xingfujie 5 directories

方法二 –find -maxdepth:一级目录 [root@oldboyedu-50 oldboy]# find -maxdepth 1 -type d . ./xiaodong ./xiaofan ./ext ./test ./xingfujie

[root@oldboyedu-50 oldboy]# find -maxdepth 1 -type d ! -name "." find的排除方法 [root@oldboyedu50-lnb /oldboy]# find -maxdepth 1 -type d -name "." ./xiaodong ./xiaofan ./ext ./test ./xingfujie

!:排除 取反 非

方法三 d开头的 ^:以。。。开头的行 三剑客使用 正则表达式 [root@oldboyedu-50 oldboy]# ll |grep "^d" drwxr-xr-x. 3 root root 4096 Jul 23 09:30 ext drwxr-xr-x. 2 root root 4096 Jul 23 09:30 test drwxr-xr-x. 2 root root 4096 Jul 23 09:30 xiaodong drwxr-xr-x. 2 root root 4096 Jul 23 09:30 xiaofan drwxr-xr-x. 2 root root 4096 Jul 23 09:30 xingfujie

方法四 第二列大于1 awd ‘$2>1’ [root@oldboyedu-50 oldboy]# ll |awk '$2>1' total 20 drwxr-xr-x. 3 root root 4096 Jul 23 09:30 ext drwxr-xr-x. 2 root root 4096 Jul 23 09:30 test drwxr-xr-x. 2 root root 4096 Jul 23 09:30 xiaodong drwxr-xr-x. 2 root root 4096 Jul 23 09:30 xiaofan drwxr-xr-x. 2 root root 4096 Jul 23 09:30 xingfujie

方法五ls [root@oldboyedu-50 oldboy]# ls -F ext/ oldboy wodi.gz xiaofan/ yingsui.gz jeacen test/ xiaodong/ xingfujie/ -F 不同类型的文件 加上不同的标记 目录/ Ls –F |grep “/” [root@oldboyedu50-lnb /oldboy]# ls -F |grep "/" ext/ test/ xiaodong/ xiaofan/ xingfujie/

[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/ -l:显示详细信息

Find 显示你当前所有目录 Find:-maxdepth 最大深度 Tree 以树状的形式显示目录文件 Tree:–d 只显示目录 -L level 最多显示多少层 第4章 创建压缩包 4.1 题: /etc/目录为Linux系统的默认的配置文件及服务启动命令的目录 a.请用tar打包/etc整个目录(打包及压缩)。 c.请把a点命令的压缩包,解压到/tmp指定目录下(最好只用tar命令实现)。 b.请用tar打包/etc整个目录(打包及压缩,但需要排除/etc/services文件)。

Windows 压缩 winrar/好压/2345压缩 Linux 打包压缩 tar

tar zcvf /tmp/etc.tar.gz 压缩之后的放在那里 /etc/ 压缩包 2.[root@oldboyedu-50 oldboy]# tar zcf /tmp/etc.tar.gz /etc/ tar: Removing leading /' from member names tar: Removing leading/' from hard link targets Z gzip 通过gzip软件压缩 C create 创建包 V verbose 显示过程 F file 指定文件

Zcvf 创建压缩包 解压 先进入 cd /tmp/ 解压:Tai zxf etc.tar.gz 查看压缩包内容:Tar ztf /tmp/etc.tar.gz t list 显示压缩包内容 查看:tar tf 解压:tar xf

解压到当前文件/opt下 [root@oldboyedu-50 tmp]# tar xf /tmp/etc.tar.gz -C /opt/[root@oldboyedu-50 tmp]# ll /opt/ total 8 drwxr-xr-x. 79 root root 4096 Jul 23 08:35 etc drwxr-xr-x. 2 root root 4096 Mar 26 2015 rh

b.请用tar打包/etc整个目录(打包及压缩,但需要排除/etc/services文件) [root@oldboyedu50-lnb /tmp]# tar zcf /tmp/etc-pai.tar.gz /etc/ --exclude /etc/services tar: Removing leading `/' from member names [root@oldboyedu50-lnb /tmp]# tar tf /tmp/etc-pai.tar.gz |grep services etc/init/readahead-disable-services.conf [root@oldboyedu50-lnb /tmp]# tar tf /tmp/etc.tar.gz |grep services etc/init/readahead-disable-services.conf etc/services tar zcf /tmp/etc-pai.tar.gz /etc/ --exclude /etc/services --exclude-from name.txt name.txt oldboy.txt /oldboy/oldboy 假如当前目录是 cd - 进入到上一次所在的位置 An argument of - is equivalent to $OLDPWD. #cd - === cd $OLDPWD cd .
cp/mv
cd ..
cd ~ ==== cd
[root@oldboyedu50-lnb /tmp]# cd /etc/ [root@oldboyedu50-lnb /etc]# touch oldboy.txt

ls -lrt #-r 逆序 #-t 按照修改时间

题:调试系统服务时,希望能实时查看系统日志/var/log/secure的更新,如何做? -f -F == -f --try 如果文件不存在 会不断重试 tail -f /var/log/secure tailf /var/log/secure

题: 打印配置文件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 -n1 stu01 stu02 stu03 stu04 stu05 stu06 stu07 stu08 stu09 stu10 [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 #显示行号
#nu === number (数字) :set nonu #取消显示行号

tar命令经典故障 Removing leading /' from member names 创建压缩包都见过这个提示吧? [root@oldboyedu50-lnb /oldboy]# tar zcf /tmp/etc.tar.gz /etc/ tar: Removing leading/' from member names 什么意思呢? 翻译: Removing leading `/' from member names 把压缩包中的开头的/(根)删除掉 背后过程: 打包压缩过程中 文件或目录 绝对路径---->相对路径 打包的时候: /etc/host /etc/profile 压缩包中样子 etc/host etc/profile 这个提示原因: 防止解压的时候覆盖源文件。

4.2 vmware 经典故障: 该虚拟机似乎正在使用中。 如果该虚拟机未在使用,请按“获取所有权(T)”按钮获取它的所有权。否则,请按“取消(C)”按钮以防损坏。 配置文件: G:\VMware\模板机01\老男孩教育50期-模板机01.vmx。 方法1.重启计算机 方法2.通过everything 搜索 .lck 删除 虚拟机名称.lck 目录 重启vmware