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 for half a day .. Recently, I have encountered classes & amp

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 for half a day .. A similar problem has been encountered recently. The record is as follows:

A: xsession-errors.old can see in the terminal Directory of the main user 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 command to solve this problem:
rm .xsession-errors.oldtouch .xsession-errors.oldsudo chattr +i .xsession-errors.old
Delete the file and create a new file with the same name. the file cannot be written! II. I have never used the chattr command before, but I found it so useful! 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. This command can lock some special files in the system to improve security. The chattr command cannot protect the/,/dev,/tmp, and/var directories. LsattrCommand is the display property, ChattrFile Attribute set by the 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:
jscese@jscese-H61M-S2P:~$ lsattr .xsession-errors.old ----i--------e-- .xsession-errors.old
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.