1、查看IP
ip addr
2、文件上傳下載命令
- lrzsz命令安裝
yum -y install lrzsz
- 上傳命令,進入文件即將上傳的存放路徑,輸入命令回車後會彈出窗口,選擇需要上傳的文件,可以多個文件一起上傳
rz
- 下載命令,進入需要下載的文件存放路徑,輸入命令回車後會彈出窗口,選擇即將下載的文件存放路徑,進行文件下載
sz + 需要下載的文件名
3、shutdown命令關機或重啓
語法格式:
shutdown [OPTIONS...] [TIME] [WALL...]
時間字符串可以採用格式hh:mm表示小時/分鐘,指定執行關閉時的時間,指定24小時時鐘格式。 或者,它可以是語法+m,指的是從現在開始的指定分鐘數。now是+0的別名,即用於觸發立即關閉。 如果未指定時間參數,則暗示爲+1。
[root@localhost ~]# shutdown --help
shutdown [OPTIONS...] [TIME] [WALL...]
Shut down the system.
--help Show this help
-H --halt Halt the machine
-P --poweroff Power-off the machine
-r --reboot Reboot the machine
-h Equivalent to --poweroff, overridden by --halt
-k Don't halt/power-off/reboot, just send warnings
--no-wall Don't send wall message before halt/power-off/reboot
-c Cancel a pending shutdown
其中,-h: halt / poweroff表示關機,-r: reboot表示重啓,-c: cancel取消前面的命令。
4、查看或修改服務器時間 - date命令
-
查看時間和日期
命令 : “date”
[root@localhost keepalived]# date 2020年 04月 30日 星期四 17:15:04 CST
-
設置時間和日期
命令 : “date -s ‘2020-5-9 15:55:30’”
[root@localhost keepalived]# date -s '2020--5-9 15:55:30' 2020年 05月 09日 星期六 15:55:30 CST
5、查看或設置當前主機名
-
查看
命令 : “hostname” 或 “hostnamectl”
[root@localhost ~]# hostname localhost.localdomain [root@localhost ~]# hostnamectl Static hostname: localhost.localdomain Icon name: computer-vm Chassis: vm Machine ID: 51e4a8d35b0b46b7bd0f049a3b9c5926 Boot ID: 8db4394ee7964864975b21b9ca7f18f5 Virtualization: vmware Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-957.el7.x86_64 Architecture: x86-64
-
修改主機名
命令 : “hostnamectl set-hostname <newhostname>”
[root@localhost ~]# hostnamectl set-hostname node08
6、開啓或關閉防火牆 - - firewalld命令
-
查看防火牆狀態
命令:systemctl status firewalld[root@node08 ~]# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since 六 2020-05-09 20:59:49 CST; 34s ago Docs: man:firewalld(1) Main PID: 26601 (firewalld) CGroup: /system.slice/firewalld.service └─26601 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid 5月 09 20:59:49 node08 systemd[1]: Starting firewalld - dynamic firewall daemon... 5月 09 20:59:49 node08 systemd[1]: Started firewalld - dynamic firewall daemon.
-
關閉防火牆
命令:systemctl stop firewalld -
禁止開機啓動
命令:systemctl disable firewalld該命令只能禁止開機啓動,但是不能關閉當前開啓的防火牆,關閉防火牆還是需要執行systemctl stop firewalld命令。
[root@node08 ~]# systemctl disable firewalld Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
-
啓動防火牆
命令:systemctl start firewalld -
設置開機啓動
命令: systemctl enable firewalld[root@node08 ~]# systemctl enable firewalld Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service. Created symlink from /etc/systemd/system/multi-user.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.
7、journalctl -xe命令
在啓動或重啓軟件或服務的時候,經常會出現如下命令(journalctl -xe):
[root@node08 keepalived]# systemctl start keepalived
Job for keepalived.service failed because a configured resource limit was exceeded. See "systemctl status keepalived.service" and "journalctl -xe" for details.
其中,journalctl是Centos7上專有的日誌管理工具。該工具是從message這個文件裏讀取信息。Systemd統一管理所有Unit的啓動日誌。帶來的好處就是,可以只用journalctl一個命令,查看所有日誌(內核日誌和應用日誌)。日誌的配置文件在/etc/systemd/journald.conf文件中。journalctl功能強大,用法非常多。參考《journalctl 日誌查看方法》博文。
下面簡單列舉了幾個常用的命令:
- journalctl -xe
-xe是排查問題時最常用的參數:
-e 從結尾開始看
-x 相關目錄(如:問題相關的網址)
journalctl -xe # -x 是目錄(catalog)的意思,在報錯的信息下會,附加解決問題的網址 -e pager-end 從末尾開始看
- 結尾看日誌,開頭看日誌
journalctl -r # -r reverse 從尾部看(推薦)
journalctl # 從開頭看(一般用不到,因爲都是看最新的日誌)
- 滾屏輸出日誌
journalctl -f -n 20; #
- 時間段的日誌
journalctl --since "2020-01-01 20:00:00" --until "2020-02-01 20:15:00"
- 某個服務的日誌
journalctl -u httpd.service # -u service unit
持續更新中