{"id":8385,"date":"2024-04-25T13:01:01","date_gmt":"2024-04-25T05:01:01","guid":{"rendered":""},"modified":"2024-04-25T13:01:01","modified_gmt":"2024-04-25T05:01:01","slug":"\u6211\u7684Linux\u5b66\u4e60\u4e4b\u65c5","status":"publish","type":"post","link":"https:\/\/mushiming.com\/8385.html","title":{"rendered":"\u6211\u7684Linux\u5b66\u4e60\u4e4b\u65c5"},"content":{"rendered":"

\u4e00\u4e2a\u591a\u6708\u7684\u65f6\u95f4\u5b66\u4e60Linux\u7684\u57fa\u7840\u77e5\u8bc6\uff0c\u770b\u5f97\u662f\u9e1f\u54e5\u7684\u79c1\u623f\u83dc\uff0c\u770b\u4e86\u6709\u4e24\u904d\u5427\u3002\u73b0\u5728\u603b\u7ed3\u4e00\u4e0b\u5e73\u65f6\u7ecf\u5e38\u7528\u5230\u7684\u77e5\u8bc6\u3002<\/span><\/p>\n

date\uff1a<\/span><\/p>\n

\u663e\u793a\u65f6\u95f4\uff0c\u66f4\u591a\u7684\u662f\u7528\u6765\u4ea7\u751f\u4e00\u4e9b\u65f6\u95f4\u683c\u5f0f\u7684\u6587\u4ef6\u5939\uff0c\u5982\uff1a\u751f\u6210\u65e5\u5fd7\u7684\u6587\u4ef6\u5939\u3002<\/span><\/p>\n

bc\uff1a<\/span><\/p>\n

\u8ba1\u7b97\u5668\uff0cquit\u9000\u51fa\uff0c\u4e00\u822c\u7528\u4e0d\u5230\u3002<\/span><\/p>\n

ctrl+alt+F1\uff5eF6\u53ef\u5207\u6362\u4e0d\u540c\u7684\u6587\u5b57\u754c\u9762\uff0c\u4e00\u822c\u7528\u4e8e\uff1a\u5982\u679c\u4e00\u4e2a\u754c\u9762\u6b7b\u6389\u4e86\uff0c\u53ef\u4ee5\u518d\u5207\u6362\u53e6\u4e00\u4e2a\u754c\u9762\u5c06\u5176\u6740\u6b7b\uff0c\u800c\u4e0d\u7528\u91cd\u542f\u8ba1\u7b97\u673a\uff0c\u5f88\u65b9\u4fbf\u7684\u3002ctrl+alt+F7\u5207\u6362\u5230\u6587\u5b57\u754c\u9762\u3002<\/span><\/p>\n

\u5f53\u6307\u4ee4\u592a\u957f\u65f6\u53ef\u7528'\\'\u7b26\u53f7\u6765\u5ef6\u7eed\u5230\u4e0b\u4e00\u884c\u3002<\/span><\/p>\n

shutdown  -r now  \u7acb\u523b\u91cd\u542f<\/span><\/p>\n

shutdown  -h now \u7acb\u523b\u5173\u673a<\/span><\/p>\n

shutdown  -h +10 \u201cguan ji le \u201d \u5341\u5206\u949f\u540e\u5173\u673a\uff0c\u5e76\u5728\u5c4f\u5e55\u4e0a\u663e\u793aguan ji le<\/span><\/p>\n

shutdown  -h 20:35 \u5230\u70b9\u5173\u673a
<\/span><\/p>\n

shutdown  -c \u53d6\u6d88\u5df2\u7ecf\u8fdb\u884c\u7684shutdown\u6307\u4ee4<\/span><\/p>\n

ll **  \u67e5\u770b**\u7684\u5c5e\u6027<\/span><\/p>\n

w\uff1a\u5199 \uff1br\uff1a\u8bfb\uff1bx\uff1a\u53ef\u6267\u884c\uff08\u53ea\u6709\u5f53\u6587\u4ef6\u5939\u662f\u53ef\u6267\u884c\u65f6\u624d\u80fd\u591f\u8fdb\u5165\u8be5\u6587\u4ef6\u5939\uff09<\/span><\/p>\n

r=4<\/span><\/p>\n

w=2<\/span><\/p>\n

x=1
<\/span><\/p>\n

\u4e00\u4e2a\u6587\u4ef6\u7684\u6743\u9650\u9488\u5bf9\u201c\u4e09\u4e2a\u4eba\u201d\u800c\u8a00\uff1a\u6587\u4ef6\u62e5\u6709\u8005\u7684\u6743\u9650(u)\u3001\u6587\u4ef6\u6240\u5c5e\u7684\u7fa4\u7ec4\u4e2d\u4ed6\u4eba\u7684\u6743\u9650(g)\u3001\u5916\u4eba\u7684\u6743\u9650(o)\u3002<\/span><\/p>\n

chgrp aa user \u628a\u5f53\u524duser\u7684\u7fa4\u7ec4\u7684\u540d\u79f0\u6539\u4e3a\u4e86aa<\/span><\/p>\n

chown bb user \u628a\u5f53\u524duser\u7684\u62e5\u6709\u8005\u7684\u540d\u79f0\u6539\u4e3a\u4e86bb<\/span><\/p>\n

chown aa:bb user  \u628a\u5f53\u524duser\u7684\u7fa4\u7ec4\u7684\u540d\u79f0\u6539\u4e3a\u4e86aa\uff0c\u62e5\u6709\u8005\u7684\u540d\u79f0\u6539\u4e3a\u4e86bb<\/span><\/p>\n

chmod 777 file \u6539\u53d8\u4e86file\u7684\u6743\u9650\u4e3a\u53ef\u8bfb\u3001\u53ef\u5199\u3001\u53ef\u6267\u884c
<\/span><\/p>\n

chmod -R 777 mulu \u6539\u53d8mulu\u6587\u4ef6\u5939\u4e0b\u9762\u6240\u6709\u6587\u4ef6\u7684\u6743\u9650\uff08chgrp\u3001chown\u4e5f\u53ef\u4ee5\u6709-R)<\/span><\/p>\n

chmod r=rwx,g=rwx,o=rwx temp
<\/span><\/p>\n

chmod a+w temp
<\/span><\/p>\n

chmod a-x temp<\/span><\/p>\n

\u5f53\u4e00\u4e2a\u8bbe\u7f6e\u4e86SUID\u4f4d\u7684\u53ef\u6267\u884c\u6587\u4ef6\u88ab\u6267\u884c\u65f6\uff0c\u8be5\u6587\u4ef6\u5c06\u4ee5\u6240\u6709\u8005\u7684\u8eab\u4efd\u8fd0\u884c\uff0c\u4e0e\u5c31\u662f\u8bf4\u65e0\u8bba\u8c01\u6765\u6267\u884c\u8fd9\u4e2a\u6587\u4ef6\uff0c\u4ed6\u90fd\u6709\u6587\u4ef6\u6240\u6709\u8005\u7684\u7279\u6743\uff0c\u5982\u679c\u6240\u6709\u8005\u7684\u8eab\u4efd\u662froot\u7684\u8bdd\uff0c\u90a3\u4e48\u6267\u884c\u4eba\u5c31\u6709\u8d85\u7ea7\u7528\u6237\u7684\u8eab\u4efd\u3002
<\/span><\/p>\n

SUID=4,SGID=2
<\/span><\/p>\n

chmod 4777 a.txt    \u6743\u9650\u53d8\u4e3a rwsrwsrwx<\/span><\/p>\n

chmod 6751 a.txt    \u6743\u9650\u53d8\u4e3a rwsrwS--x  \uff08\u5f53\u8bbe\u7f6e\u4e86x\u4f4d\u65f6\uff0c\u5c31\u7528\u5c0fs\uff1b\u6ca1\u6709\u8bbe\u7f6ex\u4f4d\u65f6\uff0c\u5c31\u7528\u5927S\uff09
<\/span><\/p>\n


<\/span><\/p>\n

\u8def\u5f84\uff1acd - \u56de\u5230\u4e0a\u4e00\u76ee\u5f55(\u5f88\u597d\u7528)<\/span><\/p>\n

cd .. \u56de\u5230\u4e0a\u4e00\u5c42\u76ee\u5f55<\/span><\/p>\n

cd \uff5e\u56de\u5230\u7528\u6237\u6839\u76ee\u5f55<\/span><\/p>\n

pwd \u663e\u793a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55<\/span><\/p>\n

mkdir aa \u5efa\u7acb\u4e00\u4e2a\u540d\u79f0\u4e3aaa\u7684\u6587\u4ef6\u5939<\/span><\/p>\n

\u5220\u9664\u4e00\u5207\u4e1c\u897f\u7528\uff1a rm -rf bb \u5f3a\u5236\u5220\u9664\uff08\u8d85\u597d\u7528\uff09<\/span><\/p>\n

ls \u5217\u51fa\u5f53\u524d\u76ee\u5f55\u4e0b\u7684\u4e1c\u897f<\/span><\/p>\n

ls -a \u9690\u85cf\u7684\u4e1c\u4e1c\u4e5f\u4f1a\u5217\u51fa<\/span><\/p>\n

ll \u5217\u51fa\u5c5e\u6027<\/span><\/p>\n

cp \u590d\u5236\u6587\u4ef6<\/span><\/p>\n

cp -r \u590d\u5236\u76ee\u5f55<\/span><\/p>\n

cp -u \u53ea\u5728\u6587\u4ef6\u6709\u6240\u6539\u53d8\u540e\u624d\u4f1a\u8fdb\u884c\u590d\u5236\u3002\uff08\u7528\u4e8e\u5907\u4efd\u6587\u4ef6\uff0c\u53ea\u6709\u5728\u4e0d\u540c\u65f6\uff0c\u624d\u4f1a\u8fdb\u884c\u5907\u4efd)<\/span><\/p>\n

