1、linux磁盘管理,如何扩展分区、格式化、挂载、解挂、永久挂载见下一篇BLOG。2、整理DELL R720 CPU:Intel Xeon E5-2630的资料,操作手册、安装操作系统(windows\linux)、(U盘\光盘)引导安装、RAID设置、F10界面操作等、F11引导菜单3、vi命令查找、修改、匹配行后插入命令模式下:按小写y两次,即yy,复制一行,再按p粘贴按dd,删除一行按x删除字符,往后删除按小写u,还原删错的字符或内容命令模式下,文本内容替换::%s/liuyong/liuy/g------------>将liuyong全部替换成liuy:%s/liuyong/liuy/1------------>将最后一行的liuyong替换成liuy技巧::%s/liuyong/ liuyong/g,在liuyong前面加一个空格:%s/^/& /g,在每一行的开头加空格:%s/$/& /g,在每一行的最后加空格插入:按小写的字母o,在行后插入一行按大写的字母O,在行前插入一行光标快速移动:两个小写的gg,移到文件最前面一个大写的字母G,移到文件最后面查找与匹配:按键盘上的“/”,在“/”后面输入要查找内容,回车后,光标跳到查找到的内容处,再按小写的n,往下匹配,大写的N,往上匹配;按dG,删除光标所在行直到文件结尾。:wq,保存再退出:q!,不保存退出4、sed命令格式:sed 's/替换前内容/替换后内容/g' /etc/selinux/config s是查找,g是全局,不带-i是显示替换,看效果sed -i 's/替换前内容/替换后内容/g' /etc/selinux/config s是查找,g是全局,带-i是真实替换sed '/匹配内容/s/替换前内容/替换后内容/g' /etc/selinux/config+++++++++++++++++++++++++++++++++替换操作++++++++++++++++++++++++++++++++++++++[root@goodluck ~]# cat vitest.txt My name is liuy ! My name is liuy ! My name is liuy ![root@goodluck ~]# sed 's/liuy/12345678/g' vitest.txt ------------->将liuy替换成12345678,只是显示替换,并未真正替换vitest.txt里的内容 My name is 12345678 ! My name is 12345678 ! My name is 12345678 ![root@goodluck ~]# sed -i 's/liuy/12345678/g' vitest.txt ------------>带“-i”参数,才真正替换vitest.txt里的内容 [root@goodluck ~]# cat vitest.txt My name is 12345678 ! My name is 12345678 ! My name is 12345678 !+++++++++++++++++++++++++++++++++插入操作++++++++++++++++++++++++++++++++++++++[root@goodluck ~]# cat vitest.txt My name is 12345678 ! bluesky My name is 12345678 ! [root@goodluck ~]# sed '/bluesky/i redsky' vitest.txt -------------------->在bluesky前面插入一行redsky My name is 12345678 ! redskybluesky My name is 12345678 ! [root@goodluck ~]# sed '/bluesky/a redsky' vitest.txt -------------------->在bluesky后面插入一行redsky My name is 12345678 ! blueskyredsky My name is 12345678 !sed技巧命令:例子:sed 's/disabled/enforcing/g' /etc/selinux/config----------------->这样子替换,会将disabled全替换成enforcing,不精确,如下:sed '/SELINUX/s/disabled/123456/g' /etc/selinux/config------------------>先匹配“SELINUX”,然后将“disabled”替换成“123456”,这样很精确替换。5、find命令,替换[root@goodluck ~]# find . -name "vitest.txt"----------->当前目录查找文件名为vitest.txt的 ./vitest.txt[root@goodluck ~]# find / -name "vitest.txt"----------->从根目录查找,慎用!效率很差。 [root@goodluck ~]# find . -name "vitest.txt" -type d------------>"-type d"是指查找目录[root@goodluck ~]# find . -name "vitest.txt" -type f------------>"-type d"是指查找文件查找某个时候修改的目录[root@goodluck ~]# find . -name "vitest.txt" -type d -mtime +1------------>"d -mtime +1"是指查找一天前的[root@goodluck ~]# find . -name "vitest.txt" -type d -mtime -1------------>"d -mtime +1"是指查找一天内的[root@goodluck ~]# ll vitest.txt-rw-r--r-- 1 root root 233 Mar 4 09:20 vitest.txt[root@goodluck ~]# find . -name "vitest.txt" -type f -mtime +1[root@goodluck ~]# find . -name "vitest.txt" -type f -mtime -1./vitest.txt[root@goodluck ~]# find /mnt/hgfs/liuyong -name "*" -type f -mtime +1 -size +10M-------->查找liuyong目录下所有的,一天前的,大于10M的文件/mnt/hgfs/liuyong/MySQL-5.7.4-m14-1.linux_glibc2.5.x86_64.rpm-bundle.tar[root@goodluck ~]# find /mnt/hgfs/liuyong -name "MySQL*" -type f -mtime +1 -size +10M -exec cp {} /root/ \;------------------->查找liuyong目录下所有的,一天前的,大于10M的文件,然后复制到/root下 [root@goodluck ~]# find /tmp/ -name "*.sql" -exec tar czf mysql.tar.gz {} \;---------->找到sql文件后,打包[root@goodluck ~]# find /tmp/ -name "*.sql" -exec rm -rf {} \;另外:[root@goodluck ~]# find /tmp/ -name "*.sql" |xargs rm -rf {} \;------------>xargs是传参数,一般与rm结合使用,其它用-exec经测试,以下两条命令,结果是一样的:[root@goodluck ~]# find /root/ -name "MySQL*" |xargs rm -rf [root@goodluck ~]# find /root/ -name "MySQL*" |xargs rm -rf {} \;6、grep命令[root@goodluck ~]# cat vitest.txt |grep "bluesky"-------------->管道符"|",就是将前面的输出,作为后面命令的输入bluesky[root@goodluck ~]# cat vitest.txt |grep "blue" bluesky[root@goodluck ~]# grep "blue" /root/vitest.txt bluesky[root@goodluck ~]# cat /etc/passwd |grep "mail" ------------>过滤"mail"mail:x:8:12:mail:/var/spool/mail:/sbin/nologin[root@goodluck ~]# cat /etc/passwd |grep -v "mail"------------>“-v”是排除“mail”[root@goodluck ~]# ifconfig |grep "Bcast"------------>只显示IP这一行[root@goodluck ~]# ifconfig |grep "Bcast" inet addr:192.168.68.129 Bcast:192.168.68.255 Mask:255.255.255.0[root@goodluck ~]# ifconfig |grep "Bcast" |awk '{print $2}'---------------------->配合awk,只显示IP addraddr:192.168.68.129 7、管道符号管道符"|",就是将前面的输出,作为后面命令的输入8、查看系统磁盘容量,文件大小[root@goodluck ~]# df -h ---------------------->以人类可读方式显示磁盘容量Filesystem Size Used Avail Use% Mounted on/dev/sda3 20G 2.2G 16G 12% /tmpfs 491M 0 491M 0% /dev/shm/dev/sda1 194M 34M 151M 19% /boot.host:/ 432G 407G 26G 95% /mnt/hgfs/dev/sdb1 20G 172M 19G 1% /data[root@goodluck ~]# df -hT ----------------------->以人类可读方式显示磁盘容量,并且显示文件系统格式Filesystem Type Size Used Avail Use% Mounted on/dev/sda3 ext4 20G 2.2G 16G 12% /tmpfs tmpfs 491M 0 491M 0% /dev/shm/dev/sda1 ext4 194M 34M 151M 19% /boot.host:/ vmhgfs 432G 407G 26G 95% /mnt/hgfs/dev/sdb1 ext4 20G 172M 19G 1% /data[root@goodluck ~]# du -h ------------------>显示当前目录下所有子目录的大小8.0K ./.ssh8.0K ./.config/htop12K ./.config15M ./nmon4.0K ./shelltest4.0K ./htop-1.0.2/.libs192K ./htop-1.0.2/.deps296K ./htop-1.0.2/m48.0K ./htop-1.0.2/scripts4.3M ./htop-1.0.226M .[root@goodluck ~]# du -h --max-depth=1 ----------------->显示当前目录中所有一级子目录的大小8.0K ./.ssh12K ./.config15M ./nmon4.0K ./shelltest4.3M ./htop-1.0.226M9、查看CPU信息、内存等[root@goodluck ~]# free -m -------------->以MB为单位显示内存 total used free shared buffers cachedMem: 980 456 524 0 30 333-/+ buffers/cache: 93 887Swap: 511 0 511[root@goodluck ~]# free -g -------------->以GB为单位显示内存 total used free shared buffers cachedMem: 0 0 0 0 0 0-/+ buffers/cache: 0 0Swap: 0 0 0以上显示内存大小,如果看剩余内存,看下面这行中的887是最准的:-/+ buffers/cache: 93 887CPU:[root@goodluck ~]# toptop - 11:24:42 up 2:35, 1 user, load average: 0.07, 0.02, 0.00Tasks: 84 total, 1 running, 83 sleeping, 0 stopped, 0 zombieCpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%stMem: 1004412k total, 468500k used, 535912k free, 31184k buffersSwap: 524280k total, 0k used, 524280k free, 341304k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1174 root 20 0 185m 4568 3624 S 0.3 0.5 0:11.48 vmtoolsd 1 root 20 0 19364 1556 1232 S 0.0 0.2 0:00.90 init 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0 4 root 20 0 0 0 0 S 0.0 0.0 0:00.02 ksoftirqd/0 5 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/010、查看进程[root@goodluck ~]# ps -ef |grep httpd ----------------->显示httpd进程信息root 2199 1629 0 11:26 pts/0 00:00:00 grep httpd[root@goodluck ~]# netstat -tnl ----------------->显示tcp连接信息Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN tcp 0 0 :::139 :::* LISTEN tcp 0 0 :::22 :::* LISTEN tcp 0 0 ::1:25 :::* LISTEN tcp 0 0 :::445 :::* LISTEN[root@goodluck ~]# netstat -nul -------------------->显示udp连接信息Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State udp 0 0 0.0.0.0:68 0.0.0.0:*tcp是可靠连接,udp是不可靠连接。