Linux password file LOKED

Posted on 2004-11-16
Last Modified: 2013-12-15
Hi i have a problem with the password file of my debian sarge.
The password file is loked.
Can you help me ?

If you need any other information ask me !

Question by:alextesi
    LVL 38

    Expert Comment


        Boot into single user mode and edit /etc/shadow.

    save and reboot.

    There is no root password. Then
    # password root
    to change the root password.

    LVL 12

    Expert Comment

    'The password file is loked.'

    you mean you lost your file? or the file locked?

    what's the error you got when you login ?

    or do you mean you lost your login password? or the root login password?

    if you lost the login password or the root login password, wesly_chen already told you how to recover the login password, which is by removing the password record in /etc/shadow.

    wesly_chen have a typo mistake, to change the password you should use 'passwd root'
    LVL 1

    Author Comment

    i can login into my linux distribution.
    but i can't add new user.
    the error
    file passwd locked
    LVL 12

    Expert Comment

    what is the attrib of the /etc/passwd??

    can you post the result of 'ls -l /etc/passwd' and 'ls -l /etc/shadow' here?
    LVL 1

    Author Comment

    Here you are:

    -rw-r--r--  1 root root 5206 2004-11-22 10:01 /etc/passwd
    -rw-r-----  1 root shadow 4374 2004-11-22 10:01 /etc/shadow

    Bye alextesi
    LVL 4

    Accepted Solution

    it's most likely due to this command: chattr
    chattr - change file attributes on a Linux second extended file system

    The immutable bit can be used to prevent accidentally deleting or overwriting a file that must be
    protected. It also prevents someone from creating a symbolic link to this file, which has been the
    source of attacks involving the deletion of “/etc/passwd”, “/etc/shadow”, “/etc/group” or
    • To set the immutable bit on the passwords and groups files, use the command:

    [root@deep /]# chattr +i /etc/passwd
    [root@deep /]# chattr +i /etc/shadow
    [root@deep /]# chattr +i /etc/group
    [root@deep /]# chattr +i /etc/gshadow

    NOTE: In the future, if you intend to add or delete users, passwords, usergroups, or group files,
    you must unset the immutable bit on all those files or you will not be able to make your changes.
    Also if you intend to install an RPM program that will automatically add a new user to the different
    immunized passwd and group files, then you will receive an error message during the install if
    you have not unset the immutable bit from those files.

    so try this command:
    chattr -i /etc/passwd
    chattr -i /etc/shadow
    chattr -i /etc/group
    chattr -i /etc/gshadow
    LVL 12

    Expert Comment

    Nemesis-Services gave you good hints, try to read the manpage of the chattr (man chattr) before you do anything on it. since there is lots of attributes can be add to the file(s) by using the chattr.

    Also backup the /etc/passwd and /etc/shadow before you do anything on it, so that even anything goes wrong you can get back the original to recover :)
    LVL 4

    Expert Comment

    thanks for the points alextesi, glad to have helped :)

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
    I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension ( This reminded me of questions tha…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now