第1章 Linux启动过程

开机自检(BIOS)##硬件检查

MBR引导

GRUB菜单(选择不同的内核)

加载内核

运行init进程(Linux系统里面第一个进程)

读取/etc/inittab配置文件(读取运行级别)

执行/etc/rc.d/sysinit脚本(系统的初始化脚本 设置IP地址)

执行/etc/rc.d/rc脚本(根据系统的运行级别 在开机的时候启动不同的软件)

启动mingetty进程

显示界面

第2章 PATH 变量

PATH 存放的是Linux下命令的位置

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

规律
/bin
/sbin
/usr/bin
/usr/sbin
/usr/local/bin
/usr/local/sbin

Linux执行命令的过程

是否是别名

在PATH中找命令是否存在

没有的话提示command not fonund

有就执行

第3章 显示一级目录

问题:

如何过滤出已知当前目录下oldboy中的所有一级目录

(提示:不包含oldboy目录下面目录的子目录及隐藏目录,即只能是一级目录)?

创建环境
mkdir /oldboy -p
cd /oldboy
mkdir ext/oldboy test xiaodong xiaofan xingfujie -p
touch jeacen oldboy wodi.gz yingsui.gz

3.1 方法一 tree

-d  只显示目录

-L level 最多显示多少层 -L 1 最多显示一层

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

5 directories

3.2 方法二 find

-maxdepth  最大的深度

-maxdepth  最大的深度
[root@oldboyedu-50 oldboy]# find -maxdepth 1 -type d
.                                                    显示出了目录 但是多了一个.
./xingfujie
./test
./xiaofan
./xiaodong
./ext

!排除取反 非

排除. 只显示目录
[root@oldboyedu-50 oldboy]# find -maxdepth 1 -type d ! -name "."
./xingfujie
./test
./xiaofan
./xiaodong
./ext

3.3 方法三grep

^以xxx/开头的行  三剑客使用 正则表达式

[root@oldboyedu-50 oldboy]# ls -l |grep "^d"
drwxr-xr-x. 3 root root 4096 Jul 10 19:45 ext
drwxr-xr-x. 2 root root 4096 Jul 10 19:45 test
drwxr-xr-x. 2 root root 4096 Jul 10 19:45 xiaodong
drwxr-xr-x. 2 root root 4096 Jul 10 19:45 xiaofan
drwxr-xr-x. 2 root root 4096 Jul 10 19:45 xingfujie
^以xxx/开头的行  三剑客使用 正则表达式

3.4 方法四awk

$2表示第二列

[root@oldboyedu-50 oldboy]# ls -l |awk '$2>1'                第二列大于一的
total 20
drwxr-xr-x. 3 root root 4096 Jul 10 19:45 ext
drwxr-xr-x. 2 root root 4096 Jul 10 19:45 test
drwxr-xr-x. 2 root root 4096 Jul 10 19:45 xiaodong
drwxr-xr-x. 2 root root 4096 Jul 10 19:45 xiaofan
drwxr-xr-x. 2 root root 4096 Jul 10 19:45 xingfujie

3.5 拓展方法两种

[root@oldboyedu-50 oldboy]# ls -F |grep "/"
-F 不同的类型文件 加上不同的标记  目录加上/
[root@oldboyedu-50 oldboy]# ls -ld */  ##看以/结尾的

第4章 压缩

问题:

/etc/目录为linux系统的默认的配置文件及服务启动命令的目录

a.请用tar打包/etc整个目录(打包及压缩)

b.请用tar打包/etc整个目录(打包及压缩,但需要排除/etc/services文件)

c.请把a点命令的压缩包,解压到/tmp指定目录下(最好只用tar命令实现)

4.1 tar下的参数

tar zcvf /tmp/etc.tar.gz  /etc/
         压缩之后放在哪   要压缩的
    z  gzip    通过gzip软件压缩
    c  create  创建包
    v  verbose 显示过程
    f  file    指定文件 (在tar中  f 必须要在最后边)
    t  list    显示压缩包内容
    x  extaact 解压
