標籤:linux學習
系統版本:
ISO:CentOS-7-x86_64-Everything-1511
(安裝時選擇的語言是中文版,支援的還不錯,看協助資訊很方便)
[[email protected] ~]$ cat /etc/redhat-release #系統迷你安裝,以上簡稱C7.2CentOS Linux release 7.2.1511 (Core)
查看SSH連接埠:
[[email protected] ~]$ ss -tnl #查看SSH連接埠,可以看到是預設的22State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 :::22 :::* LISTEN 0 100 ::1:25 :::*
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/85/35/wKioL1ecqe3xW7NqAAL4capI9pw100.jpg-wh_500x0-wm_3-wmp_4-s_3865009337.jpg" title="ssh遠端連線.jpg" alt="wKioL1ecqe3xW7NqAAL4capI9pw100.jpg-wh_50" />
添加DNS:(IP地址設定略)
註:官方建議在/etc/sysconfig/network下設定DNS
[[email protected] ~]# vi /etc/sysconfig/network #根據當地電訊廠商,添加填寫DNS1、DNS2# Created by anacondaDNS1=114.114.114.114 DNS2=202.106.0.20
查看IP地址:
描述:由於C7.2是迷你安裝,無法使用在C5或C6上常用的ifconfig命令,可以使用ip addr list命令來查看,如果要使用ifocnfig,需要安裝net-tools這個工具包。
[[email protected] ~]$ ifconfig -bash: ifconfig: 未找到命令[[email protected] ~]$ ip addr list | grep ‘inet 10.3‘ inet 10.3.20.71/24 brd 10.3.20.255 scope global eno16777736
650) this.width=650;" src="http://s2.51cto.com/wyfs02/M01/85/35/wKioL1ecrBjBnc0bAAMqC-XJ32I301.jpg-wh_500x0-wm_3-wmp_4-s_2655656240.jpg" title="ip.jpg" alt="wKioL1ecrBjBnc0bAAMqC-XJ32I301.jpg-wh_50" />
安裝net-tools工具包,來使用ifconfig命令
[[email protected] ~]# yum -y install net-tools #切換到root下,安裝工具包.......Running transaction 正在安裝 : net-tools-2.0-0.17.20131004git.el7.x86_64 1/1 驗證中 : net-tools-2.0-0.17.20131004git.el7.x86_64 1/1 已安裝: net-tools.x86_64 0:2.0-0.17.20131004git.el7
使用ifconfig查看IP
[[email protected] ~]$ ifconfig | grep ‘inet 10.3‘
inet 10.3.20.71 netmask 255.255.255.0 broadcast 10.3.20.255
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/85/35/wKioL1ecrZix2DEEAAMEkbHqIrY254.jpg-wh_500x0-wm_3-wmp_4-s_2628504443.jpg" title="ip1.jpg" alt="wKioL1ecrZix2DEEAAMEkbHqIrY254.jpg-wh_50" />
防火牆:
查看規則:
[[email protected] ~]# iptables -L -n #使用此命令查看規則Chain INPUT (policy ACCEPT)target prot opt source destination ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHEDACCEPT all -- 0.0.0.0/0 0.0.0.0/0 INPUT_direct all -- 0.0.0.0/0 0.0.0.0/0 INPUT_ZONES_SOURCE all -- 0.0.0.0/0 0.0.0.0/0 INPUT_ZONES all -- 0.0.0.0/0 0.0.0.0/0 .................略
清除規則:(只對當前有效)---一般不這麼用
[[email protected] ~]# iptables -F
關掉:(只對當前有效)
[[email protected] ~]# systemctl stop firewalld.service[[email protected] ~]# iptables -L -n Chain INPUT (policy ACCEPT)target prot opt source destination Chain FORWARD (policy ACCEPT)target prot opt source destination Chain OUTPUT (policy ACCEPT)target prot opt source destination
永久關掉:(這條常用)
[[email protected] ~]# systemctl disable firewalld.serviceRemoved symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.[[email protected] ~]# systemctl disable firewalld.service[[email protected] ~]#
Centos 6關掉防火牆:
~]#service iptables stop ~]#chkconfig iptables off
終端裝置:terminal
描述:多任務、多使用者
物理終端,控制台:console
虛擬終端:6個 tty
ctrl+alt+F[1-6]
圖形終端:
CentOS 6:
CentOS 7:
在哪個虛擬終端啟動,即位於哪個虛擬終端
串列終端:ttys
偽終端:pty
Linux的哲學思想之一:一切皆檔案:
表現之一:硬體裝置也通過檔案表示:
物理終端:/dev/console
虛擬終端:/dev/tty#[1,6]
串列終端:/dev/ttyS#
偽終端:/dev/pts/#
樣本:
在SecureCRT上查看,複製多個會話,tty查看顯示的結果,顯示是偽終端/dev/pts/0、1、2
[[email protected] ~]$ tty
/dev/pts/0
[[email protected] ~]# tty
/dev/pts/1
[r[email protected] ~]# tty
/dev/pts/2
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/85/35/wKiom1ecsvHhkjxMAAJsDGa361k195.jpg-wh_500x0-wm_3-wmp_4-s_1917790988.jpg" title="tty.jpg" alt="wKiom1ecsvHhkjxMAAJsDGa361k195.jpg-wh_50" />
在VMware上按ctrl+alt+F2,顯示為串列終端tty2
650) this.width=650;" src="http://s2.51cto.com/wyfs02/M02/85/35/wKioL1ecs_XxvEieAAJwk1CSlqM080.jpg-wh_500x0-wm_3-wmp_4-s_493804392.jpg" title="QQ20160730220417.jpg" alt="wKioL1ecs_XxvEieAAJwk1CSlqM080.jpg-wh_50" />
查看介面程式:
[[email protected] ~]# echo $SHELL/bin/bash
啟動GUI:(此命令沒有實驗)
在某一虛擬終端介面運行命令:startx &
Linux命令協助的擷取:
內部命令協助:
# help COMMAND
使用type cd得知是內嵌命令,如需擷取協助,使用help cd,就能得到cd大體的使用格式
[[email protected] ~]# type cd #得知cd是內嵌命令cd 是 shell 內嵌[[email protected] ~]# help cd #使用help cd擷取協助cd: cd [-L|[-P [-e]]] [dir] Change the shell working directory. Change the current directory to DIR. The default DIR is the value of the HOME shell variable. The variable CDPATH defines the search path for the directory containing DIR. Alternative directory names in CDPATH are separated by a colon (:). A null directory name is the same as the current directory. If DIR begins with a slash (/), then CDPATH is not used. ........略
help也是內嵌命令,來查看它的協助
[[email protected] ~]# type helphelp 是 shell 內嵌[[email protected] ~]# help help #中括弧是可省略的help: help [-dms] [模式 ...] 顯示內嵌命令的相關資訊。 顯示內嵌命令的簡略資訊。如果指定了 PATTERN 模式, 給出所有匹配 PATTERN 模式的命令的詳細協助,否則打 印一個說明主題列表 選項: -d 輸出每個主題的簡短描述 -m 以偽 man 手冊的格式顯示使用方法 -s 為每一個匹配 PATTERN 模式的主題僅顯示一個用法 簡介 參數: PATTERN Pattern 模式指定一個說明主題 退出狀態: 返回成功,除非 PATTERN 模式沒有找到或者使用了無效選項。
本文出自 “寫給自己的部落格” 部落格,請務必保留此出處http://zhaodongwei.blog.51cto.com/4233742/1832187
馬哥營運學習筆記(一)