-p 參數用於建立多級目錄是時。 好比咱們要建立 a 目錄和a目錄下的b目錄:html
mkdir -p a/b
還能夠在多個文件夾下建立,好比在A,B,C 三個目錄下穿件test 目錄:linux
mdkir -p {a,b,c}/test
建立a目錄並在在 a 目錄下建立 b,c 兩個目錄:正則表達式
mkdir -p a/{b,c}
問題: 1 tar: Removing leading `/’ from member names」的錯誤shell
| 其緣由是tar默認爲相對路徑,使用絕對路徑的話就回報這個錯,可使 用-P參數(注意大寫)解決這個問題vim
[root@iZryxshkbkz2x2Z a]# tar -jPcf shell.tar /root/shell
定義: 在文件中搜素符合條件的字符串,若是須要匹配,使用正則表達式進行匹配。服務器
[root@iZryxshkbkz2x2Z ~]# grep savepath ./backups.sh savepath=/root/tar/$(date +%F_%H%M) if [ ! -d $savepath ] mkdir -p $savepath tar -jPcf $savepath/96.tar /www/wwwroot/default/96weixin.ewm
grep -E 'bin|sacepath' ./backups.sh # 重點必定要加E參數。將範本樣式爲延伸的普通表示法來使用,意味着使用能使用擴展正則表達式
grep pattern1 files | grep pattern2 //顯示既匹配 pattern1 又匹配 pattern2 的行。ssh
[root@iZryxshkbkz2x2Z ~]# grep 'mkdir' backups.sh | grep 'savepath' mkdir -p $savepath
[root@iZryxshkbkz2x2Z find]# ls testABC.txt testA.txt testB.txt test.txt [root@iZryxshkbkz2x2Z find]# find . -name test [root@iZryxshkbkz2x2Z find]# find . -name test.txt # 因此find徹底匹配 ./test.txt
***** :tcp
[root@iZryxshkbkz2x2Z find]# ls test testA testABC [root@iZryxshkbkz2x2Z find]# find ./ -name 'test*' ./testABC ./test ./testA
? :工具
[root@iZryxshkbkz2x2Z find]# ls test testA testABC [root@iZryxshkbkz2x2Z find]# find . -name 'test?' ./testA
[] :this
find . -name 'test[AB]' 碰到tes後跟 A 或 B 就返回,注意只返回一個
[root@iZryxshkbkz2x2Z find]# ls test testA testABC testBc [root@iZryxshkbkz2x2Z find]# find . -name 'test[AB]' ./testA
[root@iZryxshkbkz2x2Z ~]# find ./ -mtime 2 ./shell/if.sh ./shell/a.txt ./shell/for.sh ./shell/while.sh ./shell/.until.swp
[root@iZryxshkbkz2x2Z ~]# find . -size +20k -a -size -10M; # 注意,k小寫,M大寫。 ./.acme.sh/acme.sh
https://blog.csdn.net/makang456/article/details/78694120
[root@iZryxshkbkz2x2Z default]# free -m total used free shared buffers cached Mem: 996 883 112 103 62 456 -/+ buffers/cache: 365 630 Swap: 1024 57 967
總內存: total 996M
系統使用內存: userd - free - buffers - cached (-buffer/cached)
系統剩餘內存: free + buffers + cached (+buffer/cached)
[root@iZryxshkbkz2x2Z ~]# cat /proc//meminfo MemTotal: 1019988 kB MemFree: 347060 kB Buffers: 24876 kB Cached: 305160 kB SwapCached: 8828 kB Active: 242408 kB Inactive: 356236 kB Active(anon): 158404 kB Inactive(anon): 216016 kB Active(file): 84004 kB Inactive(file): 140220 kB Unevictable: 0 kB Mlocked: 0 kB
[root@iZryxshkbkz2x2Z ~]# uname -o GNU/Linux
[root@iZryxshkbkz2x2Z ~]# cat /etc/issue CentOS release 6.10 (Final) Kernel \r on an \m
[root@iZryxshkbkz2x2Z ~]# uname -m x86_64
[root@iZryxshkbkz2x2Z ~]# uname -r 2.6.32-696.10.1.el6.x86_64
[root@iZryxshkbkz2x2Z ~]# uname -a Linux iZryxshkbkz2x2Z 2.6.32-696.10.1.el6.x86_64 #1 SMP Tue Aug 22 18:51:35 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@iZryxshkbkz2x2Z ~]# hostname iZryxshkbkz2x2Z
[root@iZryxshkbkz2x2Z ~]# hostname -I 172.17.0.1
[root@iZryxshkbkz2x2Z ~]# cat /etc/resolv.conf nameserver 100.100.2.136 nameserver 100.100.2.138 options timeout:2 attempts:3 rotate single-request-reopen
[root@iZryxshkbkz2x2Z ~]# who root pts/5 2018-08-16 08:13 (222.173.241.202)
未完待續。。。
[root@iZryxshkbkz2x2Z ~]# du -s 51000 .
[root@iZryxshkbkz2x2Z ~]# du -sh 50M .
[root@iZryxshkbkz2x2Z ~]# du -ah 4.0K ./b.docx 4.0K ./backups.sh 4.0K ./.ssh/known_hosts 4.0K ./.ssh/id_rsa 4.0K ./.ssh/id_rsa.pub 4.0K ./.ssh/authorized_keys 20K ./.ssh 4.0K ./firewall.sh 20K ./.cache/pip/http/b/b/8/7/6/bb876b2e6a22c2739002e9ef3388ae978b7a6192a19fe67d8b0030f2 24K ./.cache/pip/http/b/b/8/7/6 28K ./.cache/pip/http/b/b/8/7 32K ./.cache/pip/http/b/b/8 36K ./.cache/pip/http/b/b 40K ./.cache/pip/http/b 4.0K ./.cache/pip/http/f/e/d/0/e/fed0ed508030b766d5b0c2792132c8bf197804464765b46b361f93a4 8.0K ./.cache/pip/http/f/e/d/0/e 12K ./.cache/pip/http/f/e/d/0
[root@iZryxshkbkz2x2Z ~]# du -h --max-depth=1 # 重點 20K ./.ssh 80K ./.cache 4.0K ./.gconf 46M ./tar 8.0K ./.pip 12K ./a 1.7M ./.openoffice 4.0K ./find 600K ./html 56K ./.subversion 184K ./.acme.sh 124K ./shell 1.8M ./.config 8.0K ./.pki 50M .
[root@iZryxshkbkz2x2Z ~]# du -h test.txt 4.0K test.txt
vim /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT # 添加3306 端口
service iptables restart # 重啓iptables
1 shutdow
f
如當即重啓:
shutdown -r now
在5:30 重啓服務器:
[root@iZryxshkbkz2x2Z ~]# shutdown -r 05:30 Broadcast message from root@iZryxshkbkz2x2Z (/dev/pts/5) at 11:12 ... The system is going down for reboot in 1098 minutes!
取消上一個關機命令:
[root@iZryxshkbkz2x2Z ~]# shutdown -c shutdown: Shutdown cancelled [1]+ Done shutdown -r 05:30 [root@iZryxshkbkz2x2Z ~]# shutdown -c shutdown: Cannot find pid of running shutdown
2 其餘關機命令
# halt
# poweroff
# init 0
# reboot
# init 6
並不建議使用以上命令,建議使用shutdown。
3 關於linux init
init命令是Linux下的進程初始化工具,init進程是全部Linux進程的父進程,它的進程號爲1。init命令是Linux操做系統中不可缺乏的程序之一,init進程是Linux內核引導運行的,是系統中的第一個進程
能夠在 在/etc/inittab中查看 # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this) # id:3:initdefault: 中文: #0 停機(千萬不能把initdefault 設置爲0) #1 單用戶模式 #2 多用戶,沒有 NFS(和級別3類似,會中止部分服務) #3 徹底多用戶模式 #4 沒有用到 #5 x11(Xwindow) #6 從新啓動(千萬不要把initdefault 設置爲6)
未完待續 。。。