wordpress國內(nèi)能用嗎武漢標(biāo)兵seo
Linux1024一篇通俗易懂的liunx命令操作總結(jié)(第十課)
一 liunx 介紹
Linux是一種免費(fèi)開源的操作系統(tǒng),它的設(shè)計(jì)基于Unix。它最早是由芬蘭的一位大學(xué)生Linus Torvalds在1991年開始編寫的,取名為Linux。Linux具有高度的靈活性和可定制性,可以在不同的硬件平臺(tái)上運(yùn)行,并支持多個(gè)用戶同時(shí)使用。Linux系統(tǒng)是GNU計(jì)劃的一部分,GNU是一個(gè)旨在開發(fā)自由軟件的計(jì)劃。
Linux分為內(nèi)核和發(fā)行版。內(nèi)核是操作系統(tǒng)的核心部分,它控制著計(jì)算機(jī)硬件和資源的管理。發(fā)行版則是由內(nèi)核和其他軟件組成的完整操作系統(tǒng)。常見的Linux發(fā)行版有Ubuntu、Debian、Fedora、CentOS、Red Hat等。
Linux的特點(diǎn)包括:
-
開源:Linux的源代碼可以免費(fèi)獲取,用戶可以根據(jù)自己的需要自由修改和分發(fā)。
-
多用戶:Linux支持多個(gè)用戶同時(shí)使用,每個(gè)用戶都可以有自己的個(gè)人賬戶和權(quán)限。
-
高度定制化:Linux可以根據(jù)用戶的需求進(jìn)行高度的定制,用戶可以選擇自己需要的桌面環(huán)境、軟件等。
-
安全性高:由于Linux的源代碼公開,使得許多開發(fā)人員對(duì)其進(jìn)行審查,也使Linux系統(tǒng)更加安全,而且不容易受到病毒攻擊。
-
良好的兼容性:Linux可以運(yùn)行在不同的硬件平臺(tái)上,并且支持許多不同的文件格式和協(xié)議。
-
可靠性高:Linux系統(tǒng)的穩(wěn)定性和可靠性非常高,可以長時(shí)間運(yùn)行而不會(huì)出現(xiàn)問題。
總之,Linux是一種非常強(qiáng)大和可定制的操作系統(tǒng),它的開源和多樣性吸引了很多程序員和用戶使用和開發(fā)。
1 認(rèn)識(shí)Linux操作系統(tǒng)的結(jié)構(gòu)目錄
2 ls less cat 查詢命令
[root@localhost ~]# ls
anaconda-ks.cfg bin tuxwhitebg.jpg usr
[root@localhost ~]# ls /
afs boot etc lib lost+found mnt proc run srv tmp var
bin dev home lib64 media opt root sbin sys usr
[root@localhost ~]#
3? less 查看文件的內(nèi)容分頁查看內(nèi)容
[root@localhost ~]# less anaconda-ks.cfg
4 cat 查看文件的詳細(xì)內(nèi)容
[root@localhost ~]# cat tuxwhitebg.jpg
5 查看當(dāng)前位置 Pwd
[root@localhost ~]# pwd
/root
[root@localhost ~]# cd /home/
[root@localhost home]# pwd
/home
[root@localhost home]#
6?? ls -- help 尋求幫助的命令操作
7 查看目錄下或者本身的信息或者內(nèi)容 ls ls /
[root@localhost home]# ls
goodseeyu hubing lost+found student zhangsan
hello lisi paw wangwu
[root@localhost home]# ls /
afs boot etc lib lost+found mnt proc run srv tmp var
bin dev home lib64 media opt root sbin sys usr
[root@localhost home]#
8? 查看目錄下所有內(nèi)容(包含隱藏文檔) ls -a
9 查看目錄下所有內(nèi)容(不包含隱藏文檔) ls -A 目錄
10? 查看文檔目錄下的文檔詳細(xì)信息 ls -l 目錄
11 查看目錄本身而不是目錄下的內(nèi)容 ls -ld
12? 查看文檔帶上單位顯示大小 ls -h
13? 切換盤符的命令 cd /?? .?? ..
[root@localhost ~]# cd /lib
[root@localhost lib]# cd /srv
[root@localhost srv]# cd /etc
[root@localhost etc]# ls
14? 絕對(duì)路徑 相對(duì)路徑
在 Linux 中,路徑是指向文件或目錄的位置。路徑可以使用絕對(duì)路徑或相對(duì)路徑來表示。
絕對(duì)路徑
絕對(duì)路徑是指從根目錄開始的完整路徑。根目錄是 Linux 文件系統(tǒng)的頂層目錄,通常用 “/” 表示。在絕對(duì)路徑中,路徑名中的每一個(gè)目錄都用斜杠 “/” 分隔開來。
例如,要訪問 /home/user1/testfile 這個(gè)文件,其絕對(duì)路徑就是 /home/user1/testfile。
相對(duì)路徑
相對(duì)路徑是相對(duì)于當(dāng)前工作目錄的路徑。當(dāng)前工作目錄是命令行 shell 所在的目錄。在相對(duì)路徑中,路徑名中的每一個(gè)目錄都用斜杠 “/” 分隔開來。
例如,如果當(dāng)前工作目錄是 /home/user1,且要訪問 testfile,可以使用相對(duì)路徑 ./testfile 或者 testfile。
15 文件文檔的管理
16? touch:創(chuàng)建文件名
[root@localhost ~]# cd /root/seeyou/
[root@localhost seeyou]# ls
[root@localhost seeyou]# touch hellow.txt
[root@localhost seeyou]# touch hellow.ppt
[root@localhost seeyou]# touch hellow.html
[root@localhost seeyou]# touch good.txt
[root@localhost seeyou]# touch good.docx
17? mkdir:創(chuàng)建文件目錄
[root@localhost seeyou]# mkdir hello
[root@localhost seeyou]# mkdir student
[root@localhost seeyou]# mkdir a/b/c
mkdir: 無法創(chuàng)建目錄 “a/b/c”: 沒有那個(gè)文件或目錄
[root@localhost seeyou]# mkdir -r a/b/c
mkdir: 不適用的選項(xiàng) -- r
請(qǐng)嘗試執(zhí)行 "mkdir --help" 來獲取更多信息。
[root@localhost seeyou]# mkdir -p a/b/c
[root@localhost seeyou]# ls
a good.docx good.txt hello hellow.html hellow.ppt hellow.txt student
[root@localhost seeyou]#
18? 多級(jí)目錄創(chuàng)建 mkdir -p 目錄
19 復(fù)制目錄 cp 原文件 目標(biāo) 文件
20 復(fù)制目錄 cp -r 原目錄 目標(biāo)目錄
21? 移動(dòng)文檔 mv 原文檔 目標(biāo)文檔
22 刪除文檔命令 rm -f 目標(biāo)文檔
23 刪除文件目錄命令 rm -rf 目標(biāo)目錄??
24? 綜合練習(xí)
25? 文檔編輯器 Vim 基礎(chǔ)操作
Vim:一個(gè)高度可定制的文本編輯器,可以通過命令模式和插入模式進(jìn)行編輯。
Emacs:一個(gè)類Unix操作系統(tǒng)上非常強(qiáng)大的文本編輯器,它使用LISP編程語言作為擴(kuò)展語言。
Nano:一個(gè)簡(jiǎn)單易用的文本編輯器,適用于新手。
Gedit:一個(gè)GNOME桌面環(huán)境下的文本編輯器,提供基本的編輯功能。
Atom:一個(gè)由GitHub開發(fā)的跨平臺(tái)文本編輯器,支持多種編程語言。
Sublime Text:一個(gè)流行的跨平臺(tái)文本編輯器,具有快速、輕便和高度可定制的特點(diǎn)。
Visual Studio Code:一個(gè)由微軟開發(fā)的跨平臺(tái)文本編輯器,支持多種編程語言和集成開發(fā)環(huán)境。
26? 認(rèn)識(shí)Vim編輯器的操作
啟動(dòng)vim編輯器
在終端中輸入
vim
命令即可啟動(dòng)vim編輯器。創(chuàng)建或打開文件
可以在vim命令后面直接跟上文件名,如
vim file.txt
,如果文件存在則會(huì)打開,如果文件不存在則會(huì)創(chuàng)建該文件并打開。命令模式和插入模式
vim編輯器有兩種模式:命令模式和插入模式。
命令模式用于移動(dòng)光標(biāo)、復(fù)制、粘貼等操作。在命令模式下按下
i
鍵即可進(jìn)入插入模式,此時(shí)可以開始編輯文件。要返回到命令模式,可以按下ESC
鍵。保存和退出
在命令模式下,按下
:w
可以保存文件,:q
可以退出編輯器。如果文件已被修改,需要先保存后退出,則可以使用:wq
命令。光標(biāo)移動(dòng)
在命令模式下,可以使用以下鍵盤控制光標(biāo)移動(dòng):
h
:光標(biāo)左移一格
j
:光標(biāo)下移一格
k
:光標(biāo)上移一格
l
:光標(biāo)右移一格
0
:光標(biāo)移到行首
$
:光標(biāo)移到行末
G
:光標(biāo)移到文件末尾
gg
:光標(biāo)移到文件開頭復(fù)制和粘貼
在命令模式下,使用以下命令進(jìn)行復(fù)制和粘貼:
yy
:復(fù)制當(dāng)前行
p
:粘貼復(fù)制的內(nèi)容
撤銷和重做
在命令模式下,可以使用以下命令進(jìn)行撤銷和重做操作:
u
:撤銷上一次操作
CTRL + r
:重做上一次操作
27 vim實(shí)操
28 用戶的管理? 增刪改查
?[root@localhost ~]# vim? /var/www/html/t1.php
[root@localhost ~]#? useradd? hellow
[root@localhost ~]# passwd hellow
更改用戶 hellow 的密碼 。
新的密碼:
無效的密碼: 密碼少于 8 個(gè)字符
重新輸入新的密碼:
passwd:所有的身份驗(yàn)證令牌已經(jīng)成功更新。
[root@localhost ~]# id hellow
用戶id=1008(hellow) 組id=1008(hellow) 組=1008(hellow)
[root@localhost ~]# passwd hellow
更改用戶 hellow 的密碼 。
新的密碼:
無效的密碼: 密碼少于 8 個(gè)字符
重新輸入新的密碼:
passwd:所有的身份驗(yàn)證令牌已經(jīng)成功更新。
[root@localhost ~]# id hellow
用戶id=1008(hellow) 組id=1008(hellow) 組=1008(hellow)
[root@localhost ~]# ls /home/
goodseeyu? hello? hellow? hubing? lisi? lost+found? paw? student? wangwu? zhangsan
[root@localhost ~]# userdel -r lisi
[root@localhost ~]# ls /home/
goodseeyu? hello? hellow? hubing? lost+found? paw? student? wangwu? zhangsan
29 用戶組的管理 增刪改查
[root@localhost ~]# id hellow
用戶id=1008(hellow) 組id=1008(hellow) 組=1008(hellow)
[root@localhost ~]# ls /home/
goodseeyu? hello? hellow? hubing? lisi? lost+found? paw? student? wangwu? zhangsan
[root@localhost ~]# userdel -r lisi
[root@localhost ~]# ls /home/
goodseeyu? hello? hellow? hubing? lost+found? paw? student? wangwu? zhangsan
[root@localhost ~]# gro
grodvi???? groffer??? grolbp???? gropdf???? grotty???? groupdel?? groupmod
groff????? grog?????? grolj4???? grops????? groupadd?? groupmems? groups
[root@localhost ~]# group hello
-bash: group:未找到命令
[root@localhost ~]# grou
[root@localhost ~]# gro
grodvi???? groffer??? grolbp???? gropdf???? grotty???? groupdel?? groupmod
groff????? grog?????? grolj4???? grops????? groupadd?? groupmems? groups
[root@localhost ~]# groupadd hello
groupadd:“hello”組已存在
[root@localhost ~]# groupadd good
[root@localhost ~]# groupadd see
[root@localhost ~]# ls /
afs? boot? etc?? lib??? lost+found? mnt? proc?? root? sbin? sys? usr
bin? dev?? home? lib64? media?????? opt? repos? run?? srv?? tmp? var
[root@localhost ~]# ls /home/
goodseeyu? hello? hellow? hubing? lost+found? paw? student? wangwu? zhangsan
[root@localhost ~]# id hello
用戶id=1001(hello) 組id=1001(hello) 組=1001(hello)
[root@localhost ~]# gpasswd? -a hubing see
正在將用戶“hubing”加入到“see”組中
[root@localhost ~]# id hubing
用戶id=1002(hubing) 組id=1002(hubing) 組=1002(hubing),1010(see)
30 切換用戶
[root@localhost ~]# su - hubingWelcome to 5.10.0-60.18.0.50.oe2203.x86_64System information as of time: 2023年 10月 14日 星期六 11:45:39 CSTSystem load: 0.16
Processes: 169
Memory used: 24.4%
Swap used: 0%
Usage On: 6%
IP address: 192.168.10.223
IP address: 192.168.122.1
Users online: 1
To run a command as administrator(user "root"),use "sudo <command>".
[hubing@localhost ~]$
31 退出 exit
[hubing@localhost ~]$ exit
注銷
[root@localhost ~]#
?文檔的屬主 屬組? 其他權(quán)限的操作 讀 寫 可控制權(quán)限操作
32 認(rèn)識(shí)文檔權(quán)限
33 對(duì)文檔的屬主 屬組 其他權(quán)限操作 chown
33.1 chown 用戶
33.2? chown :用戶名
33.3? chown 用戶名:用戶組名 文檔名
34 文檔 可讀 可寫 可控制
U:user O:other G:grounp R:read W:writer X:exictue
chmod[ugo][+-=][rwx]? 文檔名
[root@localhost ~]# ls -l a.txt
-rw-r--r--. 1 root root 0 10月 14 11:47 a.txt
[root@localhost ~]# ch
chacl check_lft_balance.pl chkconfig chronyd
chage checkmodule chmem chroot
chardetect checkpolicy chmod chrt
chattr chem choom chsh
chcat chfn chown chvt
chcon chgpasswd chpasswd
chcpu chgrp chronyc
[root@localhost ~]# chmod u+x a.txt
[root@localhost ~]# ls -l a.txt
-rwxr--r--. 1 root root 0 10月 14 11:47 a.txt
[root@localhost ~]# chomod o+xwy a.txt
-bash: chomod:未找到命令
[root@localhost ~]# chomod o+x a.txt
-bash: chomod:未找到命令
[root@localhost ~]# chomod O+w a.txt
-bash: chomod:未找到命令
[root@localhost ~]# chomod g+w a.txt
-bash: chomod:未找到命令
[root@localhost ~]# chmod o+x a.txt
[root@localhost ~]# ls -l a.txt
-rwxr--r-x. 1 root root 0 10月 14 11:47 a.txt
[root@localhost ~]#
35 linux 掛載的基礎(chǔ)操作
36 手動(dòng)掛載 mount
37 手動(dòng)掛載綜合題
38 配置開機(jī)自動(dòng)掛載
1、創(chuàng)建掛載點(diǎn)
[root@svr223 ~]# mkdir -p /repos/openEuler
2、修改配置/etc/fstab
[root@svr223 ~]# vim /etc/fstab
// 設(shè)備文件 掛載點(diǎn) 文件系統(tǒng)類型 掛載選項(xiàng) 檢查 備份
/dev/cdrom /repos/openEuler iso9660 ro 0 0[root@svr223 ~]# reboot
3、檢查配置
[root@svr223 ~]# mount -a沒有報(bào)錯(cuò)代表配置正確
如果有報(bào)錯(cuò)代表配置有問題
4、驗(yàn)證
重啟之后,查看
reboot:重啟[root@svr223 ~]# reboot
[root@svr223 ~]#
docs images ks repodata TRANS.TBL
EFI isolinux Packages RPM-GPG-KEY-openEuler
常見錯(cuò)誤:
[root@svr223 ~]# mount -a
mount: /repos/openEuler: 特殊設(shè)備 /dev/cdom 不存在.
mount: /repos/openEuer: 掛載點(diǎn)不存在.
mount: /repos/openEuler: 未知的文件系統(tǒng)類型“iso9960”.
mount: /repos/openEuler: 文件系統(tǒng)類型錯(cuò)誤、選項(xiàng)錯(cuò)誤、/dev/sr0 上有壞超級(jí)塊、缺少代碼頁或幫助程序或其他錯(cuò)誤.
39 YUM 源的基礎(chǔ)操作
- ??? 查看系統(tǒng)中已有的YUM源列表:yum repolist
- ??? 啟用某個(gè)YUM源:yum-config-manager --enable repo_name
- ??? 禁用某個(gè)YUM源:yum-config-manager --disable repo_name
- ??? 列出某個(gè)YUM源的詳細(xì)信息:yum info repo_name
- ??? 搜索某個(gè)軟件包:yum search package_name
- ??? 安裝某個(gè)軟件包:yum install package_name
- ??? 更新某個(gè)軟件包:yum update package_name
- ??? 刪除某個(gè)軟件包:yum remove package_name
- ??? 清除YUM緩存:yum clean all
- ??? 下載某個(gè)軟件包但不安裝:yum download package_name
- ??? 檢查某個(gè)軟件包是否有更新:yum check-update package_name
- ??? 列出已安裝的軟件包:yum list installed
- ??? 展示某個(gè)軟件包的安裝信息:yum list package_name
- ??? 列出已安裝的但是沒有被其它軟件包所依賴的軟件包:yum list extras
- ??? 列出某個(gè)軟件包的依賴關(guān)系:yum deplist package_name
40? yum info 軟件 顯示軟件的詳細(xì)信息
[root@localhost ~]# yum info httpd
Last metadata expiration check: 2:14:26 ago on 2023年10月14日 星期六 09時(shí)37分52秒.
Installed Packages
Name ? ? ? ? : httpd
Version ? ? ?: 2.4.51
Release ? ? ?: 9.oe2203
Architecture : x86_64
Size ? ? ? ? : 4.6 M
Source ? ? ? : httpd-2.4.51-9.oe2203.src.rpm
Repository ? : @System
From repo ? ?: @commandline
Summary ? ? ?: Apache HTTP Server
URL ? ? ? ? ?: https://httpd.apache.org/
License ? ? ?: ASL 2.0
Description ?: Apache HTTP Server is a powerful and flexible HTTP/1.1 compliant web server.
41 yum provides 文件名 查看某個(gè)我嗯嗯那就是由那個(gè)軟件包提供的
[root@localhost ~]# yum provides ?httpd
Last metadata expiration check: 2:14:16 ago on 2023年10月14日 星期六 09時(shí)37分52秒.
httpd-2.4.51-5.oe2203.x86_64 : Apache HTTP Server
Repo ? ? ? ?: repos_openEuler_
Matched from:
Provide ? ?: httpd = 2.4.51-5.oe2203
?
httpd-2.4.51-9.oe2203.x86_64 : Apache HTTP Server
Repo ? ? ? ?: @System
Matched from:
Provide ? ?: httpd = 2.4.51-9.oe2203
42? yum -y install 軟件名 :安裝軟件
[root@localhost ~]# yum -y install httpd
Last metadata expiration check: 2:16:10 ago on 2023年10月14日 星期六 09時(shí)37分52秒.
Dependencies resolved.
===============================================================================================================Package Architecture Version Repository Size
===============================================================================================================
Installing:httpd x86_64 2.4.51-5.oe2203 repos_openEuler_ 1.3 M
Installing dependencies:mod_http2 x86_64 1.15.25-1.oe2203 repos_openEuler_ 126 k
Downgrading:httpd-filesystem noarch 2.4.51-5.oe2203 repos_openEuler_ 11 khttpd-tools x86_64 2.4.51-5.oe2203 repos_openEuler_ 71 k
?
Transaction Summary
===============================================================================================================
Install 2 Packages
Downgrade 2 Packages
?
Total size: 1.5 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
43 yum -y remove 軟件名 :卸載軟件
[root@localhost ~]# yum -y remove httpd
Dependencies resolved.
===============================================================================================================Package Architecture Version Repository Size
===============================================================================================================
Removing:httpd x86_64 2.4.51-9.oe2203 @@commandline 4.6 M
Removing dependent packages:mod_http2 x86_64 1.15.25-1.oe2203 @@commandline 329 k
?
Transaction Summary
===============================================================================================================
Remove 2 Packages
?
Freed space: 4.9 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transactionPreparing : 1/1Running scriptlet: httpd-2.4.51-9.oe2203.x86_64 1/1Running scriptlet: httpd-2.4.51-9.oe2203.x86_64 1/2
Removed /etc/systemd/system/multi-user.target.wants/httpd.service.
44? yum -y reinstall 軟件名:重裝軟件
[root@localhost ~]# yum -y reinstall httpd
Last metadata expiration check: 2:18:09 ago on 2023年10月14日 星期六 09時(shí)37分52秒.
Dependencies resolved.
===============================================================================================================
Package Architecture Version Repository Size
===============================================================================================================
Reinstalling:
httpd x86_64 2.4.51-5.oe2203 repos_openEuler_ 1.3 M
?
Transaction Summary
===============================================================================================================
?
Total size: 1.3 M
Installed size: 4.6 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
45? LAMP 環(huán)境的安裝
// 卸載之前的Apache web服務(wù)器httpd,防止與之后的LAMP環(huán)境沖突
[root@svr223 ~]# yum -y remove httpd [root@svr223 ~]# pwd
/root
[root@svr223 ~]# ls
anaconda-ks.cfg lamp_oe2203_pkgs
[root@svr223 ~]# ls lamp_oe2203_pkgs/
apr-1.7.0-4.oe2203.x86_64.rpm
apr-util-1.6.1-12.oe2203.x86_64.rpm
git-2.33.0-3.oe2203.x86_64.rpm
httpd-2.4.51-9.oe2203.x86_64.rpm
...
?安裝軟件包
[root@svr223 ~]# yum -y install ?httpd mariadb-server ?php-fpm ? php-mysqlnd
使用如下方式安裝:
[root@svr223 ~]# yum -y install ?./lamp_oe2203_pkgs/*.rpm
檢查安裝的軟件包:
httpd:Apahce web應(yīng)用服務(wù)器
mariadb-server:數(shù)據(jù)庫服務(wù)器
php-fpm:php解析器
php-mysqlnd:php操作數(shù)據(jù)庫程序[root@svr223 ~]# yum list httpd mariadb-server php-fpm php-mysqlnd
Last metadata expiration check: 2:14:09 ago on 2023年04月19日 星期三 15時(shí)24分30秒.
Installed Packages
httpd.x86_64 2.4.51-9.oe2203 @@commandline
mariadb-server.x86_64 4:10.5.16-1.oe2203 @@commandline
php-fpm.x86_64 8.0.0-10.oe2203 @@commandline
php-mysqlnd.x86_64 8.0.0-10.oe2203 @@commandline
[root@svr223 ~]#
systemctl:系統(tǒng)控制器 控制服務(wù)的開啟/關(guān)閉/設(shè)置成開機(jī)自啟/禁止開機(jī)自啟
system:系統(tǒng)
ctl:controller 控制器
start:開始/開啟 stop:停止 is-active:是否活躍/是否開啟 active:活躍/開啟 inactive:不活躍/關(guān)閉 restart:重新啟動(dòng) type:類型/列出 service:服務(wù)
status:狀態(tài) enable:開啟/開機(jī)自啟 /now:現(xiàn)在/立即/disable:禁止systemctl start <service> 啟動(dòng)服務(wù)
systemctl stop <service> 停止服務(wù)
systemctl restart <service> 重新啟動(dòng)服務(wù)
systemctl reload <service> 重新加載服務(wù)配置文件
systemctl status <service> 查看服務(wù)狀態(tài)
systemctl enable <service> 設(shè)置服務(wù)開機(jī)自啟動(dòng)
systemctl disable <service> 禁用服務(wù)開機(jī)自啟動(dòng)
systemctl is-active <service> 檢查服務(wù)是否正在運(yùn)行
systemctl is-enabled <service> 檢查服務(wù)是否開機(jī)自啟動(dòng)
systemctl list-units 列出所有運(yùn)行中的系統(tǒng)單元
systemctl list-unit-files 列出所有可用的系統(tǒng)單元文件
systemctl mask <service> 禁止啟動(dòng)和停止服務(wù)
systemctl unmask <service> 允許啟動(dòng)和停止服務(wù)[root@svr223 ~]# systemctl enable --now httpd mariadb php-fpm
[root@svr223 ~]# systemctl status httpd mariadb php-fpm //查看狀態(tài)
http://服務(wù)器IP地址
如:
http://192.168.10.223/
firewalld:Linux中防火墻服務(wù)
// 禁止防護(hù)墻開機(jī)自啟,并且立即禁止
[root@svr223 ~]# systemctl disable --now firewalld
[root@svr223 ~]# systemctl status? firewalld? //查看狀態(tài)
驗(yàn)證php-fpm是否正常
/var/www/html 目錄:網(wǎng)站根目錄
當(dāng)用戶訪問服務(wù)器http服務(wù)的時(shí)候,默認(rèn)輸入的IP地址(192.168.10.223)默認(rèn)對(duì)應(yīng)的目錄就是網(wǎng)站的根目錄
?
[root@svr223 ~]# vim ?/var/www/html/t1.php
?
<?php
phpinfo();
?>
瀏覽器輸入http://192.168.10.223/t1.php測(cè)試,出現(xiàn)以下頁面,說明正常
46 systemctl 總結(jié)
46.1? systemctl系統(tǒng)服務(wù)管理
[root@svr223 ~]# systemctl ?--type ?service ?// 查看所有的服務(wù)
[root@svr223 ~]# systemctl ?is-active ?httpd ?// 查看服務(wù)是否激活
active ?// 激活狀態(tài)
[root@svr223 ~]# systemctl stop httpd
[root@svr223 ~]# systemctl ?is-active ?httpd
inactive ?// 非激活狀態(tài),即關(guān)閉
[root@svr223 ~]# systemctl ?**start** ?httpd ?// 啟動(dòng)
[root@svr223 ~]# systemctl ?**restart** ?httpd ?// 重啟
[root@svr223 ~]# systemctl ?**stop** ?httpd ? // 停止
[root@svr223 ~]# systemctl ?**status** ?httpd ?// 查看狀態(tài)(詳細(xì))
[root@svr223 ~]# systemctl ?**is-active** ?httpd ?// 查看狀態(tài)(簡(jiǎn)潔)
46.2? 設(shè)置服務(wù)開機(jī)自啟
[root@svr223 ~]# systemctl **enable** httpd ?//設(shè)置開機(jī)自啟
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@svr223 ~]# systemctl enable httpd **--now** ?// 設(shè)置開機(jī)自啟,并開啟服務(wù)
46.3 設(shè)置禁止服務(wù)開機(jī)自啟
[root@svr223 ~]# systemctl **disable** httpd ?// 設(shè)置開機(jī)不自啟
Removed /etc/systemd/system/multi-user.target.wants/httpd.service.
[root@svr223 ~]# systemctl disable httpd **--now** ?// 設(shè)置開機(jī)不自啟,并關(guān)閉服務(wù)
[root@svr223 ~]# systemctl **is-enabled** httpd//查看服務(wù)是否是開機(jī)自啟狀態(tài)
disabled ? // 開機(jī)不自啟
[root@svr223 ~]# systemctl enable httpd
[root@svr223 ~]# systemctl is-enabled httpd
enabled ? // 開機(jī)自啟
[root@svr223 ~]# systemctl stop httpd
[root@svr223 ~]# systemctl enable httpd
[root@svr223 ~]# systemctl is-active httpd
inactive
[root@svr223 ~]# systemctl enable httpd --now ?// 設(shè)置開機(jī)自啟,并開啟服務(wù)
[root@svr223 ~]# systemctl is-active httpd
active
[root@svr223 ~]# systemctl disable httpd
Removed /etc/systemd/system/multi-user.target.wants/httpd.service.
[root@svr223 ~]# systemctl is-active httpd
active
[root@svr223 ~]# systemctl disable httpd --now// 設(shè)置為開機(jī)不自啟,并關(guān)閉服務(wù)
[root@svr223 ~]# systemctl is-active httpd
inactive
[root@svr223 ~]# systemctl disable httpd --now
[root@svr223 ~]# systemctl is-active httpd
[root@svr223 ~]# systemctl stop httpd
[root@svr223 ~]# systemctl is-active httpd
[root@svr223 ~]# systemctl status httpd
[root@svr223 ~]# systemctl restart ?firewalld
[root@svr223 ~]# systemctl is-active ?firewalld
active
[root@svr223 ~]# systemctl enable httpd
[root@svr223 ~]# systemctl disable firewalld
[root@svr223 ~]# systemctl enable mariadb php-fpm
47? SELinux 學(xué)習(xí)
[root@svr223 ~]# getenforce // 獲取當(dāng)前SELinux狀態(tài)
Permissive
[root@svr223 ~]# setenforce 1 // 修改為Enforcing 強(qiáng)制
[root@svr223 ~]# getenforce
Enforcing
[root@svr223 ~]# setenforce 0 // 修改為Permissive 寬松
[root@svr223 ~]# getenforce
Permissive
[root@svr223 ~]#
[root@svr223 ~]# vim /etc/selinux/config
SELINUX=permissive // 修改為寬松模式(利用快捷鍵Ctrl+p)
48 which基本操作
49 find 基本操作
50 管道符號(hào): 命令1 | 命令2 將命令1執(zhí)行的結(jié)果傳遞給命令2
51 grep 查找文件中滿足條件的內(nèi)容
52 進(jìn)程相關(guān)的操作 pstree:查看進(jìn)程樹
53 ACL 基礎(chǔ)操作 getfacl:獲取acl
54 SUID/SGID/STICK 基礎(chǔ)操作
-
SUID(Set User ID):SUID是一種特殊權(quán)限位,當(dāng)應(yīng)用程序被設(shè)置為SUID時(shí),用戶將以文件所有者(通常是管理員)的身份運(yùn)行該程序。這允許普通用戶以超級(jí)用戶身份執(zhí)行某些命令或操作。例如,passwd命令必須具有SUID位才能讓用戶更改自己的密碼。
-
SGID(Set Group ID):SGID是類似于SUID的特殊權(quán)限位,但它是為組而設(shè)計(jì)的。當(dāng)應(yīng)用程序被設(shè)置為SGID時(shí),用戶將以文件所屬組的身份運(yùn)行該程序。這可以確保多個(gè)用戶可以訪問同一組共享的文件時(shí),可以在相同的組權(quán)限下訪問該文件。例如,一個(gè)共享文件夾的SGID位可以確保所有成員都可以訪問并編輯該文件夾中的文件。
-
STICKY(Sticky Bit):STICKY是一種權(quán)限標(biāo)記,它可以應(yīng)用于目錄。當(dāng)一個(gè)目錄被設(shè)置為sticky bit時(shí),只有該目錄的所有者和超級(jí)用戶才能刪除或移動(dòng)該目錄中的文件。其他用戶不能刪除或移動(dòng)其他用戶的文件,因此這是一種用于保護(hù)共享目錄的有用機(jī)制。
54.1 SUID測(cè)試
// 測(cè)試普通用戶在執(zhí)行具有suid權(quán)限的程序后,能否具有此程序的屬主權(quán)限
[root@zbx ~]# cp -p /usr/bin/vim /usr/bin/.vim // -p 復(fù)制權(quán)限
[root@zbx ~]# ls -l /usr/bin/vim /usr/bin/.vim
-rwxr-xr-x. 1 root root 3222024 3月 21 2022 /usr/bin/.vim
-rwxr-xr-x. 1 root root 3222024 3月 21 2022 /usr/bin/vim
[root@zbx ~]#
[root@zbx ~]# chmod u+s /usr/bin/.vim // 給.vim 程序添加SUID權(quán)限
[root@zbx ~]#
[root@zbx ~]# ls -l /usr/bin/vim /usr/bin/.vim
-rwsr-xr-x. 1 root root 3222024 3月 21 2022 /usr/bin/.vim
-rwxr-xr-x. 1 root root 3222024 3月 21 2022 /usr/bin/vim
[root@zbx ~]# useradd student
[root@zbx ~]# su - student
[student@zbx ~]$ ls -l /usr/bin/vim /usr/bin/.vim
-rwsr-xr-x. 1 root root 3222024 3月 21 2022 /usr/bin/.vim
-rwxr-xr-x. 1 root root 3222024 3月 21 2022 /usr/bin/vim[student@zbx ~]$ vim /home/student/stu1.txt
[student@zbx ~]$ .vim /home/student/stu2.txt[student@zbx ~]$ ls -l /home/student/stu1.txt /home/student/stu2.txt// 查看發(fā)現(xiàn),雖然使用的是用戶student進(jìn)行的文檔創(chuàng)建,但是stu2.txt屬主變成了root[root@zbx ~]# find /usr/bin/ -perm -u=s -type f // 查找/usr/bin目錄下所有具有SUID的程序文件// 查找/run目錄下屬組具有s特權(quán)(SGID)的目錄
[root@zbx ~]# find /run -perm -g=s -type d
54.2 SGID測(cè)試
// 測(cè)試在不具有SGID的目錄下創(chuàng)建文檔時(shí),與具有SGID的目錄下創(chuàng)建文檔時(shí),所創(chuàng)建文檔屬組的區(qū)別[root@zbx ~]# mkdir -m ug=rwx,o=rx /public // -m : 在創(chuàng)建目錄的同時(shí)設(shè)置權(quán)限
[root@zbx ~]# ls -ld /public/
drwxrwxr-x. 2 root root 4096 4月 23 16:00 /public/
[root@zbx ~]# useradd zhangsan
[root@zbx ~]# chown :zhangsan /public/
[root@zbx ~]# ls -ld /public/
drwxrwxr-x. 2 root zhangsan 4096 4月 23 16:00 /public/
[root@zbx ~]#
[root@zbx ~]# touch /public/root1.txt
[root@zbx ~]#
[root@zbx ~]# chmod g+s /public/
[root@zbx ~]#
[root@zbx ~]# ls -ld /public/
drwxrwsr-x. 2 root users 4096 4月 23 16:03 /public/
[root@zbx ~]#
[root@zbx ~]# touch /public/root2.txt
[root@zbx ~]#
[root@zbx ~]# ls -l /public/*.txt
-rw-------. 1 root root 0 4月 23 16:03 /public/root1.txt
-rw-------. 1 root zhangsan 0 4月 23 16:05 /public/root2.txt
54.3 粘滯位測(cè)試
在一個(gè)其他人有w權(quán)限的目錄中,如果該目錄有粘滯位的特殊權(quán)限,自己只能刪自己創(chuàng)建的,不能刪除其他人的文件。
// 測(cè)試添加了t權(quán)限的目錄,用戶是否還可以操作其他用戶的文檔
[root@zbx ~]# useradd student// /home/student : student的家目錄
// ~ :家目錄,如果~后面什么都不跟,代表的是當(dāng)前用戶的家目錄
// ~用戶名 : 用戶對(duì)應(yīng)的家目錄
[root@zbx ~]# touch ~student/root.txt
[root@zbx ~]# su - student
[student@zbx ~]$ ls -ld ~student
drwx------ 2 student student 4096 6月 1 22:44 /home/student/[student@zbx ~]$ rm -rf ~student/root.txt
[student@zbx ~]
// 可以刪除,因?yàn)閟tudent用戶對(duì)/home/student目錄具有w權(quán)限,所以可以對(duì)目錄下的文件進(jìn)行刪除[student@zbx ~] exit
[root@zbx ~]# ls -ld /tmp/
drwxrwxrwt. 12 root root 240 4月 23 15:50 /tmp/[root@zbx ~]# touch /tmp/root.txt[root@zbx ~]# su - student[student@zbx ~]$
[student@zbx ~]$ rm -rf /tmp/root.txt
// rm: 無法刪除 '/tmp/root.txt': 不允許的操作
55 linunx操作命令匯總
1. pwd:顯示當(dāng)前目錄的路徑
2. cd:切換到指定目錄
3. ls:列出指定目錄下的所有文件和文件夾
4. touch:創(chuàng)建一個(gè)新文件
5. mkdir:創(chuàng)建一個(gè)新目錄
6. rmdir:刪除一個(gè)空的目錄
7. rm:刪除文件或目錄
8. mv:移動(dòng)或重命名文件或目錄
9. cp:復(fù)制文件或目錄
10. cat:顯示文件內(nèi)容
11. grep:在文件中查找指定內(nèi)容
12. find:在指定目錄下查找文件
13. chmod:改變文件或目錄的訪問權(quán)限
14. chown:改變文件或目錄的所有者
15. chgrp:改變文件或目錄的所屬組
16. ping:測(cè)試網(wǎng)絡(luò)連接
17. ifconfig:顯示網(wǎng)絡(luò)接口配置
18. netstat:顯示網(wǎng)絡(luò)狀態(tài)
19. route:顯示或修改網(wǎng)絡(luò)路由表
20. iptables:管理網(wǎng)絡(luò)防火墻規(guī)則
21. top:顯示系統(tǒng)進(jìn)程的實(shí)時(shí)信息
22. ps:顯示系統(tǒng)進(jìn)程的信息
23. kill:終止一個(gè)進(jìn)程
24. free:顯示系統(tǒng)內(nèi)存使用情況
25. df:顯示文件系統(tǒng)使用情況
26. du:顯示指定目錄的磁盤使用情況
27. tar:打包或解壓文件
28. gzip:壓縮文件
29. gunzip:解壓縮文件
30. ssh:通過 SSH 安全連接到遠(yuǎn)程服務(wù)器
31. scp:通過 SSH 安全復(fù)制文件
32. rsync:通過 SSH 安全同步文件
33. curl:傳輸數(shù)據(jù)
34. wget:下載文件
35. yum:在 CentOS 或 RHEL 系統(tǒng)中安裝、升級(jí)和刪除軟件包
36. apt-get:在 Debian 或 Ubuntu 系統(tǒng)中安裝、升級(jí)和刪除軟件包
37. service:管理系統(tǒng)服務(wù)
38. systemctl:管理 systemd 系統(tǒng)服務(wù)
39. crontab:管理定時(shí)任務(wù)
40. useradd:創(chuàng)建新用戶
41. userdel:刪除用戶
42. passwd:更改用戶密碼
43. groupadd:創(chuàng)建新用戶組
44. groupdel:刪除用戶組
45. su:切換到另一個(gè)用戶
46. sudo:以超級(jí)用戶權(quán)限執(zhí)行命令
47. ping6:測(cè)試 IPv6 網(wǎng)絡(luò)連接
48. ifconfig6:顯示 IPv6 網(wǎng)絡(luò)接口配置
49. netstat6:顯示 IPv6 網(wǎng)絡(luò)狀態(tài)
50. route6:顯示或修改 IPv6 網(wǎng)絡(luò)路由表
51. ip6tables:管理 IPv6 網(wǎng)絡(luò)防火墻規(guī)則
52. screen:在終端中創(chuàng)建多個(gè)會(huì)話
53. tmux:在終端中管理多個(gè)會(huì)話
54. who:顯示當(dāng)前登錄用戶
55. whoami:顯示當(dāng)前用戶名稱
56. uname:顯示系統(tǒng)信息
57. uptime:顯示系統(tǒng)運(yùn)行時(shí)間和負(fù)載
58. hostname:顯示或設(shè)置系統(tǒng)主機(jī)名
59. date:顯示或設(shè)置系統(tǒng)日期和時(shí)間
60. clear:清除終端上的內(nèi)容
61. echo:輸出文本
62. tee:將輸出同時(shí)發(fā)送到終端和文件
63. cut:從文本中剪切數(shù)據(jù)
64. sed:編輯文本
65. awk:處理和分析文本
66. sort:對(duì)文本數(shù)據(jù)進(jìn)行排序
67. uniq:從文本中刪除重復(fù)行
68. diff:比較兩個(gè)文本文件的差異
69. patch:將補(bǔ)丁文件應(yīng)用到源代碼中
70. make:構(gòu)建源代碼
71. gcc:編譯 C 語言源代碼
72. g++:編譯 C++ 源代碼
73. gdb:調(diào)試 C 或 C++ 程序
74. python:啟動(dòng) Python 解釋器
75. pip:管理 Python 模塊
76. virtualenv:創(chuàng)建 Python 虛擬環(huán)境
77. git:管理源代碼版本控制
78. svn:管理源代碼版本控制
79. hg:管理源代碼版本控制
80. ssh-keygen:創(chuàng)建 SSH 私鑰和公鑰對(duì)
81. ssh-copy-id:將 SSH 公鑰復(fù)制到遠(yuǎn)程服務(wù)器
82. openssl:創(chuàng)建和管理 SSL/TLS 證書和密鑰
83. nc:在網(wǎng)絡(luò)上傳輸數(shù)據(jù)
84. tcpdump:在網(wǎng)絡(luò)上捕獲數(shù)據(jù)包
85. ngrep:在網(wǎng)絡(luò)上查找指定內(nèi)容的數(shù)據(jù)包
86. nmap:掃描網(wǎng)絡(luò)和主機(jī)
87. arp:顯示和修改網(wǎng)絡(luò)地址映射表
88. dig:DNS 查詢工具
89. nslookup:DNS 查詢工具
90. host:DNS 查詢工具
91. traceroute:顯示數(shù)據(jù)包到目標(biāo)主機(jī)的路徑
92. mtr:顯示數(shù)據(jù)包到目標(biāo)主機(jī)的路徑和網(wǎng)絡(luò)延遲
93. telnet:與遠(yuǎn)程服務(wù)器進(jìn)行交互式通信
94. ftp:使用 FTP 協(xié)議進(jìn)行文件傳輸
95. sftp:使用 SSH 安全文件傳輸協(xié)議進(jìn)行文件傳輸
96. scp:使用 SSH 安全文件傳輸協(xié)議進(jìn)行文件傳輸
97. curlftpfs:使用 FTP 文件系統(tǒng)連接到遠(yuǎn)程文件夾
98. nfs:使用 NFS 文件系統(tǒng)連接到遠(yuǎn)程文件夾
99. smbclient:使用 SMB/CIFS 協(xié)議連接到遠(yuǎn)程文件夾
100. mount:掛載文件系統(tǒng)
101. umount:卸載文件系統(tǒng)
102. lsblk:顯示所有塊設(shè)備
103. fdisk:管理磁盤分區(qū)
104. mkfs:格式化磁盤分區(qū)
105. fsck:檢查和修復(fù)文件系統(tǒng)
106. mountpoint:檢查目錄是否為掛載點(diǎn)
107. blkid:顯示塊設(shè)備的 UUID 和文件系統(tǒng)類型
108. lspci:顯示系統(tǒng)中所有 PCI 設(shè)備的信息
109. lsusb:顯示系統(tǒng)中所有 USB 設(shè)備的信息
110. lshw:顯示系統(tǒng)硬件信息