【学神-RHEL7】1-3-Linux基本命令和配置服务器来电后自动开机
?
本節(jié)所講內(nèi)容:
Linux終端介紹
Shell提示符
Bash Shell基本語法
基本命令的使用:ls、pwd、cd
查看系統(tǒng)和BIOS硬件時間
Linux如何獲得幫助
Linux關(guān)機(jī)命令:shutdow、init等
Linux 7個啟動級別
創(chuàng)建一個方便快捷實(shí)驗(yàn)環(huán)境快照
設(shè)置服務(wù)器在來電后自動開機(jī)
?
?
Linux終端介紹
tty控制臺終端 ? pts虛擬終端
tty1-tty6 ?
如是一開始進(jìn)入的是圖形圖面:tty1 ?就是圖形界面。
圖形界面切換到字符界面終端: Ctrl+(Shift)+Alt+F2-6 ?
Fn
Alt+F1
pts虛擬終端
ctrl+shift+T ?
Alt + 數(shù)字鍵
放大:ctrl+shift+ +
縮小:ctrl+ -
[root@localhost?~]#?ps?-aux?|?grep?pts Warning:?bad?syntax,?perhaps?a?bogus?'-'??See?/usr/share/doc/procps-3.2.8/FAQ root??????2919??0.0??0.1?108300??1884?pts/0????Ss???10:27???0:00?/bin/bash root??????2948??0.0??0.1?110228??1184?pts/0????R+???10:29???0:00?ps?-aux root??????2949??0.0??0.0?103240???864?pts/0????S+???10:29???0:00?grep?pts?
pts(pseudo-terminalslave) ?偽終端 :通過ssh相關(guān)工具連接上后,顯示出來終端為:pts
?
Shell提示符:
[root@localhost ~]#
[用戶@主機(jī)名 當(dāng)前目錄名稱 ] 提示符 ? root為# 普通用戶為:$
?
Bash Shell基本語法
?
總結(jié)Linux命令輸入規(guī)律:
如何輸入命令:
命令 ? ? ?[選項(xiàng)]([參數(shù)]) ? ? ? [選項(xiàng)的值]([參數(shù)的值])
空格作為分割
Ls-l/root
基本命令:
ls 命令
作用:查看當(dāng)前目錄下有哪些文件
語法:ls 目錄 ,如果不加目錄查看當(dāng)前目錄
參數(shù):
-l 顯示詳細(xì)信息 系統(tǒng)里面的快捷方式#ll=ls -l
-a顯示隱藏文件
-d 查看目錄(不查看里面的內(nèi)容)
-h 增強(qiáng)可讀性
[root@localhost?~]#?ls?-l??/root [root@localhost?~]#?ll??-h?/etc/passwd -rw-r--r--?1?root?root?1.6K?Aug?25?21:27?/etc/passwdlinux系統(tǒng)中不同的顏色代表了不同的文件類型
?
藍(lán)色 ?目錄/etc
黑色 ?文件/etc/passwd
淺藍(lán)色 ?鏈接/etc/grub2.cfg
紅色 ? 壓縮包boot.tar.gz ?
綠色 ? ?可執(zhí)行文件/etc/init.d/network
黑底黃字設(shè)備文件/dev/sda
?
pwd
作用:查看當(dāng)前目錄
語法:pwd ?沒有參數(shù)
?
cd
作用:切換目錄
語法:cd 目錄名
例:
#cd ?回到用戶自己的主目錄
#cd ~ ?回到用戶自己的主目錄
#cd - ?回到上一個目錄
?
查看系統(tǒng)和BIOS硬件時間: ?指的是bios時間 ?(格里尼茲天文臺)
?
[root@localhost?sysconfig]#?hwclock? Tue?25?Aug?2015?10:06:06?PM?CST??-0.204632?seconds?
Linux如何獲得幫助
方法1:加參數(shù)-h 或--help
[root@localhost?~]#?shutdown?–-help [root@localhost?~]#?fdisk??-h Man??? [root@localhost?~]#?man?find?
help?? 查看內(nèi)部命令幫助信息
--help? 查看外部命令幫助信息
?
關(guān)機(jī)命令:
shutdown、 init 、reboot?? poweroff
shutdown
作用:關(guān)機(jī),重啟,定時關(guān)機(jī)
語法:shutdown ?[選項(xiàng)]
有如下選項(xiàng):
-r?? ? => 重新啟動計(jì)算機(jī)
-h?? ?=> 關(guān)機(jī)
-h? 時間? =>定時關(guān)機(jī)
-c??? => 取消之前的定時關(guān)機(jī)? 或ctrl+c
?
[root@localhost?~]#?shutdown?-h?+10 10分鐘之后關(guān)機(jī) [root@localhost?~]#?shutdown?-h?23:00 指定具體的時間點(diǎn)進(jìn)行關(guān)機(jī) [root@localhost?~]#?shutdown?-h?now 立即關(guān)機(jī) shutdown?-r?now??立即重啟 shutdown?-r?+10????#10?分鐘以后重啟 shutdown?-r??22:22?????#?22:22?以后重啟init 命令
作用:切換系統(tǒng)運(yùn)行級別
語法:init ?0-6
?
例:
init 0命令用于立即將系統(tǒng)運(yùn)行級別切換為0,即關(guān)機(jī);
init 6命令用于將系統(tǒng)運(yùn)行級別切換為6,即重新啟動。
?
Linux 7個啟動級別:
0 系統(tǒng)停機(jī)模式,系統(tǒng)默認(rèn)運(yùn)行級別不能設(shè)置為0,否則不能正常啟動,機(jī)器關(guān)閉。
1 單用戶模式,root權(quán)限,用于系統(tǒng)維護(hù),禁止遠(yuǎn)程登陸,就像Windows下的安全模式登錄。
2 多用戶模式,沒有NFS網(wǎng)絡(luò)支持。
3 完整的多用戶文本模式,有NFS,登陸后進(jìn)入控制臺命令行模式。
4 系統(tǒng)未使用,保留一般不用,在一些特殊情況下可以用它來做一些事情。例如在筆記本電腦的電池用盡時,可以切換到這個模式來做一些設(shè)置。
5 圖形化模式,登陸后進(jìn)入圖形GUI模式,X Window系統(tǒng)。
6 重啟模式,默認(rèn)運(yùn)行級別不能設(shè)為6,否則不能正常啟動。運(yùn)行init 6機(jī)器就會重啟。
?
啟動級別配置
RHEL7不再使用/etc/inittab文件進(jìn)行默認(rèn)的啟動級別配置
systemd使用比sysvinit的運(yùn)行級更為自由的target替代。第3運(yùn)行級用multi-user.target替代。第5運(yùn)行級用graphical.target替代。runlevel3.target和runlevel5.target分別是指向 multi-user.target和graphical.target的符號鏈接。
?
切換運(yùn)行級別
?
切換到第3運(yùn)行級
[root@localhost?~]#?systemctl?isolate?multi-user.target 或 [root@localhost?~]#?systemctl?isolate?runlevel3.target 切換到第5運(yùn)行級 [root@localhost?~]#?systemctl?isolate?graphical.target 或 [root@localhost?~]#?systemctl?isolate?runlevel5.target?
設(shè)置默認(rèn)的運(yùn)行界別
systemd使用鏈接來指向默認(rèn)的運(yùn)行級別。在創(chuàng)建新的鏈接前,可以通過下面命令刪除存在的鏈接:
rm /etc/systemd/system/default.target
默認(rèn)啟動級別3
[root@localhost?~]#?ln?-sf?/lib/systemd/system/multi-user.target?/etc/systemd/system/default.target 或 [root@localhost?~]#?systemctl?-f?enable?multi-user.target 默認(rèn)啟動級別5 [root@localhost?~]#?ln?-sf?/lib/systemd/system/graphical.target?/etc/systemd/system/default.target 或 [root@localhost?~]#?systemctl?-f?enable?graphical.target?
查看當(dāng)前的運(yùn)行級別
runlevel
[root@localhost?~]#?runlevel N?5?
?
?????? 創(chuàng)建一個方便快捷實(shí)驗(yàn)環(huán)境快照
配置好靜態(tài)IP地址,關(guān)閉iptables防火墻,關(guān)閉selinux,,光盤自動掛載,配置好yum倉庫
?
1)配置IP地址
RHEL7中弱化了setup的功能,對于網(wǎng)絡(luò)管理來說,network服務(wù)的功能弱化,主要通過NetworkManage對網(wǎng)絡(luò)進(jìn)行管理
RHEL7通過nmtui修改網(wǎng)絡(luò)配置(RHEL7默認(rèn)安裝,前提是需要開啟NetworkManager.service 才可以使用)
首先,確認(rèn)NetworkManager服務(wù)器正常運(yùn)行
[root@localhost?~]#?systemctl?status?NetworkManager NetworkManager.service?-?Network?ManagerLoaded:?loaded?(/usr/lib/systemd/system/NetworkManager.service;?enabled)Active:?active?(running)?since?Wed?2015-11-25?19:02:52?CST;?3min?10s?ago?
1、修改配置:
[root@localhost?~]#?nmtui-edit?eno16777736?
?
?
2、激活網(wǎng)絡(luò)配置
[root@localhost?~]#?nmtui?
?
?
?
?
或者
[root@localhost?~]#?systemctl?restart?network?
?
2)關(guān)閉防火墻并設(shè)置為開機(jī)自動關(guān)閉
[root@localhost?~]#?systemctl?stop?firewalld [root@localhost?~]#?systemctl?disable?firewalld3)關(guān)閉selinux
查看selinux服務(wù)開啟狀態(tài)
[root@localhost?~]#?getenforce? Disabled [root@localhost?~]#?vim?/etc/selinux/config #?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=disabled #?SELINUXTYPE=?can?take?one?of?these?two?values: #?????targeted?-?Targeted?processes?are?protected, #?????mls?-?Multi?Level?Security?protection. SELINUXTYPE=targeted臨時強(qiáng)制關(guān)閉selinux
[root@localhost?~] #?setenforce?0沒基礎(chǔ)的同學(xué),僅供了解
光盤自動掛載
[root@localhost?~]#?vim?/etc/fstab /dev/sr0????????????????/mnt????????????????????iso9660???????defaults????????0???0配置好yum倉庫
[root@localhost?~]#?cd?/etc/yum.repos.d/ [root@?localhost?yum.repos.d]#?vim?rhel-source.repo [rhel-yum] name=Red?Hat?Enterprise?Linux?$releasever?-?$basearch?-?Source baseurl=file:///mnt/ enabled=1 gpgcheck=0?????? 開機(jī)按首先按Del?? F2進(jìn)入BIOS
?????? 選擇Integrated Peripharals中的SuperIO Device
?????? 將其中的Restore On AC Power Loss選項(xiàng)修改:Power On
?????? (若要加電不開機(jī)選擇Power Off,若要加電之前斷電狀態(tài)選擇Last State)
?????? 最后按F10保存退出即可
?
學(xué)習(xí)過程中如果問題,請留言。更多內(nèi)容請加:
學(xué)神IT-linux講師-RM老師QQ:2805537762
學(xué)神IT-戚老師QQ:3341251313
學(xué)神IT-旭斌QQ:372469347
學(xué)神IT教育RHEL7交流群:468845589
?
?
轉(zhuǎn)載于:https://blog.51cto.com/xuegodlinux/1716975
總結(jié)
以上是生活随笔為你收集整理的【学神-RHEL7】1-3-Linux基本命令和配置服务器来电后自动开机的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SQLite/嵌入式数据库
- 下一篇: linux 其他常用命令