Latest web development tutorials

Linux lsattr command

Linux command Daquan Linux command Daquan

Linux lsattr command displays the file attributes.

Change with the implementation of a file or directory attributes chattr, lsattr command executable query its properties.

grammar

lsattr [-adlRvV][文件或目录...]

Parameters:

  • -a displays all files and directories, including "." character at the beginning of the name of an additional built-in, the current directory "." and the parent directory "..."
  • -d display, directory name, rather than its content.
  • -l This parameter currently has no effect.
  • -R Recursive processing, all files and subdirectories in the specified directory be dealt with.
  • -v displays the file or directory versions.
  • -V Display version information.

Examples

1, using the chattr command to prevent a critical system files are modified:

# chattr +i /etc/resolv.conf

Then mv /etc/resolv.conf and other operations in the command file, the results are obtained in Operation not permitted.

vim when editing the file prompts W10: Warning: Changing a readonly file error. To modify this file I should i attribute removed:

chattr -i /etc/resolv.conf

Use the lsattr command to display file attributes:

# lsattr /etc/resolv.conf

The output is:

----i-------- /etc/resolv.conf

2, so that a file can only be entered, additional data, but can not be deleted for a variety of log files:

# chattr +a /var/log/messages

Linux command Daquan Linux command Daquan