scp \u4e3a\u8fdc\u7a0b\u590d\u5236<\/span><\/p>\n

scp \/home\/aa.txt root@10.52.210.10:\/home \u4f20\u51fa\u6587\u4ef6<\/span><\/p>\n

scp root@10.52.210.10:\/home\/bb.txt \/home \u4f20\u5165\u6587\u4ef6
<\/span><\/p>\n

mv \u79fb\u52a8\u6587\u4ef6<\/span><\/p>\n

mv -r \u79fb\u52a8\u76ee\u5f55<\/span><\/p>\n

mv -u \u53ea\u5728\u6587\u4ef6\u6709\u6240\u6539\u53d8\u540e\u624d\u4f1a\u8fdb\u884c\u79fb\u52a8\u3002<\/span><\/p>\n

\u67e5\u770b\u6587\u4ef6\uff1a<\/span><\/p>\n

cat aa.txt
<\/span><\/p>\n

cat -n \u663e\u793a\u884c\u53f7<\/span><\/p>\n

more less<\/span><\/p>\n

head -n 10 aa \u53ea\u663e\u793aaa\u6587\u4ef6\u7684\u524d\u5341\u884c<\/span><\/p>\n

tail -n 10 aa \u53ea\u663e\u793aaa\u6587\u4ef6\u7684\u540e\u5341\u884c<\/span><\/p>\n

tail -f aa \u52a8\u6001\u663e\u793aaa\u540e\u5341\u884c\uff08\u7ecf\u5e38\u7528\uff09<\/span><\/p>\n

nl \u663e\u793a\u884c\u53f7<\/span><\/p>\n

