LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Arch
User Name
Password
Arch This Forum is for the discussion of Arch Linux.

Notices


Reply
  Search this Thread
Old 11-23-2018, 06:47 PM   #1
luther1017
LQ Newbie
 
Registered: Nov 2018
Posts: 2

Rep: Reputation: Disabled
Unhappy Accidentally removed /etc/pam.d // How to reinstall packages in my arch from a live usb?


First of all sorry for my English

I have Antergos installed on my Notebook and I accidentally deleted the folder /etc/pam.d so i cannot use any root command neither access to my user session.
I thought about reinstalling the packages which have files installed in pam.d so i tried:

pacman -S $(pacman -Ql | grep /etc/pam.d/$ | awk '{print $1}')

into a live usb of Antergos. I did it after mounting the partitions /, /home and uefi in /mnt, /mnt/home and /mnt/boot/efi respectively. Then I did:

sudo cp /etc/resolv.conf /mnt/etc/
sudo cp /etc/hosts mnt/etc/

sudo mount --bind /dev/ /mnt/dev

sudo chroot /mnt

mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts

And finally tried this options but all of them return the same error:

pacman -S $(pacman -Ql | grep /etc/pam.d/$ | awk '{print $1}')

pacman -Syu

pacman -Syyu

pacman -S libpam-runtime libpam-modules


error that returns:

error: failed retrieving file *** from mirror.*** : Could not resolve host: mirror.***
in the *** go the names of the corresponding files and mirrors

Can you help me recover the /pam.d folder in some way? Am I doing something wrong when I mount the partitions?

PS: I have connection to Internet and I also have a copy of the folder pam.d in /home/user/Downloads (I did the copy before remove it from /etc/)
 
Old 11-24-2018, 04:07 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 11,029
Blog Entries: 7

Rep: Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777
switch off that system right now and don't use it until you fixed this.

you said that all you deleted was /etc/pam.d - so why are you copying, moving and/or touching other files?

boot the machine "from the outside" with e.g. a live usb, then copy the files you have in /home/user/Downloads back to /etc/pam.d.
make sure the directory was empty.
you will likely need to adjust permissions.

this is what it looks like on my (vanilla arch) system:
Code:
ls -al /etc/pam.d
total 140K
drwxr-xr-x  2 root root 4.0K Nov 21 21:46 ./
drwxr-xr-x 93 root root  12K Nov 22 08:29 ../
-rw-r--r--  1 root root  160 Jul 28 16:18 chage
-rw-r--r--  1 root root  160 Nov  7 14:57 chfn
-rw-r--r--  1 root root  103 Jul 28 16:18 chgpasswd
-rw-r--r--  1 root root  174 Jul 28 16:18 chpasswd
-rw-r--r--  1 root root  160 Nov  7 14:57 chsh
-rw-r--r--  1 root root  160 Jul 28 16:18 groupadd
-rw-r--r--  1 root root  160 Jul 28 16:18 groupdel
-rw-r--r--  1 root root  103 Jul 28 16:18 groupmems
-rw-r--r--  1 root root  160 Jul 28 16:18 groupmod
-rw-r--r--  1 root root  171 Nov 16 00:05 i3lock
-rw-r--r--  1 root root  220 Nov  7 14:57 login
-rw-r--r--  1 root root  174 Jul 28 16:18 newusers
-rw-r--r--  1 root root  127 Oct  6  2017 other
-rw-r--r--  1 root root  198 Jul 28 16:18 passwd
-rw-r--r--  1 root root  155 Aug 24 01:10 polkit-1
-rw-r--r--  1 root root  500 Nov  6 16:12 rlogin
-rw-r--r--  1 root root  425 Nov  6 16:12 rsh
-rw-r--r--  1 root root  160 Jul 28 16:18 shadow
-rw-r--r--  1 root root  232 Oct 19 09:39 sshd
-rw-r--r--  1 root root  366 Nov  7 14:57 su
-rw-r--r--  1 root root  366 Nov  7 14:57 su-l
-rw-r--r--  1 root root   97 Nov 15 20:30 sudo
-rw-r--r--  1 root root  441 Oct  6  2017 system-auth
-rw-r--r--  1 root root  143 Oct  6  2017 system-local-login
-rw-r--r--  1 root root  675 Oct  6  2017 system-login
-rw-r--r--  1 root root  143 Oct  6  2017 system-remote-login
-rw-r--r--  1 root root  260 Oct  6  2017 system-services
-rw-r--r--  1 root root  131 Nov 14 14:28 systemd-user
-rw-r--r--  1 root root  160 Jul 28 16:18 useradd
-rw-r--r--  1 root root  160 Jul 28 16:18 userdel
-rw-r--r--  1 root root  160 Jul 28 16:18 usermod
let's hope the files you have allow you to get your system working again.

