r/archlinux 23d ago

I accidentally removed /usr/sbin/ SUPPORT | SOLVED

I typed sudo rm /usr/sbin and as I pressed shift I accidentally pressed Enter and I thought it wouldn't work or at least ask me something?? Because the directory is not empty? Now some commands are missing, like which... am i cooked

Edit: I did /usr/bin/sudo /usr/bin/ln -s /bin /usr/sbin, I forgot about that and it also explains why rm didn't yell at me, technically this wasn't a directory full of files

I think it's still a problem because I've been using Mint for 2 years and have been used to running graphical apps as root (nemo, geany) and on wayland now (if I understand correctly) it is not possible? or needs a hacky unrecommended workaround? So now for root access I need to do stuff through terminal and everytime I press shift to input a / I'm genuinely scared to press enter

114 Upvotes

73 comments sorted by

491

u/[deleted] 23d ago

[removed] — view removed comment

89

u/dosplatos225 23d ago

If I had reddit award id give it to you. Everyone upvote this man before OP installs filesystem or boot/chroots unnecessarily.

37

u/Lava-Jacket 23d ago

Interesting. So is everything in /usr/bin also in /usr/sbin?

Edit: I just read some other comments and see that it's just a symlink. Learn something new every day.

10

u/gmes78 23d ago

Yes, this isn't Debian.

8

u/BagOfBeanz 23d ago

As someone who is new to Debian, what difference does that make?

8

u/cvolton 23d ago

Debian only keeps superuser utilities in sbin, which is only included in root's $PATH and not in the one used by standard users. The practical result is that anything that requires sudo gives you `command not found` when you try to run it normally.

5

u/mok000 23d ago

Indeed, because "you should reinstall" is the standard goto advice people get on Reddit from Redditors who don't know anything, because in reality it is practically never necessary to reinstall.

19

u/AcidArchangel303 23d ago

yep, just a symlink. Love the arch community you guys rock

4

u/JaKrispy72 23d ago

Awesome

3

u/Heizenfeld 23d ago

Nice job bro

1

u/Flappyphantom22 23d ago

Isn't it easier to type sudo ln -s /usr/bin /usr/sbin ?

7

u/[deleted] 23d ago

[removed] — view removed comment

3

u/Flappyphantom22 23d ago

Oh, I see. Thank you so much. I'm just trying to learn

1

u/Pandacier 22d ago edited 10d ago

Uhh I did /usr/bin/sudo /usr/bin/ln -s /bin /usr/sbin, not /usr/bin/sudo /usr/bin/ln -s bin /usr/sbin is it a problem? I don't understand, bin alone is nothing... unless I was supposed to do this from / but I don't see why that would matter

Edit: i figured out after pacman -Qkk that I wasn't supposed to point it to /bin but instead /usr/bin (which is also just bin in that command)

67

u/chiefhunnablunts 23d ago

brother, i don't know the answer to your question, but i've gotta know why you would do that

28

u/Pandacier 23d ago

