You are not logged in.

#1 2015-06-25 20:40:49

owblique
Member
Registered: 2015-06-23
Posts: 28

[SOLVED] I deleted passwd file

I am super-noob so be gentle cool, this is my situation: I deleted passwd file like this:

$ sudo mv /etc/passwd /etc/passwd.pacnew

.

I was merging *pacnew files because I had changed my root password using passwd not properly, and I have also done some installations and upgrades. I merged /etc/group succesfully with /etc/group.pacnew. I had noticed that there is some problem with groups, as gdm is now at group 120. This is my filesystem's disk space:

[I have no name!@laptop ~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
dev             2,3G     0  2,3G   0% /dev
run             2,3G  944K  2,3G   1% /run
/dev/sda7        55G   33G   19G  64% /
tmpfs           2,3G  228K  2,3G   1% /dev/shm
tmpfs           2,3G     0  2,3G   0% /sys/fs/cgroup
tmpfs           2,3G  664K  2,3G   1% /tmp
tmpfs           471M  8,0K  471M   1% /run/user/120
tmpfs           471M   20K  471M   1% /run/user/1000

I had also noticed that shadow has some problem:

[I have no name!@laptop ~]$ systemctl status shadow.service
● shadow.service - Verify integrity of password and group files
   Loaded: loaded (/usr/lib/systemd/system/shadow.service; static; vendor preset: disabled)
   Active: inactive (dead)

Thanks in advance

Last edited by owblique (2015-06-29 18:36:10)

Offline

#2 2015-06-25 20:48:12

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,802

Re: [SOLVED] I deleted passwd file

Perhaps I am missing something here.  That command should just rename the file.  Why can you not sudo cp /etc/passwd.pacnew /etc/passwd   ?  That will copy the pacnew file back to passwd.  It will leave the pacnew as a backup?
passwd and shadow go hand-in-hand.  It used to be that the password hashes were kept in passwd.  They moved to shadow for security reasons we don't need to discuss here.   There should be a line in the shadow file for every line in the passwd file.
If the problem is that you cannot log in, you are probably going to need to boot from your install media and use a chroot environment to fix it.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2015-06-25 20:49:22

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: [SOLVED] I deleted passwd file

Re-install the filesystem package.

Offline

#4 2015-06-25 20:50:14

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,802

Re: [SOLVED] I deleted passwd file

Head_on_a_Stick wrote:

Re-install the filesystem package.

That is too easy sad


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2015-06-25 20:56:02

owblique
Member
Registered: 2015-06-23
Posts: 28

Re: [SOLVED] I deleted passwd file

Thank you for your instant replies.  My installation is boot from net, and actually a friend of mine did that, so I cannot do much by my own...
I tried sudo cp /etc/passwd.pacnew /etc/passwd but from terminal and I get sudo: unknown uid 1000: who you are?

Offline

#6 2015-06-25 21:10:05

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,802

Re: [SOLVED] I deleted passwd file

Ack!

By the way, Welcome to Arch Linux.   One of the things about installing Arch yourself is that it gives you the foundation to maintain it.  You really have to know how your system was put together in order to maintain it.

At this point, you are going to have to jump in with both feet at once.   I am going to ask you to please study this article : https://wiki.archlinux.org/index.php/Change_root
Then, come back with questions.  See if you can get into a chroot environment.  If you succeed, stop.  Then report back here for advice as to how to proceed.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#7 2015-06-26 07:20:03

Spider.007
Member
Registered: 2004-06-20
Posts: 1,175

Re: [SOLVED] I deleted passwd file

ewaller wrote:

At this point, you are going to have to jump in with both feet at once.   I am going to ask you to please study this article : https://wiki.archlinux.org/index.php/Change_root

How should he chroot as a normal user? If ts is root already, he can simply mv the file back without sudo.

Also, from that chroot he wouldn't be able to modify his 'main' system anyway, so what's the point?

Last edited by Spider.007 (2015-06-26 07:20:38)

Offline

#8 2015-06-26 08:28:07

bstaletic
Member
Registered: 2014-02-02
Posts: 658

Re: [SOLVED] I deleted passwd file

The point would be Arch iso (for example) providing a working system. From which one could chroot to one's own system.

Offline

#9 2015-06-26 09:38:29

Spider.007
Member
Registered: 2004-06-20
Posts: 1,175

Re: [SOLVED] I deleted passwd file

bstaletic wrote:

The point would be Arch iso (for example) providing a working system. From which one could chroot to one's own system.

If you're root on the iso, why would you want to chroot into a non-working system? No need for chroot here; if you have a working rescue-cd you can indeed move back the passwd file but wouldn't need the chroot other then to verify everything is working properly after that?

Offline

#10 2015-06-26 10:24:34

Steef435
Member
Registered: 2013-08-29
Posts: 577
Website

Re: [SOLVED] I deleted passwd file

The wiki page also describes how to mount the partitions from the rescue environment. Also, if owblique ends up having to reinstall the filesystem package, it's probably easier to do that in a chroot environment rather than specifying the pacman database, installation root, configuration file et cetera. In the end, everything is possible without a chroot, but in this case it's easier to work in a chroot.

Offline

#11 2015-06-26 10:39:02

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: [SOLVED] I deleted passwd file


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#12 2015-06-26 11:30:28

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,546
Website

Re: [SOLVED] I deleted passwd file

Spider.007 wrote:

If you're root on the iso, why would you want to chroot into a non-working system? No need for chroot here; if you have a working rescue-cd you can indeed move back the passwd file

Agreed.

Let's make sure we're all talking about the same problem here.  When I first read what the mistake was, my brain 'autocorrected' and assumed the more likely and more damaging mistake of moving the .pacnew file to the original and thus overwriting the original.  But this is not what happened.  The original, valid, working passwd file was simply renamed to passwd.pacnew.  Simply move it back.  That's it.  It would be wise to then reinstall the filesystem package and merge any changes properly, but just moving passwd.pacnew (which contains all the OP's user data) back to passwd would have him back to a fully functional system.

EDIT: catching up on the rest of the posts - it seems everyone is following the correct problem.   So the above paragraph may be unneeded.  But this is simpler than all the chroot stuff.  As spider suggested: boot the iso, mount your root fs, move the file.  Be happy.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Online

#13 2015-06-26 15:36:49

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,802

Re: [SOLVED] I deleted passwd file

I went for the chroot solution because it was not clear to me they they are still logged in as root.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#14 2015-06-29 18:35:27

owblique
Member
Registered: 2015-06-23
Posts: 28

Re: [SOLVED] I deleted passwd file

The solution for me was  to move the passwd.pacnew to the passwd from rescue mode.  I had the error Failed to start Create Volatile Files and Directories, in the first place (I am not sure why), but after an update everything was OK.  Thanks for your recommendations.

Offline

Board footer

Powered by FluxBB