Learn Linux 实践

Learn Linux 实践

本教程根据 Linux Upskill Challenge, 经过自身实践, 而得. 作为笔记性质存在.

https://linuxupskillchallenge.org/

0. 创建自己的服务器

# 1. 首次登陆, 设置自己的密码
sudo -i passwd
# 2. 通过ssh远程访问
ssh username@<ip_address>
# 如果是私钥, 
ssh -i /私钥文件 username@<ip_address>
# 3. 更新apt源, 并且更新包
sudo apt update
sudo apt upgrade 
# 4. 如果内核更新, 重启
sudo reboot now
# 5. 注销登录
exit

1. 了解自己的服务器

# 1. 列出文件目录
ls
# 2. 系统运行时间 和 负载信息
uptime
# 3. 内存使用情况
free
# 4. 磁盘使用情况
df -h
# 5. 系统内核版本, 主机名, 操作系统类型(系统详细信息)
uname -a

2. 基本导航

# 1. 打印工作目录
pwd 
# 2. 更改文件目录
cd # 默认省略~ ;相对路径: ./:当前目录, ../上衣目录; 绝对路径:/
# 3. 列出文件及文件夹目录
ls -l -t -r -a <目录># -l:详细信息(长格式); -t :修改时间排序; -r : 逆序; -a :所有文件;
# 4. 创建目录
mkdir <目录名>
# 5. linux在线手册(查找命令详细信息)
man <命令名>
###############################进阶################################
# 1. 移动目录( 栈式记录目录 )
pushd <目录>
popd

3. 动手之旅

# 0. 密码的哈希存放地址:
sudo vim /etc/shadow
# 1. 重命名服务器
vim /etc/hostname 
reboot
# 方法二(推荐,不需要重启):
sudo hostnamectl set-hostname <server-host-name>
# 2. 更改服务器时区
timedatectl
timedatectl list-timezones
timedatectl set-timezone <your time zone>
timedatectl

4. 安装软件, 探索文件结构

# 1. 安装软件
apt search <app_name>
sudo apt install <app_name>
# 2. 一个可视化的文件资源浏览器
mc

5. more & less

# 0. 达到文件顶部/ 底部
more
less
# 1. 查看命令历史
history
# 查找命令
Ctrl + r
Esc
# 2. history的存放目录:
~/.bash_history

6. vim

###########################第一讲###########################
正常模式 & 输入模式
# 1. 光标移动
hjkl
# 单词定位
w # 单词开头
e # 单词末尾
b # 上一个da