ln -s aa bb \u7c7b\u4f3c\u4e0ebb\u4e3aaa\u7684\u5feb\u6377\u65b9\u5f0f\uff08\u7b26\u53f7\u94fe\u63a5\u6539\u53d8bb\uff0c\u90a3\u4e48aa\u4e5f\u4f1a\u6539\u53d8\u3002\u5220\u9664aa\uff0c\u90a3\u4e48bb\u5219\u65e0\u6548\uff09<\/span><\/p>\n

umask \u7528\u4e8e\u6307\u5b9a\u5f53\u524d\u7528\u6237\u6240\u5efa\u6587\u4ef6\u548c\u76ee\u5f55\u7684\u9ed8\u8ba4\u5c5e\u6027<\/span><\/p>\n

umask 0000 \u8868\u793a\u6539\u53d8\u5176\u9ed8\u8ba4\u5c5e\u6027\u4e3a777\u201c\u4e09\u4e2a\u4eba\u201d\u90fd\u662f\u53ef\u8bfb\u3001\u53ef\u5199\u3001\u53ef\u6267\u884c\uff08\u4f46\u662f\u4e0b\u6b21\u5f00\u673a\u540e\u5c31\u56de\u590d\u539f\u6765\u9ed8\u8ba4\u7684\uff09<\/span><\/p>\n

\uff08\u82e5\u60f3\u6c38\u8fdc\u7684\u6539\u53d8umask\u7684\u503c\uff0c\u5e94\u5728\/root\/.bashrc\u6587\u4ef6\u4e2d\u52a0\u5165 umask 0000 \u7136\u540e\u4fdd\u5b58\uff0c\u518d\u6267\u884c. .bashrc \u5373\u53ef\uff09<\/span><\/p>\n

\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u67e5\u627e<\/span><\/p>\n

which<\/span><\/p>\n

whereis<\/span><\/p>\n

locate<\/span><\/p>\n

find<\/span><\/p>\n

\u786c\u76d8\u4e0e\u786c\u4ef6\u7ba1\u7406<\/span><\/p>\n

df -h \u67e5\u770b\u786c\u76d8\u7684\u603b\u5bb9\u91cf\u3001\u5df2\u7528\u5bb9\u91cf\u3001\u7cfb\u7edf\u5206\u533a<\/span><\/p>\n

ifconfig \u67e5\u770bip<\/span><\/p>\n

ifconfig eth0 192.168.120.23 netmask 255.255.255.255 broadcast 8.8.8.8  \u914d\u7f6eIP\u5730\u5740
<\/span><\/p>\n

du -sh \u76ee\u5f55\u540d \u53ea\u663e\u793a\u8be5\u76ee\u5f55\u603b\u7684\u5927\u5c0f<\/span><\/p>\n

wc -l \u7edf\u8ba1\u884c\u6570<\/span><\/p>\n

wc -c \u7edf\u8ba1\u5b57\u8282\u6570<\/span><\/p>\n

wc -w \u7edf\u8ba1\u5b57\u6570<\/span><\/p>\n

ssh root@10.52.210.10 \u767b\u5f55\u8fdc\u7a0b\u8ba1\u7b97\u673a<\/span><\/p>\n

md5sum \u4ea7\u751f\u6587\u4ef6\u6307\u7eb9\uff0c\u53ef\u4ee5\u5bf9\u6bd4\u4e24\u4e2a\u6587\u4ef6\u662f\u5426\u76f8\u540c\u3002\u4e5f\u53ef\u4ee5\u67e5\u770b\u67d0\u4e00\u8f6f\u4ef6\u662f\u5426\u4e3a\u6b63\u7248<\/span><\/p>\n

tab \u8865\u5168<\/span><\/p>\n

alias ll=\u2018ls -a -l\u2019 \u547d\u540d\u522b\u540d<\/span><\/p>\n

echo $? \u53ef\u4ee5\u5224\u65ad\u4e0a\u4e00\u6761\u6307\u4ee4\u662f\u5426\u6b63\u786e\uff0c\u4e3a0\uff0c\u5219\u6b63\u786e\u3002\u4e3a1\uff0c\u5219\u6709\u9519\u8bef<\/span><\/p>\n

shell\u811a\u672c<\/span><\/p>\n

\u53d8\u91cf\u7684\u89c4\u5219\uff1a<\/span><\/p>\n

1)=\u94fe\u63a5\u7684\u5de6\u53f3\u4e0d\u80fd\u6709\u7a7a\u683c<\/span><\/p>\n

2)\u53d8\u91cf\u53ea\u80fd\u4e3a\u5b57\u6bcd\u3001\u6570\u5b57\uff0c\u5e76\u4ee5\u5b57\u6bcd\u5f00\u5934<\/span><\/p>\n

3)\u5e94\u7528\u53d8\u91cf\u8981\u52a0$
<\/span><\/p>\n

4)\u82e5\u6709\u7a7a\u683c\u5e94\u7528\u201c \u201d \u6216\u2018 \u2019\u3002\u4e8c\u8005\u7684\u533a\u522b\uff1a\u201c \"\u4f1a\u4fdd\u7559\u53d8\u91cf\u7684\u7279\u6027\uff1b\u800c\u2018 \u2019\u503c\u662f\u8f93\u51fa\u5176\u4e2d\u7684\u5b57\u7b26<\/span><\/p>\n

name=vbird<\/span><\/p>\n

my=\"$name its me\"<\/span><\/p>\n

my2='$name its me'<\/span><\/p>\n

my3=\"${name}itsme\"  \u548c\u53d8\u91cf\u76f8\u8fde\u8981\u7528{ }\u533a\u5206\u51fa\u6765
<\/span><\/p>\n

echo $my     (\u7ed3\u679c\u4e3avbirdits me)
<\/span><\/p>\n

echo $my2   (\u7ed3\u679c\u4e3a$name its me)<\/span><\/p>\n

