玩linux笔记——持续更新
說在最前面
centos 是基于redhat linux,所以最好的教程在紅帽官網(wǎng)
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/
ubuntu是基于debian,所以u(píng)buntu學(xué)習(xí)最好的教程,也在debian官網(wǎng)
https://www.debian.org/doc/manuals/debian-faq/index.zh-cn.html
https://wiki.debian.org/zh_CN/FrontPage?action=show&redirect=%E9%A6%96%E9%A1%B5
centos7的基本管理操作(非常推薦)
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-getting_started
redhat常用系統(tǒng)管理的一些軟件(非常推薦)
https://access.redhat.com/articles/1189123
安裝
去centos官網(wǎng)下載mini安裝iso,從最基本的精簡(jiǎn)版系統(tǒng)一步一步配置。
聯(lián)網(wǎng)
開始之前先做一些預(yù)習(xí)的知識(shí)點(diǎn)
CentOS7網(wǎng)卡命名
en: Ethernet 有線局域網(wǎng)
wl: wlan 無(wú)線局域網(wǎng)
ww: wwan無(wú)線廣域網(wǎng)
——————————
o:集成設(shè)備的設(shè)備索引號(hào)
s:擴(kuò)展槽的索引號(hào)
x:基于mac地址的命名
ps:enp2s1
聯(lián)網(wǎng)方案 NetworkManger
安裝完mini系統(tǒng)后,可直接通過有線網(wǎng)絡(luò)聯(lián)網(wǎng),為了方便下面還是配置wifi聯(lián)網(wǎng)。管理網(wǎng)絡(luò),在centos中使用的是NetworkManger,這是一個(gè)軟件包,含有好幾個(gè)軟件工具:nmcli、nmtui、nm-connection-editor、control-center、control-center、network connection icon,詳細(xì)可見 https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-networkmanager_tools
簡(jiǎn)單介紹下nmtui和nmcli
1、nmtui 這是一個(gè)Text User Interface類型的軟件,用于連接wifi,nm的意思是NetworkManger Text User Interface,控制臺(tái)輸入nmtui后直接掃描可用的無(wú)線網(wǎng)絡(luò)。
nmtui是包含在NetworkManager 軟件包中的,默認(rèn)NetworkManager-tui 是集成再centos7中的,如果想要手動(dòng)安裝可使用下面的命令:
要使用該程序,直接在控制臺(tái)輸入nmtui回車即可,軟件使用非常人性化,不再詳細(xì)介紹。
一些截圖:
可用的一些命令
可參考的資料:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/sec-Networking_Config_Using_nmtui.html
https://developer.gnome.org/NetworkManager/stable/nmtui.html
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sec-networking#sec-Network-access-after-installation-nmcli
2、nmcli (NetworkManager Command Line Interface)這是一個(gè)命令行連接的方案
命令詳解:
常用:
nmcli connection show 查看所有連接 nmcli device status 查看已經(jīng)識(shí)別的設(shè)備及其狀態(tài) nmcli dev wifi list 列出可用的網(wǎng)絡(luò) nmcli radio wifi [on | off ] 更改wifi狀態(tài)可參考的資料
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-configuring_ip_networking_with_nmcli
關(guān)于這兩個(gè)工具推薦使用nmtui,圖形化做的比較好,用起來(lái)方便。
你的網(wǎng)卡硬件正常工作了嗎?
有了上面的解決方案就能準(zhǔn)確的聯(lián)網(wǎng)了
使用命令nmcli dev status查看當(dāng)前所有網(wǎng)卡信息,如果能看到wl開頭的網(wǎng)卡能正常工作那就是硬件驅(qū)動(dòng)起來(lái)了,如果沒有驅(qū)動(dòng)起來(lái)(你確定裝了無(wú)線網(wǎng)卡但沒有找到wl開頭的設(shè)備,或者其他什么提示)那么就建議,換網(wǎng)卡,不建議折騰驅(qū)動(dòng),linux內(nèi)核對(duì)于intel或者高通的無(wú)線網(wǎng)卡支持非常好基本都能直接驅(qū)動(dòng)起來(lái),如果真的出現(xiàn)無(wú)法驅(qū)動(dòng)無(wú)線網(wǎng)卡,直接換個(gè)內(nèi)核支持的硬件是非常快速有效的辦法。
使用nmcli聯(lián)網(wǎng)
至此我就認(rèn)為硬件是正常工作的,那么接下來(lái)聯(lián)網(wǎng)吧!
列出可用的wifi網(wǎng)絡(luò)
連接網(wǎng)絡(luò)
nmcli dev wifi connect <name> password <password> 不指定網(wǎng)卡連接wifi nmcli dev wifi connect <name> password <password> ifname wlan1 [profile_name] 指定網(wǎng)卡測(cè)試網(wǎng)絡(luò)是否正常工作
ping 8.8.8.8如果能ping通,說明已經(jīng)聯(lián)網(wǎng),但是別著急,你可能還需要配置dns,試著yum update一下,可能會(huì)遇到could not retrieve mirrorlist報(bào)錯(cuò),一般就是dns沒有配置的原因。
添加dns,依然可以使用nmcli命令nmcli con mod eno1 ipv4.dns "8.8.8.8",這就設(shè)置了8.8.8.8為dns,重新執(zhí)行yum update一般就沒什么問題了。
其他方案
不使用NetworkManger配置網(wǎng)絡(luò)的一些方案
使用ip命令
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-configuring_ip_networking_with_ip_commands
使用內(nèi)核命令
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-configuring_ip_networking_from_the_kernel_command_line
網(wǎng)絡(luò)配置的總結(jié)
關(guān)于網(wǎng)絡(luò)配置這部分知識(shí)多數(shù)翻譯自紅帽手冊(cè),其他對(duì)于Route(ip、netmask、Gateway等)、DNS、HostName等可參考原鏈接:
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/index
上面涉及到的知識(shí)Redhat的網(wǎng)絡(luò)管理,如果是Ubuntu等Debian系列的系統(tǒng)可參考這個(gè)鏈接:
https://wiki.debian.org/zh_CN/Network#A.2Bf1F.2B3JFNf24-
安裝桌面環(huán)境
正式安裝桌面環(huán)境之前 yum的一點(diǎn)說明
1、yum倉(cāng)庫(kù)配置
yum有一個(gè)全局的配置文件,文件目錄是 /etc/yum.conf,該文件中會(huì)有一個(gè)名為main的小節(jié),在該小節(jié)中我們可以設(shè)置一些yum的選項(xiàng)來(lái)對(duì)全局有效。比如可以手動(dòng)添加新的倉(cāng)庫(kù)到main中,但是推薦的是在/etc/yum.repos.d/目錄下創(chuàng)建一個(gè)新以.repo為結(jié)尾的文件,來(lái)添加新的倉(cāng)庫(kù)。
下面示例添加一個(gè)新的倉(cāng)庫(kù)來(lái)安裝該倉(cāng)庫(kù)中的軟件(chrome)
在文件中寫入:
[google-chrome] name=google-chrome baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64 enabled=1 gpgcheck=1 gpgkey=https://dl.google.com/linux/linux_signing_key.pub然后去終端中執(zhí)行:
yum install google-chrome-stable一路選擇y就可以了。
2、yum的一些常用操作
3、yum group操作
作開發(fā)的時(shí)候要用到好多開發(fā)工具,如果能用一條命令安裝所有常用的開發(fā)工具該有多好!
于是centos為了方便,為yum添加了group的功能,使用yum grouplist列出可用的軟件包(包含一系列軟件的名稱)
下面是常用的命令
比如安裝"Development Tools"就可以執(zhí)行:
yum groupinstall "Development Tools"參考 https://www.unixmen.com/yum-groupinstall-a-quick-introduction/
安裝gnome桌面環(huán)境
yum groupinstall "X Window System" yum groupinstall "GNOME Desktop" "Graphical Administration Tools" 這里順帶安裝了一些工具等待執(zhí)行完成就可以了,但是有一點(diǎn)問題,那就是安裝之后重啟系統(tǒng)還是會(huì)進(jìn)入命令行模式,使用startx命令之后才能進(jìn)入圖形界面。
參考 https://www.linuxidc.com/Linux/2018-04/152000.htm
設(shè)置默認(rèn)啟動(dòng)圖形環(huán)境
開始之前,國(guó)際慣例,先介紹預(yù)備知識(shí)點(diǎn)。
1、軟連接和硬連接
網(wǎng)上搜去吧,比較容易理解。
2、Linux系統(tǒng)啟動(dòng)流程
bios -> Kernel -> hardware driver-> systemd -> default.target
整個(gè)流程大體上是上面的意思。
關(guān)于硬件驅(qū)動(dòng):
Linux中把硬件驅(qū)動(dòng)與一些其他的東西看作modules,每一個(gè)硬件的驅(qū)動(dòng)就算一個(gè)module,有個(gè)默認(rèn)的配置文件說明默認(rèn)加載哪些modules,詳細(xì)的日后再補(bǔ)充吧。
一些可能有用的資料
https://www.thegeekdiary.com/centos-rhel-how-to-disable-and-blacklist-linux-kernel-module-to-prevent-it-from-loading-automatically/
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/blacklisting_a_module (推薦)
https://www.debian.org/releases/buster/s390x/ch05s02.en.html
https://wiki.archlinux.org/index.php/Kernel_module_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)
關(guān)于systemd:
systemd是一個(gè)守護(hù)服務(wù),官網(wǎng) https://freedesktop.org/wiki/Software/systemd/ ,github 代碼 https://github.com/systemd/systemd ,archwiki的解釋 https://wiki.archlinux.org/index.php/Systemd_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)
簡(jiǎn)單來(lái)說,systemd會(huì)加載一些單元,這些單元有:系統(tǒng)服務(wù)(.service)、掛載點(diǎn)(.mount)、sockets(.sockets) 、系統(tǒng)設(shè)備(.device)、交換分區(qū)(.swap)、文件路徑(.path)、啟動(dòng)目標(biāo)(.target)、計(jì)時(shí)器(.timer),目前我們關(guān)心的是.target。
systemd的執(zhí)行流程是按照/etc/systemd/system/default.target的規(guī)劃進(jìn)行的,到/etc/systemd/system/目錄里能看到很多.target文件,這些分別是systemd可以執(zhí)行的流程,有的是執(zhí)行多用戶命令行界面、有的是執(zhí)行圖形界面,詳細(xì)介紹如下:
systemd會(huì)去加載default.target(/etc/systemd/system/default.target),默認(rèn)default.target指向的多用戶,我們手動(dòng)軟連接default.target到graphal.target就會(huì)默認(rèn)加載圖形界面。
當(dāng)然也可以使用systemctl命令來(lái)設(shè)置默認(rèn)的啟動(dòng)target,例如systemctl set-default multi-user.target就是設(shè)置多用戶來(lái)啟動(dòng)。
啟動(dòng)流程
關(guān)于Linux系統(tǒng)的啟動(dòng)、systemd都還有很多知識(shí)點(diǎn),比如管理工具systemctl、insmod、rmmod、modprobe,先留個(gè)坑,有空再補(bǔ)充。
可參考的資料 :
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/kernel_administration_guide/index
https://access.redhat.com/articles/754933
https://wiki.debian.org/systemd
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/chap-managing_services_with_systemd
多語(yǔ)言
到目前為止,我們的系統(tǒng)還都是英文的,這里設(shè)置下中文。
輸入法
防火墻
未完待續(xù)——
轉(zhuǎn)載于:https://www.cnblogs.com/feipeng8848/p/11210358.html
總結(jié)
以上是生活随笔為你收集整理的玩linux笔记——持续更新的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CSS三大特性
- 下一篇: linux查看文件的编码格式的方法 se