Modified /etc/passwd file

Asked by passionguy

I m running Gutsy. I used cat command to add an user to the file passwd file like this.
Command:
cat > passwd

& appended the following lines to the file.
test:x:501:501:Bob Morris:/home/test:/bin/bash

& pressed control-d.

I opened the file again & i m able to see only the line i added.

Will this affect my login next time.

Thanks....

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu shadow Edit question
Assignee:
No assignee Edit question
Solved by:
passionguy
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
peter (peter-neuweiler) said :
#1

If you are going to create a new user, I recommend to use the following:

1: Click System > Administration > Users and Groups

This method works very well. And I'm sure, your added line will influence the log in. Ubuntu is a very consistent system - Ubuntu won't forget *lol.

Hope it helps.
Peter

Revision history for this message
Christophe Painchaud (dash-ionblast) said :
#2

And I suggest you stop playing with system files :D Or install a secondary system to break and experiment !!

Revision history for this message
passionguy (fayazahmedj) said :
#3

I thought i have appended but it was not. I am not able to login now even as root. Is there any backup created automatically which i can restore?

I played without creating a backup of it.

Thanks...

Revision history for this message
peter (peter-neuweiler) said :
#4

If your PC is running, do the following:

1: Click System > Administration > Users and Groups

Change the password of the root and make sure that rest of the data is ok, I guess, ther's no backup solution.
Peter

Revision history for this message
passionguy (fayazahmedj) said :
#5

It is giving up a message that GDM user does not exist & needs to be reconfigured.

Revision history for this message
passionguy (fayazahmedj) said :
#6

Can i switch to root using the live cd & wts the password?

Revision history for this message
passionguy (fayazahmedj) said :
#7

I m asking this to restore the /etc/passwd file.

Revision history for this message
peter (peter-neuweiler) said :
#8

Did you copy the file /etc/passwd before you updated it? If the answer will be yes, copy the backup back to /etc/passwd. If you don't have a copy, it will be difficult.
Peter

Revision history for this message
passionguy (fayazahmedj) said :
#9

I have made a copy thru the live cd & have made some modifications for the user permissions. It is not allowing me to replace saying 'Permission denied'. Is there any way to switch as root in the live cd so that i can replace?

Revision history for this message
peter (peter-neuweiler) said :
#10

If your system is running, do the following:

sudo cp /dir/file.bak /dir/file

Hope it helps.
Peter

Revision history for this message
passionguy (fayazahmedj) said :
#11

I tried the following:
cp /media/disk-2/passwd.bak /media/disk/etc/passwd

Message:
cp: cannot create regular file `/media/disk/etc/passwd': Permission denied

Revision history for this message
passionguy (fayazahmedj) said :
#12

If i login as root i believe i can replace it. Any ways

Revision history for this message
peter (peter-neuweiler) said :
#13

Ok, I'll keep my fingers crossed.
Peter

Revision history for this message
passionguy (fayazahmedj) said :
#14

I m not an expert Peter.Just a guess & i thought there may be a default

Revision history for this message
peter (peter-neuweiler) said :
#15

I'm not an expert too. Did you login as root? And what happened?
Peter

Revision history for this message
passionguy (fayazahmedj) said :
#16

Used the EXT2IFS tool in XP & restored the live cd passwd file with modifications to the original location. It worked..

Revision history for this message
peter (peter-neuweiler) said :
#17

Great. Enjoy Ubuntu and don't play again with system files *lol.
Peter