VI Delete blank line
: g/^s*$/d
Find the file in the directory that contains the specified string
Find./-name ' *.conf ' | Xargs grep-in "baidu.com.demo.upall.cn"
# Note: ' baidu.com.demo.upall.cn ' is the string to look for
# This command is used to quickly locate the profile name of a domain name in a large number of configuration files because:
# The user's profile name does not conform to the rule or has multiple domain names in a configuration file for special reasons
# I: case-insensitive
# N: Shows the line number
To view the size of a single file (or folder)
du-sh/var/log/
View the size of folders and files in a folder (which folder is the largest)
Du-h--max-depth=1/var/log/
Delete the ^m in the source code
:%s/^m$//g #注意: ^m input mode, ctrl+v+m
Bulk removal of write permissions for include and its under files
Find/var/www-type d-name "include"-print0 | xargs-0 chmod ugo-w-R # Remove Execute permissions can read this article:
Find all files in the current folder that contain the string "Fsockopen"
In fact, look for "udp://$" words will be accurate, of course, to see the actual situation, ^_^.
The code is as follows |
Copy Code |
1find./-type F | Xargs Grep-sni "Fsockopen" # or (this line below helps to understand the "-sni" argument) Find./-type F | Xargs grep--silent--line-number--ignore-case "Fsockopen" # If you find all the files can be deleted, you can use the following command to delete: Find./-type F | Xargs grep-lsi "Fsockopen" | Xargs RM |
See if the MX record for the domain name takes effect
[Upall@linux ~]$ host-t mx upall.cn upall.cn Mail is handled by mx.upall.cn.
Lists the zip files in all Web sites folders and displays their size
It is often possible to find out if the server downloads some source code packages or packs some backup files and forgets to delete them.
find/www/-type f-name "*.zip"-print0 | xargs-0 du-h
Delete users and their files (delete user login directory and all files in directory)
Userdel-r Upall
To view programs that are running on a specified port
# View 3428-Port Running Program: lsof-i: 3428
Update/etc/aliases.db database after modifying/etc/aliases
Newaliases
Disabling disable lockout user, restoring Enable user
Passwd-l upall #禁用用户upall passwd-u upall #启用用户upall
Clear the BOM header in UTF-8
Grep-r $ ' xefxbbxbf ' * |grep. php #或者直接配置vim: Set Nobomb
To view memory usage, command: FREE
The code is as follows |
Copy Code |
[ROOT@VM ~]# Free Total used free shared buffers Cached mem:514860 481808 33052 0 107536 134892 -/+ buffers/cache:239380 275480 swap:1048568 80 1048488 [Code]
|
The free command will show the associated memory usage, note: For stand-alone servers or virtual machines for XEN/KVM architectures, the free command shown in free is not the real remaining memory, why? See: Free command Memory display guide
3. View disk partition usage: fdisk and DF
The code is as follows |
Copy Code |
[Code] [Root@www ~]# Fdisk-l disk/dev/hda:16.1 GB, 16106127360 bytes 255 heads, Sectors/track, 1958 cylinders Units = Cylinders of 16065 * 8225280 bytes Device Boot Start End Blocks Id System /DEV/HDA1 * 1 104391 Linux /dev/hda2 1958 15623212+ 8e Linux LVM |
To view the use of individual partitions: DF-HL
The code is as follows |
Copy Code |
[Root@www ~]# Df-hl FileSystem Size Used Avail use% mounted on /dev/mapper/volgroup00-logvol00 14G 2.9G 9.9G 23%/ /DEV/HDA1 99M 19M 76M 20%/boot Tmpfs 252M 0 252M 0%/dev/shm
|
4, look at the system load and operating conditions: uptime
The code is as follows |
Copy Code |
[Root@www ~]# Uptime
13:36:09 up to 2 days, 16:09, 1 user, load average:0.03, 0.02, 0.00 |
Shows the system boot time, followed by the load average three numbers representing the last 1 minutes, 5 minutes, 15 minutes of the system average load.
In general, a CPU core full load value of 1, there are several cores, full load status of a few. If load exceeds this number, there are queued requests waiting to be processed in the system. In practice, generally do not let the load is larger than the total number of CPU core x2, or system efficiency will be greatly compromised.
5. View current user/view current path/view current time/print all Processes list
code is as follows |
copy code |
[Root@www local]# who Root pts/0 2012-01-14 13:35 (58.47.62.202) [roo T@www local]# whoami Root [root@www local]# pwd /usr/local [root@www local]# date Sat 14 13:44:39 CST [root@www local]# ps-aux Warning:bad syntax, perhaps a bogus '-'? See/usr/share/doc/procps-3.2.7/faq USER PID%cpu%mem VSZ RSS TTY STAT START time COMMAND Root 1 0.0 0.1 2160 648 ? Ss Jan11 0:01 init [3] Root 2 0.0 0.0 0 0? s< Jan11 0:00 [migration/0] Root 3 0.0 0.0 0 0? SN Jan11 0:00 [ksoftirqd/0] Root 4 0.0 0.0 0 0? s< Jan11 0:00 [watchdog/0] Root 5 0.0 0.0 0 0? s< Jan11 0:00 [MIGRATION/1] ... |