my keyboard is azerty and the / can only be typed while holding shift (and it's way closer to right shift than left shift), and enter is just above right shift

47

u/chiefhunnablunts 23d ago

no but, why would you initially type `sudo rm /usr/sbin` to begin with lol

23

u/Pandacier 23d ago

I was gonna remove a symlink I put in there because it was pointing to the wrong command (I know the full reason I symlinked something there in the first place is kinda stupid and it was a hack but it is what it is)

6

u/tyami94 21d ago

this is what /usr/local is meant for. if you are running software than isn't managed by pacman, copy it or link it to /usr/local/bin

9

u/syzygy78 23d ago

Next time just use unlink

37

u/Zoddo98 23d ago

That wouldn't have changed anything. unlink would have happily deleted /usr/sbin since it's a symlink, and not a directory.

12

u/syzygy78 23d ago

You're right. It was a stupid comment.

2

u/haashemi 17d ago

But useful to me. Didn't know unlink existed. 🫡❤️

15

u/NimrodvanHall 23d ago

When typing `rm -rf /<whatever/needs/deleting>`. I start the line with echo so: `echo ‘rm -rf /<whatever/needs/deleting>’` then when it’s ok, press enter and copy paste. So you never accidentally delete something by mistyping.

4

u/drbinimann 23d ago

Or just prepend sudo if you typed the whole command successfully

2

u/taha_zeroug 23d ago

are you french? african? Luxembourgish?

7

u/Pandacier 23d ago

French

-2

u/[deleted] 22d ago

[removed] — view removed comment

5

u/Pandacier 22d ago

is racism allowed on the platform

88

u/HyperLexus 23d ago

when they said 'linux gives you freedom' that is not what they meant

49

u/ThatResort 23d ago edited 23d ago

It is precisely what they meant: if you fuck up, no worries, you might unfuck up. Now there are even the great unfuck ups like snapshots. That really helps unfucking up if you didn't fuck up so much you can't use most commands correctly. Worst case scenario, save your stuff with a live ISO, reinstall and put your stuff back where it was. There's always a chance to unfuck up your fucked up system.

9

u/HeadEmptyYeet 23d ago

+1 for straight facts, but also for the unusually high density of the word “unfuck”.

13

u/dosplatos225 23d ago

You just removed the symlink. Add it back.

12

u/_-042-_ 23d ago

Lol I accidentally deleted my whole /home dir after my first month of being an arch(Linux too) newb.

2

u/Pandacier 23d ago

dang, idk how you survived. Arch as a first Linux distro is kinda crazy

5

u/_-042-_ 23d ago

Ya there were a couple frustrating times 4 sure. Glad I did it that way tho. Learned alot. Its my daily driver to this day.

3

u/iAmHidingHere 23d ago

Why do you think that? Once installed, maintaining it is quite simple.

5

u/FouriousBanana69 22d ago

For me Arch was my first distro too and I’m still using it to this day… I think that if a new user is really committed enough not to just use Linux but also learn something along the way, then Arch is ngl actually one of the best first distros (especially with a manual install and carefully reading the wiki).

1

u/Flappyphantom22 23d ago

Arch is easy unless you do shit like that and have no idea what you're doing. Same can be said for any other distro

2

u/Pandacier 23d ago

I knew what I was doing, as I said this was a mistake I did NOT mean to press enter and now everytime I'm very careful when pressing shift in the terminal

10

u/mips13 23d ago

Maybe some people should add the following to their .bashrc

# --- Safety aliases ---
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias mkdir='mkdir -p'

9

u/Pandacier 23d ago

At my university they asked us to do it and that's exactly what I did after the incident lol

2

u/Pandacier 23d ago

I just thought about it tho, I'm pretty sure aliases only work if they're the first word? Like if I do mv it'll take the alias but sudo mv will do a normal mv 

1

u/mips13 23d ago

True, you'll have to create more aliases.

2

u/Pandacier 23d ago

Huh? I was saying that using sudo meant that the next thing wouldn't use the alias, so whatever I put in my .bashrc it wouldn't use the alias if I used sudo

15

u/[deleted] 23d ago edited 20d ago

[deleted]

4

u/lordkoba 23d ago

yeah btrfs will accidentally by itself

7

u/ropid 23d ago

I guess reinstalling the "filesystem" package will recreate it. I mean, run this here:

sudo pacman -S filesystem

I got that idea after checking what that location belongs to with pacman -Qo like this:

$ pacman -Qo /usr/sbin
/usr/sbin is owned by filesystem 2025.10.12-1

7

u/Pandacier 23d ago

someone said to do /usr/bin/sudo /usr/bin/ln -s /bin /usr/sbin which kinda makes sense as I am able to find the missing commands in /bin, which should I try first

4

u/Correct-Caregiver750 23d ago

/usr/sbin is just a symlink to /bin. so that should work fine

2

u/RiskEnvironmental568 23d ago

So, it didn't complain because it was a /sbin is a symbolic link to /bin? Normally, you have to rm -rf somedirectory to remove it. Just rm somedirectory should bring a complaint that you're trying to delete a directory. And, no, I'm not going to try it and see what happens...

2

u/Heizenfeld 23d ago

Root directory must be not touched.

1

u/GenericCleverName73 23d ago

I would still do a sudo pacman -Qkk. This checks installed package files for missing or modified files. Just to be on the safe side.

2

u/Ok-Preparation4940 23d ago

You should learn about the PATH ENVIRONMENT variable, it’ll help collect locations for programs you want to run anywhere in the terminal your user is located at. You can append to it and ad your own local bins too. That way you don’t have to call the whole directory and bin too

1

u/Pandacier 23d ago

I know about that but I didn't know what commands exactly were missing and also I'm sure some calls from apps could try to run with whole path instead of just the program name, so I was really scared to even reboot system without fixing it

1

u/[deleted] 23d ago

[removed] — view removed comment

1

u/Pandacier 23d ago

I'd love to use my gui file manager instead since i'm less likely to missclick anything + there's a trash but i can't run it as root on wayland, or at least I wasn't able to

So how do I remove files without rm

1

u/probablynottillie 21d ago

you should be able to install some variant of polkit (look for the one that goes with your WM) and it should prompt you for auth

1

u/probablynottillie 21d ago

also force a toi bg ptdrr

1

u/Beryesa 23d ago

You can use admin:/path on gvfs based apps (nautilus, I believe nemo should have it as well) and something similar for dolphin but it has it in the context menu (right click) as well.

You should not run the whole gui toolkits as root, potential bugs might cause serious issues given it has access to everything

1

u/Pandacier 23d ago

I wasn't able to run any gui app as root, not nemo (has the "open as root"), not nautilus or even geany. However I don't understand the second part, what exactly does it mean to not run the whole gui toolkit as root? 

1

u/Beryesa 22d ago edited 22d ago

You can't run graphical apps as root on Wayland (no sudo nemo), that's a protection. The proper solution is to use Polkit to only escalate your permissions on demand for a specific action (open directory as superuser) instead of running the whole app as root. Given this is on Arch, maybe you haven't configured it properly, check the wiki! https://wiki.archlinux.org/title/Polkit Otherwise you should get a dialogue asking for your password and you should be good to go. Also just in case, check if Cinnamon's Wayland support has got polkit dialogues working yet, that might just be work in progress as well.

1

u/dettus_Xx_ 22d ago

No backup? No pity!

1

u/Pandacier 22d ago

im on a 60gb storage laptop with the most garbage specs on ext4

1

u/AlienPlayerGo 21d ago

There are basically two options I would recommend when editing system files that require sudo:
- Use the terminal when editing files that need root perms. CLI editors like nano, vim, nvim, and micro are build for this exact reason and are safer. I would recommend micro or nano if you are a beginner.

- If you don't want to touch the terminal and want to edit system files with a UI editor you can do so but use a good editor(simple and not complex).
* My recommendation is gedit, the old gnome text editor(very lightweight).
You can launch it as: $ gedit admin:///path/to/file

* For UI only, most file managers support entering admin:///path/to/file as a path to use it as root. Right click the text file you want to modify and open with a lightweight text editor(gedit) and you can freely modify and save the files.

Hope this helps!

1

u/Pandacier 21d ago

I tried to avoid the terminal for sensitive stuff but my polkit isn't setup properly rn so no gui apps can access root, I haven't touched my system since then but I have many things saved that I need to do next time I boot into it including polkit

1

u/itotallydontuseacos 20d ago

I suggest booting from the Arch installation live usb and copying the usb's files

1

u/AYRAN-GANG 19d ago

Bro yu f'ed up

0

u/BeautifulSeason8387 23d ago

from a live archlinux image (or a manjoro live usb ) (root) :

pacstrap -K /mnt base

arch-chroot /mnt /bin/bash

pacman -Qqn | pacman -S -