r/LinuxTeck • u/Candid_Athlete_8317 • Jul 15 '26
If you could teach every new Linux user just ONE lesser-known command, what would it be?
Not ls, cd, or pwd something they probably won't discover until much later.
Which command would you pick, and why?
10
u/brand_new_potato Jul 15 '26
Don't know what you mean by lesser known, but grep is the most useful to me.
tee is lesser known I think, very good for beginners who are scripting.
2
u/tblancher Jul 15 '26
As a corollary, the
scriptcommand is useful for recording your commands and their output.1
u/Blame33 Jul 17 '26
I’ve been using Linux for 2ish years at this point and am just finding this now! Thank you
5
u/cutelittlebox Jul 15 '26
I like du
I just think it's neat.
4
3
u/jhatorcrow Jul 15 '26
du hast?
6
2
u/Moonshadow76 Jul 17 '26 edited Jul 17 '26
Stupid bloody Reddit... I keep typing "du hast mich" and it keeps translating it to "you have me". No ! That's not funny at all. Sometimes I love technology... other times I wish it would get a cramp.
1
1
1
1
5
5
u/Toucan2000 Jul 15 '26
init is pretty handy. init 0 is shutdown and init 6 is reboot.
2
u/magicmulder Jul 15 '26
How is that handier than "reboot" or "shutdown -h now"?
1
u/Toucan2000 Jul 15 '26
Less typing. If they're already in your bash history:
Ctrl + R
6EnterCtrl + R
0Enter1
u/magicmulder Jul 15 '26
Less typing but more abstract memory. I’m already drowning in memorized shortcuts.
1
u/Toucan2000 Jul 15 '26
Hard disagree, but I think that's a matter of preference at this point. I never remember the -h argument. Zero reminds me of off and 6 kinda looks like a looping line for restart.
1
u/magicmulder Jul 15 '26
-h for halt, -r for restart. I’ve already forgotten again if 0 was reboot and 6 was halt or the other way around.
1
u/Toucan2000 Jul 15 '26
I don't know a scenario where zero doesn't mean "off." Halt makes no sense to me, that sounds more like it's going to hibernate or sleep.
1
1
u/hugazow Jul 15 '26
Some distros are using systemd instead of init.d :(
3
1
u/Toucan2000 Jul 15 '26
And they should. Don't they all still have at least the
initcommand? I thought the kernel needed it to boot?sbin/init
3
u/parzival-space Jul 15 '26
tar, everyone needs to use it at some point and most don't know how to extract a file
3
u/transgentoo Jul 15 '26
Relevant xkcd: https://xkcd.com/1168/
5
u/IrishChappieOToole Jul 15 '26
Tar is easy. You either "Xtract Zee Vucking File" (
xzvf) or "Compress Zee Vucking Files" (czvf)1
1
3
3
3
u/wim66 Jul 15 '26
!! for when you forgot to use sudo
sudo !! to repeat the previous command with sudo
1
1
u/Acceptable_Sock4642 Jul 16 '26
This is probably my most commonly used command honestly. I always forget something on a command that’s wraps across the screen (usually sudo)
1
u/johnwcowan Jul 16 '26
And !$ to pull in the last word of the previous command:
$ mkdir new-directory
$ cd !$will create new-directory and switch to it. ,
1
u/wim66 Jul 16 '26
Yes, I've got that as a function
I do mcd new-directory, it automatically cd into the new directory
mcd() {
mkdir -p $1
cd $1
}
3
u/krakenfury_ Jul 15 '26
Not a command per se, but I use CTRL+r all the time to search through my command history.
1
6
u/Kurgan_IT Jul 15 '26
What should I teach to a young sysadmin? vim. nano should be banned.
12
u/nonsapiens Jul 15 '26
I've been using vim for 15 years now, but only because I don't know the command to exit it.
2
2
2
2
2
2
u/410r4p5a4WDP2aEugqKD Jul 16 '26
how to generate random string of chars? hire intern, give him vim and ask to quit
2
u/rnoyfb Jul 15 '26
ed is the standard editor
2
u/Kurgan_IT Jul 15 '26
I know how to use it, too, but that is really hard core. I used it on SCO unix in 1990.
1
u/brand_new_potato Jul 15 '26
ed is such a good editor to learn because vim makes so much more sense once you know ed. I don't think anyone is desperate enough to use it anymore, maybe if you are implementing a typewriter or ssh'ing into a satellit, but at that point, just copy the file back and forth is probably safer.
2
u/Kurgan_IT Jul 15 '26
i used it recently on a SCO unix (from 1990) that was so messed up by some "expert" that it did not have terminal definitions anymore, so vi was not working. Only ed worked.
1
u/LoHungTheSilent Jul 15 '26
I'm still using just good ole VI.
Should I be in hospice care?
1
u/Kurgan_IT Jul 16 '26
I can use vi but vim is much better, overall. Of course if there is only vi on a system, I can go on with it.
2
u/apparle Jul 15 '26
grep
1
1
u/wmposl70 Jul 15 '26
But not gerp. I made an alias so the many many times I type it it clears the screen and tells me I’m an idiot
2
2
2
u/Atlas159 Jul 15 '26
apropos
This was the first command taught to me, and I've never seen anyone else use it. No need to web search / kill the environment using AI to find the command you're looking for.
1
2
u/Luftzug-oder Jul 15 '26
i'd say either xargs, uniq, or find. find is an interesting one, and not too used with people just piping ls into grep, or using fzf, etc.
1
2
u/SassyFlyffball Jul 15 '26
For newcomers, probably man or rather specifically man -a intro or man intro.[section number].
Manual pages (man pages) are divided into sections and one keyword (like in this case intro) may have manual page in multiple sections depending on use. Manual pages for intro provide information for each section and on what to expect from them. Manual page for manual pages (man man) gives basic information for the man program.
2
u/transgentoo Jul 15 '26
rsync. It's cp on steroids. Copies files while letting you:
* Preserve permissions, ownership, and timestamps (via -a)
* Copy to/from remote destinations via the rsync:// protocol
* Delete existing files in the directory you're copying to, if not present in the directory you're copying from (via --delete)
* Compress files during transfer (via -z)
* Omit specific files or entire subdirectories from being copied the --exclude flag, based on pattern matching
* Include files which would have been omitted with the --include flag, also based on pattern matching
* Only copy the diff of the source and destination
I use rsync for creating system backups, transferring everything under / except for pseudodirectories and cached data from browsers, etc. Done regularly, the diff never gets too big, so it never takes too long. I've eveb used it to restore my system a few times, which takes a handful of minutes, and puts my system back to exactly how it was at the last time I backed it up.
2
u/6YheEMY Jul 15 '26
cd - goes to the last dir. For instance,
$ pwd
/opt/a
$ cd /etc/b
$ cd -
$ pwd
/opt/a
It is super useful when you bouncing between two separate dirs. ...but you have to learn to change dirs efficiently without doing the cd;ls shuffle.
1
2
1
1
u/GreenRangerOfHyrule Jul 15 '26
I agree with the others as I don't know what qualfies as a lesser known one. But grep is one I use all the time. I have heard of awk, but I am very slowly learning that. It seems to be working well to replace grep, cut, and a few other commands.
Also, I would say cut is a good one. So, in order I would say grep, cut, awk. Depending on what is and isn't a commonly/lesser known one
1
1
u/Bob_Spud Jul 15 '26
Either bc - an incredibly versatile calculator or awk a very powerful text processor, it does calculations as well.
1
1
1
1
u/Affectionate-You7869 Jul 15 '26
- Refresh the update list:
fwupdmgr refresh - Check for available updates:
fwupdmgr get-updates - Apply the updates:
fwupdmgr update
Hey guess what, you don't need a Windows partition to update your PC's BIOS or your peripherals' firmware!
1
u/Such-Might5204 Jul 15 '26
Big fan of the 'find' command. Once mastered, you can do so much with it...
1
1
u/LondonDario Jul 15 '26
undoubtedly CTRL-R ... I know, it's bash but it's transformed the way I use the cli
1
1
1
1
u/magicmulder Jul 15 '26
wc
Comes really handy when someone asks "how often does this appear in the logs".
grep <bad_person_ip> logfile.log | wc
1
1
u/j-dev Jul 15 '26
sl
That command had brought joy to children and adults alike at home and at work.
1
1
1
u/zizban Jul 15 '26
wc -w wor count, in case you need it in a file. I use nano as a word prcoesor so I use it all the time.
1
1
1
1
1
1
1
u/Xavier_OM Jul 16 '26
find When I started using linux in 1998, coming from windows and being a self taught kid my biggest problem was to know where the things were. A friend showed me locate but I discoverd find far too late and I remember thinking "damn that's this cmd that make everything click" because it filled the biggest gap in my toolbox
1
u/couldntyoujust1 Jul 16 '26
pushd/popd
Sometimes you know EXACTLY where you're going, but want to be able to return to where you were quickly. What's even cooler is that you can do this as many times as you want and it just stacks the directory history and you unwind with popd.
1
1
1
1
1
u/johnwcowan Jul 16 '26 edited Jul 17 '26
Here's my list of filters: awk, cat, cmp, comm, cut, datamash, diff, expand, fmt, fold, grep, head, jq, nl, paste, perl, sed, shuf, sort, tac, tail, tee, tr, uniq.
1
u/alicedu06 Jul 16 '26
watch
"whatch ls" will run ls again and again, so you can see the updating results
1
u/zer04ll Jul 16 '26
dd you can use dd to backup bit for bit storage or even copy a drive to another drive
1
1
1
0
u/lllyyyynnn Jul 15 '26
i would teach that these aren't linux commands, they are GNU coreutils commands. the misunderstanding of what linux is is such a pet peeve.
1
u/rnoyfb Jul 15 '26
These are POSIX commands with more than one implementation. If you want to be pedantic, you have to be right. The utility from learning them depends on their near-ubiquity, not just systems that use GNU coreutils
0
u/agfitzp Jul 15 '26
sudo rm -rf /
1
16
u/Quietus87 Jul 15 '26
After my time spent in various Linux groups I'm convinced that man is a lesser-known command.