You are not logged in.

#1 2026-08-11 19:21:41

reggieArchExpert
Member
Registered: 2026-08-11
Posts: 16

[SOLVED] How to recover /usr/bin after accidentally deleting it

I already had to create a new working system as my system was totally screwed and couldn't for the life of me get it working.

So now I am currently using a fresh and working system, however I am still curious on how best to save a system under similar circumstance(in case this were to happen again).

Is completely reinstalling the only best solution under this circumstance? I assume so, as it wouldn't let me execute any commands at all.

Not being able to execute any command other than "pacman", was my biggest problem, as it was the only problem I couldn't solve and really was what led me to having to reinstall my system as I couldn't figure out why my system wouldn't execute any commands even after reinstalling all the packages from a mounted usb.

Last edited by reggieArchExpert (2026-08-23 21:37:48)

Offline

#2 2026-08-11 19:29:16

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,867

Re: [SOLVED] How to recover /usr/bin after accidentally deleting it

re-install all packages offline using the pacman from the install iso

Last edited by seth (2026-08-11 19:29:49)

Online

#3 2026-08-18 22:57:02

reggieArchExpert
Member
Registered: 2026-08-11
Posts: 16

Re: [SOLVED] How to recover /usr/bin after accidentally deleting it

Mmh thats what I thought would work as well, however weirdly it did install all the packages(at least based off of /usr/bin as all the binary files were there) yet still was not able to properly execute any commands(pre /usr/bin deletion). Yes same for the /bin symlink though unfortunately I did not check /sbin so perhaps this could be the cause?(though based off my knowledge I doubt so but who knows). Ignoring said reference example, please tell me this isn't the only way to fix the /usr root directory. If so, I could perhaps chalk it up to pacman reinstalling all the packages based on the wrong grep regex

Offline

#4 2026-08-18 23:08:35

reggieArchExpert
Member
Registered: 2026-08-11
Posts: 16

Re: [SOLVED] How to recover /usr/bin after accidentally deleting it

Also, one of the major errors whenever reinstalling all the packages per https://wiki.archlinux.org/title/pacman example, was a gpgme error. I did remove /etc/pacman.d/gpgme and reinstalled it && as well as reinstalling archlinux-keyrings(via pacman -Su archlinux-keyrings --needed && pacman -Sy). However unfortunately this did not solved top problem(I was able to somehow solve this error, so I suspect this might have not been the cause as problem still persisted, however I am sure this debug output might be helpful in understanding what was going on of course).

Offline

#5 2026-08-18 23:12:18

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,867

Re: [SOLVED] How to recover /usr/bin after accidentally deleting it

You got a gpgme error using the pacman from the install iso ?

Not being able to execute any command other than "pacman"

Do not try to fix the system from within, do not chroot into the system, do not use --sysroot but --root and --cachedir!
Don't forget to use --root when querying the list of packages as well - otherwise you'll re-install the packages from the install iso

Online

#6 2026-08-19 04:15:18

cryptearth
Member
Registered: 2024-02-03
Posts: 2,339

Re: [SOLVED] How to recover /usr/bin after accidentally deleting it

just out of pure curiosity: how does one delete /usr/bin by accident (or anything outside $home)? - as doing so requires root
or was this a script like valve's mishap?
https://youtu.be/qzZLvw2AdvM
https://github.com/valvesoftware/steam- … ssues/3671

Offline

#7 2026-08-19 04:20:20

reggieArchExpert
Member
Registered: 2026-08-11
Posts: 16

Re: [SOLVED] How to recover /usr/bin after accidentally deleting it

"You got a gpgme error using the pacman from the install iso" yes precisely, pacman returns after receiving the packages "unsign keys, do you want to delete it". It does not recognize the packages as signed.

You also you bring up some fair solutions that I will definitely try in a future broken /usr/bin dir. Its reasonable that this could be from not reinstalling all the packages from a different root properly, as certain commands would sometimes fail to work though(though would work right after fixing the packages signatures). Bizzare, will mark post as resolved

Offline

#8 2026-08-19 05:27:09

reggieArchExpert
Member
Registered: 2026-08-11
Posts: 16

Re: [SOLVED] How to recover /usr/bin after accidentally deleting it

cryptearth wrote:

