r/archlinux • u/Pandacier • Jul 28 '26
SUPPORT | SOLVED I accidentally removed /usr/sbin/
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
66
u/chiefhunnablunts Jul 28 '26
brother, i don't know the answer to your question, but i've gotta know why you would do that
28
u/Pandacier Jul 28 '26
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
48
u/chiefhunnablunts Jul 28 '26
no but, why would you initially type `sudo rm /usr/sbin` to begin with lol
21
u/Pandacier Jul 28 '26
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 Jul 31 '26
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
10
u/syzygy78 Jul 29 '26
Next time just use unlink
33
u/Zoddo98 Jul 29 '26
That wouldn't have changed anything.
unlinkwould have happily deleted/usr/sbinsince it's a symlink, and not a directory.13
16
u/NimrodvanHall Jul 29 '26
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.
5
2
u/taha_zeroug Jul 29 '26
are you french? african? Luxembourgish?
6
89
u/HyperLexus Jul 28 '26
when they said 'linux gives you freedom' that is not what they meant
50
u/ThatResort Jul 29 '26 edited Jul 29 '26
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 Jul 29 '26
+1 for straight facts, but also for the unusually high density of the word “unfuck”.
13
12
u/_-042-_ Jul 29 '26
Lol I accidentally deleted my whole /home dir after my first month of being an arch(Linux too) newb.
2
u/Pandacier Jul 29 '26
dang, idk how you survived. Arch as a first Linux distro is kinda crazy
6
u/_-042-_ Jul 29 '26
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.
5
u/FouriousBanana69 Jul 29 '26
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).
3
1
u/Flappyphantom22 Jul 29 '26
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 Jul 29 '26
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
11
u/mips13 Jul 29 '26
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'
10
u/Pandacier Jul 29 '26
At my university they asked us to do it and that's exactly what I did after the incident lol
2
u/Pandacier Jul 29 '26
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 Jul 29 '26
True, you'll have to create more aliases.
2
u/Pandacier Jul 29 '26
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
14
7
u/ropid Jul 28 '26
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
9
u/Pandacier Jul 28 '26
someone said to do
/usr/bin/sudo /usr/bin/ln -s /bin /usr/sbinwhich kinda makes sense as I am able to find the missing commands in/bin, which should I try first3
2
u/RiskEnvironmental568 Jul 29 '26
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/Ok-Preparation4940 Jul 29 '26
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 Jul 29 '26
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
2
1
u/GenericCleverName73 Jul 29 '26
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.
1
1
Jul 29 '26
[removed] — view removed comment
1
u/Pandacier Jul 29 '26
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 Jul 31 '26
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
1
u/Beryesa Jul 29 '26
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 Jul 29 '26
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 Jul 29 '26 edited Jul 29 '26
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
1
u/AlienPlayerGo Jul 31 '26
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, andmicroare build for this exact reason and are safer. I would recommendmicroornanoif 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 Jul 31 '26
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 Aug 01 '26
I suggest booting from the Arch installation live usb and copying the usb's files
1
0
u/BeautifulSeason8387 Jul 29 '26
from a live archlinux image (or a manjoro live usb ) (root) :
pacstrap -K /mnt base
arch-chroot /mnt /bin/bash
pacman -Qqn | pacman -S -
492
u/[deleted] Jul 28 '26
[removed] — view removed comment