echo $my3   (\u7ed3\u679c\u4e3anameitsme)
<\/span><\/p>\n

5)export a \u5219\u53d8\u91cfa\u53ef\u4ee5\u5728\u5176\u4ed6\u5b50\u7a0b\u5e8f\u4e2d\u4f7f\u7528<\/span><\/p>\n

6)unset a \u53d6\u6d88\u53d8\u91cf<\/span><\/p>\n

vi\u7f16\u8f91\u5668\u4e2d\u7684\u6307\u4ee4<\/span><\/p>\n

\u4e00\u822c\u6a21\u5f0f\u4e0b\uff1a
<\/span><\/p>\n

0 \u96f6 \u5149\u6807\u79fb\u52a8\u5230\u672c\u884c\u7684\u884c\u9996<\/span><\/p>\n

$ \u5149\u6807\u79fb\u52a8\u5230\u672c\u884c\u7684\u884c\u5c3e<\/span><\/p>\n

G \u5149\u6807\u79fb\u52a8\u5230\u8be5\u6587\u4ef6\u7684\u6700\u540e\u4e00\u884c<\/span><\/p>\n

nG \u5149\u6807\u79fb\u52a8\u5230\u7b2cn\u884c
<\/span><\/p>\n

gg \u5149\u6807\u79fb\u52a8\u5230\u8be5\u6587\u4ef6\u7684\u7b2c\u4e00\u884c<\/span><\/p>\n

n<enter> \u5149\u6807\u5411\u4e0b\u79fb\u52a8n\u884c<\/span><\/p>\n

n<\u7a7a\u683c> \u5149\u6807\u5411\u540e\u79fb\u52a8n\u4e2a<\/span><\/p>\n

dd \u5220\u9664\u5149\u6807\u6240\u5728\u884c<\/span><\/p>\n

yy \u590d\u5236\u5149\u6807\u6240\u5728\u884c<\/span><\/p>\n

p \u7c98\u8d34\u5230\u5149\u6807\u7684\u4e0b\u4e00\u884c<\/span><\/p>\n

U \u6062\u590d\u4e0a\u4e00\u6b65<\/span><\/p>\n

ctrl + r \u4e0eU\u662f\u76f8\u53cd\u7684\u64cd\u4f5c<\/span><\/p>\n

. \u91cd\u590d\u524d\u4e00\u4e2a\u64cd\u4f5c
<\/span><\/p>\n

\u7f16\u8f91\u6a21\u5f0f\uff1a<\/span><\/p>\n

i \u5149\u6807\u6240\u5728\u5b57\u7b26\u524d\u63d2\u5165
<\/span><\/p>\n

a\u5149\u6807\u6240\u5728\u5b57\u7b26\u540e\u63d2\u5165<\/span><\/p>\n

o \u5149\u6807\u7684\u4e0b\u4e00\u884c\u63d2\u5165<\/span><\/p>\n

\u547d\u4ee4\u884c\u6a21\u5f0f\uff1a<\/span><\/p>\n

:set nu \u663e\u793a\u884c\u53f7<\/span><\/p>\n

:wq \u4fdd\u5b58\u9000\u51fa :q! \u5f3a\u5236\u9000\u51fa<\/span><\/p>\n

\/ab \u5728\u8be5\u6587\u4ef6\u4e2d\u67e5\u627eab \uff08n\u4e3a\u67e5\u627e\u4e0b\u4e00\u4e2a\uff0cN\u4e3a\u67e5\u627e\u4e0a\u4e00\u4e2a\uff09<\/span><\/p>\n

\u4e2a\u4eba\u8bbe\u5b9a\uff1a<\/span><\/p>\n

\u5728root\u4e2d\uff0c\u6216cd ~\u4e2d\uff0c\u603b\u4e4b\u662f\u5728\u5f53\u524d\u7528\u6237\u7684\u6839\u76ee\u5f55\u4e0b\u4e2d\u7684.bashrc\u6587\u4ef6\u4e2d\u53ef\u4ee5\u8bbe\u5b9a\uff0c\u5982\uff1a\u547d\u540d\u522b\u540d\u3001\u8def\u5f84\u5b9a\u4e49\u3001umask\u7684\u8bbe\u5b9a\uff0c\u4fdd\u5b58\u4e4b\u540e\u8981\u6267\u884csource .bashrc \u624d\u80fd\u751f\u6548\u3002<\/span><\/p>\n

ctrl+H \u663e\u793a\u9690\u85cf\u7684\u4e1c\u4e1c<\/span><\/p>\n

\u8fde\u7eed\u7684\u6307\u4ee4 && \u548c ||
<\/span><\/p>\n

command1, command2 \u5168\u90e8\u6267\u884c\u4e24\u6761\u6307\u4ee4
<\/span><\/p>\n

command1 && command2  \u53ea\u6709\u5f53command1\u6267\u884c\u6b63\u786e\u540e\u624d\u6267\u884ccommand2<\/span><\/p>\n

command1 || command2  \u53ea\u6709\u5f53command1\u6267\u884c\u9519\u8bef\u540e\u624d\u6267\u884ccommand2<\/span><\/p>\n

ctrl + C \u4e2d\u6b62<\/span><\/p>\n<\/p>\n

ctrl + D \u7ed3\u675f\u8f93\u5165
<\/span><\/p>\n

ctrl + Z \u6682\u505c\u5f53\u524d\u6307\u4ee4<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n

>a.txt \u8986\u76d6\u5230a\u4e2d
<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n

>>a.txt \u7d2f\u52a0\u5230a\u7684\u540e\u9762<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n

tee a.txt \u8f93\u5165\u5230a.txt\u4e2d\uff0c\u5e76\u4e14\u5728\u5c4f\u5e55\u4e0a\u663e\u793a\uff0c\u540e\u9762\u8fd8\u53ef\u4ee5\u518d\u63a5\u5176\u4ed6\u7684\u7ba1\u7ebf\u547d\u4ee4\u3002
<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n

