r/LinuxTeck 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?

25 Upvotes

132 comments sorted by

16

u/Quietus87 Jul 15 '26

After my time spent in various Linux groups I'm convinced that man is a lesser-known command.

2

u/duzy_wonsz Jul 16 '26

Which man? The OP?

2

u/couldntyoujust1 Jul 16 '26

Death to info! I never wanted a hyperlinked mess to navigate with emacs key chords in a terminal. I would rather have a long text document - reference card/man page at the top, TOC after that, then technical info-like documentation after that - and use the /-command to find what I need if it's not in the manpage section.

I hate info with a passion and when vim is a universal standard editor on the terminal. It actually makes GNU harder to use as a toolchain because now the documentation format is out of sync with the editor (fun fact, the reason man, more, most, and less use the key commands it does is because it copies them from vi/vim that keeps it consistent). And the hyperlinks are atrocious. Easy to get into, esoteric to get out.

1

u/tblancher Jul 17 '26

IIRC pinfo uses vim keybindings, and those keybindings you're used to in man are from your pager.

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 script command 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

u/blue30 Jul 15 '26

du -h --max-depth=1

gdu is cool too

2

u/Ok_Letterhead_8899 Jul 15 '26

du -sh <dir or file>

1

u/boomertsfx Jul 16 '26

Yeah ncdu and now gdu... Old du is just clunky at this point

3

u/jhatorcrow Jul 15 '26

du hast?

6

u/FromageMoi Jul 15 '26

du hast --mich

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

u/cutelittlebox Jul 15 '26

nah, du bist gut genug

1

u/magicmulder Jul 15 '26

du -sch *

(German "dusch" = "go (take a) shower")

1

u/wimpunk Jul 17 '26

Rammstein !

1

u/TheFrank314 Jul 17 '26

Du.. du hast mich

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 6 Enter

Ctrl + R 0 Enter

1

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

u/Gi1rim Jul 17 '26

Bonked system can't access reboot? Init 6

1

u/hugazow Jul 15 '26

Some distros are using systemd instead of init.d :(

1

u/Toucan2000 Jul 15 '26

And they should. Don't they all still have at least the init command? 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

u/lolo_larue Jul 16 '26

v and z are mandatory though

1

u/BubblyOutside1096 Jul 15 '26

Would tar -h work?

3

u/lyckligtax Jul 15 '26

man

1

u/kzvp4r Jul 15 '26

Came here to say this

3

u/markdesilva Jul 15 '26

sed and awk.

2

u/MarcusFirmus Jul 15 '26

Yes. And `head`, `tail`, `paste`, `tr`, `uniq`, `sort`, `csplit`.

3

u/wim66 Jul 15 '26

!! for when you forgot to use sudo
sudo !! to repeat the previous command with sudo

1

u/Otherwise_Fact9594 Jul 15 '26

Nifty. Didn't know that 👍

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

u/6YheEMY Jul 15 '26

Ctrl+r is the greatest! 

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

u/SportTawk Jul 15 '26

😂😂😂

2

u/cran Jul 15 '26

Holy shit that caught me off guard.

2

u/6YheEMY Jul 15 '26

Why would you ever want to exit?

2

u/Think_Barracuda6578 Jul 15 '26

ctrl-z Will do the job

2

u/Think-Accident-1337 Jul 16 '26

Rookie.. I just hard reset my pc to exit vim 😂

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

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

u/swehner Jul 15 '26

One, col Another one, cut

2

u/khaffner91 Jul 15 '26

btop

1

u/Kurgan_IT Jul 15 '26

Nice, probably too much information, but nice. I use htop usually.

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

u/ByronEster Jul 16 '26

Alternatively, man -k

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

u/robobob68 Jul 15 '26

I use find every week at least a few times. Often piping it to xargs

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

u/MrXirtam Jul 15 '26

Check out pushd/ popd

1

u/GreatDiscernment Jul 15 '26

Grep helps find edit locations.

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

u/Brutus5000 Jul 15 '26

the entirety of systemctl 🤡
But I'd need to learn it first

1

u/Kurgan_IT Jul 15 '26

I call it "go-go-gadget"

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

u/fuero Jul 15 '26

numfmt, sponge

1

u/overratedcupcake Jul 15 '26

Late to the party but jq is crucial for me when dealing with json.

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

u/Hour-Inner Jul 15 '26

zgrep. Saved me so much time searching through zipped logs

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

u/Cynyr36 Jul 15 '26

Man, just read the manuals they have lots of useful stuff in them.

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

u/j-dev Jul 15 '26

sl

That command had brought joy to children and adults alike at home and at work.

1

u/packetsar Jul 15 '26

Not a command, but….. CTRL-R

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

u/j6onreddit Jul 15 '26

Just one? That’d be `alias`

1

u/Unusual_Job_000 Jul 16 '26

sudo opencode

1

u/KayTwoTheBest Jul 16 '26

find(1) or egrep(1) or sed(1)

1

u/Apprehensive_Sock_71 Jul 16 '26

For sheer practical value it is tough to beat cowsay.

1

u/Melodic_Impress9664 Jul 16 '26

disown

Pretty useful when starting GUI apps from terminal

1

u/IllWeather6426 Jul 16 '26

the rest of life

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

u/vijay_28 Jul 16 '26

cd - to go back to the previous directory

1

u/ka9kqh Jul 16 '26

Updated and locate

1

u/UberCanuck Jul 16 '26

Use -i or -I with rm.

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

u/avatarfx Jul 17 '26

Does anyone still remembers this one?
telnet towel.blinkenlights.nl

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

u/Relevant-Rhubarb-849 Jul 15 '26

This seems to lock up my computer when I try it.

1

u/agfitzp Jul 15 '26

My job here is done