systemctl start 開啓
stop 關閉
restart 重啓
reload 重新加載配置
status 查看
enable 設定服務開機啓動項
disable 禁止服務開機啓動項
list-dependencies 查看服務依賴關係
list-units 查看當前運行的所有服務
list-unit-files 查看服務的開機啓動情況
set-default multi-user.target 開機不啓動圖形
set-default graphical.target 開機啓動圖形
sysatemctl status
loaded 系統服務已經初始化完成,加載過配置
active(running) 正在執行
(exited) 僅執行一次就正常結束的服務
(目前沒有程序正在系統中執行)
(waiting) 正在執行,等待其他程序事件完成才繼續
inactive 服務關閉
enbaled 服務開機自啓動
disabled 服務開機不自啓動
static 服務開機啓動項不被管理
遠程訪問
ssh 遠程主機用戶@遠程主機ip地址
Are you sure you want to continue connecting (yes/no)? yes 建立安全傳輸key
[email protected]'s password: 密碼輸入沒有回顯
[root@foundation1 ~]# 登陸成功
ctrl +d |logout 退出
[root@foundation1 ~]# logout
Connection to 172.25.254.1 closed.
[root@localhost ~]# vim /etc/motd 設定登陸顯示字符
ssh的key認證
1.生成key
[test@foundation0 ~]$ ssh-keygen 生成公鑰和私鑰的工具
Generating public/private rsa key pair.
Enter file in which to save the key (/home/test/.ssh/id_rsa):『enter』 指定加密字符保存文件,使用默認
Created directory '/home/test/.ssh'.
Enter passphrase (empty for no passphrase): 密碼,必須大於4位(或者不設置密碼)
Enter same passphrase again:
Your identification has been saved in /home/test/.ssh/id_rsa.
Your public key has been saved in /home/test/.ssh/id_rsa.pub.
The key fingerprint is: 確認密碼
a5:4f:02:51:68:59:f4:e8:e3:c5:91:1f:6f:86:99:06 [email protected]
The key's randomart p_w_picpath is:
+--[ RSA 2048]----+
| .*+ |
| +. o . |
| .. . E . |
| o + + * |
| S + * + |
| . * . o |
| . . |
| |
| |
+-----------------+
[test@foundation0 .ssh]$ pwd
/home/test/.ssh 生成密鑰存放位置
[test@foundation0 .ssh]$ ls
id_rsa id_rsa.pub id_rsa位私鑰,id_rsa.pub位公鑰
2.使用key加密目標主機的目標用戶
[test@foundation0 ~]$ ssh-copy-id -i /home/test/.ssh/id_rsa.pub [email protected]
The authenticity of host '172.25.254.100 (172.25.254.100)' can't be established.
ECDSA key fingerprint is eb:24:0e:07:96:26:b1:04:c2:37:0c:78:2d:bc:b0:08.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.
3.
ssh-copy-id 上傳key的工具
-i 指定使用的公鑰
/home/test/.ssh/id_rsa.pub 使用公鑰的名稱
westos 被管理的目標用戶
172.25.254.100 被管理用戶所在主機的ip
authorized_keys 此文件在目標用戶加目錄的.ssh中,這個文件就是目標用戶被加密的標識,文件內容位公鑰內容。
4.sshd服務的簡單配置
vim /etc/ssh/sshd_config sshd服務的配置文件
48 PermitRootLogin yes|no 是否允許root用戶通過sshd的認證
78 PasswordAuthentication yes|no 開啓或關閉用戶密碼認證
AllowUsers student westos 用戶白名單,只允許在名單中出現的用戶使用sshd服務
systemctl restart sshd 重新加載配置
1.ip映射文件
/etc/hosts
ip 主機名稱
ip設定
ifconfig 查看或者臨時設定主機ip的工具
ifconfig 網絡接口 查看這個接口上的 ip
ifconfig 網絡接口 ip netmask 子網掩碼 臨時設定ip
ifconfig eth0 172.25.254.100 netmask 255.255.255.0
systemctl restart network 重新啓動網絡基本服務
systemctl restart NetworkManager 網絡智能管理服務
圖形網絡的配置方式
nm-connection-editor 圖形中的網絡設定工具
nmtui 文本中的網絡設定工具
命令設定ip的方式
nmcli
nmcli connection delete 連接名稱 刪除此連接
nmcli connection add con-name westos ifname eth0 type ethernet autoconnect yes 添加動態網絡
nmcli connection add con-name westos ifname eth0 type ethernet ip4 ip/24 gw4 ip 靜態網絡
網絡配置文件
/etc/sysconfig/network-scripts/ 網絡配置目錄
動態網絡配置
vim ifcfg-xxx 網絡配置文件格式
DEVICE=eth0 指定文件管理的設備名稱
BOOTPROTO=dhcp dhcp動態獲取,none和static都表示靜態網絡
ONBOOT=yes 開機自動激活設備
NAME=hello 指定網絡鏈接的名字爲hello
###靜態網絡配置###
vim ifcfg-xxx 網絡配置文件格式
DEVICE=eth0 指定文件管理的設備名稱
BOOTPROTO=static|none dhcp動態獲取,none和static都表示靜態網絡
ONBOOT=yes 開機自動激活設備
NAME=hello 指定鏈接名字
IPADDR=172.25.254.100 設定ip爲172.25.254.100
NETMASK=255.255.255.0 子網掩碼爲255.255.255.0
PREFIX=24 子網掩碼爲255.255.255.0
2.dns服務器的指向文件
vim /etc/resolv.conf
nameserver 172.25.254.254
vim /etc/sysconfig/network-scripts/ifcfg-xxx
DNS1=172.25.254.254
PEERDNS=yes|no 配置文件是否會修改/etc/resolv.conf no表示不修改
nmcli device show
nmcli device status
nmcli device disconnect eth0
nmcli device connect eth0
nmcli connection edit "System westos1"
nmcli connection modify "System westos1" ipv4.addresses 172.25.254.101/24
nmcli connection modify "System westos1" ipv4.dns 172.25.254.1
nmcli connection modify "System westos1" ipv4.method auto
nmcli connection modify "System westos1" ipv4.method manual
nmcli connection delete "System westos1"
nmcli connection add con-name eth0 ifname eth0 type ethernet ip4 172.25.254.100 gw4 172.25.254.254
nmcli connection modify eth0 ipv4.dns 172.25.254.254