压缩  zcvf  zcf
查看  ztf   tf
解压  zxf   xf

4.2 创建压缩包

一般压缩不用参数v  不用显示压缩过程 所以直接用zcf即可

[root@oldboyedu-50 tmp]# tar ztf /tmp/etc.tar.gz   打包及压缩

4.3 解压

解压前先进入要解压到的目录

[root@oldboyedu-50 tmp]# tar zxf etc.tar.gz   ##先进入tmp目录

4.4 解压到指定目录

解压使用参数zxf  z可以省略 xf即可

[root@oldboyedu-50 tmp]# tar xf /tmp/etc.tar.gz -C /opt/  解压到opt目录
[root@oldboyedu-50 tmp]# ll /opt/                         解压后检查
total 8
drwxr-xr-x. 78 root root 4096 Jul 10 19:41 etc
drwxr-xr-x.  2 root root 4096 Mar 26  2015 rh

4.5 排除某个文件或目录

要求:排除services

排除多个

--exclude-from 加个名单  .txt

.txt里写上路径内容

[root@oldboyedu-50 ~]# tar zcf /tmp/etc.tar.gz /etc/ --exclude /etc/services
[root@oldboyedu-50 ~]# tar tf /tmp/etc.tar.gz |grep "services"  检查是否排除
etc/init/readahead-disable-services.conf

4.6 tar经典故障

