命令列表node
Alinux
alias 別名,能夠將一個長命令定義成較短的別名,方便執行該命令shell
如能夠將cd /etc/sysconfig/network-scripts/定義成cdnet, alias cdnet='cd /etc/sysconfig/network-scripts/',能夠將該命令寫在~/.bashrc中來在永久保存該別名數據庫
保存在~/.bashrc,表示只有當前用戶可使用該別名ubuntu
保存在/etc/bashrc,表示全部用戶均可以使用該別名vim
[root@centos8 ~]# alias cdnet='cd /etc/sysconfig/network-scripts' [root@centos8 ~]# cdnet [root@centos8 network-scripts]#
Bwindows
bc linux自帶計算機,obase=* 爲輸出*進制數字,ibase*爲輸入*進制數字centos
[root@centos8 ~]# bc bc 1.07.1 Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. obase=2 11 1011
[root@centos8 ~]# bc bc 1.07.1 Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. ibase=16 20 32
basename 獲取路徑中的文件名api
[root@centos8 ~]# basename /etc/sysconfig/network-scripts/ifcfg-ens160 ifcfg-ens160
Cbash
clock 顯示硬件時間
clock -s 以硬件時間爲準來調整系統時間
clock -w 以系統時間爲準來調整硬件時間
[root@centos8 ~]# clock 2020-03-22 20:56:13.804032+08:00
cal 顯示本月日曆
cal -y 顯示今年全部月份的日曆
cal + 年份 顯示這一年的日曆
cal + 年份 + 月 顯示這一年這個月的日曆
[root@centos8 ~]# cal March 2020 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
cd 切換目錄
[root@centos8 ~]# cd /etc/sysconfig/
[root@centos8 sysconfig]#
cd .. 表示切換到當前目錄的上級目錄,等同於windows個人電腦中的返回上級文件夾鍵
cd - 表示切換到上次所在目錄,等同於windows個人電腦中的返回鍵
clear 清除當前終端內容
D
date 顯示當前系統時間 +%F 能夠顯示當前年月日 +%T按24小時制顯示當前時間
[root@centos8 sysconfig]# date +%F 2020-03-22 [root@centos8 sysconfig]# date +%T 20:59:51
dnf 和yum基本相同,centos8中自帶dnf軟件
[root@centos8 sysconfig]# dnf -y install bash-completion-2.7-5.el8.noarch Last metadata expiration check: 0:02:36 ago on Sun 22 Mar 2020 09:02:41 PM CST. Package bash-completion-1:2.7-5.el8.noarch is already installed. Dependencies resolved. Nothing to do. Complete!
dirname 顯示文件所在目錄
[root@centos8 ~]# dirname /etc/sysconfig/network-scripts/ifcfg-ens160 /etc/sysconfig/network-scripts
E
echo +$ 提示echo後面的字符串爲變量
Echo $SHELL 顯示當前系統使用的shell
export HISTTIMEFORMAT="%F %T `whoami` "執行history命令時,顯示時間和用戶,寫在.bash_profile中能夠永久保存,不會由於重啓而丟失
[root@centos8 ~]# history 1 2020-03-22 20:52:51 root init 2 2020-03-22 20:52:51 root init 3 3 2020-03-22 20:52:51 root init 0
exit 退出登陸
enable 啓用全部內部命令 enable –n *** 禁用***內部命令
enable –n 查看全部禁用的內部命令
[root@centos8 ~]# enable
enable .
enable :
enable [
enable alias
enable bg
enable bind
F
file 查看文件類型
[root@centos8 network-scripts]# file ifcfg-ens160 ifcfg-ens160: ASCII text
free 查看內存,free -h 更直觀顯示內存使用狀況,用M、G作單位
[root@centos8 network-scripts]# free total used free shared buff/cache available Mem: 2012220 330864 1278648 9364 402708 1517196 Swap: 4194300 0 4194300 [root@centos8 network-scripts]# free -h total used free shared buff/cache available Mem: 1.9Gi 323Mi 1.2Gi 9.0Mi 393Mi 1.4Gi Swap: 4.0Gi 0B 4.0Gi
G
gedit 圖形界面中的文本編輯工具
H
hash 能夠查看最近10條外部命令及這10條命令的使用次數
[root@centos8 network-scripts]# hash hits command 1 /usr/bin/dnf 1 /usr/bin/basename 2 /usr/bin/cal 1 /usr/bin/file 1 /usr/bin/dirname 1 /usr/bin/cat 6 /usr/bin/date 2 /usr/bin/bc 3 /usr/sbin/clock 2 /usr/bin/free 1 /usr/bin/clear
Halt 關機命令
hostname 能夠設置主機名,保存在內存中,重啓失效
hostnamectl 能夠設置主機名,保存在文件中,重啓不丟失
hexdump 查看二進制文件
[root@centos8 network-scripts]# hexdump -C ifcfg-ens160 00000000 54 59 50 45 3d 22 45 74 68 65 72 6e 65 74 22 0a |TYPE="Ethernet".| 00000010 50 52 4f 58 59 5f 4d 45 54 48 4f 44 3d 22 6e 6f |PROXY_METHOD="no| 00000020 6e 65 22 0a 42 52 4f 57 53 45 52 5f 4f 4e 4c 59 |ne".BROWSER_ONLY| 00000030 3d 22 6e 6f 22 0a 42 4f 4f 54 50 52 4f 54 4f 3d |="no".BOOTPROTO=| 00000040 22 64 68 63 70 22 0a 44 45 46 52 4f 55 54 45 3d |"dhcp".DEFROUTE=| 00000050 22 79 65 73 22 0a 49 50 56 34 5f 46 41 49 4c 55 |"yes".IPV4_FAILU| 00000060 52 45 5f 46 41 54 41 4c 3d 22 6e 6f 22 0a 49 50 |RE_FATAL="no".IP| 00000070 56 36 49 4e 49 54 3d 22 79 65 73 22 0a 49 50 56 |V6INIT="yes".IPV| 00000080 36 5f 41 55 54 4f 43 4f 4e 46 3d 22 79 65 73 22 |6_AUTOCONF="yes"| 00000090 0a 49 50 56 36 5f 44 45 46 52 4f 55 54 45 3d 22 |.IPV6_DEFROUTE="| 000000a0 79 65 73 22 0a 49 50 56 36 5f 46 41 49 4c 55 52 |yes".IPV6_FAILUR| 000000b0 45 5f 46 41 54 41 4c 3d 22 6e 6f 22 0a 49 50 56 |E_FATAL="no".IPV| 000000c0 36 5f 41 44 44 52 5f 47 45 4e 5f 4d 4f 44 45 3d |6_ADDR_GEN_MODE=| 000000d0 22 73 74 61 62 6c 65 2d 70 72 69 76 61 63 79 22 |"stable-privacy"| 000000e0 0a 4e 41 4d 45 3d 22 65 6e 73 31 36 30 22 0a 55 |.NAME="ens160".U| 000000f0 55 49 44 3d 22 38 62 65 66 64 38 61 34 2d 61 33 |UID="8befd8a4-a3| 00000100 63 31 2d 34 35 64 39 2d 61 63 63 62 2d 31 39 38 |c1-45d9-accb-198| 00000110 38 61 35 30 64 36 61 64 61 22 0a 44 45 56 49 43 |8a50d6ada".DEVIC| 00000120 45 3d 22 65 6e 73 31 36 30 22 0a 4f 4e 42 4f 4f |E="ens160".ONBOO| 00000130 54 3d 22 79 65 73 22 0a |T="yes".| 00000138
history 顯示當前用戶執行過的命令,默認保存1000條,
[root@centos8 ~]# history 1 2020-03-22 20:52:51 root init 2 2020-03-22 20:52:51 root init 3 3 2020-03-22 20:52:51 root init 0
!+a 執行歷史中從下往上最近開頭爲a的命令
history -c 清除當前用戶下內存中的全部歷史命令
history -s + cmd 在歷史中僞造一個命令,在歷史中顯示,可是並不會執行
當用戶正常退出時會將內存中的history記錄到~/.bash_history文件中
help顯示內部命令的幫助文檔
[root@centos8 network-scripts]# 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. If the directory is not found, and the shell option `cdable_vars' is set, the word is assumed to be a variable name. If that variable has a value, its value is used for DIR. Options: -L force symbolic links to be followed: resolve symbolic links in DIR after processing instances of `..' -P use the physical directory structure without following symbolic links: resolve symbolic links in DIR before processing instances of `..' -e if the -P option is supplied, and the current working directory cannot be determined successfully, exit with a non-zero status -@ on systems that support it, present a file with extended attributes as a directory containing the file attributes The default is to follow symbolic links, as if `-L' were specified. `..' is processed by removing the immediately previous pathname component back to a slash or the beginning of DIR. Exit Status: Returns 0 if the directory is changed, and if $PWD is set successfully when -P is used; non-zero otherwise.
I
init 0 3 5 6 切換運行等級,init0爲關機 init3爲命令行模式 init5爲圖形界面模式 init6爲重啓
info查看命令的幫助文件
[root@centos8 network-scripts]# info ls Next: Stand-alone Info, Up: (dir) Stand-alone GNU Info ******************** This documentation describes the stand-alone Info reader which you can use to read Info documentation. If you are new to the Info reader, then you can get started by typing 'H' for a list of basic key bindings. You can read through the rest of this manual by typing <SPC> and <DEL> (or <Space> and <Backspace>) to move forwards and backwards in it. ...
L
ls 能夠列出當前所在目錄全部文件
ls -l 能夠列出當前所在目錄中所有文件的詳細信息,等同於ll
c開頭,表示該文件爲字符設備文件
b開頭,表示該文件爲塊設備文件,有容量,如磁盤文件
-開頭,表示該文件爲普通文件
d開頭,表示該文件爲目錄文件
p開頭,表示該文件爲管道文件
s開頭,表示該文件爲表示該文件爲套接字文件
l開頭,符號連接文件
lscpu 查看cpu信息,也能夠經過cat /proc/cpuinfo查看cpu信息
[root@centos8 network-scripts]# lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 1 On-line CPU(s) list: 0 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 60 Model name: Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz Stepping: 3 CPU MHz: 2494.232 BogoMIPS: 4988.46 Hypervisor vendor: VMware Virtualization type: full L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 6144K NUMA node0 CPU(s): 0 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt arat flush_l1d arch_capabilities
[root@centos8 network-scripts]# cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 60 model name : Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz stepping : 3 microcode : 0x25 cpu MHz : 2494.232 cache size : 6144 KB physical id : 0 siblings : 1 core id : 0 cpu cores : 1 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt arat flush_l1d arch_capabilities bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs bogomips : 4988.46 clflush size : 64 cache_alignment : 64 address sizes : 43 bits physical, 48 bits virtual power management:
logout 註銷當前用戶
lsblk 查看硬盤信息和分區表
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 200G 0 disk ├─sda1 8:1 0 1G 0 part /boot ├─sda2 8:2 0 100G 0 part / ├─sda3 8:3 0 50G 0 part /data ├─sda4 8:4 0 1K 0 part └─sda5 8:5 0 4G 0 part [SWAP] sr0 11:0 1 7G 0 rom
M
mv 移動文件或目錄
[root@centos8 ~]# ls 1.txt Desktop Downloads Music Public Videos anaconda-ks.cfg Documents initial-setup-ks.cfg Pictures Templates [root@centos8 ~]# mv 1.txt /home [root@centos8 ~]# ls /home 1.txt f2.txt rzx [root@centos8 ~]# ls anaconda-ks.cfg Documents initial-setup-ks.cfg Pictures Templates Desktop Downloads Music Public Videos
man 幫助手冊,全稱manual,能夠查看各類命令的幫助信息
mandb 生成whatis數據庫 適用於centos7 8
makewhatis 生成whatis數據庫 適用於centos6
N
nano 命令行模式下文本編輯工具
P
poweroff 關機命令
ps aux 查看當前運行程序,至關於windows任務管理器
[root@centos8 ~]# ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.6 179196 13784 ? Ss 20:51 0:02 /usr/lib/systemd/systemd root 2 0.0 0.0 0 0 ? S 20:51 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? I< 20:51 0:00 [rcu_gp] root 4 0.0 0.0 0 0 ? I< 20:51 0:00 [rcu_par_gp] root 6 0.0 0.0 0 0 ? I< 20:51 0:00 [kworker/0:0H-kblockd] root 8 0.0 0.0 0 0 ? I< 20:51 0:00 [mm_percpu_wq] root 9 0.0 0.0 0 0 ? S 20:51 0:00 [ksoftirqd/0] root 10 0.0 0.0 0 0 ? R 20:51 0:00 [rcu_sched] root 11 0.0 0.0 0 0 ? S 20:51 0:00 [migration/0] root 12 0.0 0.0 0 0 ? S 20:51 0:00 [watchdog/0] root 13 0.0 0.0 0 0 ? S 20:51 0:00 [cpuhp/0] root 15 0.0 0.0 0 0 ? S 20:51 0:00 [kdevtmpfs] root 16 0.0 0.0 0 0 ? I< 20:51 0:00 [netns] root 17 0.0 0.0 0 0 ? S 20:51 0:00 [kauditd] root 18 0.0 0.0 0 0 ? S 20:51 0:00 [khungtaskd] root 19 0.0 0.0 0 0 ? S 20:51 0:00 [oom_reaper] root 20 0.0 0.0 0 0 ? I< 20:51 0:00 [writeback] root 21 0.0 0.0 0 0 ? S 20:51 0:00 [kcompactd0] root 22 0.0 0.0 0 0 ? SN 20:51 0:00 [ksmd] root 23 0.0 0.0 0 0 ? SN 20:51 0:00 [khugepaged] root 24 0.0 0.0 0 0 ? I< 20:51 0:00 [crypto] root 25 0.0 0.0 0 0 ? I< 20:51 0:00 [kintegrityd] root 26 0.0 0.0 0 0 ? I< 20:51 0:00 [kblockd]
pwd 顯示當前所在目錄
[root@centos8 ~]# pwd
/root
R
rm 刪除命令
reboot 重啓系統
runlevel 查看當前系統運行等級
[root@centos8 ~]# runlevel N 3
S
screen 虛擬終端,可使一個命令在後臺執行,也能夠遠程協助
screen -S *** 建立一個新的screen會話
screen -x *** 加入到已有的一個screen會話
screen不集成在系統內,須要自行安裝,yum -y install screen
centos8中,安裝screen須要先安裝epel-release
Ctrl+a,d 退出一個screen會話
shutdown 關機命令
sleep + 數字 使系統休眠*秒
sudo -i ubuntu系統中切換到root帳戶
systemctl start autofs 開啓自動掛載服務
systemctl status autofs 查看自動掛載服務的狀態
source +文件名等同於 . +文件名 用於執行文件,使新增的參數生效
sosreport 能夠生成一個收集本機信息的壓縮包,用來發給紅帽工程師幫助排錯
T
tty 查看當前登陸終端
[root@centos8 ~]# tty /dev/pts/0
tmux 虛擬終端,ctrl+b鬆開按」 能夠上下分屏,ctrl+b鬆開按% 能夠左右分屏
tmux不集成在系統內,須要自行安裝,yum -y install tmux
type 查看命令是內部命令仍是外部命令或者是別名,若是是外部命令會顯示外部命令的路徑
[root@centos8 ~]# type cd cd is a shell builtin [root@centos8 ~]# type vim vim is /usr/bin/vim [root@centos8 ~]# type ls ls is aliased to `ls --color=auto'
touch 建立空文件
[root@centos8 ~]# ls 123.txt Desktop Downloads Music Public Videos anaconda-ks.cfg Documents initial-setup-ks.cfg Pictures Templates [root@centos8 ~]# rm -rf 123.txt [root@centos8 ~]# ls anaconda-ks.cfg Documents initial-setup-ks.cfg Pictures Templates Desktop Downloads Music Public Videos [root@centos8 ~]# touch 123.txt [root@centos8 ~]# ls 123.txt Desktop Downloads Music Public Videos anaconda-ks.cfg Documents initial-setup-ks.cfg Pictures Templates
U
uptime 顯示系統運行多長時間
[root@centos8 ~]# uptime 21:36:14 up 44 min, 1 user, load average: 0.00, 0.00, 0.00
[root@centos8 ~]# uptime -s
2020-03-22 20:51:58
[root@centos8 ~]# uptime -p
up 45 minutes
unalias unalias -a 能夠刪除全部別名
unalias -a+別名,能夠刪除該別名
W
who 查看哪些帳戶正在使用
whoami 查看當前是哪一個用戶在使用
who am i 查看當前是哪一個用戶在使用
[root@centos8 ~]# who root pts/0 2020-03-22 20:52 (10.0.0.1) [root@centos8 ~]# who am i root pts/0 2020-03-22 20:52 (10.0.0.1) [root@centos8 ~]# whoami root
which + 命令 能夠查看命令的路徑
[root@centos8 ~]# which vim /usr/bin/vim
whereis + 命令 能夠查看命令的路徑以及幫助文檔所在路徑
[root@centos8 ~]# whereis vim vim: /usr/bin/vim /usr/share/vim /usr/share/man/man1/vim.1.gz
whatis 簡單的介紹該命令的功能
[root@centos8 ~]# whatis vim vim (1) - Vi IMproved, a programmer's text editor
Y
yum 在線安裝軟件
yes 能夠一直輸出Y的命令
符號
\ 轉義符,屏蔽後面第一個特殊符號自己的原有含義
‘ ’ 屏蔽單引號裏面全部特殊符號、變量的含義 強引用
「 」 用變量的值會替換並顯示出來,弱引用,
` ` 可執行引號裏的命令 和$(***)做用同樣,$(***)支持命令嵌套
{*,*} 將花括號裏的內容分別對括號前和括號後內容進行組合
[root@centos8 ~]# echo "$PATH" /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [root@centos8 ~]# echo '$PATH' $PATH [root@centos8 ~]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [root@centos8 ~]# echo `$PATH` -bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin: No such file or directory [root@centos8 ~]# echo `echo $PATH` /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [root@centos8 ~]#
[root@centos8 ~]# echo {a..d}and{1,5,76} aand1 aand5 aand76 band1 band5 band76 cand1 cand5 cand76 dand1 dand5 dand76
Ctrl+d 能夠退出當前用戶
Ctrl+L 清屏 等同於執行clear
Ctrl+u刪除光標前內容
Ctrl+k 刪除光標後內容
Ctrl+a 將光標移動到行首
Ctrl+e 將光標移動到行尾
Alr+r 刪除整行內容