\u7ba1\u7ebf\u547d\u4ee4\uff1a<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n

cut -d \":\" -f 2 \uff08\u4ee5\uff1a\u4e3a\u5206\u5272\u526f\uff0c\u53ea\u663e\u793a\u51fa\u7b2c2\u533a\u5757\uff09<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n

cut -c 1-20     (\u4e4b\u663e\u793a\u51fa1\u523020\u4e2a\u5b57\u7b26\uff09<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n


<\/span><\/p>\n

sort \u4ee5\u884c\u4e3a\u5355\u4f4d\uff0c\u6bd4\u8f83\u9996\u5b57\u7b26\uff0c\u9ed8\u8ba4\u6309\u5347\u5e8f\u6392\u5e8f\u3002<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n

sort -r \u7edb\u5e8f<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n

sort -n \u6309\u6570\u5b57\u5927\u5c0f\u8fdb\u884c\u6392\u5e8f<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n

sort  -n -r -t \":\" -k 2 \u6309\uff1a\u8fdb\u884c\u5206\u5757\u540e\u7684\u7b2c\u4e8c\u5757\u6309\u6570\u5b57\u8fdb\u884c\u7edb\u6392\u5e8f<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n


<\/span><\/p>\n

grep -c ljg  \u8f93\u51fa\u542b\u6709ljg\u884c\u7684\u603b\u6570<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n

grep -v ljg \u8f93\u51fa\u4e0d\u542b\u6709ljg\u7684\u884c
<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n

grep 'tea' \/home\/name1 \/home\/name2  \u53ef\u4ee5\u5728\u591a\u4e2a\u6587\u4ef6\u4e2d\u5217\u51fa<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n

pgrep cmd \u4e13\u95e8\u7528\u4e8e\u8fdb\u7a0b\u67e5\u8be2\uff0c\u53ea\u8f93\u51fa\u8be5\u6307\u4ee4\u7684PID<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n


<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n


<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n

uniq \u91cd\u590d\u7684\u884c\u53ea\u663e\u793a\u4e00\u4e2a<\/span><\/p>\n

uniq -d \u53ea\u663e\u793a\u91cd\u590d\u7684\u884c<\/span><\/p>\n

tr -d ab \u5220\u9664\u6587\u4ef6\u4e2d\u7684\u6240\u6709\u5b57\u7b26a\uff0c\u548c\u5b57\u7b26b\u3002\u800c\u4e0d\u662f\u53ea\u5220\u9664ab\u5b57\u7b26\u4e32<\/span><\/p>\n

tr '[a-z]' '[A-Z]' \u5c06\u6240\u6709\u7684\u5c0f\u5199\u5b57\u6bcd\u8f6c\u6362\u4e3a\u5927\u5199\u5b57\u6bcd<\/span><\/p>\n

tr 'ljg' 'tsh' \u610f\u5473\u7740\u628a\u8bf4\u6709\u7684l\u6362\u4e3at\uff0cj\u6362\u4e3as\uff0cg\u6362\u4e3ah\u3002\uff08\u6ce8\u610f\uff1a\u4e0d\u662f\u53ea\u628aljg\u6362\u4e3atsh\uff09
<\/span><\/p>\n

\u89e3\u538b\u7f29\u6307\u4ee4\uff1a<\/span><\/p>\n

unzip name \uff08\u7528\u4e8e*.zip\uff09
<\/span><\/p>\n

uncompress name \uff08\u7528\u4e8e*.z\uff09<\/span><\/p>\n

bzip2 -d name \uff08\u7528\u4e8e*.bz2\uff09
<\/span><\/p>\n

gzip -d name \uff08\u7528\u4e8e*.gz)<\/span><\/p>\n

tar\u4e2d -x\u662f\u89e3\u538b\uff0c-c\u662f\u538b\u7f29\uff0c-z\u662f\u540e\u7f00\u4e2d\u6709.gz
<\/span><\/p>\n

tar -zxvf name \uff08\u7528\u4e8e*.tar.gz\uff09
<\/span><\/p>\n

tar -xvf name \uff08\u7528\u4e8e*.tar\uff09
<\/span><\/p>\n

tar -cxvf name \u538b\u7f29\u6587\u4ef6 <\/span><\/p>\n


<\/span><\/p>\n

\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5c5e\u6027\u4e2d\u4e00\u5b9a\u6709x\u5c5e\u6027\u3002.\/test.sh<\/span><\/p>\n


<\/span><\/p>\n

declare\u58f0\u660e\u53d8\u91cf<\/span><\/p>\n

-a \u6570\u7ec4<\/span><\/p>\n

-f \u51fd\u6570<\/span><\/p>\n

-i \u6574\u578b<\/span><\/p>\n

read name \u4ece\u952e\u76d8\u4e0a\u8bfb\u53d6\u5185\u5bb9<\/span><\/p>\n

echo $name \u8f93\u51fa<\/span><\/p>\n

.\/test.sh a b c d \u5176\u4e2d\u6587\u4ef6\u540d\u4e3a$0, \u53c2\u6570a\u4e3a$1, b\u4e3a$2<\/span><\/p>\n

if\u7684\u4f7f\u7528\uff1a<\/span><\/p>\n

