Linux-备份压缩
参考文献
Compressing and decompressing files under Linux
Linux的备份压缩
最早的Linux备份介质是磁带,使用的命令是tar;
可以打包的磁带文件进行压缩存储,压缩命令是gzip和bzip2;
经常使用的扩展名是:.tar.gz,.tar.bz2,.tgz
常见的压缩后缀
*.Z compress 程序压缩的档案;
*.bz2 bzip2 程序压缩的档案;
*.gz gzip 程序压缩的档案;
*.tar tar 程序打包的数据,并没有压缩过;
*.tar.gz tar 程序打包的档案,其中并且经过 gzip 的压缩
tar格式
注意tar是打包,不是压缩
1Format: tar [primary option + secondary option] file or directory
Primary options(主要选项): they cannot be present at the same time, telling tar what to do is mandatory
...
Linux-文件和目录管理
参考文献
鸟哥的Linux私房菜基础学习篇(第四版)
目录和路径
相对路径和绝对路径
绝对路径: 路径的写法一定由根目录/写起,例如/usr/share/doc这个目录;
相对路径: 路径的写法不是由/写起,例如由cd ../home
目录的相关操作
.: 代表此层目录;
..: 代表上一层目录;
-: 代表前一个工作目录;
~: 代表目前使用者身份所在的家目录;
~holelin: 代表holelin这个使用者的家目录
cd: (change directory)切换目录
pwd: (print working directory)显示当前目录
mkdir: (make directory)建立一个新目录
rmdir: 删除一个空目录
文件与目录管理
ls: 文件与目录的查看
123ls [-aAdfFhilnrRSt] 文件名或目录名称ls [--color={never,auto,always}] 文件名或目录名称ls [--full-time] 文件名或目录名称
-a: 全部的文件,连同隐藏文件一起列出来
-A: 全部的文件,连同隐 ...
Linux-文本查看命令
参考文献
cat
文本内容显示到终端
1cat demo.yml
tac
文本反向显示到终端
head
查看文件开头
12head demo.ymlhead -5 demo.yml
tail
查看文件结尾
常用参数-f文件内容更新后,显示信息同步更新
wc
统计文件内容信息
1wc -l demo.yml
grep
检索文本内容
1grep -i "待查询的字符串信息" filename
说明:grep能在文件中检索特定内容
-i:大小写敏感
-A/-B/-C <N>:顺带显示前后文,-A表示后面 N 行,-B表示前面 N 行,-C表示前后各 N 行
-E:使用正则表达式来匹配
-v:反选(输出不匹配的行)
-l:只输出能匹配到内容的文件名
-F:不要将检索内容视为正则表达式
-r:递归匹配目录下所有文件的内容
-o:只输出匹配上了的部分(而不是整行)
-a:也对二进制文件进行检索,而不是忽略它们!
nl
添加打印行号
12345678910# nl [-bnw] 档案 参数:-b :指定行号指定的方式,主要有两 ...
Linux(二)-文件/目录权限管理
参考文献
鸟哥的Linux私房菜基础学习篇(第四版)
权限的概念
文件拥有者
用户组
每个账号都可以有多个用户组的支持
其他人
在Linux中,任何一个文件都具有用户(User),所属群组(Group)以及其他人(Others);
Linux用户身份与用户组记录
默认情况下,所有的系统上的账号与一般身份用户的相关信息都记录在/etc/passwd这个文件内,个人密码则是记录在/etc/shadow这个文件中,Linux所有的组名都记录在/etc/group中
Linux文件属性
使用ls -al显示的文件列表信息
123456789101112[root@holelin holelin]# ls -altotal 32drwx------ 3 holelin holelin 4096 May 25 23:34 .drwxr-xr-x. 5 root root 4096 Mar 4 11:09 ..-rw------- 1 holelin holelin 783 May 24 23:33 .bash_history-rw-r--r-- 1 h ...
Linux-基础
参考文献
鸟哥的Linux私房菜基础学习篇(第四版)
基础命令
显示日志与时间: date
显示日历: cal
计算器: bc
注销: logout
帮助命令:
man <command> : DATE(1)
代号
说明
1
用户在Shell环境中可以操作的命令或者可执行文件
2
系统内核可调用的函数与工具等
3
一些常用的函数(function)与函数库(library),大部分为C的函数库(libc)
4
设备文件的说明,通常在/dev下的文件
5
配置文件或是某些文件的格式
6
游戏(games)
7
惯例与协议等.例如Linux文件系统,网络协议,ASCII代码等的说明
8
系统管理员可使用的管理命令
9
跟内核有关的文件
<command> --help
info <command>
说明文档路径: /usr/share/doc/
获取终端支持的语系数据库:
echo $LANG
locale
1234567891011121314L ...
Linux-环境变量配置
参考文献
Linux环境变量配置全攻略
在自定义安装软件的时候,经常需要配置环境变量,下面列举出各种对环境变量的配置方法.
下面所有例子的环境说明如下:
系统:Ubuntu 14.0
用户名:uusama
需要配置MySQL环境变量路径:/home/uusama/mysql/bin
Linux读取环境变量
读取环境变量的方法:
export命令显示当前系统定义的所有环境变量
echo $PATH命令输出当前的PATH环境变量的值
env 查看所有默认的环境变量
set |more 要查看所有环境变量,包括 shell 变量、本地变量和 shell 函数(如任何用户定义的变量和命令别名)
这两个命令执行的效果如下
123456789101112131415uusama@ubuntu:~$ exportdeclare -x HOME="/home/uusama"declare -x LANG="en_US.UTF-8"declare -x LANGUAGE="en_US:"declare ...
inside-the-linux-kernel
参考文献
inside the linux kernel
https://www.baeldung.com/linux/boot-process
https://www.freecodecamp.org/news/the-linux-booting-process-6-steps-described-in-detail/
The Linux Booting Process
BIOS and UEFI
首先,系统启动后,BIOS(基本输入/输出系统)或 UEFI(统一可扩展固件接口)程序就会启动.通常,BIOS 包含获得对主机设备的初始访问的所有代码:
keyboard 键盘
display screen 显示屏
disk drives 磁盘驱动器
serial communications 串行通讯
然而,一旦系统完全启动,大多数这些设备都会有专用的设备驱动程序接管.
BIOS 和 UEFI 是计算机用来启动操作系统 (OS) 的固件接口.然而,这两个程序在如何存储驱动器上和有关驱动器的元数据方面有所不同:
BIOS 使用主引导记录 (MBR)
MBR 代表主引导记 ...
yum配置
yum源描述
yum需要一个yum库,也就是yum源。默认情况下,CentOS就有一个yum源。在/etc/yum.repos.d/目录下有一些默认的配置文件(可以将这些文件移到/opt下,或者直接在yum.repos.d/下重命名)。
首先要找一个yum库(源),然后确保本地有一个客户端(yum这个命令就是客户端),由yum程序去连接服务器。连接的方式是由配置文件决定的。通过编辑/etc/yum.repos.d/CentOS-Base.repo文件,可以修改设置。
yum配置源
首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo
1mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
进入yum源配置文件所在文件夹
1cd /etc/yum.repos.d
配置网易源
CentOS 7
1wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
CentOS ...
firewall
firewalld
firewalld常用命令
启动firewalld服务:
1systemctl start firewalld.service
关闭firewalld服务:
1systemctl stop firewalld.service
重启firewalld服务
1systemctl restart firewalld.service
查看firewalld状态
1systemctl status firewalld.service
开机自启firewalld
1systemctl enable firewalld
查看版本
1firewall-cmd --version
查看帮助
1firewall-cmd --help
显示状态
1firewall-cmd --state
查看所有打开的端口
1firewall-cmd --zone=public --list-ports
更新防火墙规则
12firewall-cmd --reload* 每次更改firewall规则后需重新加载
添加开放端口
1firewall- ...
iptables
参考文献
iptables 及 docker 容器网络分析
iptables详解(1): iptables概念
iptables
聊聊Iptables 的五表五链,你学会了吗?
企业防火墙之iptables
iptables
iptables有一个很重要的设置概念就是5表5链
一个filter表,一个nat表,一个mangle表,一个raw表,一个security.它们分别作用于不同的方向,
filter表: 此表用于数据包过滤.它有三个内置链: INPUT(用于本地传递的数据包),FORWARD(用于通过系统路由的数据包)和 OUTPUT(用于本地生成的数据包)
内核模块: iptables_filter
nat表network address translation,网络地址转换功能;
此表用于网络地址转换(nat).它有三个内置链: PREROUTING(用于到达网络接口的数据包),INPUT(用于本地生成的数据包)和 OUTPUT(用于离开网络接口的数据包)
内核模块: iptable_nat
mangle表拆解报文,做出修改,并重新封装的功能; ...