tar: Removing leading `/' from member names
安全警告  删除 开始   /
     把压缩包的 开头的/ 删除掉
由绝对路径 变为了相对路径
防止解压的时候覆盖源文件

第5章 显示行号

打印配置文件nginx.conf内容的行号及内容 如何做?

创建环境

[root@oldboyedu-50 ~]# mkdir /oldboy && echo stu{01..10} |xargs -n1 > /oldboy/ngingx.conf

5.1 方法一 cat

-n 显示行号

[root@oldboyedu-50 oldboy]# cat -n ngingx.conf
     1    stu01
     2    stu02
     3    stu03
     4    stu04
     5    stu05
     6    stu06
     7    stu07
     8    stu08
     9    stu09
    10    stu10

5.2 方法二 vim

vim /oldboy/nginx.conf
进入后
:set nu    显示行号
:set nonu  取消显示行号

5.3 方法三 awk

NR   行号

$1   表示第一列

$0   表示一整行的内容

[root@oldboyedu-50 ~]# awk '{print NR,$1}' /oldboy/ngingx.conf
1 stu01
2 stu02
3 stu03
4 stu04
5 stu05
6 stu06
7 stu07
8 stu08
9 stu09
10 stu10

5.4 方法四 nl

nl  number of lines  专门用于显示行号的

[root@oldboyedu-50 oldboy]# nl ngingx.conf
     1    stu01
     2    stu02
     3    stu03
     4    stu04
     5    stu05
     6    stu06
     7    stu07
     8    stu08
     9    stu09
    10    stu10

5.5 第五种方法 grep

-n /显示行号

. 正则表达式  表示任意一个字符

[root@oldboyedu-50 oldboy]# grep -n "." ngingx.conf
1:stu01
2:stu02
3:stu03
4:stu04
5:stu05
6:stu06
7:stu07
8:stu08
9:stu09
10:stu10

5.6 第六种方法 sed

=  表示显示行号

[root@oldboyedu-50 oldboy]# sed '=' ngingx.conf |xargs -n2
1 stu01
2 stu02
3 stu03
4 stu04
5 stu05
6 stu06
7 stu07
8 stu08
9 stu09
10 stu10

5.7 第七种方法 less (了解)

[root@oldboyedu-50 logs]# less -N /oldboy/ngingx.conf

第6章 运行级别及iptables补充

6.1 运行级别补充

查看运行级别  runlevel

切换 init

6.2 关闭iptable

装完Centos系统后,希望iptables,仅关闭3运行级别 怎么做

[root@oldboyedu-50 logs]# chkconfig |grep "ipt"   ##查看
iptables           0:off    1:off    2:on    3:on    4:on    5:on    6:off
[root@oldboyedu-50 logs]# chkconfig --level 3 iptables off   ##关闭3
[root@oldboyedu-50 logs]# chkconfig |grep "ipt"              ##关闭后检查
iptables           0:off    1:off    2:on    3:off    4:on    5:on    6:off

第7章 单独取一列命令补充

已知如下命令及结果:

[oldboy@test ~]$ echo "I am oldboy,myqq is 31333741">>oldboy.txt

[oldboy@test ~]$ cat oldboy.txt

I am oldboy,myqq is 31333741

创建环境

mkdir /oldboy
echo "I am oldboy,myqq is 31333741">/oldboy/oldboy.txt

7.1 方法一 sed |awk

[root@oldboyedu-50 oldboy]# sed 's#,# #g' oldboy.txt |awk '{print $3,$6}'
oldboy 31333741

7.2 方法二 tr | awk

tr   sed命令的阉割版

tr   一对一的替换

[root@oldboyedu-50 oldboy]# tr "," " " <oldboy.txt |awk '{print $3,$6}'
oldboy 31333741

7.3 方法三 tr | cut

-d  指定分隔符

-f  某一列

[root@oldboyedu-50 oldboy]# tr "," " " < oldboy.txt |cut -d " " -f3,6
oldboy 31333741

7.4 方法四 sed | cut

[root@oldboyedu-50 oldboy]# sed 's#,# #g' oldboy.txt |cut -d " " -f3,6
oldboy 31333741

7.5 方法五 awk

-F  指定新的分隔符

$NF  表示最后一列

[root@oldboyedu-50 oldboy]# awk -F "[, ]" '{print $3,$6}' oldboy.txt
oldboy 31333741

7.6 方法六 sed

[root@oldboyedu-50 oldboy]# sed 's#I am ##g' oldboy.txt |sed 's#,myqq is # #g'
oldboy 31333741

第8章 认识wc命令

8.1 统计信息

wc 统计文件的信息

[root@oldboyedu-50 oldboy]# wc /etc/services      统计文件的信息
 10774  58108 641020 /etc/services
[root@oldboyedu-50 oldboy]# wc -l /etc/services   只看有多少行
10774 /etc/services

8.2 统计总数

统计出/etc目录下  以.conf 结尾的文件的数量

[root@oldboyedu-50 oldboy]# find /etc/ -type f -name "*.conf" |wc -l
195

第9章 egrep

过滤出/etc/services 文件包含3306或1521两数据库端口的行的内容。

|  扩展正则表达式 egrep ==grep -E

[root@oldboyedu-50 oldboy]# grep -E "3306|1521" /etc/services
mysql           3306/tcp                        # MySQL
mysql           3306/udp                        # MySQL
ncube-lm        1521/tcp                # nCube License Manager
ncube-lm        1521/udp                # nCube License Manager
[root@oldboyedu-50 oldboy]# egrep "3306|1521" /etc/services
mysql           3306/tcp                        # MySQL
mysql           3306/udp                        # MySQL
ncube-lm        1521/tcp                # nCube License Manager
ncube-lm        1521/udp                # nCube License Manager

Linux基础命令第二波的更多相关文章

  1. 第四节,Linux基础命令

    第四节,Linux基础命令 命令是系统操作员对系统传入的指令,传入指令后回车,系统接收到指令做出相应的行为 1.查看用户位于系统什么位置 [pmd]检查操作用户位于系统的什么位置 命令         ...

  2. 【Python之路】第一篇--Linux基础命令

    pwd 命令 查看”当前工作目录“的完整路径 pwd -P # 显示出实际路径,而非使用连接(link)路径:pwd显示的是连接路径 .   表示当前目录 ..  表示上级目录 /  表示根目录 ls ...

  3. linux基础命令学习笔记(二)

    linux基础命令学习笔记(二) 1.kill :终止进程  kill pid (唯一标示一个进程) kill -9  强制终止  kill -15 命令未结束不能终止 # ps aux 查看所有进程 ...

  4. 2.Linux基础命令

    linux内一切皆文件,没有文件夹只有目录,目录也是一种文件 1.一些常用按键: 将鼠标的光标从虚拟机里切换回来:Ctrl+Alt 拖动Ubuntu内的对话框:Alt键+鼠标左键拖动 清屏:Ctrl+ ...

  5. linux基础命令一

    linux基础命令一 1.date命令 date命令介绍:显示或者设置系统日期 date命令的语法: 显示日期:date  [options...]  [+FORMAT] FORMAT:为显示日期的格 ...

  6. linux基础命令:

    linux基础命令: 显示 echo 输出我写的内容 ls 查看当前目录的文件 pwd 查看当前目录 ifconfig 查看网卡信息 grep 过滤 -v 取反 -n man 查看命令的帮助信息 md ...

  7. 常用的linux基础命令

    常用的linux基础命令 1.ls 显示目录属性 -l:(也可以简写成ll),列表显示权限等属性 -a:显示所有文件包括隐藏文件等 -d:只列出目录本身 2.chgrp 改变档案所属群组 eg:chg ...

  8. Linux基础命令-文件与目录

    Linux基础命令-文件与目录 参考:<鸟哥linux私房菜>五-七章,17/12/5复习,18/01/15复习 文件权限 rwx421:用户,用户组,其他 umask查看默认权限:000 ...

  9. Linux基础命令回顾

    前言 说到linux基础命令,网上一搜一箩筐,想学也有很多教程,如果你不幸看到此篇文章,想看就认真看完,毕竟你点进来了不是嘛? 我每次写的文章都是为了分享自己的学习成果或重要知识点,希望能帮助更多的人 ...

随机推荐

  1. [转载] Linux Futex的设计与实现

    Linux Futex的设计与实现 引子 在编译2.6内核的时候,你会在编译选项中看到[*] Enable futex support这一项,上网查,有的资料会告诉你"不选这个内核不一定能正 ...

  2. 洛谷——P4296 [AHOI2007]密码箱

    P4296 [AHOI2007]密码箱 密码x大于等于0,且小于n,而x的平方除以n,得到的余数为1. 求这个密码,$1<=n<=2,000,000,000$ 暴力枚举,数据有点儿水$O( ...

  3. C++/C union使用记一下锅

    //首先,学习编程一定要记得加几个群或者加几个讨论组,因为这样你才能不断地进步还有吵架/滑稽 记一下 关于使用union结构体时遇到的一些坑 To zero-initialize an object ...

  4. 记VS2008安装及使用及卸载的艰辛历程!!!(2018/11/6-2018/11/14)

    此文为了纪念我对VS2008“孜孜不倦的”无数次的安装及卸载,以及解决使用过程中出现的问题所花费的人力物力和财力!成功之后再作补充.

  5. (七)python3 切片

    切片:取一个 list 或 tuple 的部分元素是非常常见的操作 >>> L = ['Michael', 'Sarah', 'Tracy', 'Bob', 'Jack'] #笨办法 ...

  6. 腾讯云:iptables基础

    iptables 基础 iptables 基本命令 任务时间:5min ~ 10min iptables 可以简单理解为 Linux 系统内核级防火墙 netfilter 的用户态客户端. Linux ...

  7. idea 编译级别的设置

    File->Settings Project Structure

  8. WebSocket客户端学习

    1. WebSocket是一种网络通讯协议 参考文档:http://www.ruanyifeng.com/blog/2017/05/websocket.html https://github.com/ ...

  9. win7 32位机安装VMware win7 64位虚拟机

    VMware10虚拟机怎么安装win7系统(详细教程):https://jingyan.baidu.com/article/86f4a73ec62e8f37d65269a1.html 然而上述教程想不 ...

  10. 【BZOJ2342】双倍回文(manacher,并查集)

    题意: 思路:From http://blog.sina.com.cn/s/blog_8d5d2f04010196bh.html 首先我可以看出: (1)我们找到的串的本身也是一个回文串(显然) (2 ...