if [ \"$y\" = \"y\" ] || [ \"$y\" = \"Y\" ];  \uff08\u6ce8\u610f\uff1a[\u548c\u201c \uff0c\u201d\u548c]\u4e4b\u95f4\u90fd\u8981\u6709\u7a7a\u683c\uff09
<\/span><\/p>\n

then<\/span><\/p>\n

......<\/span><\/p>\n

fi<\/span><\/p>\n

for\u5faa\u73af<\/span><\/p>\n

declare -i s<\/span><\/p>\n

for (( i=i; i<=100; i=i+1))   \uff08\u6ce8\u610f\uff1a\u8fd9\u662f\u6709\u4e24\u4e2a\uff08\uff09\uff09
<\/span><\/p>\n

do<\/span><\/p>\n

s=s+i<\/span><\/p>\n

done<\/span><\/p>\n

\u53e6\u4e00\u79cdfor\u5faa\u73af<\/span><\/p>\n

LIST=\"tomy jony mary geoge\"<\/span><\/p>\n

for i in $LIST<\/span><\/p>\n

do<\/span><\/p>\n

echo $i<\/span><\/p>\n

done<\/span><\/p>\n

while\u5faa\u73af<\/span><\/p>\n

declare -i i<\/span><\/p>\n

declare -i s<\/span><\/p>\n

while [ \"$i\" != \"101\u201c ]<\/span><\/p>\n

do<\/span><\/p>\n

s=s+1<\/span><\/p>\n

i=i+1<\/span><\/p>\n

done<\/span><\/p>\n


<\/span><\/p>\n


<\/span><\/p>\n

sh -n test.sh \u67e5\u770b\u811a\u672c\u7684\u8bed\u6cd5\uff0c\u82e5\u6709\u9519\u8bef\u5219\u5217\u51fa\u3002<\/span><\/p>\n

\u5e10\u53f7\u7ba1\u7406\uff1a<\/span><\/p>\n

\/etc\/passwd  \u7528\u6237\u5e10\u53f7      \/etc\/shadow \u5bc6\u7801      \/etc\/group  \u7fa4\u5e10\u53f7      \/etc\/gshadow  \u7fa4\u5bc6\u7801<\/span><\/p>\n

groups \u663e\u793a\u51fa\u8be5\u5e10\u53f7\u90fd\u5b58\u5728\u4e0e\u54ea\u4e9b\u7ec4\u5f53\u4e2d
<\/span><\/p>\n

groupadd -g 55 testing  \u5efa\u7acb\u4e00\u4e2aGID\u4e3a55\u7684\u7fa4\u7ec4<\/span><\/p>\n

groupdel testing \u5220\u9664\u7fa4\u7ec4 \uff08\u82e5\u6709\u7528\u6237\uff0c\u5219\u5fc5\u987b\u5148\u5220\u9664\u7528\u6237\uff09<\/span><\/p>\n

\u65b0\u52a0\u4e00\u7528\u6237\uff1a
<\/span><\/p>\n

1\uff09useradd -m ljg \u5efa\u7acb\u4e00\u4e2a\u7528\u6237\uff0c\u540d\u79f0\u4e3aljg \uff08-m \u4e3a\u751f\u6210\u6839\u76ee\u5f55\uff0c\u4e0d\u7136\u5219\u8fdb\u4e0d\u5230ljg\u4e2d\uff09
<\/span><\/p>\n

2\uff09passwd ljg  \u8bbe\u7f6e\u5bc6\u7801
<\/span><\/p>\n

userdel ljg \u5220\u9664\uff08\u53ea\u5220\u9664passwd\u548cshadow\u4e2d\u7684\u4e1c\u897f\uff09
<\/span><\/p>\n

user -r ljg \u5c06\u7528\u6237\u7684\u4e00\u5207\u6570\u636e\u90fd\u5220\u9664<\/span><\/p>\n

su \u8f6c\u6362\u4e3aroot\u8eab\u4efd<\/span><\/p>\n

su -
<\/span><\/p>\n

su ljg \u5207\u6362\u4e3aljg\u8eab\u4efd<\/span><\/p>\n

su -l ljg<\/span><\/p>\n

su \u8fdb\u884c\u8eab\u4efd\u8f6c\u6362\u65f6\u8981\u8f93\u5165\u5bf9\u65b9\u7684\u5bc6\u7801\uff0c\u4f46\u7528sudo\u4e0d\u80fd\u5207\u6362\u8eab\u4efd\uff0c\u4f46\u662f\u53ef\u4ee5\u5728\u5bf9\u65b9\u7528\u8bdd\u4e0b\u8fdb\u884c\u4e00\u5b9a\u7684\u64cd\u4f5c<\/span><\/p>\n

sudo -u ljg shutdown -h now \u5e76\u4e14\u53ea\u9700\u8981\u8f93\u5165\u81ea\u5df1\u7684\u5bc6\u7801\u3002
<\/span><\/p>\n

at\u4ec5\u6267\u884c\u4e00\u6b21\u7684\u4f7f\u7528\u65b9\u6cd5\uff1a<\/span><\/p>\n

1\uff09\u8f93\u5165 at 5:30 2014-06-01 \u56de\u8f66    \uff08at now +5 minutes,          \u4e5f\u53ef\u4e00\u662fhours\u3001days\u3001weeks\uff09
<\/span><\/p>\n

2\uff09\u8fdb\u5165at>\u547d\u4ee4\u6a21\u5f0f\uff0c\u8f93\u5165\u8981\u6267\u884c\u7684\u547d\u4ee4\uff0cshutdown -h now<\/span><\/p>\n

3\uff09ctrl + D\u5219\u4fdd\u5b58\u9000\u51fa\u3002\u5e76\u4e14\u9000\u51fa\u4e4b\u540e\u663e\u793a\u8be5\u5de5\u4f5c\u7684\u7f16\u53f7\u5982\uff1ajob 3 at thu may 1 05:30:00 2014<\/span><\/p>\n

4\uff09atq \u67e5\u770b\u5f53\u524d\u6240\u6709\u7684at\u5de5\u4f5c<\/span><\/p>\n

5\uff09atrm 3 \u5220\u9664\u4e0a\u9762\u7684at\u5de5\u4f5c\u3002<\/span><\/p>\n

crontab\u5faa\u73af\u6267\u884c\u7684\u4f7f\u7528\u65b9\u6cd5\uff1a<\/span><\/p>\n

\u8f93\u5165crontab -e \u8fdb\u5165crontab\u7f16\u8bd1<\/span><\/p>\n

\u8f93\u5165\u547d\u4ee4\u7684\u683c\u5f0f\u4e3a\uff1a  \u5206 \u65f6 \u65e5 \u6708 \u5468   \u547d\u4ee4     *\u8868\u793a\u6240\u6709\u6570\u7ec4\u90fd\u9002\u7528<\/span><\/p>\n

\u5982\uff1a59 23 1 5 *  mail xiaozhu <\/home\/test\/test.txt   \u8868\u793a\u5728\u6bcf\u5e74\u76845\u67081\u65e523:59\u90fd\u4f1a\u628a\u90ae\u4ef6test.txt\u7684\u5185\u5bb9\u53d1\u9001\u7ed9xiaozhu<\/span><\/p>\n

\u5982\uff1a*\/5 * * * * sh \/home\/test\/test.sh  \u8868\u793a\u6bcf\u96945\u5206\u949f\u6267\u884c\u4e00\u6b21<\/span><\/p>\n

\u4f46\u5f53\u6709\u591a\u4e2a\u4efb\u52a1\u90fd\u662f\u6bcf\u96945\u79d2\u6267\u884c\u4e00\u6b21\uff0c\u8fd9\u6837\u4f1a\u589e\u52a0\u7cfb\u7edf\u5728\u67d0\u4e00\u65f6\u523b\u7684\u8d1f\u62c5\uff0c\u53ef\u4ee5\u8fd9\u6837<\/span><\/p>\n

1,6,11,16.....51,56 * * * * cmd1<\/span><\/p>\n

2,7,12,17.....52,57 * * * * cmd2 \u8fd9\u6837\u53ef\u4ee5\u89e3\u51b3\uff0c\u5176\u4e2d\u7684......\u4e0d\u80fd\u7701\u7565\uff0c\u5fc5\u987b\u4e00\u4e2a\u4e00\u4e2a\u7684\u5217\u51fa<\/span><\/p>\n

crontab -l \u67e5\u770b\u6240\u6709\u7684crontab\u6d41\u7a0b<\/span><\/p>\n

crontab -r \u5220\u9664\u6240\u6709\u7684crontab\u6570\u636e\u3002\uff08\u82e5\u8981\u5220\u9664\u67d0\u4e00\u6761\uff0c\u7528crontab -e\u8fdb\u5165\u7f16\u8bd1\u4e2d\u53bb\u5220\u9664\uff09<\/span><\/p>\n

* \u4ee3\u8868\u6240\u6709\u53ef\u80fd<\/span><\/p>\n

\uff0c\u9694\u5f00 1\uff0c5\uff0c9<\/span><\/p>\n

- \u5236\u5b9a\u8303\u56f4 2-6<\/span><\/p>\n

*\/n \u8868\u793a\u65f6\u95f4\u95f4\u9694\u9891\u7387<\/span><\/p>\n

crontab -e \u662f\u5904\u7406\u7528\u6237\u4f8b\u884c\u6027\uff0c\u5373\u6539\u53d8\u7684\u662f\/usr\/bin\/crontab\u7684\u5185\u5bb9<\/span><\/p>\n

\u82e5\u8981\u662f\u8bbe\u7f6e\u201c\u7cfb\u7edf\u7684\u4f8b\u884c\u6027\u4efb\u52a1\u201d\u76f4\u63a5vim \/etc\/crintab,\u6309\u7167\u5df2\u6709\u7684\u4f8b\u5b50\u6dfb\u52a0\u5373\u53ef\u3002
<\/span><\/p>\n

\u811a\u672c\u7684\u903b\u8f91\u5224\u65ad\uff1a<\/span><\/p>\n

eq  =<\/span><\/p>\n

ne \uff01=<\/span><\/p>\n

lt     <<\/span><\/p>\n

gt    ><\/span><\/p>\n

le    <=<\/span><\/p>\n

ge   >=<\/span><\/p>\n

a     and<\/span><\/p>\n

o     or<\/span><\/p>\n

z     \u7a7a\u5b57\u7b26\u4e32<\/span><\/p>\n

n    \u975e\u7a7a\u5b57\u7b26\u4e32<\/span><\/p>\n


<\/span><\/p>\n

ps -auxh | grep  xxx    \u67e5\u770b\u8fdb\u7a0bxxx \uff08\u4f1a\u5217\u51fa\u7528\u6237\u540d\u3001PID\u3001CPU\u548cMEM\u7684\u4f7f\u7528\u60c5\u51b5\u3001tty1-6\u8868\u793a\u4e3a\u672c\u673a\u767b\u5f55\u8005 pts\/\uff1f\uff1f\u8868\u793a\u4e3a\u8fdc\u7a0b\u767b\u5f55\u8005\u3001\u8fd0\u884c\u72b6\u6001\u3001\u5f00\u59cb\u8fd0\u884c\u7684\u65e5\u671f\u3001\u8fd0\u884c\u7684\u65f6\u95f4\u3001\u6307\u4ee4\u540d\u79f0\uff09<\/span><\/p>\n

ps\u540e\u7684\u8fd0\u884c\u72b6\u6001<\/span><\/p>\n

R \u8fd0\u884c<\/span><\/p>\n

S \u4e2d\u65ad<\/span><\/p>\n

T \u505c\u6b62<\/span><\/p>\n

D \u4e0d\u53ef\u4e2d\u65ad<\/span><\/p>\n

Z \u50f5\u6b7b \uff08\u4e14ps\u540e\u7684\u6307\u4ee4\u540d\u79f0\u4e2d\u663e\u793a<defunct>\uff09 ps auxh | grep defunct \u53ef\u4ee5\u5217\u51fazombie\u8fdb\u7a0b
<\/span><\/p>\n

top\u4e2d\u7684\u7b2c\u4e8c\u884c\u7684zombie\u8868\u793a\u50f5\u5c38\u8fdb\u7a0b\u7684\u4e2a\u6570
<\/span><\/p>\n

top\u52a8\u6001\u663e\u793a\u8fdb\u7a0b\u7684\u4fe1\u606f\uff0c\u9ed8\u8ba4\u6bcf\u96945\u79d2\u5237\u65b0\u4e00\u6b21\u3002<\/span><\/p>\n

top -d 1 \u6539\u53d8\u5237\u65b0\u65f6\u95f4\u4e3a1\u79d2\u4e00\u6b21<\/span><\/p>\n

top -p 1278 \u53ea\u89c2\u5bdfPID\u4e3a1278<\/span><\/p>\n

top | grep cmd \u53ea\u89c2\u5bdf\u6307\u4ee4cmd
<\/span><\/p>\n

who \u663e\u793a\u767b\u5f55\u65f6\u95f4<\/span><\/p>\n

w \u663e\u793auptime\u548cwho\u7684<\/span><\/p>\n

last \u663e\u793a\u8fd1\u671f\u7528\u6237\u6216\u7ec8\u7aef\u7684\u767b\u5f55\u60c5\u51b5<\/span><\/p>\n

hostname \u663e\u793a\u4e3b\u673a\u540d<\/span><\/p>\n

df -h \u67e5\u770b\u6587\u4ef6\u7cfb\u7edf\u5927\u5c0f\u548c\u4f7f\u7528\u60c5\u51b5<\/span><\/p>\n

free -m \u663e\u793a\u5185\u5b58\u3001SWAP\u7684\u5927\u5c0f\u548c\u4f7f\u7528\u60c5\u51b5
<\/span><\/p>\n

fdisk -l<\/span><\/p>\n

command & \u540e\u53f0\u8fd0\u884c<\/span><\/p>\n

time command \u4fa6\u6d4b\u4e00\u4e2a\u8fdb\u7a0b\u6240\u9700\u8981\u7684\u65f6\u95f4<\/span><\/p>\n

route -n \u663e\u793a\u8def\u7531\u5668<\/span><\/p>\n

netstat -antlp \u67e5\u770b\u672c\u673a\u5404\u7aef\u53e3\u7684\u7f51\u7edc\u8fde\u63a5<\/span><\/p>\n

diff \u548c cmp \u6bd4\u8f83\u4e24\u4e2a\u6587\u4ef6\u7684\u4e0d\u540c\u4e4b\u5904<\/span><\/p>\n

dmesg \u663e\u793a\u5f00\u673a\u4fe1\u606f<\/span><\/p>\n

\u7528\u6237\u5bf9\u8bdd\uff1a<\/span><\/p>\n

write \u9488\u5bf9\u4e00\u4e2a\u5728\u7ebf\u7528\u6237 
<\/span><\/p>\n

wall \u9488\u5bf9\u6240\u6709\u5728\u7ebf\u7528\u6237
<\/span><\/p>\n

mail \u53ef\u4ee5\u5b9e\u73b0\u79bb\u7ebf\u4f20\u8f93<\/span><\/p>\n

\u6740\u6b7b\u8fdb\u7a0b\uff1a<\/span><\/p>\n

kill %\u5de5\u4f5c\u53f7<\/span><\/p>\n

kill PID<\/span><\/p>\n

pkill -9 cmd (\u6307\u4ee4\u7684\u540d\u79f0\u53ef\u4ee5\u53ea\u8f93\u5165\u4e00\u90e8\u5206)<\/span><\/p>\n

pkill -u \u7528\u6237\u540d  \u53ef\u4ee5\u6740\u6b7b\u7528\u6237  \uff08\u5f53userdel -r ljg\uff0c\u663e\u793a\u7528\u6237ljg\u76ee\u524d\u5df2\u767b\u5f55\u3002\u53ef\u4ee5\u7528pkill -u\u6765\u89e3\u51b3\uff09
<\/span><\/p>\n

killall -9 cmd<\/span><\/p>\n

xkill \u7528\u4e8e\u5173\u95ed\u56fe\u50cf\u754c\u9762\uff08\u5f53\u4e00\u8f6f\u4ef6\u6b7b\u540e\uff0c\u4e0d\u80fd\u5173\u95ed\u7a97\u53e3\uff0c\u53ef\u4ee5\u8fd9\u6837\u505a\uff09
<\/span><\/p>\n

pstree \u5217\u51fa\u6240\u6709\u8fdb\u7a0b\u7684\u5173\u8054\uff0c\u53ef\u4ee5\u627e\u51fa\u7236\u8fdb\u7a0b<\/span><\/p>\n

\uff08\u82e5\u6740\u6b7b\u4e0d\u4e86\u4e00zombie\u8fdb\u7a0b\uff0c\u53ef\u4ee5\u7528pstree\u67e5\u627e\u51fa\u5176\u7236\u8fdb\u7a0b\uff0c\u6765\u6740\u5176\u7236\u8fdb\u7a0b\uff09
<\/span><\/p>\n

\u6240\u6709\u7684\u8fdb\u7a0b\u90fd\u5b58\u5728\u4e8e\/proc\u4e2d\uff0c\u4ee5PID\u53f7\u4e3a\u76ee\u5f55\u540d\u3002
<\/span><\/p>\n


<\/span><\/p>\n


<\/span><\/p>\n


<\/span><\/p>\n


<\/span><\/p>\n


<\/span><\/p>\n


<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"\u6211\u7684Linux\u5b66\u4e60\u4e4b\u65c5\u4e00\u4e2a\u591a\u6708\u7684\u65f6\u95f4\u5b66\u4e60Linux\uff0c\u5e93_list=\"tomyjonymarygeoge\"\u7a7a\u683c\u5065fenge","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8385"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=8385"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8385\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=8385"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=8385"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=8385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}