Handling of user error messages added in Linux

Source: Internet
Author: User
Article Title: handling of user error messages added in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

When adding users today,

# Useradd test

Useradd: cannot open shadow password file

At first, the permission for the/etc/shadow file was mistakenly modified. view the/etc/passwd and/etc/shadow attributes.

[Root @ mango root] # ls-rlt/etc/passwd

-Rw-r -- 1 root 1726 April 20 17:43/etc/passwd

[Root @ mango root] # ls-rlt/etc/shadow

-R -------- 1 root 1262 April 20 17:43/etc/shadow

Normally, the following attributes can be added.

Ls-rlt/etc/passwd

-Rw-r -- 1 root 1831/etc/passwd

[Guest @ www5 guest] $ ls-rlt/etc/shadow

-R -------- 1 root 1294/etc/shadow

Change/etc/shadow of the faulty host to 600. An error is returned. do not modify the host!

[Root @ mango root] # chmod 600/etc/shadow

Can not modify

After asking the security specialist, I realized that I had performed security reinforcement. I could use lsattr and chsttr to change the attributes!

[Root @ toddy root] # lsattr/etc/shadow

---- I --------/etc/shadow

[Root @ toddy root] # chattr-I/etc/shadow

[Root @ toddy root] # useradd ywg

[Root @ toddy root] # lsattr/etc/passwd

Details about chattr command use http://linux.chinaitlab.com/command/38018.html

Chattr

1. Role 

Modify the attributes of the ext2 and ext3 file systems and use the permission superuser.

2. Format  

Chattr [-RV] [-+ = AacDdijsSu] [-v version] file or directory

3. Main Parameters

-R: recursively processes all files and subdirectories.

-V: displays the modified content in detail and prints the output.

-: Invalid attribute.

+: Activation attribute.

=: Specifies the attribute.

A: Atime: Tell the system not to modify the last access time of this file.

S: Sync. Once the application writes the file, the system immediately writes the Modification result to the disk.

A: Append Only. The system Only allows data to be appended to this file. No process is allowed to overwrite or intercept this file. If the directory has this attribute, the system will only allow the creation and modification of files under this directory, and will not allow the deletion of any files.

I: Immutable. The system does not allow any modifications to this file. If the directory has this attribute, any process can only modify the files under the Directory and cannot create or delete files.

D: Check for errors in the compressed file.

D: No dump. During file system backup, the dump program ignores this file.

C: Compress. The system compresses the file transparently. When reading from this file, the returned data is extracted. When writing data to this file, the data is first compressed before being written to the disk.

: Secure Delete: enables the system to fill in the region of the file with 0 When deleting the file.

U: Undelete: When an application requests to delete this file, the system will keep its data block so that the file can be deleted in the future.

4. Description

The chattr command is very useful. Some of the functions are supported by the Linux kernel version. If the Linux kernel version is earlier than 2.2, many functions cannot be implemented. Similarly, if-D is used to check the wrong function in the compressed file, the kernel 2.5.19 or later is required. In addition, modifying attributes using the chattr command can improve system security, but it is not suitable for all directories. The chattr command cannot protect the/,/dev,/tmp, And/var directories.

Chattr

Http://www.linuxmine.com/2452.html

Chattr can prevent key files from being modified

In linux, some configuration files cannot be modified by anyone including root users. To prevent accidental deletion or modification,

You can set "immutable" for this file )".

For example:

Chattr + I/etc/fstab

If you need to modify the file:

Chattr-I/etc/fstab

Modify the file later.

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.