尊龙凯时人生就是博

Linux³£ÓÃÏÂÁî & ÊÊÓÃÏÂÁîÍò×Ö×ܽá

Linux×ÅʵÊÇÇ°ºó¶Ë¶¼±Ø»áµÄÊÖÒÕ £¬Ç°¶ËÏÖÔÚÐí¶àͯЬ¶¼ÔÙ×ß´óÇ°¶Ëõ辶 £¬ºó¶Ë¾Í¸ü²»±Ø˵ÁË £¬Ð¡±à¸ø¸÷ÈËÅÌÁËÉÏÍò×Ö£¨ÓÉÓÚ×ÖÊýÏÞÖƱ¾ÎÄÒÑɾ¼õ)¹ØÓÚLinuxµÄÊÃ÷ÈÕ½»ù´¡ÏÂÁî £¬¿ÉÒÔËÃ÷ÈÕâЩ¶¼ÊDZØÐèÕÆÎÕµÄ £¬ËäÈ»ÕâЩҲÊDz»·óµÄ £¬ºóÃæС±à»¹»á¼ÌÐø¸üР£¬¸÷ÈË¿ÉÒÔ¹Ø×¢ÎҵĶ¯Ì¬ £¬ÅÌÆðÀ´ £¬ÕⲨ¿ÉÒÔÕä²ØÆðÀ´ÁË¡£

ls

×î¸ßʹÓÃƵÂʵÄÏÂÁîÖ®Ò»¡£

ÏÂÁîÃûÌÃ:  ls [OPTION]… [FILE]… ´¿´âµÄÊäÈë:

[root@iz2ze76ybn73dvwmdij06zz /]# lsbin   dev  home  lib64       media  opt    proc  run   srv  tmp  varboot  etc  lib   lost+found  mnt    patch  root  sbin  sys  usr  www

µÇ¼ºó¸´ÖÆ

¼Ó option -l ËüչʾÁËȨÏÞ £¬ÊôÖ÷ £¬Êô×é £¬¾Þϸ £¬Ê±¼ä £¬ÎļþÃû³Æ
[root@iz2ze76ybn73dvwmdij06zz /]# ls -l×ÜÓÃÁ¿ 68lrwxrwxrwx    1 root root     7 8Ô  26 22:36 bin -> usr/bindr-xr-xr-x.   5 root root  4096 8Ô  26 22:39 bootdrwxr-xr-x   19 root root  2960 4Ô  11 12:59 devdrwxr-xr-x.  81 root root  4096 9Ô   5 17:09 etcdrwxr-xr-x.   2 root root  4096 4Ô  11 12:59 homelrwxrwxrwx    1 root root     7 8Ô  26 22:36 lib -> usr/liblrwxrwxrwx    1 root root     9 8Ô  26 22:36 lib64 -> usr/lib64drwx------.   2 root root 16384 10Ô 15 2017 lost+founddrwxr-xr-x.   2 root root  4096 4Ô  11 12:59 mediadrwxr-xr-x.   2 root root  4096 4Ô  11 12:59 mntdrwxr-xr-x.   3 root root  4096 8Ô  26 22:40 optdrwxr-xr-x    2 root root  4096 8Ô  26 23:00 patchdr-xr-xr-x  110 root root     0 4Ô  11 12:59 procdr-xr-x---.  12 root root  4096 9Ô  11 20:59 rootdrwxr-xr-x   26 root root   760 9Ô   7 21:50 runlrwxrwxrwx    1 root root     8 8Ô  26 22:36 sbin -> usr/sbindrwxr-xr-x.   2 root root  4096 4Ô  11 12:59 srvdr-xr-xr-x   13 root root     0 4Ô  11 12:59 sysdrwxrwxrwt.   9 root root  4096 9Ô  15 03:19 tmpdrwxr-xr-x.  13 root root  4096 8Ô  26 22:36 usrdrwxr-xr-x.  19 root root  4096 8Ô  26 22:55 vardrwxr-xr-x    6 root root  4096 8Ô  26 22:39 www

µÇ¼ºó¸´ÖÆ

ls -a (all) linux ‘.’£¨µã£©¿ªÍ·µÄÎļþĬÈÏÊÇÒþ²ØµÄ £¬-a¿ÉÒÔÅÌÎÊËùÓеÄÎļþ¡£
[root@iz2ze76ybn73dvwmdij06zz /]# ls -a.             bin   etc   lib64       mnt    .pearrc  run   sys    usr..            boot  home  lost+found  opt    proc     sbin  .test  var.autorelabel  dev   lib   media       patch  root     srv   tmp    www

µÇ¼ºó¸´ÖÆ

ls -F ÒÔ”/”×îºóµÄ·½·¨Õ¹Ê¾Îļþ¼Ð¡£
[root@iz2ze76ybn73dvwmdij06zz /]# ls -Fbin@   dev/  home/  lib64@       media/  opt/    proc/  run/   srv/  tmp/  var/boot/  etc/  lib@   lost+found/  mnt/    patch/  root/  sbin@  sys/  usr/  www/

µÇ¼ºó¸´ÖÆ

ls -r µ¹Ððչʾ £¬Ä¬ÈϵÄ˳ÐòÊÇ(a,b,c,d)ÕýÐòÕâÑùչʾ
[root@iz2ze76ybn73dvwmdij06zz /]# ls -rwww  usr  sys  sbin  root  patch  mnt    lost+found  lib   etc  bootvar  tmp  srv  run   proc  opt    media  lib64       home  dev  bin

µÇ¼ºó¸´ÖÆ

ls -R ()µÝ¹éչʾ×ÓĿ¼
[root@iz2ze76ybn73dvwmdij06zz test]# ls -R.:data./data:img./data/img:car  product  user./data/img/car:./data/img/product:./data/img/user:

µÇ¼ºó¸´ÖÆ

ls -lS ƾ֤Îļþ¾Þϸ½µÐòÏÔʾ
[root@iz2ze76ybn73dvwmdij06zz /]# ls -lS×ÜÓÃÁ¿ 72drwx------.   2 root root 16384 10Ô 15 2017 lost+founddr-xr-xr-x.   5 root root  4096 8Ô  26 22:39 bootdrwxr-xr-x.  81 root root  4096 9Ô   5 17:09 etcdrwxr-xr-x.   2 root root  4096 4Ô  11 12:59 homedrwxr-xr-x.   2 root root  4096 4Ô  11 12:59 mediadrwxr-xr-x.   2 root root  4096 4Ô  11 12:59 mntdrwxr-xr-x.   3 root root  4096 8Ô  26 22:40 optdrwxr-xr-x    2 root root  4096 8Ô  26 23:00 patchdr-xr-x---.  12 root root  4096 9Ô  15 22:03 rootdrwxr-xr-x.   2 root root  4096 4Ô  11 12:59 srvdrwxr-xr-x    3 root root  4096 9Ô  15 22:10 testdrwxrwxrwt.   9 root root  4096 9Ô  15 03:19 tmpdrwxr-xr-x.  13 root root  4096 8Ô  26 22:36 usrdrwxr-xr-x.  19 root root  4096 8Ô  26 22:55 vardrwxr-xr-x    6 root root  4096 8Ô  26 22:39 wwwdrwxr-xr-x   19 root root  2960 4Ô  11 12:59 devdrwxr-xr-x   26 root root   760 9Ô   7 21:50 runlrwxrwxrwx    1 root root     9 8Ô  26 22:36 lib64 -> usr/lib64lrwxrwxrwx    1 root root     8 8Ô  26 22:36 sbin -> usr/sbinlrwxrwxrwx    1 root root     7 8Ô  26 22:36 bin -> usr/binlrwxrwxrwx    1 root root     7 8Ô  26 22:36 lib -> usr/libdr-xr-xr-x  110 root root     0 4Ô  11 12:59 procdr-xr-xr-x   13 root root     0 4Ô  11 12:59 sys

µÇ¼ºó¸´ÖÆ

ls -g ²»Êä³öËùÓÐÕß(ÊôÖ÷)ÐÅÏ¢
[root@iz2ze76ybn73dvwmdij06zz /]# ls -g×ÜÓÃÁ¿ 72lrwxrwxrwx    1 root     7 8Ô  26 22:36 bin -> usr/bindr-xr-xr-x.   5 root  4096 8Ô  26 22:39 boot-rw-r--r--    1 root     0 9Ô  15 22:20 cdrwxr-xr-x   19 root  2960 4Ô  11 12:59 devdrwxr-xr-x.  81 root  4096 9Ô   5 17:09 etcdrwxr-xr-x.   2 root  4096 4Ô  11 12:59 homelrwxrwxrwx    1 root     7 8Ô  26 22:36 lib -> usr/liblrwxrwxrwx    1 root     9 8Ô  26 22:36 lib64 -> usr/lib64drwx------.   2 root 16384 10Ô 15 2017 lost+founddrwxr-xr-x.   2 root  4096 4Ô  11 12:59 mediadrwxr-xr-x.   2 root  4096 4Ô  11 12:59 mntdrwxr-xr-x.   3 root  4096 8Ô  26 22:40 optdrwxr-xr-x    2 root  4096 8Ô  26 23:00 patchdr-xr-xr-x  110 root     0 4Ô  11 12:59 procdr-xr-x---.  12 root  4096 9Ô  15 22:18 rootdrwxr-xr-x   26 root   760 9Ô   7 21:50 runlrwxrwxrwx    1 root     8 8Ô  26 22:36 sbin -> usr/sbindrwxr-xr-x.   2 root  4096 4Ô  11 12:59 srvdr-xr-xr-x   13 root     0 4Ô  11 12:59 sysdrwxr-xr-x    3 root  4096 9Ô  15 22:18 testdrwxrwxrwt.   9 root  4096 9Ô  15 03:19 tmpdrwxr-xr-x.  13 root  4096 8Ô  26 22:36 usrdrwxr-xr-x.  19 root  4096 8Ô  26 22:55 vardrwxr-xr-x    6 root  4096 8Ô  26 22:39 www

µÇ¼ºó¸´ÖÆ

