Big problem: shell entry in /etc/passwd corrupted for user root


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Big problem: shell entry in /etc/passwd corrupted for user root
# 1  
Old 12-18-2019
Big problem: shell entry in /etc/passwd corrupted for user root

did a big mistake, changing root entry of /etc/passwd to
Code:
root:x:0:0:root:/root:/usr/bin/tmux split-window -v \; attach

as expected, now I can't login as root anymore. sudo ed /etc/passwd etc. doesn't work.

Any idea?

Moderator's Comments:
Mod Comment
Use code tags to increase readability and follow the rules.

Last edited by Peasant; 12-19-2019 at 01:59 AM..
# 2  
Old 12-18-2019
Can you boot from installation software - DVD, thumb drive?
Boot to run-level 1 which makes the console root and allows no other logins.

Example with run-level 1 boot on linux with GRUB2

How-To: Change boot runlevel with Grub2 - Debuntu

You want to be in the console as root, and you can work with any file. Try to keep backups from now on, I assumed you had none.
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 12-19-2019
When dealing with /etc/passwd, /etc/shadow, PAM or sudo files :
  • Have a root session / prompt opened aside from everything else, you will use this session to fix / remedy if something does not work.
  • Backup those files before editing cp /etc/passwd /etc/passwd_<date string>
  • Use tools like vipw, vigr, visudo to avoid corruption.

Hope that helps
Regards
Peasant.
This User Gave Thanks to Peasant For This Post:
# 4  
Old 12-19-2019
Sometimes when I am working on these kinds of "gotacha" files, I temporarily change the permissions to read:write for all users or change the owner of the file to an "other than root" user, or both. Then, when all is testing and working OK, I change back to how it was (root ownership, only root can modify, etc.)

I have a funny story to tell (someday) about this, regarding temporarily disabling google_authentication on a server, because of problems with an iPhone lightening connector (battery would not charge, port did not work at all) and the many hours of headaches a small mistake caused me (blocked my own root access on a remote server); all of this started with dust in the iPhone charge port and me spraying some contact cleaner into the port, gumming it up ever worse.

Always have one more more backup plans when doing these kinds of "gotcha" file changes. In the case cited above, because I had to restart sshd, even having two other open ssh connections as root into the server did not help!

Of course, all these editorial comments do not help "after the fact" and so it if makes you feel any better, most of us have made similar mistakes at one time or another.
Remember, you can temporarily change permissions and ownership on files when working on these kinds of "whoops, it got me" changes.
This User Gave Thanks to Neo For This Post:
# 5  
Old 12-19-2019
Quote:
Originally Posted by dodona
did a big mistake, changing root entry of /etc/passwd to
Code:
root:x:0:0:root:/root:/usr/bin/tmux split-window -v \; attach

as expected, now I can't login as root anymore. sudo ed /etc/passwd etc. doesn't work.

Any idea?
If you have physical access to the disk, a common way to correct this problem is to mount the disk on another machine and edit the problem files.

Or, boot from another disk or thumb drive, etc, and mount the filesystem and edit it (as someone mentioned earlier, as I recall).
This User Gave Thanks to Neo For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Sudo entry required to set permission similar to ROOT without using password (PASSWD) change optio

Hi All I had installed sudo in HP UX 11.3 and it is working fine but not able to make entry required to set permission similar to ROOT without using password (PASSWD) change option for define user in /etc/sudoers file Please help if some know the syntex? :confused::wall: (2 Replies)
Discussion started by: deviltech
2 Replies

2. Shell Programming and Scripting

Dont want to mention user id passwd in shell script

Hi, i have one shell script which transfers files from one server to other server through FTP, but i can see login id and password is not mentioned. kindly help to understand the script.then how below script is working if login and password is not mentioned in script #!/bin/sh... (1 Reply)
Discussion started by: ni3b007
1 Replies

3. UNIX for Dummies Questions & Answers

Passwd Utility Corrupted

I have a legacy Solaris 8 machine. Someone has overwitten the passwd utility so I now can't change passwords. Is there somwhere I can download a copy? I do have the installation CDs as well. Thanks (1 Reply)
Discussion started by: hawess
1 Replies

4. Shell Programming and Scripting

How to Login as another user through Shell script from current user[Not Root]

Hi Every body, I would need a shell script program to login as different user and perform some copy commands in the script. example: Supppose ora_toms is the active user ora_toms should be able to run a script where user: ftptomsp pass: XXX should login through and run the commands ... (9 Replies)
Discussion started by: ujjwal27
9 Replies

5. Solaris

passwd cmd reenables passwd aging in shadow entry

Hi Folks, I have Solaris 10, latest release. We have passwd aging set in /etc/defalut/passwd. I have an account that passwd should never expire. Acheived by emptying associated users shadow file entries for passwd aging. When I reset the users passwd using passwd command, it re enables... (3 Replies)
Discussion started by: BG_JrAdmin
3 Replies

6. Programming

C++ - Problem in asking and checking user's passwd

This is the source code: #include <pwd.h> #include <iostream> #include <string.h> using namespace std; int main() { struct passwd *user; char login="alex", password="qwertyuiop"; if ((user= getpwnam(login)) == NULL) cout << "No such user\n"; else if... (24 Replies)
Discussion started by: hakermania
24 Replies

7. Red Hat

Root shell in /etc/passwd is corrupted

I accidentally changed root shell from /bin/bash to bash in /etc/password, then logged out from root. Now I can't login as root and got "No shell" error, although I have root password. "su -f -s /bin/bash" command does NOT work. There is no GUI interface for this system. My question: Do I have... (7 Replies)
Discussion started by: aixlover
7 Replies

8. Shell Programming and Scripting

root user command in shell script execute as normal user

Hi All I have written one shell script for GPRS route add is given below named GPRSRouteSet.sh URL="www.google.com" VBURL="10.5.2.211" echo "Setting route for $URL for GPRS" URL_Address=`nslookup $URL|grep Address:|grep -v "#"|awk -F " " '{print $2}'|head -1` echo "Executing ... (3 Replies)
Discussion started by: mnmonu
3 Replies

9. UNIX for Dummies Questions & Answers

Help! passwd file corrupted

Hi, I am new to UNIX, and have recently installed Suse 9.3. I have been experimenting with all of the commands and have somehow managed to modify the default shell of the root user to an invalid file. Consequently I cannot su to the root user as I receive the 'no such file or directory' error... (2 Replies)
Discussion started by: Tony Montana
2 Replies

10. HP-UX

passwd file corrupted

Good Day Our HP box was hacked and the passwd file has been altered,there are only 2 user accounts active,and these dont have any administrative rights.I need to edit the passwd file to correct the su and root entries. Does any body have any suggestions as to how i can do this with out the root... (10 Replies)
Discussion started by: cantona7
10 Replies
Login or Register to Ask a Question