"Weight loss" for Linux systems"

Source: Internet
Author: User
Tags clear internet ssh server
In the face of the ever-expanding Linux system, the space on your hard disk is increasingly stretched. How to lose weight in Linux can usually be done manually or using system tools. This article introduces the following tools: ActivityLogManager, BleachBit, find, fdupes

In the face of the ever-expanding Linux system, the space on your hard disk is increasingly stretched. How to lose weight in Linux can usually be done manually or using system tools. This article introduces the following tools and techniques: Activity Log Manager, BleachBit, find, fdupes, geeqie, and GConf Cleaner.

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 spam files.

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:

#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:

# 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.

# cd /usr/share/man# find ./ -maxdepth 1 -type d | tail -n +2 | grep -E -v '(en|zh|man).*' | \    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

# apt-get install fdupes

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

#fdupes /etc

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

#fdupes -r -f . | grep -v ^$ | tee duplicate.txt cat duplicate.txt | \    while read file; do rm -v "$file"; done

You can also use the sed command to delete files:

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

Clear old software caches

# apt-get autoclean

Clear all software caches:

#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:

# 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.

Figure 1. select "Find duplicates recursive ..."

Select the "Compare by:" drop-down menu in the lower left corner to select the matching method Similarity (custom) to find the image with a Similarity of more than 99%. you can also select "Thumbnails" to display the thumbnail, as shown in figure 2.

Figure 2. find images with a similarity of more than 99%

Right-click the selected project and click "Delete" to Delete all selected images. a confirmation interface is provided before deletion to avoid accidental deletion. Note: 99% is the default value of image similarity. you can modify the parameters in the following way: Edit → Preferences... → Behavior → Miscellaneous: Custom similarity threshold, as shown in figure 3.

Figure 3. modify parameters

Introduction to using BleachBit to clear files

BleachBit is an open-source free system cleanup tool that features similar features to CCleaner on Windows. BleachBit can delete hidden junk files and easily protect your privacy. It is a very practical cross-platform system cleanup tool that can erase cache, delete cookies, clear internet browsing history, delete unused localized fragment logs, and delete temporary files. BleachBit provides rpm and deb binary packages. it is applicable to Linux Ora, CentOS, RHEL, Debian, Ubuntu, and other Linux distributions. Other Linux users can choose BleachBit source code package (: http://bleachbit.sourceforge.net/download.php ). With BleachBit, you can clear unwanted items such as cache, history, temporary files, and cookies in the system, so that you can release your disk space. Currently, BleachBit can clean up junk files generated by more than 70 software programs, such as Beagle, Firefox, Epiphany, Flash, OpenOffice.org, KDE, GIMP, Java programming tools, vim, and Gedit editors. There are also "Thumbs. db" files generated during system running, cache files generated during installation using apt or YUM software packages, and historical files in the clipboard.

First install the software:

#apt-get install bleachbit

After installation, there will be two more tools in the system tool menu: bleachbit and bleachbit as root. If you use 2nd root users and the software runs for the first time, the "preference window" is displayed, as shown in figure 4.

Figure 4. BleachBit settings page

A brief description of the settings page: includes custom files and folders, drive list, language, whitelist (exempt from cleanup) settings, and whether to enable BleachBit at startup.

See figure 5.

Figure 5 BleachBit work interface

BleachBit is easy to use because it has a single function. As shown in figure 5. On the left side of the software, various spam items can be cleared. click the "preview" button to analyze the details and sizes of the spam files. Select the software and press the clean button.

Use Chrome as an example to describe how to operate

Files that can be cleaned by Chrome include:

  • Cache: delete the cached webpage files (these cached files can reduce the next time you access the webpage)
  • Cookies: delete cookies. they store website preferences, authentication, and identity information.
  • Current Session: delete the current session
  • DOM (Document Object Model) storage: delete HTML5 cookies
  • Form history: Website form input history
  • History: deletes historical records of browsed websites, downloads, and thumbnails.
  • Search engine: resets the use history of search engines and deletes non-built-in search engines.
  • Database sorting: clear database fragments to reduce space and increase the speed (no data needs to be deleted)

First, view the cleanup Chrome browser file, as shown in figure 6.

Figure 6. View system garbage that can be cleared by Chrome

After selecting the project you want to clean up, click the "preview" button to scan the junk files contained in the project. the scan process is fast and complete, the user will see the list of detected junk files and their statistics. The following users can easily clear these detected junk files by clicking the "clear" button.

The above I chose to execute a scan cleaning task for the Chrome browser. of course, you can select all items in the whole junk list. you only need to select scan items and select activation items one by one.

Use Activity Log Manager to clear traces of use left in the system

Surfing the Internet, logging on to the system with an account, including using some editing software, leaves clues in the system. the residual information contains personal information. if exploited by criminals, this will cause privacy leakage, the tool described below is Activity Log Manager, which is configured to be recorded in Zeitgeist Activity logs and can be used to effectively protect privacy. First install this tool:

#apt-get install activity-log-manager

The Chinese name of Activity Log Manager is the Activity Log Manager, which is displayed in the attachment menu after installation. It is easy to use. The most direct is to set the stop record function, and then delete all historical files, as shown in Figure 7.

Figure 7. delete all historical files

Of course, you can also set different settings. you can set which applications and files can be retained based on the actual situation. See Figure 8.

Figure 8. set which applications and files can retain historical files but not those

Here, I select "workbooks, text, and instant messages" as privacy-related options. You can also add some special applications to the Activity Log Manager, as shown in Figure 9.

Figure 9. Add application users to the Activity Log Manager

Use GConf Cleaner to clear GConf

GConf is a system used to store the GNOME Application options. If the system is filled with a lot of useless key values, it will make GConf bloated. This affects the startup speed and performance of the application. To solve this problem, you can use GConf Cleaner to clean it. Gconf-Cleaner is a tool similar to Windows Registry Cleaner. It checks the Gconf database (that is, The GNOME configuration database) and removes useless and outdated projects.

First install this tool:

#apt-get install gconf-cleaner

Then run gconf-cleaner from the terminal to start the GConf Cleaner program. This program has an execution wizard, you only need to follow the steps. Wizard initial screen. click Forward to go to the analysis process. Figure 10 shows the analysis result, which provides specific data and can be saved. Click "Forward" again to start the cleaning process.

Figure 10. analysis results

Figure 11 shows a clean-up interface combined with Linux commands.

Related Article

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.