ls -lG Òþ²ØËùÓÐ×飨Êô×飩ÐÅÏ¢
[root@iz2ze76ybn73dvwmdij06zz /]# ls -lG×ÜÓÃÁ¿ 72lrwxrwxrwx    1 root     7 8Ô  26 22:36 bin -> usr/bindr-xr-xr-x.   5 root  4096 8Ô  26 22:39 boot-rw-r--r--    1 root     0 9Ô  15 22:20 cdrwxr-xr-x   19 root  2960 4Ô  11 12:59 devdrwxr-xr-x.  81 root  4096 9Ô   5 17:09 etcdrwxr-xr-x.   2 root  4096 4Ô  11 12:59 homelrwxrwxrwx    1 root     7 8Ô  26 22:36 lib -> usr/liblrwxrwxrwx    1 root     9 8Ô  26 22:36 lib64 -> usr/lib64drwx------.   2 root 16384 10Ô 15 2017 lost+founddrwxr-xr-x.   2 root  4096 4Ô  11 12:59 mediadrwxr-xr-x.   2 root  4096 4Ô  11 12:59 mntdrwxr-xr-x.   3 root  4096 8Ô  26 22:40 optdrwxr-xr-x    2 root  4096 8Ô  26 23:00 patchdr-xr-xr-x  110 root     0 4Ô  11 12:59 procdr-xr-x---.  12 root  4096 9Ô  15 22:18 rootdrwxr-xr-x   26 root   760 9Ô   7 21:50 runlrwxrwxrwx    1 root     8 8Ô  26 22:36 sbin -> usr/sbindrwxr-xr-x.   2 root  4096 4Ô  11 12:59 srvdr-xr-xr-x   13 root     0 4Ô  11 12:59 sysdrwxr-xr-x    3 root  4096 9Ô  15 22:18 testdrwxrwxrwt.   9 root  4096 9Ô  15 03:19 tmpdrwxr-xr-x.  13 root  4096 8Ô  26 22:36 usrdrwxr-xr-x.  19 root  4096 8Ô  26 22:55 vardrwxr-xr-x    6 root  4096 8Ô  26 22:39 www10.ls -li ÏÔʾÎļþµÄË÷ÒýºÅ[root@iz2ze76ybn73dvwmdij06zz /]# ls -li

µÇ¼ºó¸´ÖÆ

ls -li ÏÔʾÎļþµÄË÷ÒýºÅ
[root@iz2ze76ybn73dvwmdij06zz /]# ls -li×ÜÓÃÁ¿ 72  7628 lrwxrwxrwx    1 root root     7 8Ô  26 22:36 bin -> usr/bin1179650 dr-xr-xr-x.   5 root root  4096 8Ô  26 22:39 boot  4923 -rw-r--r--    1 root root     0 9Ô  15 22:20 c  1026 drwxr-xr-x   19 root root  2960 4Ô  11 12:59 dev917505 drwxr-xr-x.  81 root root  4096 9Ô   5 17:09 etc655362 drwxr-xr-x.   2 root root  4096 4Ô  11 12:59 home    17 lrwxrwxrwx    1 root root     7 8Ô  26 22:36 lib -> usr/lib    13 lrwxrwxrwx    1 root root     9 8Ô  26 22:36 lib64 -> usr/lib64    11 drwx------.   2 root root 16384 10Ô 15 2017 lost+found786434 drwxr-xr-x.   2 root root  4096 4Ô  11 12:59 media131074 drwxr-xr-x.   2 root root  4096 4Ô  11 12:59 mnt393219 drwxr-xr-x.   3 root root  4096 8Ô  26 22:40 opt1966081 drwxr-xr-x    2 root root  4096 8Ô  26 23:00 patch     1 dr-xr-xr-x  110 root root     0 4Ô  11 12:59 proc131073 dr-xr-x---.  12 root root  4096 9Ô  15 22:18 root   218 drwxr-xr-x   26 root root   760 9Ô   7 21:50 run    15 lrwxrwxrwx    1 root root     8 8Ô  26 22:36 sbin -> usr/sbin393220 drwxr-xr-x.   2 root root  4096 4Ô  11 12:59 srv     1 dr-xr-xr-x   13 root root     0 4Ô  11 12:59 sys2097153 drwxr-xr-x    3 root root  4096 9Ô  15 22:18 test393217 drwxrwxrwt.   9 root root  4096 9Ô  15 03:19 tmp1048578 drwxr-xr-x.  13 root root  4096 8Ô  26 22:36 usr262145 drwxr-xr-x.  19 root root  4096 8Ô  26 22:55 var1441793 drwxr-xr-x    6 root root  4096 8Ô  26 22:39 www

µÇ¼ºó¸´ÖÆ

ls -lt ƾ֤ÐÞ¸Äʱ¼äÅÅÐò£¨µ¹Ðò£©ÒÀ´Î½¨ÉèÎļþ a b
[root@iz2ze76ybn73dvwmdij06zz test]# ls -lt×ÜÓÃÁ¿ 0-rw-r--r-- 1 root root 0 9Ô  15 22:18 b-rw-r--r-- 1 root root 0 9Ô  15 22:18 a

µÇ¼ºó¸´ÖÆ

ls -version
[root@iz2ze76ybn73dvwmdij06zz test]# ls --versionls (GNU coreutils) 8.22Copyright (C) 2013 Free Software Foundation, Inc.ÔÊÐíÖ¤£ºGPLv3+£ºGNU ͨÓù«¹²ÔÊÐíÖ¤µÚ3 °æ»ò¸üа汾<http://gnu.org/licenses/gpl.html>¡£±¾Èí¼þÊÇ×ÔÓÉÈí¼þ£ºÄú¿ÉÒÔ×ÔÓÉÐ޸ĺÍÖØÐÂÐû²¼Ëü¡£ÔÚÖ´ÂÉÀýÄ£ÄÚûÓÐÆäËû°ü¹Ü¡£ÓÉRichard M. Stallman ºÍDavid MacKenzie ±àд¡£

µÇ¼ºó¸´ÖÆ

cat

cat,ÓÖÊÇÒ»¸öÏà¶Ô¸ßƵÂʵÄÏÂÁî¡£½ÏÁ¿¹Ù·½µÄ˵·¨ÊÇÏÂÁîÓÃÓÚÁ´½ÓÎļþ²¢´òÓ¡µ½±ê×¼Êä³ö×°±¸ÉÏ¡£Õâ¸öÎı¾Êä³öÏÂÁî¿ÉÒÔÓÃÀ´Éó²éÎļþÄÚÈÝ £¬½¨ÉèÄÚÈݵÈ £¬ÏÂÃæÎÒÃÇÏÈÈݼ¸¸ö½ÏÁ¿ÊÊÓõÄÓ÷¨¡£ÏÂÁîÃûÌà : cat [Ñ¡Ïî]… [Îļþ]…

cat -n Éó²é²¢ÏÔʾÐкÅ
[root@iz2ze76ybn73dvwmdij06zz linuxdemo]# cat -n a    1  this is a txt    2  hello every body    3  hello world    4  hahaha

µÇ¼ºó¸´ÖÆ

cat ½¨ÉèÒ»¸ö¿ÕÎļþ b
[root@iz2ze76ybn73dvwmdij06zz linuxdemo]# cat >b <<EOF> EOF[root@iz2ze76ybn73dvwmdij06zz linuxdemo]# lsa  b

µÇ¼ºó¸´ÖÆ

cat Çå¿ÕÎļþÄÚÈÝ
[root@iz2ze76ybn73dvwmdij06zz linuxdemo]# cat >a<<EOF> EOF[root@iz2ze76ybn73dvwmdij06zz linuxdemo]# cat a

µÇ¼ºó¸´ÖÆ

cat дÈëÄÚÈÝ(ÈôÊÇÔ­À´ÓÐÄÚÈݽ«±»ÁýÕÖ)
[root@iz2ze76ybn73dvwmdij06zz linuxdemo]# cat >a<<EOF> today is a good day> because off work> hahaha> EOF[root@iz2ze76ybn73dvwmdij06zz linuxdemo]# cat atoday is a good daybecause off workhahaha

µÇ¼ºó¸´ÖÆ

cat ͬʱÏÔʾ¶à¸öÎļþÄÚÈÝ( bÖÐд³öhappy)
[root@iz2ze76ybn73dvwmdij06zz linuxdemo]# cat a > b[root@iz2ze76ybn73dvwmdij06zz linuxdemo]# cat btoday is a good daybecause off workhahaha

µÇ¼ºó¸´ÖÆ

×·¼ÓÄÚÈÝ ¿ÉÒÔ¿´µ½ÓÃÁËÁ¬¸ö>ÒÔºóÄÚÈÝÊÇ×·¼ÓµÄ
[root@iz2ze76ybn73dvwmdij06zz linuxdemo]# cat a >> b[root@iz2ze76ybn73dvwmdij06zz linuxdemo]# cat btoday is a good daybecause off workhahahatoday is a good daybecause off workhahaha

µÇ¼ºó¸´ÖÆ

cat –help (ÈçÏëѧϰ¸ü¶à £¬¿ÉÒÔ×Ô¼ºÏÂÊÖʵÑé)
[root@iz2ze76ybn73dvwmdij06zz linuxdemo]# cat --helpÓ÷¨£ºcat [Ñ¡Ïî]... [Îļþ]...½«[Îļþ]»ò±ê×¼ÊäÈë×éºÏÊä³öµ½±ê×¼Êä³ö¡£ -A, --show-all           ¼´ÊÇ-vET -b, --number-nonblank    ¶Ô·Ç¿ÕÊä³öÐбàºÅ -e                       ¼´ÊÇ-vE -E, --show-ends          ÔÚÿÐп¢Ê´¦ÏÔʾ"$" -n, --number             ¶ÔÊä³öµÄËùÓÐÐбàºÅ -s, --squeeze-blank      ²»Êä³ö¶àÐпÕÐÐ -t                       Óë-vT µÈ¼Û -T, --show-tabs          ½«Ìø¸ñ×Ö·ûÏÔʾΪ^I -u                       (±»ºöÂÔ) -v, --show-nonprinting   ʹÓÃ^ ºÍM- ÒýÓÃ£¬³ýÁËLFDºÍ TAB Ö®Íâ     --help    ÏÔʾ´Ë×ÊÖúÐÅÏ¢²¢Í˳ö     --version    ÏÔʾ°æ±¾ÐÅÏ¢²¢Í˳öÈôÊÇûÓÐÖ¸¶¨Îļþ£¬»òÕßÎļþΪ"-"£¬Ôò´Ó±ê×¼ÊäÈë¶ÁÈ¡¡£Ê¾Àý£º cat f - g  ÏÈÊä³öf µÄÄÚÈÝ£¬È»ºóÊä³ö±ê×¼ÊäÈëµÄÄÚÈÝ£¬×îºóÊä³ög µÄÄÚÈÝ¡£ cat        ½«±ê×¼ÊäÈëµÄÄÚÈݸ´ÖƵ½±ê×¼Êä³ö¡£GNU coreutils online help: <http://www.gnu.org/software/coreutils/>ÇëÏò<http://translationproject.org/team/zh_CN.html> ±¨¸æcat µÄ·­Òë¹ýʧҪ»ñÈ¡ÍêÕûÎĵµ£¬ÇëÔËÐУºinfo coreutils 'cat invocation'

