Accidentally removed my admin account

I limited mirrors to 4 after the update of all mirrors.

    ~  ls -la /etc/pacman.d/                                                                                                                           ✔ 
total 24
drwxr-xr-x   3 root root  4096 Sep 28  2023 .
drwxr-xr-x 118 root root 12288 Nov 16 15:15 ..
drwxr-xr-x   5 root root  4096 Nov 16 05:18 gnupg
-rw-r--r--   1 root root   543 Nov 16 16:30 mirrorlist
    ~  cat /etc/pacman.d/mirrorlist                                                                                                                    ✔ 
##
## Manjaro Linux default mirrorlist
## Generated on 2024-11-16 16:30
##
## Please use 'pacman-mirrors -f [NUMBER] [NUMBER]' to modify mirrorlist
## (Use 0 for all mirrors)
##

## Country : United_States
Server = https://opencolo.mm.fcix.net/manjaro/stable/$repo/$arch

## Country : United_States
Server = https://mnvoip.mm.fcix.net/manjaro/stable/$repo/$arch

## Country : Bulgaria
Server = https://mirror.telepoint.bg/manjaro/stable/$repo/$arch

## Country : Greece
Server = https://ftp.cc.uoc.gr/mirrors/linux/manjaro/stable/$repo/$arch
    ~  sudo pacman -Syuv                                                                                                                               ✔ 
[sudo] password for alexandra: 
Root      : /
Conf File : /etc/pacman.conf
DB Path   : /var/lib/pacman/
Cache Dirs: /var/cache/pacman/pkg/  
Hook Dirs : /usr/share/libalpm/hooks/  /etc/pacman.d/hooks/  
Lock File : /var/lib/pacman/db.lck
Log File  : /var/log/pacman.log
GPG Dir   : /etc/pacman.d/gnupg/
Targets   : None
:: Synchronizing package databases...
error: failed to synchronize all databases (unexpected error)```

You know … I was just looking and at the bottom of the /etc/passwd you might be missing

alpm:x:953:953:Manjaro Linux Package Management:/:/usr/bin/nologin

Please add this as the last line (plus an empty newline) to the /etc/passwd file.

Click here for steps to open/edit file

You can just open the file with kate.
Via a command: kate /etc/passwd
Or you can use sudo and terminal editor like nano.
sudo nano /etc/passwd

Then attempt running pacman again;

sudo pacman -Syu
3 Likes

I don’t have that line, you are right. What is the command to write that to the file, please?

You can do so with any editor.

(Also see the “Click here…” section in the previous post.)

But if you want to copy/paste something this should work;

printf 'alpm:x:953:953:Manjaro Linux Package Management:/:/usr/bin/nologin\n' | sudo tee -a /etc/passwd

Running that command prints the quoted string, including a newline \n, then uses sudo and tee -a to append it to the bottom of that file.

You can also inspect it after any changes to verify with something like

cat /etc/passwd

If I’m right pacman should work directly after the change.

2 Likes
    ~  printf 'alpm:x:953:953:Manjaro Linux Package Management:/:/usr/bin/nologin\n' | sudo tee -a /etc/passwd
alpm:x:953:953:Manjaro Linux Package Management:/:/usr/bin/nologin
    ~  sudo pacman -Syu                                               ✔ 
:: Synchronizing package databases...
 core is up to date
 extra is up to date
 multilib is up to date
:: Starting full system upgrade...
 there is nothing to do

Thank you so much!

1 Like

Hurrah!
So much more exciting than backups. :slight_smile:
Happy penguining. :penguin:

3 Likes

@Persephone, from reading this thread, you need to develop a better strategy for dealing with *.pacnew files, instead of blindly overwriting them.

Arch Wiki

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.