Linux system "weight loss"

Source: Internet
Author: User
Preface after Linux computer is installed, various junk files will be generated in the hard disk due to activities such as adding and deleting software, surfing the Internet, and debugging programs, as these junk files continue to expand, they will not only flat our valuable hard disk space, but also drag down the running speed of the machine and affect our work efficiency. This article describes how to use the tool and weight loss methods for Linux. The Linux release version used in this article is Ubuntu12.04. The tools described in this article include: Act

Preface

After the Linux computer is installed, during our continuous use, various junk files will be generated in the hard disk due to activities such as adding and deleting software and surfing the Internet, debugging programs, etc, as these junk files continue to expand, they will not only flat our valuable hard disk space, but also drag down the running speed of the machine and affect our work efficiency. This article describes how to reduce the weight of a Linux system and how to use the tool. The Linux release version used in this article is Ubuntu 12.04. Tools described in this article include Activity Log Manager, BleachBit, find, fdupes, Geeqie, and GConf Cleaner. these tools are all open-source tools, linux users can download and compile the source code in other popular Linux versions (such as Redhat and SUSE.

Which files in Linux are spam files?

  • Temporary files generated during software installation

When installing many bin-format software, you must first extract the installation file to a temporary directory (usually the/tmp directory) and then install it. If the software design is neglected or the system is faulty, after the installation is complete, these temporary files will become non-"temporary" and become a pile of garbage in the hard disk. in many cases, they use *. tmp faces appear.

  • Temporary files generated during software running

Like the installation process, some temporary exchange files are usually generated during the operation of the software. after some software runs, the garbage may even reach hundreds of megabytes, for example, files generated when the SSH server and client are connected. There are also files generated when the VM is running. In addition, some useless junk files and directories will exist after we delete an account.

  • Temporary files generated by surfing the Internet

When we access the Internet, the browser always Downloads webpage files to a local machine. these cached files not only occupy valuable disk space, but also often make our privacy public.

  • Some infrequently used chicken ribs files

For example, some application software comes with help and System Manual pages. Since they are tasteless, they are also seen as a manifestation of junk files. A large amount of space is occupied, which seriously slows down the running speed of the system and some graphics processing software. There are also some corrupted desktop files, including damaged application menu buttons and file associations.

  • Various cached files

If a Linux user installs and uses GIMP, Geeqie, and other graphical editing tools, the image preview function is available in these software. in the folder where the image is saved, a file named "Thumbs. db file, this file will expand with the increase of image files. There is also the. DS_Store file. the DS_Store file is used to store the display attributes of this folder, such as the placement location of the file icon. The side effect after deletion is the loss of such information. In addition, cache files generated during installation using apt or YUM software package.

Use Linux commands to delete junk files

  • Delete the junk files left by the user

The main command we use here is find. For example, after deleting an account, some useless junk files and directories will exist. to find out the junk items belonging to this user, use the find/-user username: you can find the user-related files in the root directory and run the following command:

 
  1. #find ./ -nouser  |xargs rm ?rf

  • Core file

When an error occurs when a program is running in the system, the system automatically saves the data that remains in the memory as core files. Over time, more and more cores will be left in the system, it is annoying to scatter like dust in every corner of the system. At this time, we can apply the find command and add the-exec parameter to clear them. Run the following command:

 
  1. # find / -name core -print -exec rm -rf {} \;

  • Additional manual pages

In addition, Linux provides many language manual pages (man). For example, the Ubuntu manual page is located in the/usr/share/man Directory. you can use commands to delete the manual pages of redundant languages and keep them in Chinese and English.

 
  1. # cd /usr/share/man

  2. # find ./ -maxdepth 1 -type d | tail -n +2 | grep -E -v '(en|zh|man).*' | \

  3. while read d; do rm -rf $d; done

Note: The keyword is (en | zh | man). you can modify the keyword as needed.

  • Use fdupes to delete duplicate files in a specified directory

Fdupes is a command line tool that searches for and deletes duplicate files in a specified directory. it compares the file size with the MD5 value. Compare one byte to one byte. First install this tool

 
  1. # apt-get install fdupes

Run the following command to find duplicate files in the/etc directory:

 
  1. #fdupes /etc

It can be used in combination with Linux commands to delete files:

 
  1. #fdupes -r -f . | grep -v ^$ | tee duplicate.txt cat duplicate.txt | \

  2. while read file; do rm -v "$file"; done

You can also use the sed command to delete files:

 
  1. # fdupes -r -n -S /tmp | sed -r “s/^/#rm \”/” | sed -r “s/$/\”/” >duplicate-files.sh

  • Delete cached files

Clear old software caches

 
  1. # apt-get autoclean

Clear all software caches:

 
  1. #apt-get clean

Delete isolated software that is no longer used by the system

These three commands mainly clean up and upgrade the cache and useless packages.

Use the Geeqie tool to find similar Image files

The current hard disk capacity is getting bigger and bigger. due to backup considerations, many friends will save the image by taking the principle of "Please do not miss it", which may lead to duplicate files, the efficiency of file search is low. It is not easy to find duplicate documents in massive buckets. In fact, with the famous image browsing tool Geeqie, you can easily find duplicate and similar image files in the system. These files are larger than text files, occupying a lot of hard disk space for a long time. The fdupes tool described above does not work, because the fdupes tool can only delete duplicate files identical (md5sum is the same), but to remove "similar" image files, you can use the geeqie tool. First install this tool:

 
  1. # apt-get install gqview

Run the tool below, right-click the directory to be searched, and select "Find duplicates recursive...", as shown in Figure 1.

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.