µÇ¼ºó¸´ÖÆ

Óû§È¨ÏÞ

¸÷È˶¼ÖªµÀlinuxÊÇÒ»¸ö¶àʹÃü £¬¶àÓû§µÄ²Ù×÷ϵͳ¡£¶à¸öÓû§¿ÉÒÔÔÚͳһʱ¼ä²Ù×÷ϵͳִÐвî±ðµÄʹÃü £¬Ò»¸öÓû§Ò²¿ÉÒÔ¶àСÎÒ˽ÈËÉÏ°¶²Ù×÷¡£Ò»Ñùƽ³£À´ËµrootµÄȨÏÞ×î´ó,ÎÒÃǾ­³£Ê¹ÓõÄÊý¾Ý¿âÒ»Ñùƽ³£»áÓÃÒ»¸ömysqlµÄÓû§,ÍøÒ³Ïà¹ØµÄÎÒÃÇ¿ÉÄÜÓÃÒ»¸öwwwµÄÕ˺Å,¸÷È˶¼ÊÇÖªµÀɾ³ýÅÜ·µÄ¹ÊÊ £¬Òò´ËÓÐһЩ²Ù×÷ȨÏÞÊÇÒª½»¸øһЩרÈËÖÎÀíµÄ¡£ÎªÁËϵͳµÄѧϰ £¬ÎÒÒÔΪÓÐÐëÒªÏàʶһÏÂËüµÄ»ù±¾ÖªÊ¶¡£

linux½ÇÉ«·ÖÀà

³¬µÈÓû§:root (user id –UID) 0 ×î¸ßµÄÖÎÀíȨÏÞ¡£

ͨË×Óû§£º

    ϵͳÓû§ UID:1-999(rhel7  centos7) 1-499(rhel6)        ÍâµØÓû§ UID:1000+(rhel7 centos7)  500+(rhel6)

µÇ¼ºó¸´ÖÆ

UID:Óû§Éí·Ý±êʾ,Ψһ±êʾ¡£

linux×é·ÖÀà

×飺

×é·ÖÀà:

ƾ֤Õ˺ŵĹ¦Ð§·ÖÀà:           ³¬µÈÓû§×飺root GID:0           ͨË×Óû§×é £º                               ϵͳÓû§×é: GID 1---999                                ÍâµØÓû§×é: GID 1000+

µÇ¼ºó¸´ÖÆ

linuxÓû§ºÍ×éµÄ¹Øϵ

Ò»¸öÓû§ÊôÓÚÒ»¸ö×é £¬Ò²¿ÉÒÔÊôÓÚ¶à¸ö×é £¬¶à¸öÓû§¿ÉÒÔÔÚÒ»¸ö×é £¬¿ÉÒÔÔÚ¶à¸ö×é¡£

linuxÓû§ºÍ×éµÄÏà¹ØÉèÖÃÎļþ

1./etc/passwd:Óû§ and ÊôÐÔÐÅÏ¢¡£

2./etc/group: ×é and ÊôÐÔÐÅÏ¢¡£

3./etc/shadow: Óû§ÃÜÂë and ÊôÐÔÐÅÏ¢¡£

4./etc/gshadow:×éÃÜÂë and ÊôÐÔÐÅÏ¢¡£

5./etc/default/useradd: ÉèÖÃÌí¼ÓÓû§¹æÔòÎļþ¡£

6./etc/login.defs:ÉèÖÃÓû§Õ˺ÅÏÞÖÆ¡£

linuxÓû§ÐÅÏ¢Îļþ

Óû§ÖÎÀíÖÐ×îÖ÷ÒªµÄÒ»¸öÎļþ £¬Õâ¸öÎļþÊǶÔËùÓÐÓû§¿ª·ÅµÄ £¬Ã¿Ò»ÐдæÒ»¸öÓû§µÄÐÅÏ¢ £¬Ã¿¸öÊôÐÔÖ®¼äÓÃðºÅÖ§½â¡£

cat /etc/passwdroot:x:0:0:root:/root:/bin/zshbin:x:1:1:bin:/bin:/sbin/nologindaemon:x:2:2:daemon:/sbin:/sbin/nologinadm:x:3:4:adm:/var/adm:/sbin/nologinlp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

µÇ¼ºó¸´ÖÆ

¾ÙÀý: root:x:0:0:root:/root:/bin/zsh

1.ÉÏ°¶Óû§Ãû:root

2.Óû§ÃÜÂëռλ·û:x

3.Óû§UID:0

4.Óû§×éGID:0

5.¶ÔÓû§ÕË»§µÄÐÎò:root

6.Óû§¼ÒĿ¼λÖÃ:/root

7.Óû§Ä¬ÈϵÄshell:/bin/zsh (ĬÈÏÊÇ/bin/bash)

linuxÃÜÂëÐÅÏ¢Îļþ

¸ÃÎļþÖ»ÓÐrootÓû§ÓжÁȨÏÞ £¬Ã¿Ò»ÐдæÒ»¸öÓû§µÄ¼Í¼ £¬Ã¿¸öÊôÐÔÓÃðºÅÖ§½â¡£

cat /etc/shadowroot:$6$LxE7qiaZ$ZZXf/aCO1Zqs1oOS9WDutUk9rFOq4MOoSG9IeXq2f5sduGrgfYvzOWHZmJZFGC.0Of1DjCna0M.oQZTY8r00/.:17769:0:99999:7:::bin:*:17110:0:99999:7:::daemon:*:17110:0:99999:7:::

µÇ¼ºó¸´ÖÆ

¾ÙÀý: bin:*:17110:0:99999:7::: 1.µÇÈÎÃü»§Ãû: bin

2.¼ÓÃܵÄÃÜÂë: * ºÅ´ú±íÃÜÂë±»Ëø¶¨

3.×î½ü¸ü¸ÄÃÜÂëµÄÈÕÆÚ: 17110´ú±íµ½1970-1-1ÃÜÂë²»¿É¸ÄµÄÌìÊý

4.ÃÜÂëÐÞÍÑÏÞÆÚ£º99999 ´ú±íÓÀÔ¶²»±Ø¸Ä,ÈôÊÇÊÇÆäËûÊý×ÖÔòÌåÏÖ´Ó1970-1-1Äڵļ¸¶àÌì±ØÐèÐÞ¸ÄÃÜÂë¡£

5.¸ü¸ÄÃÜÂë×î´óÓÐÓÃÌìÊý: ´ú±íÃÜÂë¼á³ÖÓÐÓõÄ×î´óÌìÊý¡£

6.ÃÜÂëÓâÆÚÖÒÑÔ:ÃÜÂëµ½ÕýʽʧЧǰÓм¸¶àÌì(-1,ÓÀÔ¶²»ÌáÐÑ)

7.ÃÜÂëÓâÆں󼸶àÌì½ûÓÃÓû§:¿ÉÉÏ°¶ £¬µ¥²»¿É²Ù×÷¡£

8.Óû§±»½ûÓÃÈÕÆÚ:¼¸¶àÌìºóÕ˺ÅÓâÆÚ £¬²»¿ÉÉÏ°¶¡£

9.±£´æ²ÎÊý

linux×éÐÅÏ¢Îļþ

Óû§×éµÄ×éÐÅÏ¢´æ·ÅÔÚÕâ £¬Ò»ÐдæÒ»¸ö×é¼Í¼ £¬ÊôÐÔÓÃðºÅÖ§½â¡£

  ~ cat /etc/grouproot:x:0:bin:x:1:daemon:x:2:sys:x:3:adm:x:4:tty:x:5:disk:x:6:lp:x:7:mem:x:8:kmem:x:9:

µÇ¼ºó¸´ÖÆ

¾ÙÀý: root:x:0:

1.×éÃû£ºroot

2.×éÃÜÂëռλ·û: x

3.×éGID: 0

×°Öðü¹ÜÀí»ù´¡

ÐÅÍд󲿷ÖÈËÓ¦¸ÃºÍÎÒÒ»Ñù £¬×î×îÏȶ¼ÊÇÓà windowsÉÏÊÖµÄ £¬ÄÇÔÚwindowsƽ̨µÄ×°Öðü¾ÍÔÙÊìϤ²»¹ýÁË £¬ºÃ±È.exe,ÊDz»ÊÇÌ«³£¼ûÁË £¬Ò»Ñùƽ³£ÔÚwindows×°ÖùýmysqlµÄ £¬ÐÅÍÐ.msiÒ²ÊǼû¹ýµÄ¡£´ó´ó¶¼µÄЧÀÍÆ÷¶¼ÊÇlinuxµÄ,Òò´ËÎÒÃÇÀ´Ñ§Ï°Ò»ÏÂlinuxµÄ×°Öðü»ù´¡ÖªÊ¶¡£²î±ð¿¯ÐаæµÄϵͳÓõŤ¾ßÒ²ÊDz»ÏàͬµÄ¡£ÏÖÔÚ´ó´ó¶¼µÄ¹«Ë¾Ð§ÀÍÆ÷ÊÇ»ùÓÚcentos,ÒòÒÔºóÐø»áÒÔcentosΪÀý½ÏÁ¿¶à¡£

»ùÓÚredhat

yum

zypper

rpm

»ùÓÚcentos

yum

rpm

rpm

È«³Æ: Redhat Package Manager

ÏÂÔØÍøÖ·: http://rpmfind.net

ÏÈÀ´¿´Ï°üµÄÃüÃûÃûÌÃ,ÒÔ rpm-5.4.10-10.i586.rpm ΪÀý¡£

rpm : Èí¼þ°üÃû

5 : Ö÷°æ±¾ºÅ

4 : ´Î°æ±¾ºÅ

10 : ÐÞ¶©ºÅ

i586 : cpu¼Ü¹¹Æ½Ì¨

rpm : °üºó׺

yum

