云盘算 (连续更新中)
PING baidu.com (110.242.68.66) 56(84) bytes of data.64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=1 ttl=128 time=27.5 ms
* 关闭防火墙
# systemctl stop firewalld
* 确认防火墙关闭情况
ystemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead) since 二 2024-03-26 21:00:13 CST; 2min 18s ago
Docs: man:firewalld(1)
Process: 705 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
Main PID: 705 (code=exited, status=0/SUCCESS)
3月 26 19:44:55 localhost.localdomain systemd: …
3月 26 19:44:56 localhost.localdomain systemd: …
3月 26 19:44:57 localhost.localdomain firewalld: …
3月 26 21:00:12 localhost.localdomain systemd: …
3月 26 21:00:13 localhost.localdomain systemd: …
Hint: Some lines were ellipsized, use -l to show in full.
* 开启防火墙
systemctl start firewalld
# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since 二 2024-03-26 21:04:38 CST; 1min 7s ago
Docs: man:firewalld(1)
Main PID: 9130 (firewalld)
CGroup: /system.slice/firewalld.service
└─9130 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid
3月 26 21:04:38 localhost.localdomain systemd: Starting firewalld - dynamic firewal…
3月 26 21:04:38 localhost.localdomain systemd: Started firewalld - dynamic firewall…n.
3月 26 21:04:38 localhost.localdomain firewalld: WARNING: AllowZoneDrifting is en…
Hint: Some lines were ellipsized, use -l to show in full.
* 取消防火墙开机自动启动设置
# systemctl disable firewalld
* 临时关闭防火墙
# setenforce 0
# setenforce 1
* 永久关闭防火墙
* ```
# vi /etc/selinux/config
bled
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
~
~
~
~
:wq
[*]检察状态
# getenforce
4.快照
[*]在假造服务器中进行对应时间的快照操作
https://img-blog.csdnimg.cn/direct/e67368f455a946c883b7cfaa95c1e8ae.png
如果出现标题,可以通过规复前面的快照,规复快照时的指令
https://img-blog.csdnimg.cn/direct/a67b6ed35da145a195d5eec548c48f3e.png
5.路径-目录的创建
[*]Ls 检察当前路径
[*]Ls /中国 检察路径下中国文件
[*]CD切换目录
[*]Cd … 返回上一级目录
[*]Cd . 当前目录
[*]Cd …/…/./点点数量返回次数,好比在西安,通过此返回到西安。
[*]Cd -返回上一次进入的目录
[*]CD /中国 切换到中国的路径
[*]Pwd 检察当前所在目录(检察
绝对路径
,即/中国/陕西)
[*]Mkdir 创建目录
[*]Mkdir /a 在根下创建的目录
[*]Mkdir a 在所在目中创建的一个小小根
[*]Mkdir -p 直接在用户名下指定根下创建目录
[*]Mkdir -p /01/01/{01,02}
[*]Mkdir-v检察创建过程
[*]Yum install tree 安装tree
# ls
01 bootetc lib mediaprocrun srvtmpvar 学习
bindev homelib64mnt rootsbinsysusrzhongguo中国
#
# mkdir -p /opt/a/b/c
# tree /opt
/opt
└── a
└── b
└── c
3 directories, 0 files
touch 创建文本
[*]
# touch /opt/file.txt
# tree /opt
/opt
├── a
└── file.txt
1 directory, 1 file
查找小知识:当yum关闭,执行rm -f /var/run/yum.pid后正常进行yum安装的内容
终端连接到服务器重要使用IP进行连接,使用的是ssh进行协议连接,ssh root @192.168.42.125(端口号22位)
### 6.文件拷备
拷贝主要使用命令词cp
# cp -r /opt/a /tmp
# cd /tmp
# ls
a
ks-script-6_CVQf
systemd-private-21884cc5cf934fa897803901bc0c5010-chronyd.service-9VXlBi
systemd-private-278a64b471014c7c9e06255891e9db60-chronyd.service-V6LscI
systemd-private-4ba49a680b2143acad4b4f22972a738d-chronyd.service-cpie7T
systemd-private-7700d0306cf04fa7974aded2a5b4163b-chronyd.service-hqtM4M
systemd-private-7d007bbf789a46f98aae0f9ce4b79c59-chronyd.service-EpYhNT
systemd-private-90d6be988e1a4f04a156c442b76d1669-chronyd.service-Mo5Xuj
systemd-private-a03007a2665542b192b481f04ec40f07-chronyd.service-0fQMtS
systemd-private-d2783f5906cf4b6ba77272eed962d29f-chronyd.service-xaDnqE
systemd-private-f86f9439466540fe8135d13c42f5605b-chronyd.service-VB5RIR
yum.log
>
> 扩展:在复制中,可以对复制的内容进行重命名 (cp -r /otp/a /tmp/a-1)
>
>
>
### 7.文件移动
拷贝主要使用命令词mv
# cd /home
# ls
etc ifcfg-ens33 passwd tt yun
### 8.文件删除
拷贝主要使用命令词rm
# rm -rf /opt/a/b
# tree /opt/a
/opt/a
0 directories, 0 files
# tree /opt
/opt
└── a
1 directory, 0 files
### 9.
绝对路径
与相对路径
相对路径
# cd
# cd /
# cd opt
# cd a
# cd b
# cd c
# cd …
# cd …/…/…
# cd otp
-bash: cd: otp: 没有那个文件或目录
# cd opt
# tree
.
└── a
└── b
└── c
3 directories, 0 files
绝对路径
# cd /opt/a/b/c
#
### 10.查看各个指定路径下的文件
使用代码 tree
# tree /etc/sysconfig
/etc/sysconfig
├── anaconda
├── authconfig
├── cbq
│ ├── avpkt
│ └── cbq-0000.example
├── chronyd
├── console
├── cpupower
├── crond
├── ebtables-config
├── firewalld
├── grub -> …/default/grub
├── init
├── ip6tables-config
├── iptables-config
├── irqbalance
├── kdump
├── kernel
├── man-db
├── modules
├── netconsole
├── network
├── network-scripts
│ ├── ifcfg-lo
│ ├── ifdown -> …/…/…/usr/sbin/ifdown
│ ├── ifdown-bnep
│ ├── ifdown-eth
│ ├── ifdown-ippp
│ ├── ifdown-ipv6
│ ├── ifdown-isdn -> ifdown-ippp
│ ├── ifdown-post
│ ├── ifdown-ppp
│ ├── ifdown-routes
│ ├── ifdown-sit
│ ├── ifdown-Team
│ ├── ifdown-TeamPort
│ ├── ifdown-tunnel
│ ├── ifup -> …/…/…/usr/sbin/ifup
│ ├── ifup-aliases
│ ├── ifup-bnep
│ ├── ifup-eth
│ ├── ifup-ippp
│ ├── ifup-ipv6
│ ├── ifup-isdn -> ifup-ippp
│ ├── ifup-plip
│ ├── ifup-plusb
│ ├── ifup-post
│ ├── ifup-ppp
│ ├── ifup-routes
│ ├── ifup-sit
│ ├── ifup-Team
│ ├── ifup-TeamPort
│ ├── ifup-tunnel
│ ├── ifup-wireless
│ ├── init.ipv6-global
│ ├── network-functions
│ └── network-functions-ipv6
├── ntpdate
├── rdisc
├── readonly-root
├── rsyslog
├── run-parts
├── selinux -> …/selinux/config
├── sshd
└── wpa_supplicant
4 directories, 61 files
## 二、指令汇总
1. IP
1. Ip a (查询ip的详情,如果不显示可以使用ipup ens33显示ip地址)
2. IP自启
1. 查看时间 date
1. Date命令查看时间
2. Date -r 修改系统时间
3. Hwdate -r 修改硬件时间
4. Ntpdate {systohc hctosys}同步时间,如果插件未安装,需要使用yum install进行安装,然后同步时间--ntpdate ntp.aliyun.com 同步阿里云时间
5. 将硬件时间写入到主办中 hwclock -w
6. 硬盘时间同步系统 hwclick --hctosys
7. 系统时间同步硬盘 hwclock --systihc
2. 查看防火墙
1. 检查防火墙状态:systemctl status firewalld
2. 关闭防火墙:systemctl stop firewalld
3. 关闭防火墙自启:systemctl disable firewalld
4. 重启系统:reboot
3. 关闭selinux
1. 查看状态:getenforce
2. 关闭:vi /etc/selinux/config 中将SELINUX=disabled
3. 临时关闭: setenforce 0
4. 重启系统:reboot
4. 查看目录类操作
1. 查看指定路径:cd
2. 查看路径下的目录:ls
3. 查看路径下文件的详情:ls -l
4. 查看文件中的所有文件包括隐藏文件 :ls -a
5. 查看路径下文件详情且文件大小转码:ls-lh
6. 查看当前位置:pwd
7. 创建目录:mkdir
8. 创建文件:touch
9. 查看目录下的文件且以树状展示:tree tree -l 数字表示展示几级目录
10. 拷贝文件 cp
11. 拷贝目录:cp -r
12. 移动文件:mv
13. 移动目录:mv-r
14. 删除文件:rm
15. 删除目录:rm -r
16. 强制删除: rm -rf
17. 查看文件详情:cat
18. 查看文件详情且展示行号:cat -n
19. 查看文件的结尾符号:cat-A
20. 查看文件的开头和结尾:heed tail
21. 指定行号: head - 数字 |tail -数字
22. 上传:rz
23. 下载:sz
5. Yum的配置
1. 先保存现有机器上的yum ,现有yum在
2. 下载curl -o /etc/yum.repos.d/CentOS-Base.repo ( )
curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
1. 1. 清理yum缓存:yum clean all
2. 加载yum:yum makecache
3. 显示yum: yum repolist
2. 远程登录
1. Ssh (mailto:root@192.168.42.131)
2. 远程拷贝 :scp 目录路径 root@192.168.42.131:保存路径
3. 远程查看复制内容是否成功:ssh (mailto:root@192.168.42.131) “ls 路径
4. 端口更改后远程登录:ssh -p root@192.168.42.131
3. 创建单用户
* + vi /etc/grub.d/10\_linux
+ 将复制到文档最后,其中new为用户名,将两个new都要给为新的用户名
cat <<EOF
set superusers="new"
password new 123456
EOF
1. * + 生成新的grub文件:grub2-mkconfig --output=/boot/grub2/grub.cfg
* 查看本服务器的内核:uname -r
* 终端对话:write root pts/0
2. 给其他IP重名
* + Vi /etc/hosts 在文档中的第三行开始进行编写,ip空格自定义的名称。
3. 编写文档
* + 一个井号为一级标题
两个井号为二级标题
快捷键为Ctrl+数字
* + - 代码块
三个上撇,多行代码块
单行代码`stemectl`,用一个上撇
* + - 字体换颜色,只能给标题和正文添加
<font colir=red> 文本 </font>
1. 打包、压缩(打包后文件大小不变,) -f 文件;-v列出过程;-c创建包;-x归档中解析;-z使用gzip的格式进行压缩。
* + 解压zip压缩包,使用unzip进行解压。
+ 进行打包:tar cvf tar cvf 打包后的名称.tar 压缩前的目录
Tar cvf root.tar root/
* + - 解压 tar xvf 解压的文件。
- 压缩并打包:tar czvf tar czvf root.tar.gz root/
- 解包&解压缩:tar xzvf 文件名称
- 解压到对应的位置 :tar xzvf 文件名称 -C路径
- Dd if=/dev/zero of=/xa2402.txt bs=1024M count=5 查看磁盘写的速率,创建一个文件并指定大小。文件大小等于 bs\*count
- Gzip 压缩文件,但是源文件被删除,只压缩文件
- Gzip -d 进行解压
1. 1. Ll-h 查看文件的大小。
2. Du -sh 文件名 查看指定目录的空间大小,不包含快捷内容(工作中可以使用此命令看磁盘大小,进行相应的清理)
* Du -sh \*
2. 免密登录
1. 创建秘钥对:Ssh-keygen 生成秘钥对的地址 id\_rse 私钥
2. 秘钥在:/root/.ssh 生成 rse(私钥) pub(公钥)
3. Ssh-copy-id 传递公钥
4. Koown 我登录过的 authouized 远程登录过的账号
5. echo >清空文件
10.36.178.100 -2017 131 0
181.128 333
1. 远程登录
* 远程登录后,更改文件sshd\_config中信息 /etc/ssh/sshd\_config
* 远程登录更改欢迎词
1. 登录词:远程登录后,在etc/ssh/sshd\_config中将banner中贴入Banner /etc/ssh/banner;编辑/etc/ssh/banner 中的信息,然后保存
2. 输入密码后:更改/etc/ssh/banner 中的信息,保存
3. 更新ssh ,systemctl instart sshd
## 三、作业
### 3.27
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]