lesson learned:
  • don't be root when you don't need to, and esp. do not use a graphical filemanager as root
  • make routine system backups
 
1 members found this post helpful.
Old 11-24-2018, 07:00 PM   #3
luther1017
LQ Newbie
 
Registered: Nov 2018
Posts: 2

Original Poster
Rep: Reputation: Disabled
Talking

Quote:
Originally Posted by ondoho View Post
switch off that system right now and don't use it until you fixed this.

you said that all you deleted was /etc/pam.d - so why are you copying, moving and/or touching other files?

boot the machine "from the outside" with e.g. a live usb, then copy the files you have in /home/user/Downloads back to /etc/pam.d.
make sure the directory was empty.
you will likely need to adjust permissions.

this is what it looks like on my (vanilla arch) system:
Code:
ls -al /etc/pam.d
total 140K
drwxr-xr-x  2 root root 4.0K Nov 21 21:46 ./
drwxr-xr-x 93 root root  12K Nov 22 08:29 ../
-rw-r--r--  1 root root  160 Jul 28 16:18 chage
-rw-r--r--  1 root root  160 Nov  7 14:57 chfn
-rw-r--r--  1 root root  103 Jul 28 16:18 chgpasswd
-rw-r--r--  1 root root  174 Jul 28 16:18 chpasswd
-rw-r--r--  1 root root  160 Nov  7 14:57 chsh
-rw-r--r--  1 root root  160 Jul 28 16:18 groupadd
-rw-r--r--  1 root root  160 Jul 28 16:18 groupdel
-rw-r--r--  1 root root  103 Jul 28 16:18 groupmems
-rw-r--r--  1 root root  160 Jul 28 16:18 groupmod
-rw-r--r--  1 root root  171 Nov 16 00:05 i3lock
-rw-r--r--  1 root root  220 Nov  7 14:57 login
-rw-r--r--  1 root root  174 Jul 28 16:18 newusers
-rw-r--r--  1 root root  127 Oct  6  2017 other
-rw-r--r--  1 root root  198 Jul 28 16:18 passwd
-rw-r--r--  1 root root  155 Aug 24 01:10 polkit-1
-rw-r--r--  1 root root  500 Nov  6 16:12 rlogin
-rw-r--r--  1 root root  425 Nov  6 16:12 rsh
-rw-r--r--  1 root root  160 Jul 28 16:18 shadow
-rw-r--r--  1 root root  232 Oct 19 09:39 sshd
-rw-r--r--  1 root root  366 Nov  7 14:57 su
-rw-r--r--  1 root root  366 Nov  7 14:57 su-l
-rw-r--r--  1 root root   97 Nov 15 20:30 sudo
-rw-r--r--  1 root root  441 Oct  6  2017 system-auth
-rw-r--r--  1 root root  143 Oct  6  2017 system-local-login
-rw-r--r--  1 root root  675 Oct  6  2017 system-login
-rw-r--r--  1 root root  143 Oct  6  2017 system-remote-login
-rw-r--r--  1 root root  260 Oct  6  2017 system-services
-rw-r--r--  1 root root  131 Nov 14 14:28 systemd-user
-rw-r--r--  1 root root  160 Jul 28 16:18 useradd
-rw-r--r--  1 root root  160 Jul 28 16:18 userdel
-rw-r--r--  1 root root  160 Jul 28 16:18 usermod
let's hope the files you have allow you to get your system working again.

lesson learned:
  • don't be root when you don't need to, and esp. do not use a graphical filemanager as root
  • make routine system backups
Thank you! It works now
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/etc/pam.d/system-auth-ac vs. /etc/pam.d/password-auth-ac vs. /etc/pam.d/sshd christr Red Hat 2 08-01-2014 07:08 PM
Accidentally removed part of the FC5 base packages andigeniu Linux - Newbie 2 09-10-2006 04:30 PM
well, there's info written inside /etc/group. accidentally del /etc/group in RedHat9 karmakid Red Hat 1 07-27-2005 10:27 PM
newbie - removed partition accidentally kristalchimera Debian 6 07-12-2003 11:36 PM
I accidentally removed lilo from my bootsector. Grafbak Linux - Newbie 2 06-20-2003 03:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Arch

All times are GMT -5. The time now is 02:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration