Linux鍩虹
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux鍩虹相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e9%bb%98%e8%ae%a4' title='榛樿'>榛樿
pat 鑷姩鎹㈣ df -h 绯荤粺 mem 鏃ュ巻1.Linux甯歌鍛戒护
/etc/motd 绯荤粺鐧诲綍鍚庢彁绀烘枃浠?/p>
/etc/issue 绯荤粺鐧诲綍鍓嶆彁绀烘枃浠?/p>
cat 鏌ョ湅鏂囨湰鏂囦欢
free -h 鏌ョ湅鍐呭瓨
tty 鏌ョ湅绔彛
echo $SHELL 鏌ョ湅shell绫诲瀷
cat /etc/shells 鏌ョ湅鎵€鏈塻hell绫诲瀷锛堟墦寮€ 鏂囦欢澶癸級
ps aux 鍒楀嚭鍚庡彴杩愯鐨勬墍鏈夌▼搴?/p>
hostname 鏌ョ湅涓绘満鍚?锛堜富鏈哄悕涓嶈鐢ㄤ笅鍒掔嚎锛?/p>
hostname NAME 淇敼涓绘満鍚嶏紙涓存椂淇敼锛?/p>
hostnamectl set-hostname NAME 锛堜慨鏀瑰苟淇濆瓨鏂囦欢澶癸級
/etc/hostname 涓绘満鍚嶆枃浠跺す
hostname -I 鏌ョ湅ip
sudo -i 鍒囨崲璐︽埛锛圲buntu锛?/p>
su 锛坈entos锛?/p>
who 鏄剧ず鎵€鏈夌櫥褰曚富鏈虹殑鎯呭喌
whoami 鏄剧ず褰撳墠鐢ㄦ埛
int 0 3 5 6 鍏虫満 瀛楃鐣岄潰 鍥惧舰鐣岄潰 閲嶅惎
nano 鏂囦欢缂栬緫宸ュ叿
鐢ㄦ埛锛?/p>
$ 鏅€氱敤鎴?/p>
# 绠$悊鍛?/p>
PS1= 淇敼鎻愮ず绗?/p>
/etc/profile.d/env.sh 鏂囦欢澶瑰鎵€鏈夌敤鎴烽兘鐢熸晥
exit 閫€鍑?/p>
logout 娉ㄩ攢
/bin/bash 鍐呴儴鍛戒护鏂囦欢
type 鍒ゆ柇鍛戒护灞炰簬鍐呴儴鍛戒护杩樻槸澶栭儴鍛戒护锛堝閮ㄥ懡浠ゅ瓨鏀惧湪鏂囦欢澶归噷浼氭樉绀洪€斿緞锛?/p>
type -a 鏄剧ず鍚屽懡浠ょ殑鍐呭閮ㄥ懡浠?/p>
echo $PATH 鏄剧ず澶栭儴鍛戒护瀛樻斁鐨勬枃浠?/p>
hash 鍒楀嚭鎵€鏈夌殑鎵ц杩囩殑澶栭儴鍛戒护
hash -r 娓呴櫎缂撳瓨
hash -d 娓呴櫎涓€涓紦瀛?/p>
enable 鏄剧ず鍐呴儴鍛戒护
enable -n 绂佺敤鍐呴儴鍛戒护
enable 鍛戒护 鍚敤鍐呴儴鍛戒护
. / source 閮藉彲浠ヨ閰嶇疆鐨勬枃浠剁敓鏁?/p>
which 鏌ョ湅澶栭儴鍛戒护璺緞
whereis 鏄剧ず澶栭儴鍛戒护鍜屽府鍔╂枃妗g殑璺緞
mv 绉诲姩鏂囦欢澶?/p>
alias 鏄剧ず鐢熸晥鐨勫埆鍚?/p>
unalias 鍙栨秷鎵€鏈夊埆鍚?/p>
unalias -a 娓呴櫎鎵€鏈夊埆鍚嶏紙shell鐢熸晥鐨勫叏閮ㄥ埆鍚嶏級
鍒悕浼樺厛鍐呴儴鍛戒护浼樺厛澶栭儴鍛戒护
ls 鏌ョ湅鏂囦欢澶?/p>
ls -a 鏌ョ湅鏂囦欢澶瑰寘鎷殣钘忔枃浠跺す
lsblk 鏄剧ず褰撳墠鐨勭‖鐩樺垎鍖?/p>
uptime 鏄剧ず寮€鍏虫満鏃堕棿
鍛戒护鏍煎紡
鍛戒护 -l 闀挎牸寮忛€夐」鏄剧ず鏂囦欢灞炴€?/p>
鐭€夐」 UNIX椋庢牸 -l -a -h
闀块€夐」 GUN椋庢牸 --all --human
BSD椋庢牸 a 渚嬶細ps a 锛堜娇鐢ㄨ緝灏戯級
id -u 鐢ㄦ埛鍚?nbsp; 鏄剧ず鐢ㄦ埛鍚峣d
id 鐢ㄦ埛鍚?nbsp; 鏄剧ず鎵€鏈塱d
ls -a -l 鏄剧ず鎵€鏈夐殣钘忔枃浠跺拰鏂囦欢灞炴€?/p>
Ctrl+c 寮鸿閫€鍑?nbsp;
Ctrl+d 姝e父閫€鍑?/p>
bc 璁$畻鍣ㄥ懡浠?/p>
浜岃繘鍒惰浆鍖栧崄杩涘埗锛歩base=2
鍗佽繘鍒惰浆鍖栦簩杩涘埗锛歰base=2
鎵归噺鎵ц鍛戒护锛屽鏉″懡浠ょ敤锛涢殧寮€
浜烘満浜や簰鎵ц锛屼竴鏉″懡浠ゆ墽琛?/p>
闀垮懡浠ゅ垎寮€鎵ц锛歕
lscpu 鏌ョ湅cpu
cat /proc/cpuinfo 鏂囦欢鏌ョ湅cpu
free 鏌ョ湅鍐呭瓨
free -h 甯﹀崟浣嶆柟寮忔煡鐪嬪唴瀛?/p>
cat /proc/meminfo 鏂囦欢鏌ョ湅鍐呭瓨
锛坧roc涓哄唴瀛樻枃浠朵笉鍗犵敤纾佺洏绌洪棿锛?/p>
uname 浠庡唴鏍歌幏鍙栫郴缁熶俊鎭?/p>
uname -r 鏌ョ湅鍐呮牳鐗堟湰
uname -a 鏌ョ湅鍏ㄩ儴淇℃伅
uname -n 鏌ョ湅涓绘満鍚?/p>
cat /etc/redhat-release
cat /etc/os-release 鏌ョ湅鐗堟湰淇℃伅
date 鏄剧ず鏃堕棿
date 鏃ユ湡锛堟湀鏃ユ椂鍒嗗勾绉掞級 淇敼鏃ユ湡
date +%F 鏄剧ず浠婂ぉ鐨勫勾鏈堟棩
date -d ‘-2 day’ 鏄剧ず涓ゅぉ鍓嶇殑鏃ユ湡
date -d ‘2 day’ 鏄剧ず涓ゅぉ鍚庣殑鏃ユ湡
date +%s 鏄剧ず1970骞村埌鐜板湪鐨勭鏁?/p>
clock 鏌ョ湅纭欢鏃堕棿
clock -s 浠ョ‖浠舵椂闂翠负鍑嗭紝淇敼绯荤粺鏃堕棿
clock -w 浠ョ郴缁熸椂闂翠负鍑嗭紝淇敼纭欢鏃堕棿
cal 鏄剧ず鏃ュ巻琛?/p>
cal 2020 鏄剧ず鏁村勾鐨勬棩鍘?/p>
cal 10 2020 鏄剧ず2020骞?0鏈堟棩鍘?/p>
鍏虫満鍜岄噸鍚?/p>
reboot 閲嶅惎
shutdown / halt 鍏虫満
shutdown -c 鍙栨秷鍏虫満
shutdown + 10 鍗佸垎閽熷悗鍏虫満
shutdown + TIME 鏃堕棿涔嬪悗鍏虫満
w 鏌ョ湅褰撳墠鎵€鏈夌櫥褰曚細璇濈殑鎿嶄綔
screen 寮傚父鍏抽棴绋嬪簭涓嶄細缁堟缁х画鎵ц锛堝彲瀹炵幇妗岄潰鍚屾锛?/p>
screen -S 鍒涘缓浼氳瘽
screen -ls 鏄剧ず浼氳瘽
screen -x 鍔犲叆浼氳瘽
Ctrl ad 閫€鍑轰細璇?/p>
tmux 鍒嗗睆浣跨敤
Ctrl+b % 宸﹀彸鍒嗗睆
Ctrl+b “ 涓婁笅鍒嗗睆
Ctrl+b 锛?nbsp; 鍏夋爣鍒囨崲鍒颁笂涓€涓獥鏍?/p>
Ctrl+b o 鍏夋爣鍒囨崲鍒颁笅涓€涓獥鏍?/p>
Ctrl+b { 褰撳墠绐楁牸宸︾ЩCtrl+b } 褰撳墠绐楁牸鍙崇ЩCtrl+b Ctrl+o 褰撳墠绐楁牸涓婄ЩCtrl+b alt+o 褰撳墠绐楀彛涓嬬ЩCtrl+b x锛氬叧闂綋鍓嶇獥鏍?/div>Ctrl+b !锛氬皢褰撳墠绐楁牸鎷嗗垎涓轰竴涓嫭绔嬬獥鍙?/div>Ctrl+b z锛氬綋鍓嶇獥鏍煎叏灞忔樉绀猴紝鍐嶄娇鐢ㄤ竴娆′細鍙樺洖鍘熸潵澶у皬Ctrl+b Ctrl+<arrow key>锛氭寜绠ご鏂瑰悜璋冩暣绐楁牸澶у皬Ctrl+b q锛氭樉绀虹獥鏍肩紪鍙?/div>exit 閫€鍑哄垎灞?/div>echo 杈撳嚭淇℃伅
echo -n 涓嶈嚜鍔ㄦ崲琛?/p>
echo -e 鍚敤瀛楃瑙i噴鍔熻兘
echo -e “a” 鍙戝嚭澹伴煶
sleep 浼戠湢
瀛楃闆嗗拰缂栫爜
ASCII 缇庡浗
Unicode 锛圲TF-8 UTF-16 UTF-32锛?/p>
echo $LANG 鏄剧ず鏀寔璇█缂栫爜
echo鍙緭鍏SCII瀛楃
LANG= 鏀瑰彉璇█缂栫爜
Ctrl+l / clear 娓呭睆
df 鏌ョ湅纾佺洏浣跨敤淇℃伅
df -h 甯﹀崟浣嶆煡鐪嬬鐩樹俊鎭?/p>
file 鏌ョ湅鏂囦欢瀛楃闆?/p>
pwd 鏌ョ湅鎵€鍦ㄨ矾寰?/p>
鍛戒护琛屾墿灞?/p>
``=$(command)
褰撳涓懡浠ゆ墽琛屾椂锛?()鏀寔宓屽锛宍 `涓嶆敮鎸佸祵濂椼€?/p>
` ` ,鈥?鈥?, " " 鐨勫尯鍒細
` `閲岀殑鍙橀噺鍜屽懡浠ら兘璇嗗埆锛屽苟浼氬皢寮曞彿閲岀殑鍐呭褰撴垚鍛戒护杩涜鎵ц锛屽湪浜ょ粰璋冪敤鍙嶅悜鍗曞紩鍙风殑鍛戒护杩涜鎵ц銆?/p>
鈥?鈥橀噷鐨勫彉閲忓拰鍛戒护閮戒笉鑳借瘑鍒紝杈撳嚭鐨勯兘涓哄瓧绗︿覆銆?/p>
" "鎵ц鍙橀噺锛屼笉鑳借瘑鍒懡浠ゃ€?/p>
鎷彿鎵╁睍
{ } 鍙互瀹炵幇鎵撳嵃閲嶅瀛楃涓茬殑绠€鍖栧舰寮?/p>
echo file{1,3,5}
rm -f file{1,3,5,}
echo {1..10}
echo {a..z}
echo {000..20..2}
tab閿?/p>
tab閿敤鏉ヨˉ鍏?/p>
鍛戒护琛ュ叏
褰撶粰瀹氱殑瀛楃涓插彧鏈夊敮涓€瀵瑰簲鐨勫懡浠わ紝鎸変竴涓嬬洿鎺ヨˉ鍏紝濡傛灉涓嶆槸闇€瑕佹寜涓や笅缁欏嚭鍒楄〃銆?/p>
璺緞琛ュ叏
鑻ョ粰瀹氱殑瀛楃涓插綋鍋氳矾寰勫紑澶达紝鍦ㄦ寚瀹氫笂绾х洰褰曚笅鎼滅储鎸囧畾瀛楃涓诧紝濡傛灉鍞竴鐩存帴琛ュ叏锛屼笉鍞竴鍐嶆tab缁欏嚭鍒楄〃銆?/p>
history
鐧诲綍shell鏃讹紝浼氳鍙栧巻鍙叉枃浠朵腑鐨勫懡浠わ紝涔嬪悗鏂版墽琛岀殑鍛戒护璁板綍鍦ㄧ紦瀛樹腑锛屽湪鐢ㄦ埛閫€鍑烘椂杩藉姞鍒版枃浠堕噷銆?/p>
history -c 娓呯┖鍘嗗彶鍛戒护
history -d offset 鍒犻櫎鍘嗗彶涓offset涓懡浠?/p>
history n 鏄剧ず鏈€杩戠殑n鏉″巻鍙?/p>
history -a 杩藉姞鏈浼氳瘽鏂版墽琛岀殑鍛戒护鍒板巻鍙叉枃浠?/p>
history -r 璇诲彇鍘嗗彶鏂囦欢鍒板巻鍙插垪琛?/p>
history -w 淇濆瓨鍘嗗彶鍒楄〃鍒版寚瀹氬巻鍙叉枃浠?/p>
history -n 璇诲巻鍙叉枃浠朵腑鏈杩囧巻鍙插垪琛?/p>
history -p 灞曞紑鍘嗗彶鍙傛暟鎴愬琛岋紝涓嶅瓨鍦ㄥ巻鍙插垪琛ㄤ腑
history -s 灞曞紑鍘嗗彶鍙傛暟鎴愪竴琛岋紝闄勫姞鍦ㄥ巻鍙插垪琛ㄥ悗
HISTSIZE 鍛戒护鍘嗗彶璁板綍鐨勬潯鏁?/p>
HISTFILE 鎸囧畾鍘嗗彶鏂囦欢锛岄粯璁/.bash_history
HISTFILESIZE 鍛戒护鍘嗗彶鏂囦欢璁板綍鍘嗗彶鐨勬潯鏁?/p>
HISTTIMEFORMAT=“%F %T`whoami`” 鏄剧ず鏃堕棿鍜岀敤鎴?/p>
淇濆瓨鍙橀噺鍒版枃浠跺す etc/profile 鎴?~/.bash_profile
! 缂栧彿 鎵ц缂栧彿鍛戒护
锛?缂栧彿 鍊掓暟鎵ц缂栧彿鍛戒护
涓婃柟鍚戦敭 閲嶅涓婁竴涓懡浠?/p>
锛乻tring 閲嶅鍓嶄竴涓猻tring寮€澶寸殑鍛戒护
锛?锛焥tring 閲嶅鍓嶄竴涓寘鍚玸tring鐨勫懡浠?/p>
^string 鍒犻櫎涓婁竴鏉″懡浠や腑鐨勭涓€涓猻tring
瑕佽皟鐢ㄥ墠涓€涓懡浠や腑鐨勬渶鍚庝竴涓弬鏁帮細
esc锛? 鐐瑰嚮esc鏉惧紑鍚庣偣鍑?閿?/p>
alt+. 鍚屾椂鎸塧lt鍜?閿?/p>
bash蹇嵎閿?/p>
Ctrl+l 娓呭睆
Ctrl+s 闃绘灞忓箷杈撳嚭锛岄攣灞?/p>
Ctrl+q 鍏佽灞忓箷杈撳嚭
Ctrl+a 鍏夋爣绉诲姩鍒板懡浠よ棣?/p>
Ctrl+e 鍏夋爣绉诲姩鍒板懡浠よ灏?/p>
Ctrl+f 鍏夋爣鍚戝彸绉诲姩涓€涓瓧绗?/p>
Ctrl+b 鍏夋爣鍚戝乏绉诲姩涓€涓瓧绗?/p>
alt+f 鍏夋爣鍚戝彸绉诲姩涓€涓崟璇嶅熬
alt+b 鍏夋爣鍚戝乏绉诲姩涓€涓崟璇嶅熬
Ctrl+xx 鍏夋爣鍦ㄥ懡浠よ棣栧拰鍏夋爣涔嬮棿绉诲姩
Ctrl+u 鍏夋爣澶勫垹闄よ嚦鍛戒护琛岄
Ctrl+k 鍏夋爣澶勫垹闄よ嚦鍛戒护琛屽熬
alt+r 鍒犻櫎褰撳墠鏁磋
Ctrl+w 浠庡厜鏍囧鍚戝乏鍒犻櫎鑷冲崟璇嶉
alt+d 浠庡厜鏍囧鍚戝彸鍒犻櫎鑷冲崟璇嶅熬
Ctrl+d 鍒犻櫎鍏夋爣澶勭殑涓€涓瓧绗?/p>
Ctrl+h 鍒犻櫎鍏夋爣鍓嶇殑涓€涓瓧绗?/p>
蹇敭閿產lt缁忓父涓庡叾浠栬蒋浠跺啿绐?/p>
鑾峰緱甯姪
whatis=man -f 鍛戒护鐨勭畝鍗曟弿杩帮紝鍒氬畨瑁呬笉鍙珛鍗充娇鐢紝闇€瀹夎鏁版嵁搴?/p>
鍐呴儴鍛戒护锛?/p>
help command
man bash
澶栭儴鍛戒护锛?/p>
--help
-h
help鏍煎紡锛?/p>
[ ]琛ㄧず鍙€夐」
CAPS鎴?lt;>琛ㄧず鍙樺寲鐨勬暟鎹?/p>
...琛ㄧず涓€涓垪琛?/p>
x|y|z 琛ㄧず x鎴杫鎴杬
-abc 琛ㄧず-a -b -c
{ } 琛ㄧず鍒嗙粍
man command
man鍛戒护锛?nbsp; /user/share/man 鏂囦欢甯姪
man椤甸潰鏈変笉鍚岀珷鑺?/p>
1 鐢ㄦ埛鍛戒护
2 绯荤粺璋冪敤
3 c搴撹皟鐢?/p>
4 璁惧鏂囦欢鍙婄壒娈婃枃浠?/p>
5 閰嶇疆鏂囦欢鏍煎紡
6 娓告垙
7 鏉傞」
8 绠$悊绫诲懡浠?/p>
9 Linux鍐呮牳
man -a 鏌ョ湅鎵€鏈夊府鍔?/p>
man鍛戒护鎿嶄綔锛?/p>
space锛宆v,^f,^F锛氬悜鏂囦欢灏剧炕灞?/p>
b,^b 锛氬悜鏂囦欢棣栭儴缈诲睆
d,^d 锛氬悜鏂囦欢灏鹃儴缈诲崐灞?/p>
u,^u 锛氬悜鏂囦欢棣栭儴缈诲崐灞?/p>
RETURN,^N,e,^E or j or ^J锛氬悜鏂囦欢灏鹃儴缈讳竴琛?/p>
y or ^Y or ^P or k or ^K 锛氬悜鏂囦欢棣栭儴缈讳竴琛?/p>
q锛氶€€鍑?/p>
#锛氳烦杞嚦绗?琛?/p>
1G锛氬洖鍒版枃浠堕閮?/p>
G 锛氬洖鍒版枃浠跺熬閮?/p>
/KEYWORD:
浠EYWORD鎸囧畾瀛楃涓蹭负鍏抽敭瀛楋紝浠庡綋鍓嶄綅缃悜鏂囦欢灏鹃儴鎼滅储
n锛氫笅涓€涓?/p>
N锛氫笂涓€涓?/p>
锛烱EYWORD:
浠EYWORD鎸囧畾瀛楃涓蹭负鍏抽敭瀛楋紝浠庡綋鍓嶄綅缃悜鏂囦欢棣栭儴鎼滅储
n锛氫笅涓€涓?/p>
N锛氫笂涓€涓?/p>
info锛?/p>
info閫傚悎閫氱敤鏂囨。鍙傝€冿紝娌℃湁鍙傛暟锛屽垪鍑烘墍鏈夌殑椤甸潰
缁撴瀯涓庣綉绔欑晫闈㈢被浼?/p>
姣忎竴椤靛垎涓鸿妭鐐?/p>
杩炴帴鑺傜偣涔嬪墠*
鎿嶄綔锛?/p>
鏂瑰悜閿鑸?/p>
tab锛?绉诲姩鍒颁笅涓€涓摼鎺?/p>
d 锛氭樉绀轰富棰樼洰褰?/p>
HOME锛氭樉绀轰富棰橀閮?/p>
Enter 锛氳繘鍏ラ€夊畾閾炬帴
n/p/u/l 锛氳繘鍏ヤ笅锛屽墠锛屼笂锛屾渶鍚庝竴灞傞摼鎺?/p>
s 鏂囧瓧 锛氭枃鏈悳绱?/p>
q 锛氶€€鍑篿nfo
鍦ㄧ嚎鏂囨。鑾峰緱甯姪锛?/p>
http://www.github.comhttps://www.kernel.org/doc/html/latest/http://httpd.apache.orghttp://www.nginx.orghttps://mariadb.com/kb/enhttps://dev.mysql.com/doc/http://tomcat.apache.orghttps://jenkins.io/zh/doc/https://kubernetes.io/docs/home/https://docs.openstack.org/train/http://www.python.orghttp://php.net绾㈠附鐭ヨ瘑搴撳畼鏂瑰湪绾挎枃妗o細http://kbase.redhat.comhttp://www.redhat.com/docshttp://access.redhat.comhttps://help.ubuntu.com/lts/serverguide/index.html缃戠珯鎼滅储锛?/div>http://tldp.orghttp://www.slideshare.nethttp://www.google.com
以上是关于Linux鍩虹的主要内容,如果未能解决你的问题,请参考以下文章
linux鍩虹11-bash缂栫▼(瀛楃涓叉祴璇?鍜?for寰幆)
Linux绯荤粺鍩虹鐭ヨ瘑鐩綍銆佸厓鏁版嵁銆佽蒋纭摼鎺ャ€佹枃浠剁鐞嗗懡浠ゃ€乿im鏌ユ壘鏇挎崲銆乿imtab缂╄繘