½â¾öÈí¼þ°ü×°ÖõÄÒÀÀµ¹ØϵÎÊÌâ £¬×Ô¶¯ÏÂÔØÈí¼þ°ü £¬»ùÓÚc/s¼Ü¹¹¡£repoÎļþÊÇyumÔ´µÄÉèÖÃÎļþ £¬¸ÄÎļþ½ç˵Èí¼þ¿ÍÕ»µÄÐÅÏ¢¡£ÎªÊ²Ã´ËµËüÊÇc/s¼Ü¹¹ £¬Ô­À´rpmÈí¼þµÄÍ·(header)Àï»á¼Í¼¸ÄÈí¼þµÄÒÀÀµÐÅÏ¢ £¬Òò´Ë¿ÉÒÔ¶ÔÍ·ÄÚÈݾÙÐÐÆÊÎö,¾Í¿ÉÒÔÖªµÀÆäÏà¹ØµÄÒÀÀµ £¬²¢½«ÕâЩÐÅÏ¢¼Í¼ÏÂÀ´¡£ÄÇôЧÀͶËÊÇÌṩÕâЩrpmµÄÈí¼þ°ü £¬È»ºóÆÊÎö°üµÄÒÀÀµ¹Øϵ £¬½«¼Í¼±£´æЧÀÍÆ÷ijĿ¼ÉÏ¡£¿Í»§¶ËÔÚ×°ÖÃÈí¼þʱÏÂÔØÆä¼Í¼ÒÀÀµ¹ØϵÎļþ²¢ÆÊÎö £¬×îºóÒ»´ÎÐÔÏÂÔØ¡£

Àú³ÌÖÎÀí»ù´¡

Ò»Ñùƽ³£À´Ëµ³ÌÐò·ÖΪÁ½Àà £¬Ò»ÖÖÊÇϵͳ³ÌÐò £¬Ò»ÖÖÊÇÓ¦ÓóÌÐò¡£Ò»¸öÔËÐÐÁ˳ÌÐò £¬¾Í¿ÉÒÔ˵ÊÇÒ»¸öÀú³ÌÁË £¬Àú³ÌÊÇÕ¼ÓÃÄÚ´æ¿Õ¼äµÄ £¬¶øµ±Äãɱµô½ø³Çʱ £¬×ÊÔ´Ò²»áËæÖ®ÊÍ·Å¡£

Àú³ÌµÄÀàÐÍ

Óû§Àú³Ì£ºÓû§×Ô¼ºµÄ³ÌÐò,Óû§¿ÉÒÔ¿ØÖÆËûµÄ¿ªÆôºÍ¹Ø±Õ¡£

½»»¥Àú³Ì: ÓëÓû§¾ÙÐн»»¥²Ù×÷µÄÀú³Ì¡£

Åú´¦ÀíÀú³Ì£ºÊÇÒ»¸öÀú³ÌÜöÝÍ £¬°´Ë³ÐòÆô¶¯ÆäËûÀú³Ì¡£

ÊØ»¤Àú³Ì£ºÒ»Ö±ÔËÐеÄÀú³Ì.crond¡£

Àú³ÌµÄÊôÐÔ

Àú³ÌID : (pid) ΨһµÄÊý×Ö±êʾ £¬Çø·Ö²î±ðµÄÀú³Ì¡£

Àú³ÌÓи¸Àú³ÌºÍ×ÓÀú³Ì¡£

Æô¶¯Àú³ÌµÄÓû§ID(uid)ºÍÓû§µÄÊô×é¡£

Àú³ÌµÄÈýÖÖ״̬:

ÔËÐÐ — R

ÐÝÃß — S

½©Ê¬ — Z

Àú³ÌµÄÓÅÏȼ¶: È¡Öµ¹æÄ£(-20,19) ,ÊýֵԽСÓÅÏȼ¶Ô½´ó,ĬÒÔΪ0¡£

Àú³ÌÁ´½ÓµÄÖնˡ£

Àú³ÌÕ¼ÓÃ×ÊÔ´ÇéÐΡ£

¸¸×ÓÀú³ÌµÄ¹Øϵ

¸¸×ÓÀú³ÌµÄ¹Øϵ,¸¸Ç×ÖÎÀí¶ù×Ó¡£¸¸Àú³ÌÖÕֹʱ×ÓÀú³ÌÒ»¶¨ÖÕÖ¹,¶ø×ÓÀú³ÌÖÕֹʱ¸¸Àú³Ì·×Æ綨ÖÕÖ¹¡£

Àú³ÌÖÎÀí¹¤¾ß
    ps:   Éó²éÀú³Ì¡£    top:  ¿ÉÒÔÉó²éÀú³ÌµÄ¶¯Ì¬ÐÅÏ¢¡£    kill:  ɱÀú³Ì¡£    pstree:  Éó²éÀú³ÌÊ÷¡£    pgrep:  ËÑÀú³Ì¡£    lsof:  Éó²éÀú³Ì·­¿ªµÄÎļþ¡£

µÇ¼ºó¸´ÖÆ

Àú³ÌÖÎÀíʵ¼ù

ps

¾²Ì¬µÄÏÔʾĿ½ñÀú³ÌµÄÐÅÏ¢ ¡£

ÏÂÁî: ps

Óï·¨: ps ²ÎÊý

³£ÓòÎÊý:

               a      ÏÔʾËùÓÐÓû§µÄÀú³Ì               r       ÏÔʾÔËÐÐÖеÄÀú³Ì               l        ³¤ÃûÌÃÊä³ö               u        °´Óû§ÃûºÍÆô¶¯Ê±¼äµÄ˳ÐòÀ´ÏÔʾÀú³Ì               f         ÓÃÊ÷ÐÎÃûÌÃÀ´ÏÔʾÀú³Ì               x        ÏÔʾûÓпØÖÆÖն˵ÄÀú³Ì

µÇ¼ºó¸´ÖÆ

