1. Linux基础
1.1 Linux目录结构
具体介绍
1.2 远程操作工具
首先,需要Linux系统开启sshd服务
查看本人的Linux系统是否开启该服务
systemctl list-unit-files|grep enable


或者
service sshd status
Xshell(远程登录到Linux)
Xftp(远程上传下载文件)
1.3 Vi和Vim编辑器
三种常用模式
- 正常模式

- 插入模式/编辑模式

- 命令行模式
模式切换

尝试编辑一个Hello.java源文件
vim Hello.java
常用快捷键
1.4 关机、重启和用户登录注销
1.5 用户管理
添加用户
指定/修改密码
删除用户

# 删除用户xiaoming,但是保留家目录userdel xiaoming
# 删除用户xiaohong及用户主目录userdel -r xiaohong
查询用户信息
切换用户
查看当前用户/登录用户
# whoami# who am i
组的管理
- 新增组

- 删除组

- 增加用户时加上组

- 修改用户的组

- 用户和组的配置文件
1.6 实用指令
运行级别


然而在CentOS 8系统中,/etc/inittab已被弃用
可采用systemctl指令进行操作
查看存在哪些运行级别
ls -ll /usr/lib/systemd/system | grep 'runlevel[0-6].*target$'

查看当前用户的默认启动级别
systemctl get-default

切换当前用户的默认启动级别
systemctl set-default xxx# xxx可为 runlevel3.target# xxx可为 multi-user.target
找回root密码
帮助指令
文件目录类指令

















pwd

ls
ls -a

ls -l

cd

# 回到当前目录的上一级目录cd ..
# 回到家目录cd# 或者cd ~
- mkdir

mkdir -p /home/animal/tiger
- rmdir

创建多个文件
touch hello2.txt hello3.txt
- cp```shell# 将 /home/aaa.txt文件拷贝到 /home/bbb文件夹下cp aaa.txt bbb

# 将 /home/test目录整个拷贝到 /home/zwj目录下# 如果在/home目录下时cp -r test zwj
rm
# 将/home/aaa.txt文件删除rm aaa.txt

# 递归删除整个文件夹bbbrm -r bbb

mv
# 将/home/aaa.txt重命名为pig.txtmv aaa.txt pig.txt

# 将/home/pig.txt移动到/root目录下mv pig.txt /root

cat
cat -n /etc/profile | more
more

- less

- 重定向 >

# 重定向(也就是覆盖整个文件)ls -ll > a.txt

- 追加 >>

# 追加(也就是 将内容追加到文件末尾)ls -ll >> a.txt

echo
# 输出环境变量echo $PATH# 输出:hello worldecho 'hello world'
head
# 查看/etc/profile文件的前5行head -n 5 /etc/profile

tail ```shell
查看/etc/profile文件最后5行
tail -n 5 /etc/profile
实时监控mydate.txt
tail -f mydate.txt
- ln```shell# 在/home目录下创建一个linkToRoot软链接,链接到/root目录ln -s /root linkToRoot# 删除软链接linkToRootrm linkToRoot


显示最近执行过的10个指令
history | tail -n 10
执行历史编号为5的指令
!5
<a name="BcZmT"></a>#### 时间日期类指令- date<br />```shell# 显示当前时间date# 显示当前时间:xxx年xxx月xxx日date '+%y年%m月%d日'# 显示当前时间:xxx年xxx月xxx日 xxx时xxx分xxx秒date '+%y年%m月%d日 %H时%M分%S秒'
- cal

# 显示当前日历cal# 显示2020年日历cal 2020
搜索查找类指令
- find

# 根据名称查找/home目录下的hello.txt文件find /home -name hello.txt# 查找/opt目录下,用户名称为nobody的文件find /opt -user nobody# 查找整个Linux系统下大于20M的文件find / -size +20M
- locate

# 使用locate指令快速定位hello.txt文件所在的目录updatedblocate hello.txt
- grep指令和管道符号|

# 在hello.txt文件中,查找"yes"所在行且显示行号cat helo.txt | grep -n yes
压缩和解压缩类指令
- gzip/gunzip

# gzip压缩,将/home下的hello.txt文件进行压缩gzip hello.txt# gunzip压缩,将/home下的hello.tar.gz文件进行解压缩gunzip hello.txt.gz
- zip/unzip

# 将/home下的所有文件进行压缩呈mypackage.zipzip -r mypackage.zip /home/*# 将mypackage.zip解压到/opt/tmp目录下unzip -d /opt/tmp mypackaage.zip
- tar

# 压缩多个文件,将/home/a1.txt和/home/a2.txt压缩成a.tar.gztar -zcvf a.tar.gz a1.txt a2.txt# 将/home的文件夹 压缩成myhome.tar.gztar -zcvf myhome.tar.gz /home/*# 将a.tar.gz解压到当前目录tar -zxvf a.tar.gz# 将myhome.tar.gz解压到/opt/tmp2目录下tar -zxvf myhome.tar.gz -C /opt/tmp2
















