Our disk space often takes a long time to become full, or only a small amount affects the speed of the system, so how do we solve this problem? Cleaning is a good way. Today, Xiaobian teaches you how to use the command line to clean up system garbage.
Solution:
1, is greater than 10M linux find the file
find -type f -size + 10000k
2,. Delete all empty directories
find /data -type d -empty -exec rm -rf {} \\;
3. How to delete empty files (files with size equal to 0) in batches under linux
find /data -type f -size 0c -exec rm -rf {} \\;
find /data -type f -size 0c|
Xargs rm –f
4, delete the file five days ago
find /data -mtime +5 -type f -exec rm -rf {} \\;
5, delete the duplicate parts of the two files, print other
cat 1.txt 3.txt |
Sort |
Uniq
Installation: rpm -ivh gcc-c++-4.1.1-52.el5.x86_64.rpm
Delete: rpm -e gcc-c++-4.1.2-44.el5 - -nodeps
View the installation package: rpm -q gcc-c++
Add a method
1. Monitor important file systems regularly
The file system scans and compares the results of each scan to analyze which files are often read and written. Through analysis, we predict the growth of space. At the same time, we can consider compressing and storing large files that are not frequently read and written to reduce the space they occupy.
#ls -lR /home >files.txt
#diff filesold.txt files.txt
Compress the directory /home/odd that is not frequently read or written :
#tar cvf odd.bak /home/odd
#compress odd.bak
2. View inodes consumption
View space with the following command The inodes of the occupied file system consumes, if there are a large number of inodes available, it means that the large file takes up space, otherwise it may be that a large number of small files take up space.
#df -i /home
3. Find the directory that takes up a lot of space
View the space occupied by /home:
#du - Hs /home
View directories with more than 1000MB of space under /home:
#du |
Awk '$1>2000'
4. Find out files that take up more space
Find files that take up more than 2000KB:
#find /home -size + 2000k
Find files between 500KB and 1000KB in size:
#find -type f -size +500k -and -size -1000k
5.Find out the nearest Modified or created files
If the file system is still normal yesterday, the space is full, so you need to find out which files have been updated and which ones are newly created to find and process them. Unusual large files. First “touch” a file, the timestamp is set to a relatively recent date according to the specific situation, and then use the find command to find a file that is newer than this file.
#touch -t 08190800 test
#find /home -newer test -print
6. Delete unused files such as logs and emails
Delete core, mbox, etc. files:
#find /-name core |
Xargs rm -rf
#find /-name mbox |
Xargs rm -rf Previous12Next Total 2 Pages
In the Linux system, there are a total of 5 commands for finding files, but general
Servers using Linux have built-in PHP environments, so some users will use PHP to w
PyCharm is used for the functions of the general IDE, but many people have errors w
The Ubuntu system notebook can be rebooted by remote control, but this feature is n
Introduction to multi-threaded shell scripts in Linux system
How to use the cat command under Linux?
Steps to install GitLab on CentOS system
How to view Linux mounted disk
How to fix sublime text in Linux to launcher
Linux using the fdisk tool to create partitions
Fedora through l2tp vpn networking method
Linux tips for modifying tab widths
Linux prompts [root@localhost ~]# iptraf when executing commands?
Does Linux use the ODBC method or the DBI way to install the R language extension package?
How to wake up the encryption for Windows 8.1 system
Ten should be away from the workload of the public cloud
Linux how to use the ss command to view the socket status
Win7 system IE task bar how to pop up IE
Windows8 has no reason to sleep problem endings according to the scheme
Win10 is easy to use? US media suggested that users do not install Win10 3 reasons
How to install Win10 dual system with U disk under Win7
The small speaker in the lower right corner of the Win7 system computer is missing. How to fix it?
How to solve the four hot problems of Microsoft Windows7 system
Win8 system settings open public folder sharing graphic method