1, how to filter out the known current directory in the Oldboy of all the first-level directory (does not contain subdirectories, that is, only a level of directory)
Method 1:find./-type d-maxdepth 1
Method 2:ls-f
Method 3:ls-l | grep ^d
Method 4:ls-f | grep/$
Method 5:ls-l | Grep-v ^-
Method 6:ls-l | Sed-n/^d/p
2, a directory has a lot of files (LS Viewing a lot of screen), want to see the fastest speed to the most recently updated files, how to see?
Ls-lrt/etc #最底部的就是最新更新的文件
Parameter description:
-r,–reverse #翻转排序
-T #按照修改时间排序
3. The access log of the Apache service is known to be logged by day in the server local directory/app/logs, because of the tight disk space, now requires only the last 7 days of access logs! How can I resolve this?
method or configure or process the command (hint: You can start from the Apache service configuration or from the generated log)
1>: The function realization of the service itself
2> Manually delete
Find./-mtime +7-type f-name "*.log"-exec rm-f {} \; #查找7天以前的日志并删除之
4. How do I print the line number and content of the nginx.conf content of the configuration file?
Method 1:cat-n nginx.conf
Method 2:less-n nginx.conf
Method 3:grep-n. Nginx.conf #此处的. (dot), which represents any single character, n is the line number of each line that is filtered out
5, how to quickly return to the previous directory?
cd– #环境变量OLDPWD始终记录着上一次的位置
6, debugging system services, want to be able to view the system log/var/log/messages update, how to do?
Method 1:tail-f/var/log/messages
Method 2:tail-f/var/log/messages #和-F than multiple retries, that is, the file does not exist, will continue to try
7, after installing the System (Centos/rhel), want to let the network File Sharing service NFS, only in the 3 level on the boot on the How to do?
Chkconfig–level 3 NFS Off
8, how to view the/etc/services file how many lines?
Method 1: Use the command WC directly
Wc-l/etc/services
Method 2: Add line numbers to the contents of the file
Cat-n/etc/services | Tail-1
Method 3: Use the SED command
Sed-n ' $= '/etc/services
Method 4: Use the grep command
Grep-n $/etc/services | Tail-1
9, please filter out the IP address in the ifconfig?
Method 1:ifconfig Eth1|grep "inet Add" |cut-d ': '-f2|cut-d '-f1
Method 2:ifconfig Eth1|grep "inet addr" |awk-f: ' {print $ {} ' |awk ' {print '} '
Method 3:ifconfig eth0|awk-f ' [:]+ ' Nr==2{print $} '
Method 4:ifconfig eth0|sed-n ' 2p ' |sed ' s#^.*addr:# #g ' |sed ' s# bc.*$# #g '
10, how to remove the permissions in the/etc/inittab, in the form of the number 644 printing
Method 1:stat/etc/inittab |sed-n ' 4p ' |awk-f "[(/]" ' {print $} '
Method 2:stat-c%a/etc/inittab
Method 3:ll/etc/inittab|cut-c 1-9|tr rwx-4210|awk-f "" ' {print $1+$2+$3 $4+$5+$6 $7+$8+$9} '
11, in the/tools directory of files are embedded in the advertising link, how to remove it
Delete an implant ad: sed-i '/AD link/d ' file
Sed-i '/<p class= "Chromeframe" >you is using an outdated browser. Please <a href= "https:\/\/www.google.com\/chrome\/" rel= "external nofollow" target= "_blank" >upgrade your Browser<\/a> and try Again.<\/p>\//d ' *
12. Print out the contents of the empty line in the Kaka file
Method 1:grep-v "^$" Kaka
Method 2:sed '/^$/d ' Kaka
13, the date of printing 3 days ago, format such as: 2016-05-06
Method 1:date "+%f"-D "3 day Ago"
Method 2:date "+%f"-D "-3 day"
Linux topic Collation (ii)