just out of pure curiosity: how does one delete /usr/bin by accident (or anything outside $home)? - as doing so requires root
or was this a script like valve's mishap?
https://youtu.be/qzZLvw2AdvM
https://github.com/valvesoftware/steam- … ssues/3671

Fair question. definitely wasn't intentional haha. Was ordinary(non root) user when trying to delete a previously but needless bin in $HOME directory. Wouldn't let me delete it with current permissions. I suspect it was most likely from installing the bin files via sudo. Though this was a weird error indeed as I expected it to stick to current pwd regardless of sudo. Should have definitely chown the custom bin dir for appropriate user before mindlessly using "sudo rm -rf bin"(yes I have seen the sudo https://wiki.archlinux.org/title/sudo article, though if useful in my case would love to see how).

Last edited by reggieArchExpert (2026-08-19 06:54:06)

Offline

#9 2026-08-19 05:32:33

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,867

Re: [SOLVED] How to recover /usr/bin after accidentally deleting it

pacman returns after receiving the packages "unsign keys, do you want to delete it"

Please don't paraphrase, https://bbs.archlinux.org/viewtopic.php?id=57855
Most likely you're using an older iso w/ outdated keyring.

pacman -Sy archlinux-keyring

This is supposed to update the keyring on the (temporary filesystem of) the installation iso and will hopefully then allow you to update the system w/ "pacman -Qnq --root /mnt | pacman -Syu --root /mnt --cachedir…"

Online

#10 2026-08-19 06:21:03

cryptearth
Member
Registered: 2024-02-03
Posts: 2,339

Re: [SOLVED] How to recover /usr/bin after accidentally deleting it

reggieArchExpert wrote:

. I suspect it was most likely from installing the bin files via sudo. Though this was a weird error indeed as I expected it to stick to current pwd regardless of sudo. Should have definitely chown the custom bin dir for appropriate user before mindlessly using "sudo rm -rf bin"(.

well, usually when you in $home and execute something via sudo this shouldn't (tm) change your working directory - sounds more like planed command was "rm -rf ($home/)bin" but by accident an additional / slipped in resulting in "rm -rf /bin" instead (which is a symlink to /usr/bin) ... happens to the best
also "something something sudo something $home something" sounds like the initial "install" of what you wanted to remove went wrong: usually you either install a package via "sudo package -U pgk.zst" or you just unpack some archive inside $home - require sudo within $home already sounds wrong -> the chain to what you end up seem to have started sometime earlier combined with a few unlucky mishaps

no offense - has happened to the best - the important part: you already learned one possible option: next time rather chown instead of rm -rf ... although this won't save you when you again slip in a / and end up chown /usr/bin instead wink

Offline

#11 2026-08-19 10:01:41

reggieArchExpert
Member
Registered: 2026-08-11
Posts: 16

Re: [SOLVED] How to recover /usr/bin after accidentally deleting it

seth wrote:

pacman returns after receiving the packages "unsign keys, do you want to delete it"

Please don't paraphrase, https://bbs.archlinux.org/viewtopic.php?id=57855
Most likely you're using an older iso w/ outdated keyring.

pacman -Sy archlinux-keyring

Correct, mounted usb was pretty old. If anything, you might have found the problem

This is supposed to update the keyring on the (temporary filesystem of) the installation iso and will hopefully then allow you to update the system w/ "pacman -Qnq --root /mnt | pacman -Syu --root /mnt --cachedir…"

As cryptearth mentioned previously, I understand that I have to use set example though I won't report is as duplicated(though I am not even sure how to)  as I always prefer an "explicit written cli example".

Offline

#12 2026-08-19 10:26:27

reggieArchExpert
Member
Registered: 2026-08-11
Posts: 16

Re: [SOLVED] How to recover /usr/bin after accidentally deleting it

cryptearth wrote:

.
also "something something sudo something $home something" sounds like the initial "install" of what you wanted to remove went wrong: usually you either install a package via "sudo package -U pgk.zst" or you just unpack some archive inside $home - require sudo within $home already sounds wrong -> the chain to what you end up seem to have started sometime earlier combined with a few unlucky mishaps

This is notable as I am also not fully aware how the $bin dir in $HOME ended up needing sudo privileges anyway. I just assumed that I used sudo, however note this is simply an assumption. Yeah above case to me actually seems much more likely to be the case, though I wish I could gain insight on installation specifics. Yeah definitely some unlucky mishaps, and no offense taken. I am sure many users may found this example useful, as I don't believe this bug is documented explicitly. Will add an edit https://wiki.archlinux.org/title/pacman to document possible bug in #troubleshooting of course

Offline

#13 2026-08-19 12:31:09

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,867

Re: [SOLVED] How to recover /usr/bin after accidentally deleting it

As cryptearth mentioned previously, I understand that I have to use set example though I won't report is as duplicated(though I am not even sure how to)  as I always prefer an "explicit written cli example".

Errr… what? (I also didn't follow your side-chatter w/ cryptearth)

Did the keyring update allow you to re-install the packages on the installed system w/ the pacman instance of the install iso?
Did that fix the original problem?

Online

#14 2026-08-19 14:20:40

cryptearth
Member
Registered: 2024-02-03
Posts: 2,339

Re: [SOLVED] How to recover /usr/bin after accidentally deleting it

seth wrote:

(I also didn't follow your side-chatter w/ cryptearth)

*sad cat face with tear

reggieArchExpert wrote:

though I wish I could gain insight on installation specifics.

well, "(to) install (software)" usually means: extract an archive and make the system aware of it by adding information into a database (list of installed packages / on windows: registry)
this extraction happen either inside folders the user has write permission themself, usually home, or system wide with the latter require root
what maybe could have happened: used root to extract an archive within home
why this resulted in something owned by root in a user home: software to be distributed is usually shipped in a user-agnostic way - that means: when the archive is unpacked the resulting files are owned by the current process' user - either your user or root
when you extract a package within home but with root the resulting files end up owned by root instead of your user
again: likely just some "monday morning"-ish level of unfortunate combination of mishaps - has happened to all of us - and ever will - hell, AI caused production systems to be wiped or hacked another related project ... "all in the name of science!" *sorry, couldn't resist to smuggle that one in

whatever it was - it happened and had some unfortunate result
luckly with the help of power users like seth and others with mucho knowledge arch is quite forgiving in terms of restorability - should be possible to fully recover

Offline

#15 2026-08-20 07:57:28

reggieArchExpert
Member
Registered: 2026-08-11
Posts: 16

Re: [SOLVED] How to recover /usr/bin after accidentally deleting it

cryptearth wrote:

luckly with the help of power users like seth and others with mucho knowledge arch is quite forgiving in terms of restorability - should be possible to fully recover

Yeah largely why I even posted this question in the forum. Its been the only consistent thing causing me having to reinstall. I have always largely found the wiki to be very(if not entirely) helpful for most things/troubleshooting related. The "bbs.archlinux.org" site is definitely important, however I don't know how we deal with users not following the guidelines on how to pose a question(or if we were to be a little less uncharitable, some could call ‘just being honest’, at least know how to pose a question themselves). This is the one major problem I have always noticed as it always stopped me from searching the forum when troubleshooting, as 'Op' -> "I have a problem", 'helpful user' -> 'Can you please post so and so log so we can at least help you troubleshoot the problem ', Op either doesn't even know about this, complains, or discussion usually ends rights here. Whenever half or more of the questions asked on the forums largely consists of the same thing, it really removes one of the major usefulness for users like me.

Luckily again, I have always found the wiki to be pretty much helpful for almost every single problem I have encountered when dealing with arch. So its not like its the end of the world for this site. I wonder if any maintainer or frequent "archlinux.org" contributor have any ideas on how to deal with this.

Last edited by reggieArchExpert (2026-08-20 10:17:19)

Offline

#16 2026-08-21 06:18:18

reggieArchExpert
Member
Registered: 2026-08-11
Posts: 16

Re: [SOLVED] How to recover /usr/bin after accidentally deleting it

Sorry how do I mark a post as solved? Also, if I could get a detailed manual/wiki of forums guidelines(plus any extra y'all think could help expand my knowledge on this would be very much appreciated).

Offline

#17 2026-08-21 06:23:05

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,867

Re: [SOLVED] How to recover /usr/bin after accidentally deleting it

Mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

https://wiki.archlinux.org/title/General_guidelines

Online

Board footer

Powered by FluxBB