²Ù×÷: BSDÃûÌÃÀ´ÏÔʾÀú³Ì

  ~ ps auxUSER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMANDroot         1  0.0  0.0  43364  3596 ?        Ss   11ÔÂ03   0:01 /usr/lib/systroot         2  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [kthreadd]root         3  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [ksoftirqd/0]root         5  0.0  0.0      0     0 ?        S<   11ÔÂ03   0:00 [kworker/0:0Hroot         7  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [migration/0]root         8  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [rcu_bh]root         9  0.0  0.0      0     0 ?        S    11ÔÂ03   0:05 [rcu_sched]root        10  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [watchdog/0]root        11  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [watchdog/1]root        12  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [migration/1]root        13  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [ksoftirqd/1]root        15  0.0  0.0      0     0 ?        S<   11ÔÂ03   0:00 [kworker/1:0H

µÇ¼ºó¸´ÖÆ

±ê×¼ÃûÌÃÏÔʾÀú³ÌunixÆøÑæÆøÑæ

ËÑË÷ÃñÖںŶ¥¼¶Ëã·¨»Ø¸´¡°Ëã·¨Ðĵá± £¬ËÍÄãÒ»·Ý¾ªÏ²Àñ°ü¡£

 ~ ps -efUID        PID  PPID  C STIME TTY          TIME CMDroot         1     0  0 11ÔÂ03 ?      00:00:01 /usr/lib/systemd/systemd --systeroot         2     0  0 11ÔÂ03 ?      00:00:00 [kthreadd]root         3     2  0 11ÔÂ03 ?      00:00:00 [ksoftirqd/0]root         5     2  0 11ÔÂ03 ?      00:00:00 [kworker/0:0H]root         7     2  0 11ÔÂ03 ?      00:00:00 [migration/0]root         8     2  0 11ÔÂ03 ?      00:00:00 [rcu_bh]root         9     2  0 11ÔÂ03 ?      00:00:05 [rcu_sched]root        10     2  0 11ÔÂ03 ?      00:00:00 [watchdog/0]root        11     2  0 11ÔÂ03 ?      00:00:00 [watchdog/1]root        12     2  0 11ÔÂ03 ?      00:00:00 [migration/1]root        13     2  0 11ÔÂ03 ?      00:00:00 [ksoftirqd/1]root        15     2  0 11ÔÂ03 ?      00:00:00 [kworker/1:0H]root        17     2  0 11ÔÂ03 ?      00:00:00 [kdevtmpfs]root        18     2  0 11ÔÂ03 ?      00:00:00 [netns]root        19     2  0 11ÔÂ03 ?      00:00:00 [khungtaskd]root        20     2  0 11ÔÂ03 ?      00:00:00 [writeback]root        21     2  0 11ÔÂ03 ?      00:00:00 [kintegrityd]

µÇ¼ºó¸´ÖÆ

ÊôÐÔÏê½â:

USER: Àú³ÌµÄÊôÖ÷

PID: Àú³ÌµÄID

%CPU: Àú³ÌÕ¼cpu°Ù·Ö±È

%MEM: Àú³ÌÕ¼ÄÚ´æµÄ°Ù·Ö±È

VSZ: Àú³ÌÕ¼ÓÃÐéÄâÄÚ´æ¾Þϸ

RSS: Àο¿ÄÚ´æʹÓÃÊýÄ¿

STAT Àú³Ì״̬

       R    ÕýÔÚÔËÐпÉÖÐÔÚÐÐÁÐÖпɹýÐеÄ£» S    ´¦ÓÚÐÝÃß״̬£»   T    ×èÖ¹»ò±»×·×Ù£»   Z    ½©Ê¬Àú³Ì£»   N    ÓÅÏȼ¶½ÏµÍµÄÀú³Ì   L    ÓÐЩҳ±»Ëø½øÄÚ´æ£»   s    Àú³ÌµÄÏòµ¼Õߣ¨ÔÚËüÖ®ÏÂÓÐ×ÓÀú³Ì£©

µÇ¼ºó¸´ÖÆ

START Æô¶¯Àú³ÌµÄʱ¼ä £»

TIME Àú³ÌÏûºÄCPUµÄʱ¼ä £»

COMMAND ÏÂÁîµÄÃû³ÆºÍ²ÎÊý;

ƾָ֤¶¨ÊôÐÔÅÅÐò:

ƾ֤cpu´ÓСµ½´óÅÅÐò¡£

  ~ ps aux --sort %cpuUSER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMANDroot         1  0.0  0.0  43364  3596 ?        Ss   11ÔÂ03   0:01 /usr/lib/systroot         2  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [kthreadd]root         3  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [ksoftirqd/0]root         5  0.0  0.0      0     0 ?        S<   11ÔÂ03   0:00 [kworker/0:0Hroot         7  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [migration/0]root         8  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [rcu_bh]root         9  0.0  0.0      0     0 ?        S    11ÔÂ03   0:05 [rcu_sched]root        10  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [watchdog/0]root        11  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [watchdog/1]

µÇ¼ºó¸´ÖÆ

ƾ֤cpu´Ó´óµ½Ð¡ÅÅÐò¡£

  ~ ps aux --sort -%cpuUSER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMANDroot     21342  0.3  0.4 137184 17112 ?        Ssl  03:24   1:16 /usr/local/aegiroot         1  0.0  0.0  43364  3596 ?        Ss   11ÔÂ03   0:01 /usr/lib/systroot         2  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [kthreadd]root         3  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [ksoftirqd/0]root         5  0.0  0.0      0     0 ?        S<   11ÔÂ03   0:00 [kworker/0:0Hroot         7  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [migration/0]root         8  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [rcu_bh]root         9  0.0  0.0      0     0 ?        S    11ÔÂ03   0:05 [rcu_sched]root        10  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [watchdog/0]root        11  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [watchdog/1]root        12  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [migration/1]root        13  0.0  0.0      0     0 ?        S    11ÔÂ03   0:00 [ksoftirqd/1]

µÇ¼ºó¸´ÖÆ

top

ÓëpsÏà·´µÄÊÇtopÏÂÁî¿ÉÒÔÉó²éÀú³ÌµÄ¶¯Ì¬ÐÅÏ¢¡£

ÏÂÁî: top

Óï·¨: top ²ÎÊý

³£ÓòÎÊý:

²Ù×÷:

  ~ toptop - 11:38:42 up 13:15,  2 users,  load average: 0.01, 0.03, 0.05Tasks:  98 total,   1 running,  97 sleeping,   0 stopped,   0 zombie%Cpu(s):  0.2 us,  0.0 sy,  0.0 ni, 99.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 stKiB Mem :  3881688 total,   229264 free,   543932 used,  3108492 buff/cacheKiB Swap:  1049596 total,  1049596 free,        0 used.  3026944 avail Mem PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND   1 root      20   0   43364   3596   2340 S   0.0  0.1   0:01.79 systemd   2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kthreadd   3 root      20   0       0      0      0 S   0.0  0.0   0:00.14 ksoftirqd/0   5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:+   7 root      rt   0       0      0      0 S   0.0  0.0   0:00.33 migration/0   8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh   9 root      20   0       0      0      0 S   0.0  0.0   0:05.73 rcu_sched

µÇ¼ºó¸´ÖÆ

ÊôÐÔÚ¹ÊÍ:

Ç°ÎåÐÐÊÇÊý¾ÝµÄÕûÀíͳ¼ÆÐÅÏ¢¡£

µÚÒ»ÐÐ:

     11:38:42     Ä¿½ñʱ¼ä           up 13:15     ϵͳÔËÐÐʱ¼ä,ÃûÌÃΪʱ:·Ö            2 user         Ä¿½ñÉÏ°¶Óû§ÊýÄ¿            load average: 0.01, 0.03, 0.05  ϵͳ¸ºÔØ,ʹÃüÐÐÁÐƽ¾ù³¤¶È 1·ÖÖÓ,5·ÖÖÓ,15·ÖÖÓÇ°µ½ÏÖÔÚµÄƽ¾ùÖµ¡£

µÇ¼ºó¸´ÖÆ

µÚ¶þÈýÐУº

98 total  Àú³Ì×ÜÊýÄ¿ 1 running ÕýÔÚÔËÐеÄÀú³ÌÊýÄ¿ 97 sleeping ˯ÃßµÄÀú³ÌÊýÄ¿ 0 stopped  ×èÖ¹µÄÀú³ÌÊýÄ¿ 0 zombie   ½©Ê¬Àú³ÌÊýÄ¿ %Cpu(s): 0.2 us ϵͳÓû§Àú³ÌʹÓÃcpu°Ù·Ö±È 0.0 sy ÄÚºËÀú³ÌÕ¼ÓÃcpu°Ù·Ö±È 0.0 ni Óû§Àú³Ì¿Õ¼äÄڸıä¹ýÓÅÏȼ¶µÄÀú³ÌÕ¼ÓÃcpu°Ù·Ö±È     99.8 id ¿ÕÏÐcpu°Ù·Ö±È       0.0 wa ÆÚ´ýÊäÈëÊä³öµÄcpuʱ¼ä°Ù·Ö±È       0.0 hi   Ó²¼þcpuÖÐÖ¹Õ¼ÓÃ°Ù·Ö±È       0.0  si   ÈíÖÐÖ¹Õ¼ÓÃ°Ù·Ö±È       0.0  st  ÐéÄâ»úÕ¼ÓðٷֱÈ

µÇ¼ºó¸´ÖÆ

µÚËÄÎåÐÐ:

Mem : (µ¥Î»K)

3881688 total  ÎïÀíÄÚ´æ×ÜÁ¿229264 free    ¿ÕÏÐÄÚ´æ×ÜÁ¿543932 used    ʹÓõÄÎïÀíÄÚ´æ×ÜÁ¿3108492 buff/cache Äں˻º´æµÄÄÚ´æÁ¿

µÇ¼ºó¸´ÖÆ

Swap: (µ¥Î»K)

 1049596 total      ½»Á÷Çø×ÜÁ¿ 1049596 free       ¿ÕÏн»Á÷Çø×ÜÁ¿ 0 used             ʹÓõĽ»Á÷Çø×ÜÁ¿ 3026944 avail Mem  ¿ÉʹÓõÄÄÚ´æÁ¿

µÇ¼ºó¸´ÖÆ

ÎÊÌâÐÐ:

PID: Àú³Ìid

USER: Àú³ÌËùÓÐÕßÓû§Ãû

PR: ÓÅÏȼ¶

NI: Àú³ÌÓÅÏȼ¶ £¬niceÖµ £¬¸ºÖµ -> ¸ßÓÅÏȼ¶ £¬ÕýÖµ -> µÍÓÅÏȼ¶

VIRT: ÐéÄâÄÚ´æ×ÜÁ¿ virt=swap + res

RES: ÏÖʵʹÓÃÄÚ´æ¾Þϸ

SHR: ¹²ÏíÄÚ´æ¾Þϸ

S: Àú³Ì״̬

   d: ²»¿ÉÖÐÖ¹µÄ˯Ãß״̬   r: ÔËÐÐ   s: ˯Ãß   t: ¸ú×Ù   z: ½©Ê¬Àú³Ì

µÇ¼ºó¸´ÖÆ

%CPU: Éϴθüе½ÏÖÔÚcpuʱ¼äÕ¼ÓðٷֱÈ

%MEM: Àú³ÌʹÓÃÎïÀíÄÚ´æ°Ù·Ö±È

TIME+: Àú³ÌʹÓÃcpuµÄʱ¼ä×ܼÆ £¬µ¥Î» 1/100Ãë

COMMAND: ÏÂÁîÐÐ

kill

ÏÂÁî: kill

Óï·¨:

      kill [-s signal|-p] [-q sigval] [-a] [--] pid...      kill -l [signal]

µÇ¼ºó¸´ÖÆ

³£ÓòÎÊý:

     -l ÁгöËùÓÐÐźÅÃû³Æ     -s Ö¸¶¨·¢ËÍÐźţ¨Ä¬ÈÏ£©     -u Ö¸¶¨Óû§

µÇ¼ºó¸´ÖÆ

²Ù×÷: ÁгöËùÓÐÐźÅÃû³Æ

  ~ kill -lHUP INT QUIT ILL TRAP ABRT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERM STKFLT CHLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF WINCH POLL PWR SYS

µÇ¼ºó¸´ÖÆ

Ç¿ÖÆÖÕÖ¹

  ~ kill -9 23423

µÇ¼ºó¸´ÖÆ

ÖÕÖ¹  ~ kill -15 22323

µÇ¼ºó¸´ÖÆ

ɱËÀÖ¸¶¨Óû§µÄËùÓÐÀú³Ì

  ~ kill -u superh

µÇ¼ºó¸´ÖÆ

procĿ¼

Õâ¸öĿ¼ÖÐÓÐÄÚºË £¬Àú³ÌÔËÐÐ״̬µÄÐÅÏ¢¡£

  /proc ls1      21320  21628  240   392   7          diskstats    loadavg       swaps10     21342  21976  242   42    722        dma          locks         sys10353  21465  21977  243   44    7561       driver       mdstat        sysrq-trigger10509  21613  21978  244   442   8          execdomains  meminfo       sysvipc107    21614  22     249   45    803        fb           misc          timer_list11     21615  220    26    46    8179       filesystems  modules       timer_stats11010  21616  22285  261   466   8307       fs           mounts        tty11102  21617  22287  262   467   8327       interrupts   mtrr          uptime12     21618  22361  267   469   9          iomem        net           version13     21619  22363  268   476   acpi       ioports      pagetypeinfo  vmallocinfo14461  21620  22396  3     477   buddyinfo  irq          partitions    vmstat15     21621  22467  31    485   bus        kallsyms     sched_debug   zoneinfo17     21622  225    3198  5     cgroups    kcore        schedstat18     21623  229    32    505   cmdline    keys         scsi19     21624  23     33    506   consoles   key-users    self2      21625  23884  336   5217  cpuinfo    kmsg         slabinfo20     21626  23885  34    5515  crypto     kpagecount   softirqs21     21627  24     357   65    devices    kpageflags   stat

µÇ¼ºó¸´ÖÆ

ÉÏÃæµÄÿ¸ö±êºÅ¼´ÊÇÓÃÎÒÃÇÄ¿½ñÀú³ÌµÄpidËùÃüÃûµÄĿ¼Ãû¡£

free

Éó²éϵͳʹÓúͿÕÏеÄÄÚ´æÇéÐΡ£

ÏÂÁî: free

Óï·¨: free ²ÎÊý

³£ÓòÎÊý:

 -b, --bytes        byteΪµ¥Î»Õ¹Ê¾ -k, --kilo            kΪµ¥Î»Õ¹Ê¾ -m, --mega       mΪµ¥Î»Õ¹Ê¾ -g, --giga           gΪµ¥Î»Õ¹Ê¾

µÇ¼ºó¸´ÖÆ

²Ù×÷:

  ~ free -m             total        used        free      shared  buff/cache   availableMem:           3790         536         210           2        3043        2950Swap:          1024           0        1024

µÇ¼ºó¸´ÖÆ

µ¥Î»ÎªgÏÔʾ¡£

  ~ free -h            total        used        free      shared  buff/cache   availableMem:           3.7G        538M        207M        2.4M        3.0G        2.9GSwap:          1.0G          0B        1.0G

µÇ¼ºó¸´ÖÆ

Îļþ²éÕÒ

ÔÚ×öÔËάÏà¹ØµÄÊÂÇéʱ £¬ÎÒÃÇÉÙ²»ÁËÒª²éÕâÑùÄÇÑùµÄÎļþ £¬Ò»Ñùƽ³£À´ËµÎÒÃÇ¿ÉÄÜ»á²éºÃ±È´øxxx.confÃû×ÖµÄÎļþÔÚÄÄÄØ,²éÈÕÖ¾°¡ £¬Ä³¸ö¿ÉÖ´ÐÐÎļþµÄλÖð¡¡£

¸ÅÀÀ
which : Éó²éÖ´ÐÐÎļþµÄλÖá£whereis : Éó²é¿ÉÖ´ÐÐÎļþλÖúÍÏà¹ØÎļþ¡£locate : ÅäºÏÊý¾Ý¿â»º´æ£¬¿ìËÙÉó²éÎļþµÄλÖá£grep : ¹ýÂËÆ¥Åä£¬ËûÊÇÒ»¸öÎļþËÑË÷¹¤¾ß¡£find  :  ¿ÉÒÔƾ֤Ìõ¼þÉó²éÎļþ¡£

µÇ¼ºó¸´ÖÆ

which

ÏÂÁwhich

Óï·¨: which ²ÎÊý ÅÌÎÊÄ¿µÄ

³£ÓÃÏÂÁî: Ò»Ñùƽ³£²»¼Ó²ÎÊýʹÓÃ

          --all, -a      ÏÔʾËùÓеÄÆ¥Åä·¾¶

µÇ¼ºó¸´ÖÆ

²Ù×÷:

  ~ which pwd/usr/bin/pwd

µÇ¼ºó¸´ÖÆ

whereis

ÏÂÁî: whereis

Óï·¨: whereis ²ÎÊý ÅÌÎÊÄ¿µÄ

³£ÓÃÏÂÁî:

           Ò»Ñùƽ³£²»¼Ó²ÎÊýʹÓà         -b         Ö»ËÑË÷¶þ½øÖÆÎļþ         -B <Ŀ¼>  ½ç˵¶þ½øÖÆÎļþ²éÕÒ·¾¶         -m         Ö»ËÑË÷ man ÊÖ²á         -M <Ŀ¼>  ½ç˵ man ÊÖ²á²éÕÒ·¾¶         -s         Ö»ËÑË÷Ô´´úÂë         -S <Ŀ¼>  ½ç˵Դ´úÂë²éÕÒ·¾¶

µÇ¼ºó¸´ÖÆ

²Ù×÷:

  ~ whereis lsls: /usr/bin/ls /usr/share/man/man1/ls.1.gz

µÇ¼ºó¸´ÖÆ

locate

ÏÂÁî: locate

Óï·¨: locate ÎļþÃû

³£ÓòÎÊý: ÎÞ

²Ù×÷: locateºÍfindÏÂÁЧ²îδ¼¸ £¬¿ÉÊÇËÑË÷ЧÂʸü¸ß £¬ÓÉÓÚlocate²éµÄÊÇÊý¾Ý¿â¶øfind²éÕÒµÄÊÇĿ¼Îļþ¡£

Êý¾Ý¿â:

  ~ ls /var/lib/mlocate/mlocate.db/var/lib/mlocate/mlocate.db

µÇ¼ºó¸´ÖÆ

Ïà¹ØÉèÖÃÎļþ:

  ~ ls /etc/updatedb.conf/etc/updatedb.conf

µÇ¼ºó¸´ÖÆ

Ïà¹Ø׼ʱʹÃü:

  ~ ls /etc/cron.daily/mlocate/etc/cron.daily/mlocate

µÇ¼ºó¸´ÖÆ

¾ÙÀý:

  ~ touch shafa  ~ locate shafa  ~ updatedb  ~ locate shafa/root/shafa

µÇ¼ºó¸´ÖÆ

×¢£ºÈôÊÇÎÒÃǵ±Ììн¨µÄÎļþ²éÕÒ £¬ÐèÒªÊÖ¶¯updatedb¡£

ËÑË÷ÃñÖÚºÅLinux¾Í¸ÃÕâÑùѧ»Ø¸´¡°È¨ÏÞϵͳ¡± £¬ËÍÄãÒ»·Ý¾ªÏ²Àñ°ü¡£

grep

ÏÂÁgrep

Óï·¨£ºgrep ²ÎÊý Ä¿µÄÖµ Îļþ

³£ÓòÎÊý:

            -v       È¡·´            -i        ºöÂÔ¾Þϸд            -n        Êä³öµÄͬʱ´òÓ¡ÐкŠ           ^*        ÒÔ*¿ªÍ·            *$         ÒÔ*×îºó            ^$         ¿ÕÐÐ

µÇ¼ºó¸´ÖÆ

²Ù×÷:

²é /etc/passwdÓÐrootµÄÐÐ

  ~ grep root /etc/passwdroot:x:0:0:root:/root:/bin/zshoperator:x:11:0:operator:/root:/sbin/nologin

µÇ¼ºó¸´ÖÆ

²é /etc/passwd ûÓÐrootµÄÐÐ(ÄÚÈݽ϶à £¬½ûչʾ¼¸ÐÐ)

  ~ grep -v root /etc/passwdbin:x:1:1:bin:/bin:/sbin/nologindaemon:x:2:2:daemon:/sbin:/sbin/nologinadm:x:3:4:adm:/var/adm:/sbin/nologinlp:x:4:7:lp:/var/spool/lpd:/sbin/nologinsync:x:5:0:sync:/sbin:/bin/sync

µÇ¼ºó¸´ÖÆ

²é /etc/passwd ÓÐwwwµÄÐв¢ÏÔʾÐкÅ

  ~ grep -n www /etc/passwd23:www:x:1000:1000::/home/www:/sbin/nologin

µÇ¼ºó¸´ÖÆ

find

ÏÂÁfind

Óï·¨£ºfind ·¾¶ ²ÎÊý Êä³ö

³£ÓòÎÊý:

            ·¾¶: ÀýÈçÓà . À´ÌåÏÖÄ¿½ñĿ¼£¬Óà / À´ÌåÏÖϵͳ¸ùĿ¼¡£           -print£ºÏÔʾµÄʱ¼ä¡±\n¡±×öΪ¶¨½ç·û, »»ÐÐ          -print0£ºÓëxargsÅäÌ×ʹÓÃ£¬ÒÔ¡°\0¡±×öΪ¶¨½ç·û

µÇ¼ºó¸´ÖÆ

find³£ÓÃÏÂÁîÑ¡Ïî:

-name   ƾ֤ÎļþÃû²éÕÒÎļþ¡£¡°Ãû³Æ¡±-perm   ƾ֤ÎļþȨÏÞÀ´²éÕÒÎļþ¡£666 777 µÈ-depth  ÔÚ²éÕÒÎļþʱ£¬Ê×ÏȲéÕÒÄ¿½ñĿ¼ÖеÄÎļþ£¬È»ºóÔÙÔÚÆä×ÓĿ¼ÖвéÕÒ-user   ƾ֤ÎļþÊôÖ÷À´²éÕÒÎļþ -atime  -ctime (µ¥Î»ÊÇÌì) -mmin -cmin  -amin(µ¥Î»ÊÇ·ÖÖÓ) -size n [c] ²éÕÒÎļþ³¤¶ÈΪn¿éµÄÎļþ£¬´øÓÐcʱÌåÏÖÎļþ³¤¶ÈÒÔ×Ö½Ú¼Æ -follow  ÈôÊÇfindÏÂÁîÓöµ½·ûºÅÁ´½ÓÎļþ£¬¾Í¸ú×ÙÖÁÁ´½ÓËùÖ¸ÏòµÄÎļþ¡£

µÇ¼ºó¸´ÖÆ

²Ù×÷:

Éó²éÄ¿½ñĿ¼ÏÂtest.¿ªÍ·µÄÎļþ

  ~ find . -name "test*"./test.txt./autojump/tests./test.1

µÇ¼ºó¸´ÖÆ

Éó²éÄ¿½ñĿ¼ÏÂtest.¿ªÍ·µÄÎļþ,Êä³öЧ¹û»»ÐÐÏÔʾ(ĬÈÏ)

  ~ find . -name "test*" -print./test.txt./autojump/tests./test.1

µÇ¼ºó¸´ÖÆ

Éó²éÄ¿½ñĿ¼ÏÂtest.¿ªÍ·µÄÎļþ,Êä³öЧ¹û²»»»ÐÐÏÔʾ

  ~ find . -name "test*" -print0./test.txt./autojump/tests./test.1

µÇ¼ºó¸´ÖÆ

¶Ô²éÕÒµÄÄÚÈÝÖ´ÐÐÏìÓ¦ÏÂÁî

ĬÈÏÖ´ÐÐÐж¯ : -print

³£ÓÃÐж¯:

              -exec  Õâ¸ö²ÎÊýºó¿ÉÒÔ¸ú×Ô½ç˵shellÏÂÁî

µÇ¼ºó¸´ÖÆ

²Ù×÷:

ÅÌÎÊ.txt×îºóµÄÎļþ²¢ÓÃlsÅÌÎÊÆä¸ü¶àÊôÐÔ

  test find . -name "*.txt" -exec ls -l {} \;-rw-r--r-- 1 root root 0 11ÔÂ  4 14:56 ./xq1.txt-rw-r--r-- 1 root root 0 11ÔÂ  4 14:56 ./xq.txt-rw-r--r-- 1 root root 0 11ÔÂ  4 14:56 ./xq2.txt

µÇ¼ºó¸´ÖÆ

ÅÌÎÊ.txt×îºóµÄÎļþ²¢Äð³É.bak×îºóµÄÎļþ

  test find . -name "*.txt" -exec mv {} {}.bak \;  test lsxq1.txt.bak  xq2.txt.bak  xq.txt.bak

µÇ¼ºó¸´ÖÆ

Âß¼­ÅÌÎÊ:

        -a  ²¢ÇÒ        -o  »òÕß         +  ¸ßÓÚ         -   µÍÓÚ

µÇ¼ºó¸´ÖÆ

²Ù×÷£ºÉó²é .sh»òÕß.q×îºóµÄÎļþ¡£

  test find . -name "*.sh" -o -name "*.q"./book.q./stop.sh./start.sh

µÇ¼ºó¸´ÖÆ

Éó²é.sh×îºó²¢ÇÒs¿ªÍ·µÄÎļþ¡£

  test find . -name "*.sh" -a -name "s*"./stop.sh./start.sh

µÇ¼ºó¸´ÖÆ

ÔÚÎļþÖвåÈëÄÚÈݺóÉó²é¡£

  test ll×ÜÓÃÁ¿ 12K-rw-r--r-- 1 root root  9 11Ô  4 15:10 book.q-rw-r--r-- 1 root root 13 11Ô  4 15:10 start.sh-rw-r--r-- 1 root root  4 11Ô  4 15:10 stop.sh-rw-r--r-- 1 root root  0 11Ô  4 14:56 xq1.txt.bak-rw-r--r-- 1 root root  0 11Ô  4 14:56 xq2.txt.bak-rw-r--r-- 1 root root  0 11Ô  4 14:56 xq.txt.bak

µÇ¼ºó¸´ÖÆ

Éó²é/etc ´óÓÚ40kСÓÚ50kµÄÎļþ

  test find /etc/ -size +40k -a -size  -50k/etc/selinux/targeted/active/modules/100/sysadm/hll/etc/selinux/targeted/contexts/files/file_contexts.homedirs.bin

µÇ¼ºó¸´ÖÆ

ÍýÏëʹÃü

˵µ½ÍýÏë,åÚÏëµ½µÄÊÇʱ¼ä,˵µ½Ê¹Ãü,åÚÏëµ½µÄ¾ÍÊÇ×öʲô¡£Á¬ÆðÀ´¾ÍÊÇʲôʱ¼ä×öʲô¡£ÌìÌ켸µãÉϰ༸µãϰࡣÿÄêµÄ¹úÇì £¬Ôªµ©¶¼ÔÚÀο¿µÄʱ¼ä½Úµã±¬·¢¡£ÀàËÆÕâЩ,ÎÒÃÇ¿ÉÒÔ³Æ֮Ϊ׼ʱʹÃü¡£

ÔٺñÈ,ÓеÄʱ¼ä¡£¿ìÏ°àÁË,Ïòµ¼À´¸ö½ôÆÈʹÃü,СÍõ°¡,¼Ó¸ö°à¡£Ã÷ÌìÐÄÇéºÃ £¬Çë¸ö¼ÙÈ¥ÃæÊÔ¡£ÕâÖÖµÄÊôÓÚÔÝʱʹÃü¡£

ÄÇôÔÚlinuxÖÐÎÒÃÇÔõôÀ´×öÕâÁ½¼þÊÂÄØ¡£

ʹÃüÀàÐÍ

׼ʱ: ƾ֤һ¶¨µÄÖÜÆÚÖظ´Ò»Á¬µÄ×öij¸öÊ¡£

ÔÝʱ: Ö´ÐÐÒ»´ÎÒÔºóʹÃü¾Í¿¢ÊÂÁË £¬Ö»Ò»´Î¡£

ʹÃüÀàÐͶÔÓ¦µÄÏÂÁî

crontab( ׼ʱʹÃü): ƾ֤Äã Äã»®¶¨µÄÖÜÆÚ Ñ­»·ÖÏÏ¢¸Ð¡£

at (ÔÝʱʹÃü): Ö´ÐÐÒ»´Î¾Í¿¢ÊµÄʹÃü¡£

atµÄʹÓÃ

ÏÂÁat

Óï·¨: at ʱ¼ä

³£ÓòÎÊý:

         -l    Éó²éʹÃüÁÐ±í         -c   Éó²éʹÃüÏêÇé

µÇ¼ºó¸´ÖÆ

²Ù×÷£ºÉó²éЧÀÍÊÇ·ñ¿ªÆô

[root@iz2ze0ajic0vbv28hcdctpz ~]# systemctl status atd¡ñ atd.service - Job spooling tools  Loaded: loaded (/usr/lib/systemd/system/atd.service; enabled; vendor preset: enabled)  Active: active (running) since ¶þ 2018-11-13 11:50:47 CST; 1 day 9h agoMain PID: 491 (atd)  CGroup: /system.slice/atd.service          ©¸©¤491 /usr/sbin/atd -f11Ô 13 11:50:47 iz2ze0ajic0vbv28hcdctpz systemd[1]: Started Job spooling tools.11Ô 13 11:50:47 iz2ze0ajic0vbv28hcdctpz systemd[1]: Starting Job spooling tools...

µÇ¼ºó¸´ÖÆ

¼¸ÖÖÉ趨ʹÃüµÄÒªÁì: ½¨ÉèÒ»¸öʹÃü(ĬÈÏÊǽñÌì,ÈôÊÇʱ¼ä´óÓÚÄ¿½ñʱ¼ä»á½¨ÉèÔÚÏÂÒ»Ìì £©

[root@iz2ze0ajic0vbv28hcdctpz ~]# lssoft[root@iz2ze0ajic0vbv28hcdctpz ~]# at 21:17at> mkdir skat> <EOT>job 6 at Wed Nov 14 21:17:00 2018

µÇ¼ºó¸´ÖÆ

ָ׼ʱ¼ä½¨Éè:

[root@iz2ze0ajic0vbv28hcdctpz ~]# at 20:00 2018-11-19at> mkdir happyat> <EOT>job 7 at Mon Nov 19 20:00:00 2018

µÇ¼ºó¸´ÖÆ

´ÓÏÖÔÚ×îÏȼÓʱ¼ä:

[root@iz2ze0ajic0vbv28hcdctpz ~]# at now + 3minat> mkdir helloat> <EOT>job 8 at Wed Nov 14 21:41:00 2018

µÇ¼ºó¸´ÖÆ

Ã÷Ìì11:11 Ö´ÐÐ

[root@iz2ze0ajic0vbv28hcdctpz ~]# at 11:11 tomorrowat> mkdir worldat> <EOT>job 9 at Thu Nov 15 11:11:00 2018

µÇ¼ºó¸´ÖÆ

2ÌìºóµÄÏÂÕ½Êé3.24Ö´ÐÐ

[root@iz2ze0ajic0vbv28hcdctpz ~]# at 3:24 pm +2 daysat> mkdir newat> <EOT>job 11 at Fri Nov 16 15:24:00 2018

µÇ¼ºó¸´ÖÆ

Éó²éʹÃüÁбí(ÏÔʾ»¹Î´Ö´ÐеÄʹÃü £©

[root@iz2ze0ajic0vbv28hcdctpz ~]# atq5  Thu Nov 15 21:11:00 2018 a root

µÇ¼ºó¸´ÖÆ

Éó²éÒ»¸öµ¥¸öµÄʹÃüÐÅÏ¢:(ÓÉÓÚÄÚÈݽ϶àÈ¥µô²¿·ÖÐÅÏ¢)

[root@iz2ze0ajic0vbv28hcdctpz /]# at -c 7#!/bin/sh# atrun uid=0 gid=0# mail root 0umask 22XDG_SESSION_ID=243; export XDG_SESSION_IDHOSTNAME=iz2ze0ajic0vbv28hcdctpz; export HOSTNAMESHELL=/bin/bash; export SHELLHISTSIZE=1000; export HISTSIZESSH_CLIENT=113.46.167.195\ 17211\ 22; export SSH_CLIENTSSH_TTY=/dev/pts/0; export SSH_TTYUSER=root; export USERMAVEN_HOME=/usr/local/apache-maven-3.6.0; export MAVEN_HOMEMAIL=/var/spool/mail/root; export MAILPATH=/usr/local/apache-maven-3.6.0/bin:/usr/local/jdk1.8.0_191/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin; export PATHPWD=/root; export PWDJAVA_HOME=/usr/local/jdk1.8.0_191; export JAVA_HOMELANG=zh_CN.UTF-8; export LANGHISTCONTROL=ignoredups; export HISTCONTROLSHLVL=1; export SHLVLHOME=/root; export HOMELOGNAME=root; export LOGNAMECLASSPATH=.:/lib/dt.jar:/lib/tools.jar; export CLASSPATHSSH_CONNECTION=113.46.167.195\ 17211\ 172.17.187.244\ 22; export SSH_CONNECTIONLC_CTYPE=zh_CN.UTF-8; export LC_CTYPELESSOPEN=\|\|/usr/bin/lesspipe.sh\ %s; export LESSOPENXDG_RUNTIME_DIR=/run/user/0; export XDG_RUNTIME_DIRcd /root || {  echo 'Execution directory inaccessible' >&2  exit 1}${SHELL:-/bin/sh} << 'marcinDELIMITER550b4fbb'mkdir happymarcinDELIMITER550b4fbb

µÇ¼ºó¸´ÖÆ

²ÎÊýÚ¹ÊÍ:

5 : ʹÃü±àºÅ

Thu Nov 15 21:11:00 2018 : ʱ¼ä

a : ÐÐÁÐ

root : Ö´ÐÐÓû§

ɾ³ýʹÃü£º

ÏÈÀ´Éó²éÒ»ÏÂÓÐÄÄЩʹÃü

[root@iz2ze0ajic0vbv28hcdctpz /]# atq7  Mon Nov 19 20:00:00 2018 a root5  Thu Nov 15 21:11:00 2018 a root11  Fri Nov 16 15:24:00 2018 a root9  Thu Nov 15 11:11:00 2018 a root12  Wed Nov 14 22:11:00 2018 a root

µÇ¼ºó¸´ÖÆ

ɾ³ýʹÃü±àºÅΪ12µÄʹÃü

[root@iz2ze0ajic0vbv28hcdctpz /]# atrm 12[root@iz2ze0ajic0vbv28hcdctpz /]# atq7  Mon Nov 19 20:00:00 2018 a root5  Thu Nov 15 21:11:00 2018 a root11  Fri Nov 16 15:24:00 2018 a root9  Thu Nov 15 11:11:00 2018 a root

µÇ¼ºó¸´ÖÆ

׼ʱʹÃü´¦Àí

cronÊÇlinuxµÄÒ»¸ö׼ʱʹÃüÖ´Ðй¤¾ß,¶øcrondtabÊÇÖÜÆÚÐÔÖ´ÐÐÏÂÁî,crondÔòÊÇ׼ʱʹÃüµÄÊØ»¤Àú³Ì¡£

ЧÀÍÆô¶¯
 Éó²éЧÀÍÊÇ·ñÆô¶¯

µÇ¼ºó¸´ÖÆ

[root@iz2ze0ajic0vbv28hcdctpz ~]# systemctl status crond¡ñ crond.service - Command Scheduler  Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)  Active: active (running) since ¶þ 2018-11-13 11:50:47 CST; 1 day 10h agoMain PID: 489 (crond)  CGroup: /system.slice/crond.service          ©¸©¤489 /usr/sbin/crond -n11Ô 13 11:50:47 iz2ze0ajic0vbv28hcdctpz systemd[1]: Started Command Scheduler.11Ô 13 11:50:47 iz2ze0ajic0vbv28hcdctpz systemd[1]: Starting Command Scheduler...11Ô 13 11:50:47 iz2ze0ajic0vbv28hcdctpz crond[489]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 7...ed.)11Ô 13 11:50:47 iz2ze0ajic0vbv28hcdctpz crond[489]: (CRON) INFO (running with inotify support)Hint: Some lines were ellipsized, use -l to show in full.

µÇ¼ºó¸´ÖÆ

ÈôÊÇûÓÐÆô¶¯,Ö´ÐÐsystemctl start crondsystemctl enable crond

µÇ¼ºó¸´ÖÆ

crontabÏÂÁî

Óï·¨ : crontab ²ÎÊý

³£ÓòÎÊý :

        crontab -u   #Ö¸¶¨Óû§µÄcronÐÅÏ¢        crontab -l   #ÁгöÄ¿½ñÓû§ÏµÄcronЧÀ͵ÄÐÅÏ¢        crontab -u user -l   #ÁгöÖ¸¶¨Óû§µÄcronЧÀ͵ÄÐÅÏ¢        crontab -r   #ɾ³ýcronЧÀÍ        crontab -e   #±à¼­cronЧÀÍ        crontab -r -u user   #ɾ³ýÖ¸¶¨Óû§µÄ׼ʱʹÃü

µÇ¼ºó¸´ÖÆ

²Ù×÷:

±à¼­cronЧÀÍ

[root@iz2ze0ajic0vbv28hcdctpz ~]# crontab -ecrontab: installing new crontab

µÇ¼ºó¸´ÖÆ

Éó²éÄ¿½ñÓû§ÏÂʹÃüÄÚÈÝ

[root@iz2ze0ajic0vbv28hcdctpz ~]# crontab -l22 22 22 * * mkdir /linux/test

µÇ¼ºó¸´ÖÆ

ɾ³ýʹÃü

[root@iz2ze0ajic0vbv28hcdctpz ~]# crontab -r[root@iz2ze0ajic0vbv28hcdctpz ~]# crontab -lno crontab for root

µÇ¼ºó¸´ÖÆ

Éó²éqaÕâ¸öÓû§ÏµÄʹÃüÄÚÈÝ

[root@iz2ze0ajic0vbv28hcdctpz ~]# crontab -u qa -l22 22 22 * * mkdir /linux/test

µÇ¼ºó¸´ÖÆ

ɾ³ýqaÕâ¸öÓû§ÏµÄ׼ʱʹÃü

[root@iz2ze0ajic0vbv28hcdctpz ~]# crontab -u qa -r[root@iz2ze0ajic0vbv28hcdctpz ~]# crontab -u qa -lno crontab for qa

µÇ¼ºó¸´ÖÆ

ϵͳʹÃü

ϵͳµÄʹÃüµ÷ÀíÉèÖÃÎļþÔÚ/etc/crontabÏÂ

[root@iz2ze0ajic0vbv28hcdctpz ~]# ll /etc/crontab-rw-r--r-- 1 root root 451 Nov 15 07:49 /etc/crontab

µÇ¼ºó¸´ÖÆ

¿ÉÒÔÖ±½ÓÔÚ/etc/crontabÏÂÌí¼ÓϵͳʹÃü(²»½¨Òé)

[root@iz2ze0ajic0vbv28hcdctpz ~]# cat /etc/crontabSHELL=/bin/bashPATH=/sbin:/bin:/usr/sbin:/usr/binMAILTO=root# For details see man 4 crontabs# Example of job definition:# .---------------- minute (0 - 59)# |  .------------- hour (0 - 23)# |  |  .---------- day of month (1 - 31)# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat# |  |  |  |  |# *  *  *  *  * user-name  command to be executed

µÇ¼ºó¸´ÖÆ

׼ʱʹÃüÏà¹ØµÄĿ¼

[root@iz2ze0ajic0vbv28hcdctpz etc]# ll crcron.d/       cron.deny     cron.monthly/ cron.weekly/cron.daily/   cron.hourly/  crontab       crypttab

µÇ¼ºó¸´ÖÆ

Ŀ¼×÷ÓÃÚ¹ÊÍ:

cron.d/       ÊÇϵͳ×Ô¶¯°´ÆÚÐèÒª×öµÄʹÃü(²»ÊÇƾ֤ʱ£¬·Ö£¬ÃëµÈʱ¼äÖÜÆÚÖ´ÐеÄ)cron.deny   ÔÚ¸ÃÎļþÄÚµÄÓû§ÎÞ·¨×öÍýÏëʹÃüÆäËûÎļþΪ²î±ðÖÜÆÚµÄÖ´Ðо籾¡£

µÇ¼ºó¸´ÖÆ

׼ʱʹÃü¹æÔò

Ê×ÏÈÀ´¿´ÏÂʹÃüµÄÃûÌÃ(Èçͼ):

ʱ¼äµÄһЩÌØÊâ·ûºÅ:

ÏÂÃæÎÒÃÇÀ´¾ÙһЩÀý×Ó:

#ÿÍíµÄ20:30ÖؼÓÔØnginx30 20 * * * /usr/local/nginx/sbin/nginx -s reload#ÿÔÂ1¡¢10¡¢15ÈÕµÄ5:30ÖؼÓÔØnginx30 5 1,10,15 * * /usr/local/nginx/sbin/nginx  -s reload#ÌìÌì20: 00ÖÁ22 : 00Ö®¼äÿ¸ô30·ÖÖÓÖؼÓÔØnginx0,30 20-22 * * * /usr/local/nginx/sbin/nginx -s reloadÿÐÇÆÚÁùµÄ10 : 00 pm ÖؼÓÔØnginx0 22* * 6 /usr/local/nginx/sbin/nginx  -s reload#ÿһСʱÖؼÓÔØÒ»´Înginx0 */1 * * * /usr/local/nginx/sbin/nginx -s reload

µÇ¼ºó¸´ÖÆ

expect

Ðí¶àʱ¼äÎÒÃǺÍlinuxµÄ²Ù×÷½»»¥ÐèÒªÈ˹¤¸ÉÔ¤ £¬ÓÐʱ¼äÎÒÃÇ¿ÉÄÜÐèÒªÒ»ÖÖ¹¤¾ß¿ÉÒÔ²»ÐèÒªÈ˹¤¸ÉÔ¤µÄºÍlinux½»»¥ £¬ÕâÀïÒýÈëÁËÒ»¸ö¹¤¾ßexpect,±¾Ð¡½áÎÒÃÇÖ÷ÒªÀ´½²ÔõÑùʹÓÃexpect¡£

expectÏÈÈÝ

TCL(tool command language)ÊÇÒ»ÖÖÀàËÆshell¾ç±¾µÄÓïÑÔ,Äã¿ÉÒÔʹÓÃËûÀ´Íê³ÉÐí¶à²Ù×÷ £¬expectÊÇÔÚËüµÄ»ù´¡ÉÏÉú³¤¶øÀ´µÄ £¬expect»¹ÌṩÁËһЩtclûÓеÄÏÂÁî¡£ÈôÊÇÄãҪдһ¸ö×Ô¶¯´¦ÀíÊäÈëÊä³öµÄ¾ç±¾ £¬ÎÒ½¨ÒéÑ¡Ôñexpect¡£

expect×°ÖÃ

yum install -y expect

expectʹÓÃ
1.½ç˵¾ç±¾Ö´ÐÐʹÓõÄshell¡£     #!/usr/bin/expect2.ÉèÖó¬Ê±Ê±¼ä£¬µ¥Î»ÎªÃë£¬timeout -1 ΪÓÀ²»³¬Ê±¡£        set timeout 23.¿Ç×Ó       spawnÐèÒªÔÚexpectÇéÐÎÏÂÔËÐÐ£¬ÓÃÀ´×ª´ï½»»¥Ö¸Áî¡£ 4.expectÏÂÁî       ÅжÏÊä³öЧ¹ûÊÇ·ñ°üÀ¨Ä³×Ö·û´®£¬Ã»ÓÐÁ¬Ã¦·µ»Ø£¬²»È»¾ÍµÈÒ»¶Îʱ¼äºó·µ»Ø£¬ÓÃtimeoutÉèÖÃÆÚ´ýʱ¼ä¡£5.send        Ö´Ðн»»¥Ðж¯£¬½«½»»¥ÒªÖ´ÐеÄÐж¯¾ÙÐÐÊäÈë¸ø½»»¥Ö¸Áî¡£ÏÂÁî×Ö·û´®×îºóÒª¼ÓÉÏ"\r"£¬ÈôÊÇ·ºÆðÒì³£ÆÚ´ýµÄ״̬¿ÉÒÔ¾ÙÐк˲é¡£6.exp_continue         ¼ÌÐøÖ´ÐнÓÏÂÀ´µÄ½»»¥²Ù×÷¡£7.interact        Ö´Ðкó¼á³Ö½»»¥×´Ì¬£¬°Ñ¿ØÖÆȨ½»¸ø¿ØÖÆ̨£¬Èç²»¼Óinteract£¬½»»¥Íê³É»á×Ô¶¯Í˳ö¡£

µÇ¼ºó¸´ÖÆ

ÃâÃÜÂëͨ¹ýsshÉÏ°¶Ð§ÀÍÆ÷

²Ù×÷¾ç±¾

  batch cat sf#!/usr/bin/expect -fspawn ssh  root@ipexpect {"yes/no" { send "yes\r";exp_continue}"*password:" { send "passwordstr\r" }}interact

µÇ¼ºó¸´ÖÆ

Ö´ÐÐÉó²éЧ¹û £¬ÉÏ°¶ÀÖ³É

  batch ./35spawn ssh root@iproot@ip's password:Last login: Sat Jan  5 10:15:56 2019 from 113.46.187.213Welcome to Alibaba Cloud Elastic Compute Service !

µÇ¼ºó¸´ÖÆ

ÕâЩֻÊÇLinuxµÄ±ùÉÏÒ»½Ç £¬Ð¡±à»¹ÔÚ·ÉÏ £¬Ò»Á¬¸üС£¡£¡£️

  ÉùÃ÷£º±¾ÎIJ¿·ÖËزÄתÔØ×Ô»¥ÁªÍø£¬ÈôÓÐÇÖȨÁ¬Ã¦É¾³ý ¡£

µÇ¼ºó¸´ÖÆ

ÒÔÉϾÍÊÇLinux³£ÓÃÏÂÁî & ÊÊÓÃÏÂÁîÍò×Ö×ܽáµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

13452372176

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