fx # 移动到当前行的下一个'x'字符处
tx # 移动到 下一个 'x'字符之前
ma # 标记当前位置 为 'a'
`a # 返回标记的 'a' 位置
# 2. 保存退出
:wq
# 3. 删除字符
x # 向后删除 
X # 向前删除
# 4. 文本添加
i I a A o O
###########################第二讲###########################
# 5. 删除类命令
dw # 删除到下一个单词的开头前
d$ # 删除至当前行尾部
de # 删除到当前单词的最后
# 6. 数字+动作
2w # 光标移动到第二个单词开始
2e # 光标移动到第二个单词末尾
0 # 移动到行开头
d2w # 删除两个单词
# 7. 删除行
dd
2dd
# 8. 撤销
u # 撤销一个操作
U # 撤销至初始状态
Ctrl + r # 重做撤销
###########################第三讲###########################
# 1. 剪贴 粘贴(置入类命令)
dd
p
# 2. (替换类命令)
r
R
# 3. 替换文本直到单词的末尾(更改类命令 c) 
cw / ce 
c [number] motion
###########################第四讲###########################
# 1. 跳转
gg
G
# 2. 搜索类命令
/
?
n # 向下重做搜索
N # 向上重做搜索
# 3. 匹配单词/括号
# 配对括号, 匹配当前词, 向后搜索当前词
* 向前搜索当前词
# 4. 替换类命令
s/old/new # 可以替换old为new
s/old/new/g # 替换整行的匹配串
[number],[number]s/old/new/g # 替换[]行 到 []行 之间的 匹配串
%s/old/new/gc # 替换整个文件中的匹配串, 并每次询问
###########################第五讲###########################
# 1. 执行外部命令
:<number> # 跳转到某行
:!<command> # 比如 :!ls
:w <文件名> # 另存为<文件名>
v # 进入可视化选择模式
: # 选择完成后, :进入命令模式
:r <文件名> # 在当前文件中插入其他文件的内容 例: :r :!ls , 将ls插入到当前文件
###########################第六讲###########################
:set ic # ignore Case, 忽略大小写
:set noic # 关闭 忽略大小写
:set hls is # hlsearch incsearch 设置搜索为高亮(默认打开), 同时 实时显示
:set nohls nois # 关闭

:help 

6.2 vim进阶

###########################第七讲###########################
# vim 进阶教程:https://www.ycyaw.com/Linux/271.html
  1. 地址定界+命令 模式
:start_pos,end_pos CMD

地址格式

数字 具体的第几行(行号可以进行+ - 运算)
. 当前行
$ 最后一行
% 全文
/pattern/ 模式匹配

命令

d       #删除
y #复制
w file #将范围内的行另存至指定文件中
r file #在指定位置插入指定文件中的所有内容
t#行号     将前面指定的行复制到#行后
m#行号     将前面指定的行移动到#行后
  1. 光标跳转
# 当前页跳转:
H:页首    
M:页中间行    
L:页底

# 句间移动
( 上一句
) 下一句

# 段间移动
{ 上一段
} 下一段

  1. 命令
d # 以文本为单位进行剪贴操作
x # 以字符为单位进行剪贴操作
#x  # 剪切光标处起始的#个字符
xp  # 交换光标所在处的字符及其后面字符的位置 (剪贴字符,粘贴字符)
~   # 转换大小写(字符)
J   # 删除当前行后的换行符 (删除下一个空行, 注释上移)

  1. 高级用法
# 插入多遍重复内容
# 范例:粘贴“wang”100次
100iwang [ESC] 

di"   删除 当前行 "" 之间的内容
yi(   复制 当前行 () 之间的内容
vi[   选中 当前行 [] 之间的内容
ci"   修改 当前行 "" 之前的内容
  1. 可视模式
v  
V  
ctrl+v
进入可视模式后,
:normal <command> # 可对每一行执行命令 
# 例:1. 在每一行开口添加前缀
:normal I前缀
# 2. 在每一行后添加后缀
:normal A后缀

7. 服务器及其服务

# 1. 安装apache2
sudo apt update
sudo apt install apache2
# 2. 启动apache2
sudo systemctl stop apache2
systemctl start apache2
systemctl status apache2
# 3. apache2 配置文件
vim /etc/apache2/apache2.conf

IncludeOptional conf-enabled/*.conf # 加载配置文件时, 与这些文件合并

vim /etc/apache2/sites-enabled/000-default.conf # 定义默认网页位置
/var/www/html/index.html

# 4. 日志保存位置
/var/log/apache2
access.log
error.log

8. "grep"和其他文本处理器

1. cat filename1 filename2 ...
cat 连接n个文件的内容并打印到控制台

2. more filename
more 可以分页显示文件的内容,不过只能使用 空格 逐页显示, Enter 逐行显示. 且不能回滚. 
q退出.

3. less filename 
less 更加强大, 空格 向后翻页;b 向前翻页, 方向键浏览, /搜索, q退出. 等等.

4. tail filename
显示文件的后10行内容,主要用于实时查看日志文件等不断更新的文件.
tail -n N filename 
查看文件的后N行内容.
tail -f filename
实时跟踪文件 filename 的末尾,显示新添加的内容。

5. head filename
head -n N filename
查看文件的开头N行内容.

6. | (管道) 使用管道, 将一个命令的输出 作为 另一个命令的输入
cat /var/log/auth.log | grep "authenticating"

7. grep [选项] 模式 文件名
在文件中搜索指定的文本模式(正则表达式), 并打印
-i:忽略大小写。
-r 或 -R:递归地搜索目录及其子目录。
-n:显示匹配行的行号。
-l:仅显示包含匹配模式的文件名,而不显示匹配的具体行。
-v:反转匹配,显示不匹配模式的行。

8. cut -d "<分隔符>" -f n,n,n..(n-n n行到n行) filename
按列切割文本文件内容, -d 指定 分隔符, -f 指定要显示的列号(从1开始).

9. awk 'pattern { action }' filename
可以按行处理文本文件,提供了条件判断、循环、数学运算等功能,可以进行更复杂的文本处理操作。

9. 网络

  1. ss

查看套接字状态

ss
  1. nmap

    端口扫描器

nmap <要扫描的ip地址>

# 查看ip
ip a
ifconfig
  1. 防火请

iptables, nftables, ufw

ufw: 最简单的防火墙

# 查看防火墙规则表
sudo iptables -L

sudo ufw allow ssh
sudo ufw deny http
# 最后 使用以下命令启动 ufw
sudo ufw enable

10. 计划任务

1. 查看用户的计划任务
crontab -l
sudo crontab -l # root用户的计划任务

2. 查看系统的计划任务
less /etc/crontab

3. 查看每月/周/日/时 的计划任务:
/etc/cron.* # 这些计划任务的放置位置

yjy@user:~$ ls /etc | grep cron
cron.d
cron.daily
cron.hourly
cron.monthly
crontab
cron.weekly

4. 通过定时器运行特定任务
# 查看系统配置的定时器任务
systemctl list-timers

11. 查找文件/文件中的文本

1. locate filename

1. locate filename
定位 文件名中包含 "filename" 的位置

2. find

find 命令在 Linux 系统中被广泛用于搜索文件和目录。它提供了非常强大和灵活的搜索功能。以下是 find 命令的基本语法和常见用法:

基本语法:

find [搜索路径] [匹配条件] [操作]

常见用法:

  1. 按文件名搜索

    find /path/to/search -name "filename"
    
  2. 按目录搜索

    find /path/to/search -type d
    
  3. 按文件类型搜索

    find /path/to/search -type f
    
  4. 按大小搜索

    • 搜索大于10MB的文件:
    find /path/to/search -size +10M
    
    • 搜索小于1KB的文件:
    find /path/to/search -size -1k
    
  5. 按时间搜索

    • 搜索在最近7天内修改过的文件:
    find /path/to/search -mtime -7
    
    • 搜索在最近1小时内访问过的文件:
    find /path/to/search -amin -60
    
  6. 组合多个条件

    • 搜索所有在 /path/to/search 目录下的 .txt 文件,并且文件大小小于 1MB:
    find /path/to/search -name "*.txt" -size -1M
    
  7. 执行操作

    • 查找到的文件执行 ls -l 命令:
    find /path/to/search -exec ls -l {} \;
    
    • 或者,使用 + 替代 \; 可以提高效率(在 find 命令的末尾使用 \+):
    find /path/to/search -exec ls -l {} +
    

以上只是 find 命令的一些基本用法示例。你可以根据具体的需求组合不同的条件和操作。请注意,find 命令支持的选项和功能非常多,你可以通过 man find 命令来查看完整的文档。

3. which

which 查找指定命令的可执行文件的路径.

which command_name
which ls
which myscript.sh
which ls cp mv

请注意,which 命令仅查找在系统路径(通常是环境变量 PATH 中定义的路径)中的可执行文件。

12. 文件传输

使用特定软件, 比如 xftp

13. 文件权限管理

用户是按组分类的,一个用户属于一个或多个组。

user group others

1. 文件与目录权限管理

1. 更改文件属组
chgrp [-R] 属组名 文件名

2. 更改文件属主
chown [–R] 属主名 文件名
chown [-R] 属主名:属组名 文件名

3. 更改文件属性
chmod [-R] 权限 文件/目录

# 权限描述方式
①. 符号
# user group others all
u/g/o/a [+-=] 权限(rwx)
②. 数字
r:4  w:2  x:1  求和

14. 用户和组管理

用户是按组分类的,一个用户属于一个或多个组。

用户管理

  1. useradd:用于添加新用户。
    • 用法useradd username
  2. passwd:用于设置用户密码。
    • 用法passwd username
  3. userdel:用于删除用户。
    • 用法userdel username
  4. usermod:用于修改用户属性。
    • 用法usermod options username
    • 示例usermod -g groupname -G additional_groups -s new_shell -d new_home -m username
      • -g groupname:指定用户主组。
      • -G additional_groups:指定用户附加组,多个组名用逗号分隔。
      • -s new_shell:指定用户登录后使用的Shell。
      • -d new_home:指定用户的新家目录。
      • -m:移动用户的家目录。
  5. groups:显示用户所属的用户组。
    • 用法groups username

用户组管理

  1. groupadd:用于添加新用户组。
    • 用法groupadd groupname
  2. groupdel:用于删除用户组。
    • 用法groupdel groupname
  3. usermod:用于修改用户所属的用户组。
    • 用法usermod -g groupname username
    • 示例usermod -g developers john

切换用户身份命令

  • su:用于切换用户身份。
    • 用法su username
  • sudo:允许授权用户以其他用户身份执行命令,前提是该用户在/etc/sudoers文件中被授权。
    • 用法sudo command
    • 示例sudo apt-get update

15. 存储库

1. 存储库位置
/etc/apt/sources.list

2. 查看可以安装的软件包的数量
apt-cache dump | grep "Package:" | wc -l
# 过滤掉包名称grep,并使用以方式对它们进行计数:(wc -l是wc“字数统计”,“-l”使其计算行数而不是单词数) - 像这样↑

netperf # 网络性能测试工具

16. 压缩文件

  1. tar
tar [options] archive_file files_or_directories

常见选项:

  • -c:创建归档文件。
  • -x:解压缩归档文件。
  • -v:显示详细信息,也就是 verbose 模式。
  • -f:指定归档文件的名称,后面紧跟文件名。
  • -z:使用 gzip 压缩或解压缩。
  • -j:使用 bzip2 压缩或解压缩。
  • -t:显示归档文件中的内容。
  • -r:向归档文件中追加文件。
  • -A:从指定文件中追加到归档文件中(用于多个归档的合并)。
  • --delete:从归档文件中删除文件。
  • --list:显示归档文件中的内容。(只显示文件名)
  • --wildcards:使用通配符来匹配文件。

示例用法:

1. 创建归档文件

tar -cvf archive.tar file1 file2 directory/

这会将 file1file2directory 打包成 archive.tar

2. 解压缩归档文件

tar -xvf archive.tar

这会将 archive.tar 解压缩到当前目录。

3. 压缩和解压缩使用gzip

  • 压缩

    tar -czvf archive.tar.gz file1 file2 directory/
    

    这会将 file1file2directory 打包并使用 gzip 压缩成 archive.tar.gz

  • 解压缩

    tar -xzvf archive.tar.gz
    

    这会将 archive.tar.gz 解压缩到当前目录。

4. 列出归档文件内容

tar -tvf archive.tar

这会列出 archive.tar 中的文件和目录。

5. 追加文件到现有归档文件

tar -rvf archive.tar new_file

这会将 new_file 追加到 archive.tar 中。

6. 删除归档文件中的文件

tar --delete -f archive.tar file_to_delete

这会从 archive.tar 中删除 file_to_delete

7. 将一个归档文件的内容追加到另一个归档文件中

tar -Af archive1.tar archive2.tar

这会将 archive2.tar 的内容追加到 archive1.tar 中。

8. 使用通配符

tar -cvf archive.tar.gz --wildcards '*.txt' '*.log'

这会将当前目录下所有 .txt.log 文件打包并使用 gzip 压缩成 archive.tar.gz

这些是 tar 命令的一些最常用的用法。根据实际需求,您可以灵活使用 tar 命令的不同选项和功能。

17. 从源头构建应用程序

sudo apt install build-essential
wget -v https://nmap.org/dist/nmap-7.70.tar.bz2
# -v(详细)提供一些反馈,以便您可以看到发生了什么。完成后,通过列出目录内容进行检查
tar -jxvf nmap-7.70.tar.bz2
# ....其中 -j 表示“首先解压缩 bz2 文件”,-x 表示解压缩,-v 表示详细信息,-f 表示“接下来是文件名”。
make
sudo make install

18. 日志管理

logrotate教程: https://www.thegeekstuff.com/2010/07/logrotate-examples/

logrotate 是一个用于日志轮换和管理的实用工具。日志轮换是一种将旧的日志文件进行备份、压缩或删除,以便释放磁盘空间,同时保留足够的日志历史记录,以便查看系统活动和故障排除。logrotate 可以确保日志文件的大小和数量得以控制,避免日志文件无限增长,导致磁盘空间耗尽。

  1. 配置 logrotate

    logrotate 的配置文件通常位于 /etc/logrotate.conf 或者在 /etc/logrotate.d/ 目录中的单独文件中。您可以编辑这些文件来配置日志轮换策略。

配置文件示例:

以下是一个简单的 logrotate 配置文件示例:

    rotate 7
    daily
    missingok
    notifempty
    compress
    create 0644 username groupname
  • rotate 7:保留最近7个日志文件,旧日志将被删除。
  • daily:每天轮换一次日志文件。
  • missingok:如果日志文件丢失,继续轮换而不报错。
  • notifempty:只有在日志文件非空时才进行轮换。
  • compress:轮换后的日志文件将被压缩。
  • create 0644 username groupname:创建新的日志文件并设置权限、所有者和所属组。

我的ubuntu /etc/logrotate.conf:

  1 # see "man logrotate" for details
  2 # rotate log files weekly
  3 weekly
  4 
  5 # use the adm group by default, since this is the owning group
  6 # of /var/log/syslog.
  7 su root adm
  8 
  9 # keep 4 weeks worth of backlogs
 10 rotate 4
 11 
 12 # create new (empty) log files after rotating old ones
 13 create
 14 
 15 # use date as a suffix of the rotated file
 16 #dateext
 17 
 18 # uncomment this if you want your log files compressed
 19 #compress
 20 
 21 # packages drop log rotation information into this directory
 22 include /etc/logrotate.d
 23 
 24 # system-specific logs may be also be configured here.

手动执行 logrotate

默认情况下,logrotate 是由系统的定时任务自动执行的。但是,您也可以手动运行 logrotate 来测试您的配置文件是否正常工作,或者立即轮换日志文件:

sudo logrotate -vf /etc/logrotate.conf

这将以详细模式(-v)运行 logrotate,并显示操作过程。请根据需要使用不同的配置文件路径。

通过 logrotate,您可以自动化日志文件的管理和轮换,确保系统的日志文件得到适当的处理,同时也方便了管理员的管理工作。

19. 索引节点, 文件链接

Linux文件系统剖析: https://developer.ibm.com/tutorials/l-linux-filesystem/

1. Inodes(索引节点)

Inodes是文件系统中的数据结构,用于存储有关文件或目录的元数据。每个文件或目录都有一个唯一的Inode号码,该Inode包含文件的所有信息,如权限、拥有者、大小、时间戳等。硬链接和文件都是通过Inodes来表示的。

ls -li # -i 查看Inodes id

stat filepath # 查看文件信息


2. 硬链接 与 软链接

1. 硬链接(Hard Links)

硬链接是文件系统中的两个或多个目录项指向同一个Inode的文件。换句话说,多个文件名指向同一个数据块。当您创建一个硬链接时,新的文件名将与原始文件的Inode关联起来。

ln originalfile hardlink

在这个例子中,hardlinkoriginalfile 的硬链接。硬链接的限制是它们只能在同一个文件系统内工作。

2. 软链接(Symbolic Links)

软链接(也称为符号链接或symlinks)是一个特殊的文件,它包含指向另一个文件或目录的路径。软链接类似于Windows中的快捷方式。

ln -s /path/to/targetfile symlink

在这个例子中,symlink 是指向 /path/to/targetfile 的软链接。与硬链接不同,软链接可以跨越文件系统。

差异

硬链接:

  • 只链接到文件,而不链接到目录
  • 无法引用不同磁盘/卷上的文件
  • 即使文件被移动,链接也会引用该文件
  • 链接引用磁盘上的索引节点/物理位置

符号(软)链接:

  • 可以链接到目录
  • 可以引用不同硬盘/卷上的文件/文件夹
  • 如果删除原始文件,链接仍然存在
  • 如果文件被移动,链接将不再引用该文件
  • 链接引用抽象文件名/目录,而不是物理位置。
  • 他们有自己的inode

补充1. 磁盘管理

1. df (disk free) : 列出文件系统的磁盘使用量

df [-ahikHTm] [目录或文件名]
# 常用:
df -h 

选项与参数:

  • -a :列出所有的文件系统,包括系统特有的 /proc 等文件系统;
  • -k :以 KBytes 的容量显示各文件系统;
  • -m :以 MBytes 的容量显示各文件系统;
  • -h :以人们较易阅读的 GBytes, MBytes, KBytes 等格式自行显示;
  • -H :以 M=1000K 取代 M=1024K 的进位方式;
  • -T :显示文件系统类型, 连同该 partition 的 filesystem 名称 (例如 ext3) 也列出;
  • -i :不用硬盘容量,而以 inode 的数量来显示

2. du(disk used) : 检查磁盘空间使用量

du [-ahskm] 文件或目录名称
# 常用:
du -sh

选项与参数:

  • -a :列出所有的文件与目录容量,因为默认仅统计目录底下的文件量而已。
  • -h :以人们较易读的容量格式 (G/M) 显示;
  • -s :列出总量而已,而不列出每个各别的目录占用容量;
  • -S :不包括子目录下的总计,与 -s 有点差别。
  • -k :以 KBytes 列出容量显示;
  • -m :以 MBytes 列出容量显示;

3. fdisk : 磁盘分区表操作工具

fdisk [-l] 装置名称
# 常用
sudo fdisk -l

选项与参数:

  • -l :输出后面接的装置所有的分区内容。若仅有 fdisk -l 时, 则系统将会把整个系统内能够搜寻到的装置的分区均列出来。

输入m后, 命令介绍:

Command (m for help): m   <== 输入 m 后,就会看到底下这些命令介绍
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition            <==删除一个partition
   l   list known partition types
   m   print this menu
   n   add a new partition           <==新增一个partition
   o   create a new empty DOS partition table
   p   print the partition table     <==在屏幕上显示分割表
   q   quit without saving changes   <==不储存离开fdisk程序
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit  <==将刚刚的动作写入分割表
   x   extra functionality (experts only)

4. 磁盘格式化

mkfs [-t 文件系统格式] 装置文件名

选项与参数:

  • -t :可以接文件系统格式,例如 ext3, ext2, vfat 等(系统有支持才会生效)

5. 磁盘检验

fsck [-t 文件系统] [-ACay] 装置名称

选项与参数:

  • -t : 给定档案系统的型式,若在 /etc/fstab 中已有定义或 kernel 本身已支援的则不需加上此参数
  • -s : 依序一个一个地执行 fsck 的指令来检查
  • -A : 对/etc/fstab 中所有列出来的 分区(partition)做检查
  • -C : 显示完整的检查进度
  • -d : 打印出 e2fsck 的 debug 结果
  • -p : 同时有 -A 条件时,同时有多个 fsck 的检查一起执行
  • -R : 同时有 -A 条件时,省略 / 不检查
  • -V : 详细显示模式
  • -a : 如果检查有错则自动修复
  • -r : 如果检查有错则由使用者回答是否修复
  • -y : 选项指定检测每个文件是自动输入yes,在不确定那些是不正常的时候,可以执行 # fsck -y 全部检查修复。

6. 磁盘挂载与删除

  1. 磁盘挂载
mount [-t 文件系统] [-L Label名] [-o 额外选项] [-n]  装置文件名  挂载点
  1. 磁盘删除
umount [-fn] 装置文件名或挂载点

补充2. 正则表达式

1.限定符

  • ?

    零个或一个

  • *

    零个或多个

  • +

一个或多个

  • {[最小次数], 最多次数}

限定字符出现几次

注: 要匹配一串字符出现的次数, 需要将这一串用括号括起来

(ab)+

2. 或运算符 |

不加括号, 会默认匹配前后所有

a cat|dog 
// 匹配a cat 或 dog
a (cat|dog)
//  匹配 cat或者dog

3. 字符类

[abc]

//一般使用:
[a-zA-z]+

^

除^后面包含的字符以外的字符

[^0-9]+
//匹配非数字字符

4. 元字符

\d+

数字

\w+

英文, 数字 ,下划线

\s

空白符, tab ,换行符

\D+

非数字字符

\W+

非单词字符

\S+

非空白字符

.

任意字符, 但不包含换行符

\b

单词分界符: 单词的开头或结尾

5. 特殊字符

^

匹配行首字符

$

匹配行尾字符

6. 贪婪匹配 与 懒惰匹配

<.+>
//会匹配尖括号内的所有
<.+?>
//当遇到第一个 > 就结束匹配 , 懒惰匹配 .+的零次或一次
^#[0-9a-fA-F]{6}
^([0-9]{3}\.){3}[0-9]{3}$

总结

在这里插入图片描述

20. shell 脚本

Bash 脚本编程 : https://wangdoc.com/bash/

shell学习教程(超完整) : https://blog.csdn.net/w918589859/article/details/108752592

TODO(内容太多,另开一章,暂未完成)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Learning Linux Shell Scripting 2nd Edition pdf Break through the practice of writing tedious code with shell scripts Key Features Learn to impeccably build shell scripts and develop advanced applications Create smart solutions by writing and debugging scripts A step-by-step tutorial to automate routine tasks by developing scripts Book Description Linux is the most powerful and universally adopted OS. Shell is a program that gives the user direct interaction with the operating system. Scripts are collections of commands that are stored in a file. The shell reads this file and acts on commands as if they were typed on the keyboard. Learning Linux Shell Scripting covers Bash, GNU Bourne Again Shell, preparing you to work in the exciting world of Linux shell scripting. CentOS is a popular rpm-based stable and secured Linux distribution. Therefore, we have used CentOS distribution instead of Ubuntu distribution. Linux Shell Scripting is independent of Linux distributions, but we have covered both types of distros. We start with an introduction to the Shell environment and basic commands used. Next, we explore process management in Linux OS, real-world essentials such as debugging and perform Shell arithmetic fluently. You'll then take a step ahead and learn new and advanced topics in Shell scripting, such as decision making, starting up a system, and customizing a Linux environment. You will also learn about grep, stream editor, and AWK, which are very powerful text filters and editors. Finally, you'll get to grips with taking backup, using other language scripts in Shell Scripts as well as automating database administration tasks for MySQL and Oracle. By the end of this book, you will be able to confidently use your own shell scripts in the real world. What you will learn Familiarize yourself with the various text filtering tools available in Linux Understand expressions and variables and how to use them practically Automate decision-making and save a lot of time

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值