Disk Cleanup protection in Ubuntu

Source: Internet
Author: User
Many people who have been using Ubuntu for a long time will suddenly prompt that the disk space is less than 1 GB! Then analyze the data for half a day. Recently encountered a similar problem, record as follows: A:. xsession-errors.old can be seen in the terminal under the main user directory has such a hidden file, I see the size of around 22 GB! I checked it online and said that this file is a set of records of communication errors between our local machine and the server, and records will be continuously added. Someone suggested that you write a script to regularly Delete this file, which is too troublesome. You can use the following

Many people who have been using Ubuntu for a long time will suddenly prompt that the disk space is less than 1 GB! Then analyze the data for half a day. A similar problem has been encountered recently. The record is as follows:

1:. xsession-errors.old

You can see such a hidden file in the main user directory on the terminal. The size is around 22 GB! I checked it online and said that this file is a set of records of communication errors between our local machine and the server, and records will be continuously added.

Someone suggested that you write a script to regularly Delete this file, which is too troublesome. You can use the following command to solve this problem:

Rm. xsession-errors.old

Touch xsession-errors.old

Sudo chattr + I. xsession-errors.old

Delete the file and create a new file with the same name. The file cannot be written!

Ii. chattr command Learning

I have never used this chattr command before, but I found it so useful later!

Sometimes a file cannot be modified even if the root permission is used in the system. It is probably locked by the chattr command. Some functions of this command are supported by the Linux kernel. Use this command to lock some special files in the system,

Improve security.

The chattr command cannot protect the/,/dev,/tmp, And/var directories. The lsattr command is the display attribute, and the file attribute set by the chattr command.

Generally, the chmod chown command is used to modify the read and write permissions. The owner, chattr, is a more underlying attribute control command!

Usage of the chattr command: chattr [-RVf] [-v version] [mode] files...

The most important part is in the [mode] section. The [mode] Section is composed of the +-= and [ASacDdIijsTtu] characters. This part is used to control the file attributes, as shown below:

+: Append parameters based on the original parameter settings.

-: Remove the parameter based on the original parameter settings.

=: Updated to the specified parameter settings.

A: The atime (access time) of A file or directory cannot be modified, which can effectively prevent I/O errors on A laptop disk.

S: Hard Disk I/O synchronization option, similar to sync.

A: append. After this parameter is set, data can only be added to the file, but cannot be deleted. This attribute is mostly used for server log file security and can only be set by root.

C: compresse: Specifies whether the file is compressed before being stored. Automatic decompression is required for reading.

D: no dump. the file cannot be the backup target of the dump program.

I: The set file cannot be deleted, renamed, or linked, and cannot be written or added. The I parameter is very helpful for security settings of the file system.

J: That is, journal. this parameter is set so that when the file system is mounted by the mount parameter: data = ordered or data = writeback, the file is first recorded (in journal) when written ). If the filesystem parameter is set to data = journal, this parameter is automatically invalid.

S: Confidential deletion of files or directories, that is, the hard disk space is all withdrawn.

U: opposite to s. When set to u, the data content still exists in the disk and can be used for undeletion.

A and I are often used in each parameter option. Option a can only be added and cannot be deleted. It is mostly used for security settings of the log system. I is a more rigorous security setting. This option can be applied only to processes with superuser (root) or CAP_LINUX_IMMUTABLE processing capability (identifier.

The above. xsession-errors.old as an example:

Sudo chattr + I. xsession-errors.old

Then lsattr:

Www.linuxidc.com@www.linuxidc.com :~ $ Lsattr. xsession-errors.old

---- I -------- e --. xsession-errors.old

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2014-05/101014.htm

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.