Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to clean the Linux disk when it is full

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains how to clean up the Linux disk when it is full. Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to clean up Linux disks when they are full.

First, what if there is not enough Linux space?

1. Scan important file systems regularly, compare them, and analyze which files are read and written frequently

# ls-lR / home >; files.txt

# diff filesold.txt files.txt

By analyzing the growth of the predicted space, we can also consider compressing the files that read and write infrequently to reduce the space occupied.

two。 View the inodes consumption of a full file system

# df-I / home

If there is still a large amount of inode available, large files take up space, otherwise it is possible that a large number of small files take up space.

3. Find out the directory that takes up more space.

View the space occupied by / home

# du-hs / home

View / home occupies more than 1000m space

# du | awk'$1 >; 2000'

4. Find out the files that take up more space.

# find / home-size + 2000k

5. Find files that have been recently modified or created

The file to touch the time you want is as follows:

# touch-t 08190800 test

# find / home-newer test-print

6. Delete Syslog, etc.

Delete files such as generating core,mbox

# find /-name core | xargs rm-rf

Delete Log

# rm-rf / var/log/*

7. Link the partition

In zones with spaces, link zones without spaces

# ln-s / home / usr/home

8. Find a process that consumes a lot of space

According to different applications, find out the corresponding process. Analyze the reason.

9. Check and repair the file system

# fsck-y / home

10. Restart the machine

With the above ten tips, you should be able to solve most of the problems, but the key is to plan the partition during installation. In addition, it is found that when the disk is full, do not rush, operate carefully, analyze the reason carefully, and then deal with it carefully. It should be noted that the above ten moves do not need to be carried out sequentially, some may seal the throat in one move, and some may need to use several moves at the same time. Delete operations must be careful. If it doesn't work, we can only take "hard" measures such as adding hard drives and reinstalling the system.

You can also:

Cd\

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

Find the largest directory and enter it

Run du-h-max-depth=1 | grep G |-n

If there is no result, you can run du-h-max-depth=1 | grep M | sort-n

Find out the files to see if they are useful, and delete them if they are useless.

Second, how to clean up the Linux disk when it is full?

1. Determine whether it is really a lack of disk space

Enter the command: df-lh to view disk information

2. How to locate the largest file directory

Enter the command: cd / enter the root directory.

Enter the command: du-h max-depth=1 to find the current directory, which folder takes up the most space

3. How to locate the largest file

Enter command: ls-lhS presents files in order from largest to smallest

4. Confirm that the file is not occupied

Anyone can delete a file: rm-f catalina.out, but it's best to make sure you want to download it and let the developer analyze the log.

At this point, I believe you have a deeper understanding of "how to clean up Linux disks". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report