Linux基本操作命令
1.1shell命令基础
shll作为Linux操作系统的外壳,为用户提供使用操作系统的接口。它是命令语言、命令解释程序及程序设计语言的统称。
shell是用户和Linux内核之间的接口程序,如果把Linux内核想象成一个球体的中心,shell就是球体的外层。当shell或其他程序传递命令时,内核会做出相对反应。
1.2shell命令格式
在Linux操作系统中看到的命令其实就是shell命令,shell命令基本格式如下。
command [选项] [参数]
(1)command为命令名称,例如,查看当前文件夹下文件或文件夹的命令是ls
(2)[选项]表示可选,是对命令的特别定义,以链接符号"-“开始,多个选项可以用一个连接符号”-"链接起来,列如ls-l -a与ls-la的作用是相同的。有些命令不写选项和参数也能执行,有些命令在必要的时候可以附带参数和选项。
列如:ls -l -a和ls -la是一样的
[root@szx ~]# ls -l -a
总用量 36
dr-xr-x---. 14 root root 4096 3月 20 23:27 .
dr-xr-xr-x. 18 root root 256 3月 20 23:17 ..
drwxr-xr-x. 2 root root 6 3月 20 23:17 公 共
drwxr-xr-x. 2 root root 6 3月 20 23:17 模 板
drwxr-xr-x. 2 root root 6 3月 20 23:17 视 频
drwxr-xr-x. 2 root root 6 3月 20 23:17 图 片
drwxr-xr-x. 2 root root 6 3月 20 23:17 文 档
drwxr-xr-x. 2 root root 6 3月 20 23:17 下 载
drwxr-xr-x. 2 root root 6 3月 20 23:17 音 乐
drwxr-xr-x. 2 root root 6 3月 20 23:17 桌 面
-rw-------. 1 root root 999 3月 20 22:14 anaconda-ks.cfg
-rw-------. 1 root root 71 3月 20 23:27 .bash_history
-rw-r--r--. 1 root root 18 8月 11 2021 .bash_logout
-rw-r--r--. 1 root root 141 8月 11 2021 .bash_profile
-rw-r--r--. 1 root root 429 8月 11 2021 .bashrc
drwx------. 6 root root 78 3月 20 23:17 .cache
drwx------. 7 root root 4096 3月 20 23:17 .config
-rw-r--r--. 1 root root 100 8月 11 2021 .cshrc
drwx------. 3 root root 19 3月 20 23:17 .local
drwx------. 2 root root 6 3月 20 22:05 .ssh
-rw-r--r--. 1 root root 129 8月 11 2021 .tcshrc
[root@szx ~]# ls -la
总用量 36
dr-xr-x---. 14 root root 4096 3月 20 23:27 .
dr-xr-xr-x. 18 root root 256 3月 20 23:17 ..
drwxr-xr-x. 2 root root 6 3月 20 23:17 公 共
drwxr-xr-x. 2 root root 6 3月 20 23:17 模 板
drwxr-xr-x. 2 root root 6 3月 20 23:17 视 频
drwxr-xr-x. 2 root root 6 3月 20 23:17 图 片
drwxr-xr-x. 2 root root 6 3月 20 23:17 文 档
drwxr-xr-x. 2 root root 6 3月 20 23:17 下 载
drwxr-xr-x. 2 root root 6 3月 20 23:17 音 乐
drwxr-xr-x. 2 root root 6 3月 20 23:17 桌 面
-rw-------. 1 root root 999 3月 20 22:14 anaconda-ks.cfg
-rw-------. 1 root root 71 3月 20 23:27 .bash_history
-rw-r--r--. 1 root root 18 8月 11 2021 .bash_logout
-rw-r--r--. 1 root root 141 8月 11 2021 .bash_profile
-rw-r--r--. 1 root root 429 8月 11 2021 .bashrc
drwx------. 6 root root 78 3月 20 23:17 .cache
drwx------. 7 root root 4096 3月 20 23:17 .config
-rw-r--r--. 1 root root 100 8月 11 2021 .cshrc
drwx------. 3 root root 19 3月 20 23:17 .local
drwx------. 2 root root 6 3月 20 22:05 .ssh
-rw-r--r--. 1 root root 129 8月 11 2021 .tcshrc
1.3显示系统信息的命令
1.3.1who——查看用户登录信息
[root@localhost ~]# who
root seat0 2024-03-20 23:17 (login screen)
root tty2 2024-03-20 23:17 (tty2)
root pts/1 2024-03-20 23:18 (192.168.113.1)
[root@localhost ~]# who -a //显示所有用户信息
系统引导 2024-03-20 23:17
运行级别 5 2024-03-20 23:17
root ? seat0 2024-03-20 23:17 ? 5640 (login screen)
root + tty2 2024-03-20 23:17 00:02 5640 (tty2)
root + pts/1 2024-03-20 23:18 . 6351 (192.168.113.1)
1.3.2whoami——显示当前操作用户
[root@localhost ~]# whoami
root
1.3.3hostname/hostnamectl——显示或设置当前系统的主机名
[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]# hostnamectl set-hostname szx //永久修改系统主机名
[root@localhost ~]# bash //执行命令
[root@szx ~]#
[root@szx ~]# hostname
szx
1.3.4date——显示时间/日期
[root@szx ~]# date
2024年 03月 26日 星期二 19:14:02 CST
1.3.5cal——显示日历信息
[root@szx ~]# cal
三月 2024
一 二 三 四 五 六 日
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
1.3.6clear——清除屏幕命令
[root@szx ~]# clear
[root@szx ~]#
1.4shell使用技巧
1.4.1命令和文件的自动补齐功能——Tab键补全
输入字符后,按两下tab键,shell就会列出以输入字符开头的所有可用命令,如果只有一个匹配,就自动补齐。还有路径、文件名补齐。
在命令行上操作时,一定要勤用tab键,可以避免少犯错误
1.4.2历史命令——history
[root@szx ~]# history
1 who
2 who -a
3 whoami
4 hostname
5 hostnamectl set-hostname szx
6 bash
7 hostname
8 date
9 cal
10 clear
11 [root@szx ~]# clear
12 ls -l -a
13 ls -la
14 claer
15 clear
16 history
配置文件:/root/.bash_history
1.4.3命令别名
alias——给一个经常使用的复杂指令设置别名,提高工作效率
格式:alias [别名]=[命令名称]
unalias——取消别名
1.4.4命令帮助
1)whatis——查询命令
2)利用“–help”选项查询
3)利用man查询
4)利用info查询
1.5Linux文件及目录管理
Linux操作系统的目录结构(文件层级系统)
/boot系统启动目录 /devLinux设备文件保存位置 /etc存放系统管理员的配置文件和子目录的文件
/home普通用户的主目录(家目录) /media挂载目录(媒体设备) /mnt挂载目录(额外设备)
/opt第三方安装的软件保存位置 /proc虚拟目录,系统内存映射 /root系统管理员的主目录
/run系统启动以来描述系统信息的文件 /srv服务数据目录 /tmp临时目录
/usr存储系统软件资源 /bin系统基本的用户命令 /lib与lib64系统调用函数库保存位置
/sbin系统管理员,命令存放目录
1.6文件及目录显示类命令
1.6.1pwd——显示当前目录
显示当前目录,以绝对路径的形式显示
[root@szx ~]# pwd
/root
1.6.2cd——改变当前目录
[root@szx ~]# cd /tmp
[root@szx tmp]#
1.6.3ls——显示目录文件
[root@szx ~]# ls
公共 视频 文档 音乐 anaconda-ks.cfg
模板 图片 下载 桌面
[root@szx ~]# ls -l //长格式输出,包含文件属性详细信息
总用量 4
drwxr-xr-x. 2 root root 6 3月 20 23:17 公共
drwxr-xr-x. 2 root root 6 3月 20 23:17 模板
drwxr-xr-x. 2 root root 6 3月 20 23:17 视频
drwxr-xr-x. 2 root root 6 3月 20 23:17 图片
drwxr-xr-x. 2 root root 6 3月 20 23:17 文档
drwxr-xr-x. 2 root root 6 3月 20 23:17 下载
drwxr-xr-x. 2 root root 6 3月 20 23:17 音乐
drwxr-xr-x. 2 root root 6 3月 20 23:17 桌面
-rw-------. 1 root root 999 3月 20 22:14 anaconda-ks.cfg
[root@szx ~]# ls -a //显示所有文件,包含隐藏文件
. 图片 anaconda-ks.cfg .cache .tcshrc
.. 文档 .bash_history .config
公共 下载 .bash_logout .cshrc
模板 音乐 .bash_profile .local
视频 桌面 .bashrc .ssh
1.6.4stat——显示文件或文件系统状态信息
[root@szx ~]# stat /root
文件:/root
大小:4096 块:8 IO 块:4096 目录
设备:fd00h/64768d Inode:134348930 硬链接:14
权限:(0550/dr-xr-x---) Uid:( 0/ root) Gid:( 0/ root)
环境:system_u:object_r:admin_home_t:s0
最近访问:2024-03-26 19:02:31.557347045 +0800
最近更改:2024-03-20 23:27:24.742594703 +0800
最近改动:2024-03-20 23:27:24.742594703 +0800
创建时间:2024-03-21 06:04:11.573001436 +0800
1.7文件及目录操作类命令
1.7.1touch——创建文件或修改文件的存取时间。无中生有,万象更新:如果指定文件不存在,则会生成一个空文件
[root@szx mnt]# touch file01.txt
[root@szx mnt]# touch file02.txt file03.txt
[root@szx mnt]# ls -l
总用量 0
-rw-r--r--. 1 root root 0 3月 26 20:36 file01.txt
-rw-r--r--. 1 root root 0 3月 26 20:38 file02.txt
-rw-r--r--. 1 root root 0 3月 26 20:38 file03.txt
[root@szx mnt]# touch -d 20200626 /mnt/*
[root@szx mnt]# ls -l
总用量 0
-rw-r--r--. 1 root root 0 6月 26 2020 file01.txt
-rw-r--r--. 1 root root 0 6月 26 2020 file02.txt
-rw-r--r--. 1 root root 0 6月 26 2020 file03.txt
1.7.2mkdir——创建新目录
[root@szx mnt]# mkdir user01
[root@szx mnt]# ls -l
总用量 0
-rw-r--r--. 1 root root 0 6月 26 2020 file01.txt
-rw-r--r--. 1 root root 0 6月 26 2020 file02.txt
-rw-r--r--. 1 root root 0 6月 26 2020 file03.txt
drwxr-xr-x. 2 root root 6 6月 26 2020 hgfs
drwxr-xr-x. 2 root root 6 3月 26 20:46 user01
[root@szx mnt]# mkdir -p /mnt/usr03/a01 /mnt/usr03/a02 //递归创建父目录usr03子目录a01、a02
[root@szx mnt]# ls -l /mnt/usr03
总用量 0
drwxr-xr-x. 2 root root 6 3月 26 20:51 a01
drwxr-xr-x. 2 root root 6 3月 26 20:51 a02
1.7.3redir——删除空目录
[root@szx mnt]# ls -l
drwxr-xr-x. 2 root root 6 6月 26 2020 hgfs
drwxr-xr-x. 2 root root 6 3月 26 20:46 user01
drwxr-xr-x. 4 root root 28 3月 26 20:51 usr03
[root@szx mnt]# rmdir user01
[root@szx mnt]# ls -l
drwxr-xr-x. 2 root root 6 6月 26 2020 hgfs
drwxr-xr-x. 4 root root 28 3月 26 20:51 usr03
1.7.3rm——删除文件或目录
[root@szx ~]# ls -l /mnt
总用量 0
-rw-r--r--. 1 root root 0 6月 26 2020 file01.txt
-rw-r--r--. 1 root root 0 6月 26 2020 file02.txt
-rw-r--r--. 1 root root 0 6月 26 2020 file03.txt
drwxr-xr-x. 2 root root 6 6月 26 2020 hgfs
drwxr-xr-x. 4 root root 28 3月 26 20:51 usr03
[root@szx ~]# rm -r -f /mnt/* //强制删除目录下的所有文件和目录
[root@szx ~]# ls -l /mnt
总用量 0
1.7.4cp——复制文件或目录
[root@szx ~]# cd /mnt
[root@szx mnt]# ls
a01.txt a02.txt use01 use02
[root@szx mnt]# cd /root
[root@szx ~]# cp -r /mnt/a01.txt /mnt/use01/test01.txt
[root@szx ~]# ls -l /mnt/use01/test01.txt
-rw-r--r--. 1 root root 0 3月 27 19:39 /mnt/use01/test01.txt
1.7.5mv——移动/重命名文件或目录
[root@szx ~]# ls -l /mnt
总用量 0
-rw-r--r--. 1 root root 0 3月 27 19:27 a01.txt
-rw-r--r--. 1 root root 0 3月 27 19:27 a02.txt
drwxr-xr-x. 2 root root 39 3月 27 19:39 use01
drwxr-xr-x. 2 root root 6 3月 27 19:28 use02
[root@szx ~]# mv -f /mnt/a01.txt /mnt/test.txt
[root@szx ~]# ls -l /mnt
总用量 0
-rw-r--r--. 1 root root 0 3月 27 19:27 a02.txt
-rw-r--r--. 1 root root 0 3月 27 19:27 test.txt
drwxr-xr-x. 2 root root 39 3月 27 19:39 use01
drwxr-xr-x. 2 root root 6 3月 27 19:28 use02
1.7.6tar——打包、归档文件或目录
[root@szx ~]# cd /mnt
[root@szx mnt]# ls -l
总用量 0
[root@szx mnt]# touch /mnt/a01.txt /mnt/a02.txt
[root@szx mnt]# mkdir /mnt/test.txt
[root@szx mnt]# ls -l /mnt
总用量 0
-rw-r--r--. 1 root root 0 3月 27 20:14 a01.txt
-rw-r--r--. 1 root root 0 3月 27 20:14 a02.txt
drwxr-xr-x. 2 root root 6 3月 27 20:14 test.txt
[root@szx mnt]# mkdir /root/user01
[root@szx mnt]# tar -cvf /root/user01/tesr.tar /mnt
tar: 从成员名中删除开头的“/”
/mnt/
/mnt/a01.txt
/mnt/a02.txt
/mnt/test.txt/
[root@szx mnt]# ls -l /root/tesr.tar
ls: 无法访问 '/root/tesr.tar': 没有那个文件或目录
[root@szx mnt]# ls -l /root/user01
总用量 12
-rw-r--r--. 1 root root 10240 3月 27 20:16 tesr.tar
1.7.7du——查看文件或目录容量的大小
[root@szx mnt]# du -h /boot //以KB、MB、GB为单位显示文件或目录大小
1020K /boot/efi/EFI/BOOT
6.0M /boot/efi/EFI/redhat
7.0M /boot/efi/EFI
7.0M /boot/efi
2.3M /boot/grub2/fonts
2.3M /boot/grub2
8.0K /boot/loader/entries
8.0K /boot/loader
259M /boot
[root@szx mnt]# du -hs /boot //仅显示总计,及当前目录的大小
259M /boot
1.8文件内容的显示和处理
1.8.1cat——显示文件内容
[root@szx mnt]# dir
a01.txt a02.txt test.txt
[root@szx mnt]# cat a01.txt
[root@szx mnt]#
1.8.2more——逐页显示文件中的内容(仅向下翻页)
[root@szx ~]# more /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin
tss:x:59:59:Account used for TPM access:/:/sbin/nologin
1.8.2less——逐页显示文件中的内容(可向上、向下翻页)
j[root@szx ~]# less -N /etc/passwd
4 adm:x:3:4:adm:/var/adm:/sbin/nologin
5 lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
6 sync:x:5:0:sync:/sbin:/bin/sync
7 shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
8 halt:x:7:0:halt:/sbin:/sbin/halt
9 mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
10 operator:x:11:0:operator:/root:/sbin/nologin
11 games:x:12:100:games:/usr/games:/sbin/nologin
12 ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
13 nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin
14 tss:x:59:59:Account used for TPM access:/:/sbin/nologin
15 systemd-coredump:x:999:997:systemd Core Dumper:/:/sbin/nologin
16 dbus:x:81:81:System message bus:/:/sbin/nologin
:
1.8.3head——查看文件的N行
[root@szx ~]# head -n5 -v /etc/passwd
==> /etc/passwd <==
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
1.8.4tail——查看文件的最后N行
[root@szx ~]# tail -n5 -v /etc/passwd
==> /etc/passwd <==
sshd:x:74:74:Privilege-separated SSH:/usr/share/empty.sshd:/sbin/nologin
chrony:x:980:979:chrony system user:/var/lib/chrony:/sbin/nologin
dnsmasq:x:979:978:Dnsmasq DHCP and DNS server:/var/lib/dnsmasq:/usr/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
szx:x:1000:1000:szx:/home/szx:/bin/bash
1.8.4file——查看文件或目录的类型
[root@szx mnt]# dir
a01.txt a02.txt test.txt
[root@szx mnt]# file a01.txt
a01.txt: empty
1.8.5wc——统计命令:统计一个文件内容的单词量、字节数、换行数
[root@szx ~]# dir
公共 模板 视频 图片 文档 下载 音乐 桌面 anaconda-ks.cfg user01
[root@szx ~]# cat anaconda-ks.cfg
# Generated by Anaconda 34.25.3.8
# Generated by pykickstart v3.32
#version=RHEL9
# Use graphical install
graphical
repo --name="AppStream" --baseurl=file:///run/install/sources/mount-0000-cdrom/AppStream
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
# Keyboard layouts
keyboard --xlayouts='cn'
# System language
lang zh_CN.UTF-8
# Use CDROM installation media
cdrom
%packages
@^graphical-server-environment
%end
# Run the Setup Agent on first boot
firstboot --enable
# Generated using Blivet version 3.6.0
ignoredisk --only-use=nvme0n1
autopart
# Partition clearing information
clearpart --none --initlabel
# System timezone
timezone Asia/Shanghai --utc
# Root password
rootpw --iscrypted --lock --allow-ssh $6$S0UFf.YXMwD2450n$Qnmt.Is3aTk4OfzXwfWOnkUhrxhGqJvtQ0Fcm0az9bsRSwYjH0q4S4HDaAhvqd4kWKnBIx2xoFpNXQ83U8nb.0
user --name=szx --password=$6$71sVk4CKP3W3.l/m$gL24RGo77t3jqIyZOiGgqtGz/o6.x1xVHAXuZpeBGXaNQ0b5puwDOw0hk3PPB3UN53HpioMTRLj7iPQaWdCgr. --iscrypted --gecos="szx"
[root@szx ~]# wc anaconda-ks.cfg
40 88 999 anaconda-ks.cfg
1.8.6sort——统计命令:将文本文件内容加以排序
[root@szx mnt]# cat a01.txt
3
1
9
[root@szx mnt]# sort a01.txt
1
3
9
1.8.7echo——将显示内容输出到屏幕上
[root@szx mnt]# echo "hello welcome\n" //换行输出
hello welcome\n
[root@szx mnt]# echo -en "1 2 3\n" //整行换行输出
1 2 3
[root@szx mnt]# \echo -en "1\n2\n3\n" //每个字符换行输出
1
2
3
[root@szx mnt]# echo -n aaa //字符串不加引号,不换行输出
aaa[root@szx mnt]# echo -n sss
sss[root@szx mnt]#
[root@szx mnt]# echo "hello welcome">a01.txt //显示输出的内容输入文件中
[root@szx mnt]# echo "hello everyone">>a01.txt
[root@szx mnt]# cat a01.txt
hello welcome
hello everyone
1.9文件查找类命令
1.9.1whereis——查找文件位置
[root@szx mnt]# whereis passwd
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man5/passwd.5.gz /usr/share/man/man1/passwd.1ossl.gz /usr/share/man/man1/passwd.1.gz
1.9.2locate——查找绝对路径中包含指定字符串的文件位置
[root@szx mnt]# locate passwd
/etc/passwd
/etc/passwd-
/etc/pam.d/passwd
/etc/security/opasswd
/usr/bin/gpasswd
/usr/bin/grub2-mkpasswd-pbkdf2
/usr/bin/passwd
/usr/lib/firewalld/services/kpasswd.xml
/usr/lib64/samba/pdb/smbpasswd.so
......
[root@szx mnt]# locate -c passwd //只输出找到的数量
132
1.9.3find——文件查找
[root@szx ~]# find /etc -name passwd //查找指定名称的文件
/etc/pam.d/passwd
/etc/passwd
1.9.4which——确定程序的具体位置
[root@szx ~]# which find
/usr/bin/find
[root@szx ~]# which --show-tilde pwd //输出一个目录的非根
/usr/bin/pwd
[root@szx ~]# which --version bash //输出版本信息
GNU which v2.21, Copyright (C) 1999 - 2015 Carlo Wood.
GNU which comes with ABSOLUTELY NO WARRANTY;
This program is free software; your freedom to use, change
and distribute this program is protected by the GPL.
1.9.5grep——查找文件包含有指定字符串的行
[root@szx ~]# grep "root" /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
[root@szx ~]# grep -il "root" /etc/passwd //忽略字母大小写的不同,只显示包含匹配模式的文件名
/etc/passwd
1.10vi/vim编辑器的使用
1.10.1命令模式(其他模式→【Esc】)
使用户进入vim的初始状态,在此模式下,用户可以输入vim命令,使vim完成不同的工作命令,也可以从其他模式返回命令模式,在编辑模式下按“esc”键或在末行模式下输入错误的命令都回返回到命令模式。
1.10.2编辑模式(命令模式→【a/A】、【i/I】或【o/O】)
可以对编辑的文件添加新的内容并进行修改,这是唯一功能。
1.10.3末行模式(命令模式→【:】或【/】与【?】)
主要用来进行一些文字编辑辅助功能,如:查找、替换、文件保存等。
1.11文件进阶管理
1.11.1硬链接与软连接
Linux中可以为一个文件取多个名称,称为链接文件,分为硬链接和软连接两种。链接文件命令是【ln】,它的功能是为一个文件在另一个位置建立一个同步的连接,及不必再每一个需要的目录下都存放一个相同的文件,不必重复占用磁盘空间。
1)硬链接:以文本文件的形式存在,不占用实际空间;不允许给目录创建;只能在同一文件系统中创建。
2)软连接:以路径的形式存在类似于Windows中的快捷键;可以跨文件系统;可以对一个不存在的文件进行连接;可对目录进行链接。
1.11.2建立硬链接
[root@szx mnt]# dir
a01.txt a02.txt test.txt
[root@szx mnt]# touch test01.txt
[root@szx mnt]# ln test01.txt test.txt
1.11.3建立软连接
[root@szx mnt]# dir
a01.txt a02.txt test01.txt test02.txt test03.txt test.txt
[root@szx mnt]# ln -s test01.txt test04.txt
[root@szx mnt]# dir
a01.txt a02.txt test01.txt test02.txt test03.txt test04.txt test.txt
1.12通配符与文件名变量
1.12.1【*】——匹配任何字符和任何数目的字符组合
[root@szx ~]# mkdir temp
[root@szx ~]# cd temp
[root@szx temp]# touch test01.txt test02.txt test03.txt test33.txt test333.txt a03.txt
[root@szx temp]# dir test*
test01.txt test02.txt test03.txt test333.txt test33.txt
[root@szx temp]# dir *3*
a03.txt test03.txt test333.txt test33.txt
1.12.2【?】——匹配单个任意字符
[root@szx temp]# dir test0?.txt
test01.txt test02.txt test03.txt
1.12.3【[]】——匹配任何包含在括号里的单个字符
[root@szx temp]# dir test[2-3]*
test333.txt test33.txt
1.13输入/输出重定向与管道
1.13.1【<】——输入重定向
[root@szx ~]# wc < /etc/resolv.conf
3 8 74
1.13.2【>】——输出重定向
[root@szx mnt]# echo "hello windows">a01.txt
[root@szx mnt]# echo "hello eva">test01.txt
[root@szx mnt]# cat a01.txt>test01.txt
[root@szx mnt]# cat test01.txt
hello windows
1.13.2【|】——用于将上一次命令的输出作为下一次命令的输入
[root@szx mnt]# echo -en "hello\nhello\nworld\n">test01.txt
[root@szx mnt]# cat test01.txt
hello
hello
world
[root@szx mnt]# cat test01.txt | grep "hello"
hello
hello
1.14Linux快捷键的使用
1.14.1【Ctrl+a】——把光标移动到命令行的开头
1.14.2【ctrl+e】——把光标移动到命令行的末尾
1.14.3【ctrl+c】——键盘中断请求,结束当前任务
1.14.4【Ctrl+l】——清屏,相当于clear命令
1.14.4【tab】——自动补齐命令行与文件名,双击“tab”可列出所有可能匹配选项
.txt test33.txt
## 1.13输入/输出重定向与管道
### 1.13.1【<】——输入重定向
```bash
[root@szx ~]# wc < /etc/resolv.conf
3 8 74
1.13.2【>】——输出重定向
[root@szx mnt]# echo "hello windows">a01.txt
[root@szx mnt]# echo "hello eva">test01.txt
[root@szx mnt]# cat a01.txt>test01.txt
[root@szx mnt]# cat test01.txt
hello windows
1.13.2【|】——用于将上一次命令的输出作为下一次命令的输入
[root@szx mnt]# echo -en "hello\nhello\nworld\n">test01.txt
[root@szx mnt]# cat test01.txt
hello
hello
world
[root@szx mnt]# cat test01.txt | grep "hello"
hello
hello
1.14Linux快捷键的使用
1.14.1【Ctrl+a】——把光标移动到命令行的开头
1.14.2【ctrl+e】——把光标移动到命令行的末尾
1.14.3【ctrl+c】——键盘中断请求,结束当前任务
1.14.4【Ctrl+l】——清屏,相当于clear命令
1.14.4【tab】——自动补齐命令行与文件名,双击“tab”可列出所有可能匹配选项