this post was submitted on 23 Oct 2025
166 points (96.1% liked)

Linux

9966 readers
466 users here now

A community for everything relating to the GNU/Linux operating system (except the memes!)

Also, check out:

Original icon base courtesy of lewing@isc.tamu.edu and The GIMP

founded 2 years ago
MODERATORS
 

Today had some important markdown file that accidentally deleted on my SSD and had to go over the recovery of it.

All I did was this:


run sudo systemctl status fstrim.timer to check how often TRIM runs on my system (apparently it runs weekly and the next scheduled run was in 3 days)

run sudo pacman -S testdisk

run sudo photorec

choose the correct partition where the files were deleted

choose filesystem type (ext4)

choose a destination folder where to save recovered files

start recovery

10-15 minutes and it's done.

open nvim in parent folder and grep for content in the file that I remember adding today


That's it - the whole process was so fast. No googling through 10 different sites with their shitty flashy UIs promising "free recovery," wondering whether this is even trustworthy to install on your machine, dealing with installers that'll sneak in annoying software if you click too fast, only to have them ask for payment later. No navigating complex GUIs either.

I was so thankful for this I actually donated to the maintainers of the software. Software done right.

you are viewing a single comment's thread
view the rest of the comments
[–] TachyonTele@piefed.social 38 points 1 week ago* (last edited 1 week ago) (10 children)

Question. Where do you learn commands? There's no way you thought "let's try sudo" out of no where.

Sincerely,
New Linux User

Edit: Great responses everyone, thank you!

[–] puttputt@beehaw.org 26 points 1 week ago (1 children)

In another comment, OP said they checked the arch wiki, specifically https://wiki.archlinux.org/title/File_recovery. The arch wiki is a great resource; most of the information is not arch-specific and is useful for linux in general.

Regarding "let's try sudo": you should get familiar with sudo because it's one of the most important linux commands. It runs a command with elevated privileges (it originally stood for "super-user do"). That means sudo isn't actually the important part of the commands; it just means that the following commands (pacman and photorec) need elevated privileges. pacman deals with systemwide package management and photorec needs access to the raw storage device objects in order to recover files.

[–] thingsiplay@beehaw.org 15 points 1 week ago (1 children)

Acktually sudo is there to run a command as another user, it does not need to be "superuser" (also known as rot). "superuser" is just the default. To be honest, I never used the option to run as another user, because my computers are single user only. There are so many more options. One should look into man sudo to see whats possible, its incredible!

However, there are alternatives to sudo, such as doas from OpenBSD ported over and run0 from the evil SystemD. They find sudo to be complicated and bloated.

Also quick tip: sudoedit (same as sudo -e or sudo --edit) instead sudo vim to edit your files with elevated privileges while using your personal configuration. If you want do that, that's up to you. I want to use my Vim configuration while editing files within sudo right.

[–] towerful@programming.dev 4 points 1 week ago (1 children)

Yeh, I think it's actually "switch user do".
Like "su" is "switch user".

The default being root is handy.

[–] thingsiplay@beehaw.org 3 points 1 week ago (1 children)

Yes and no. The original design of sudo stands for super user do, and could only run with super user privileges. The run as other users feature was added later, and then they renamed it to substitute user do. I even looked up to get that fact right, and always forget its "substitute" and not "switch", but I also think of sudo as switch user do.^^

[–] towerful@programming.dev 3 points 1 week ago

Massive Linux lore dumps going on, and I love it.
Thanks for correcting me.

[–] styanax@lemmy.world 21 points 1 week ago (1 children)

In the old days, we would ls /usr/bin/ (sic, there are several locations defined for apps) and either look at the man page (if it existed) for the items we saw, or just run the commands with a --help option to figure out what they did. At best we maybe had an O'Reilly book (the ones with animals on the covers) or friends to ask. You can still do that today instead of reading blog posts or websites, just look, be curious and be willing to break something by accident. :)

Part of the Linux journey is to be inquisitive and break some stuff so you can learn to fix it - unlike say Windows, on a Unix-style system the filesystem is laid out in a very specific way (there's a specification [1]) so one always know where "things" are - docs go here, icons go there, programs go here, configs go there... - lending itself to just poking around and seeing what something does when you run it.

After awhile your brain adjusts and starts to see all the beautiful patterns in design of the typical Linux OS/distro because it's all laid out in a logical manner and documented how it's supposed to work if you play the game correctly.

[1] https://refspecs.linuxfoundation.org/fhs.shtml

[–] AnUnusualRelic@lemmy.world 3 points 1 week ago

In the old days, we would ls /usr/bin/ (sic, there are several locations defined for apps) and either look at the man page (if it existed) for the items we saw, or just run the commands with a --help option to figure out what they did

I confirm, that's exactly what I did in the 90s.

[–] nope@jlai.lu 9 points 1 week ago* (last edited 1 week ago)

A very nice terminal-based cheatsheet is named tldr (or tealdeer).
It gives you a very short explanation of what a program does, and then lists common uses of that program and explains them

there are lots of cheatsheets out there but the best way to learn commands is practice. different people will use different commands, so you may not need to spend time learning ffmpeg syntax whereas others find it invaluable. Google is your friend while learning. if you have a Linux question, chances are someone else has had the same question and posted about it online. as far as basics go, spend some time learning about grep and find, they are probably the two most valuable basic commands imo outside of the common ls/mkdir/etc.

as for sudo, it's just "superuser do" so it's essentially the same as hitting run as admin in windows. lots of times if you try to run a command without sudo that needs it, you'll get a permission error which reminds you to run as superuser. it eventually becomes second nature to say "ah, this command needs direct access to a hardware device or system files" which means it'll need to be run with sudo.

[–] Labotomized@lemmy.world 3 points 1 week ago

I am also a novice so take that into account. But it seems to me it’s something you learn over time what commands do what and when to use them. I think it’s kind of like knowing what folders or settings to navigate to in other operating systems. Over time you get a feel for it.

Also most troubleshooting guides or things like photo rec have the steps kind of built in and explained to you what commands do what.

If the guide you’re reading has the steps try to break them down and figure out what the command is actually doing rather than blindly copy pasting.

[–] bitwolf@sh.itjust.works 2 points 1 week ago

It takes some time to understand the manpage format but it's worth the time because they're always available.

When I first started, I used the website explainshell to help my get an idea of how the most common commands worked.

This has the benefit of referencing the man pages directly so you can better learn how to interpret them.

[–] Badabinski@kbin.earth 2 points 1 week ago

If you'd like to learn more about Bash itself, this is an amazing resource: https://mywiki.wooledge.org/BashGuide

Probably the ONLY place on the internet that will teach you to write safe shell scripts. Most shit on StackOverflow (and consequently, most shell generated by LLMs) is dangerous garbage.

[–] Cris_Color@lemmy.world 2 points 1 week ago* (last edited 1 week ago)

Most of what I've learned has been the handful that have stuck when I've looked up how to do stuff. If you ever install a minimal distro and follow a guide or anything that's a great way to learn. Or if you look up how to fix something and you find commands on the internet, you can look up what their solutions do. But mostly I'm just replying to wish you well on your journey.

Best of luck with linux, hope you have a lovely day ☺️

[–] misteloct@lemmy.dbzer0.com -2 points 1 week ago* (last edited 1 week ago) (1 children)

AI is great for learning Linux imo, e.g. ask "why did my command say Permission Denied?". If you object to ChatGPT there are local AI engines too

[–] misteloct@lemmy.dbzer0.com 1 points 1 week ago* (last edited 1 week ago)

Downvoted because "AI bad". Seriously OP don't discount it. Source: I'm a professional software engineer.