Linux disk space is full of some solutions to share

Source: Internet
Author: User
Tags touch


1. Find files larger than 10M under Linux

Find. -type f-size +10000k

2. Delete all empty directories
Find/data-type d-empty-exec rm-rf {} \;

3, Linux Bulk Delete empty files (size equals 0 of the file) method
Find/data-type f-size 0c-exec rm-rf {} \;
Find/data-type f-size 0c|xargs rm–f

4, delete five days before the file
Find/data-mtime +5-type f-exec rm-rf {} \;

5, delete the duplicate parts of 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
To view the installation package: Rpm-q gcc-c++

Add the method


1. Regular monitoring of important file systems

Periodically scan important file systems and compare the results of each scan to show that those files are often read and written. By analyzing and predicting the growth of space, we can also consider compressing and storing large files that are infrequently read and written to reduce the space they occupy.
#ls-lr/home >files.txt
#diff Filesold.txt Files.txt
Compress infrequently read and write directory/home/odd:
#tar CVF odd.bak/home/odd
#compress Odd.bak

2. View Inodes consumption

Use the command below to view the inodes consumption of the space-filled file system, and if there is a large number of inodes available, it means that the large file occupies space, otherwise it may be a large number of small files occupy space.
#df-I./home

3. Find a large footprint directory

To view the space occupied by/home:
#du-hs/home
View directories that occupy more than 1000MB of space under/home:
#du |awk ' $1>2000 '

4. Find a document that occupies a larger space

Find files that occupy more than 2000KB of space:
#find/home-size +2000k
Find files between 500KB and 1000KB:
#find-type f-size +500k-and-size-1000k

5. Find the most recently modified or created file

If the file system was normal yesterday and the space was filled today, it would be necessary to find out which files were updated and which were newly created in order to find and process an abnormally large file. First "Touch" a file, the time stamp according to the specific circumstances of a relatively near date, and then use the Find command to identify files that are newer than this file.
#touch-T 08190800 Test
#find/home-newer Test-print

6. Delete the log, mail, and other useless files

Delete files such as core, mbox, and so on:
#find/-name Core | Xargs RM-RF
#find/-name mbox | Xargs RM-RF
To delete a log file:
#rm-rf/var/log/*

7. Link to file system

Link to a file system that has no space and link to a filesystem with space.
#ln-S/home/usr/home

8. Check and Repair file system

#fsck-y/home

9. Find a process that consumes a lot of space

Some applications will take up a lot of disk space, this situation can not be specified, the need for different applications to choose the Optimization method. For example, the messaging system and the Web Proxy system can control disk space usage by setting the file retention time and the percentage of disk space consumed.

10. Reboot the Machine

Restarting the system scans the file system and initializes process, memory, and disk space management, which is a good way to solve many problems. With these tips, you should be able to solve most of the problems, but the key is to plan the partitions at the time of installation. In addition, the discovery file system is occupied, should carefully analyze the reason, careful response, do not delete the wrong file. If these tricks have been tried or not solve the problem, it will only take to increase the hard drive, reinstall the system and so on.

11. Find the directory that occupies the largest amount of disk space to enter the step-by-step lookup

Du-h--max-depth=1|grep G|sort-n

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.