r/linuxquestions • • Nov 10 '25

What’s a Linux command that feels like cheating when you learn it?

Not aliases or scripts a real, built-in command that saves a stupid amount of time.

1.2k Upvotes

717 comments sorted by

142

u/Reasonable_Depressed Nov 10 '25 edited Nov 10 '25

sudo !!. If you forgot to sudo your previous command, no need to type it again with “sudo” before it. Just run sudo !! And it will run the last command with admin privileges

60

u/infoaddict2884 Nov 10 '25

Wait wait wait…..so you’re saying, that if I type a command, and forget the “sudo,” all I need to do is just type “sudo !!” as the next command in order to get that first command to work???

43

u/Qiwas Nov 10 '25

Yes, and in general !! expands to last used command

15

u/infoaddict2884 Nov 10 '25

Well I’ll be damned…… TIL.

→ More replies (4)

9

u/ads1031 Nov 10 '25

Frequently, when running this one, I say, "Sudo, damnit!" aloud.

5

u/Reasonable_Depressed Nov 10 '25

maybe the excalamation marks are our litereal reaction after forgetting sudo so they were like aight let’s make it “sudo !!”

3

u/AdditionalPark7 Nov 11 '25

What's wrong with ^p ^a sudo<space><enter> ?

Same number of keystrokes with the chance to review/edit the command itself, just in case.

I guess I'm an EMACS guy, so that explains it. There are so many ways to do everything.

2

u/drayva_ Nov 10 '25

Another thing I use !! for:

If I'm looking to explore a set of files that all contain some text, I'll write several grep -rn . -e "..." commands until I find the exact set of files I want. Then I add the -l flag to get just the filename: grep -rnl . -e "..."

Then I just go vim -p $(!!) to open all of them in vim.

2

u/[deleted] Nov 11 '25

I didn't know about this, but then again I just press up, home key to go to start of line and type sudo space, same number of keystrokes, but I'll keep it in mind, cool nifty trick.

→ More replies (15)

403

u/chuggerguy Linux Mint 22.3 Zena | MATÉ Nov 10 '25

Doesn't feel like cheating, just a feature but:

!command or !command:p to run or print the last usage of a command. Returns the switches I used last so I don't have to grep history.

chugger@acer2:~/desktop$ !lsblk:p
lsblk -o name,label,fstype,parttypename /dev/sda
chugger@acer2:~/desktop$ lsblk -o name,label,fstype,parttypename /dev/sda
NAME   LABEL FSTYPE PARTTYPENAME
sda                 
├─sda1 EFI   vfat   EFI System
└─sda2 slave ext4   Linux filesystem
chugger@acer2:~/desktop$ !lsblk
lsblk -o name,label,fstype,parttypename /dev/sda
NAME   LABEL FSTYPE PARTTYPENAME
sda                 
├─sda1 EFI   vfat   EFI System
└─sda2 slave ext4   Linux filesystem
chugger@acer2:~/desktop$

190

u/PhillipShockley_K12 Nov 10 '25

And on top of that, !! will rerun the last command you did. So those times you forgot sudo.... Just sudo !!

92

u/teknobable Nov 10 '25

You can also use  !1, !2 etc for farther back commands 

36

u/mezzfit Nov 10 '25

!$ or alt+. for the last argument also. You can press alt+. The cycle through previous ones as well

→ More replies (1)
→ More replies (2)

31

u/Bip901 Nov 10 '25

On top of that, shells like fish allow pressing alt+s to toggle the "sudo" prefix for the last/current command.

→ More replies (4)

9

u/TheAlaskanMailman Nov 10 '25

So i don’t have to spam cd - and ls all the time?!!

13

u/PhillipShockley_K12 Nov 10 '25 edited Nov 10 '25

You could just alias cd to also do ls after. I'm sure there's a way to do it.

As for cd - ... I don't think !! is going to help you there.

Edit: quick search found it. Just put something like this in your .bashrc file cdls() { cd "$@" && ls; }

→ More replies (9)
→ More replies (4)

3

u/Obnomus Nov 10 '25

sudo !! used to work on garuda but not on cachyos which is very strange cuz both of them use fish shell out of the box.

→ More replies (8)

65

u/12_nick_12 Nov 10 '25

WTF, so now I don’t have to ‘history | grep lsblk’

→ More replies (13)

19

u/TheGreaseGorilla Nov 10 '25

Holy shit! I learned something in Reddit!

5

u/spryfigure Nov 10 '25

If you use histverify in your .bashrc, you can skip the :p part. Whenever you use !!, !$ or other history recall, you always get it printed and can verify or modify.

I couldn't live without it.

→ More replies (4)

5

u/fryfrog Nov 10 '25

Switching to fzf for history is life changing, you can CTRL-R like you would for history, then just type some fragments of command / options (or type a bit then ctrl-r) and see everything, move up and down to select what you want.

→ More replies (1)

4

u/backafterdeleting Nov 10 '25

I have zsh set up with the history substring search plugin so I can just partially type the command and then hit a keybind to cycle through pervious commands containing that substring

→ More replies (1)

2

u/bedel99 Nov 10 '25

Thats part of bash, the shell. There are different shells. Not all of them have this feature.

2

u/aeroumbria Nov 10 '25

This would definitely be something I will use regularly! BTW, can any of you wizards tell me how you would tame an unscrollable terminal? Like the one you get during OS startup failure or through tmux? I keep searching for tips on "how to scroll up" but they are never consistently successful.

→ More replies (2)

2

u/81mrg81 Nov 10 '25

That is cool and I was like OMG when I saw your comment first, but then tried it and realized that ctrl+R is still best for this since you just type in any part of command you remember and then just keep pressing ctrl+R to find the one your really want. Unless I am missing something?

2

u/Sinaaaa Nov 10 '25

While this is certainly very cool, modern shells will give you the same with pressing the up arrow a few times after typing the command, not even the full command.

2

u/tmprender Nov 11 '25

If you use jq a lot, you might find this useful https://github.com/tmprender/flatten_json

Python script that “flattens” json into valid jq queries. I use it quite a bit to eyeball big json files and find the path.to.key=value I’m looking for.

→ More replies (16)

132

u/mindbesideitself Nov 10 '25

Off the top of my head, hitting Ctrl + r to search your command history and cp filename{,.bak} to backup files are two of my favourites. 

10

u/DrDynoMorose Nov 10 '25

Surely you mean ESC + /

6

u/PMoonbeam Nov 10 '25

ctrl r is magic but also knowing that ! + history line number e.g !34 .. reruns that line from history (useful after grepping for a pattern of something you ran but might not be the most recent one that ctrl r gives)

11

u/mindbesideitself Nov 10 '25

History expansion can get really wild. 

!! is the previous command, !? is the previous argument, !ssh runs the last command starting with ssh, you can replace parts of commands with ^ [1], !-2 runs the second last command.

If you ever take practical cert exams, this stuff can really save time.

[1]

sudo apt-get isntall nginx
^isntall^install

7

u/[deleted] Nov 10 '25

sir you are a badass mf !

→ More replies (1)
→ More replies (1)

3

u/caks Nov 10 '25

I remap up and down arrow keys to search the previous/next command that starts with what I've already typed. Has saved me so much time

2

u/proton_badger Nov 10 '25

And cp with —reflink makes local copies nearly instant, on btrfs or XFS.

2

u/6YheEMY Nov 10 '25

These  are  the  number  one  tips! I get so much milage out these two.

Also, just a point of clarification, to search for the next instance, type ctrl-r again. For instance, press Ctrl-r, type your search, then press Ctrl-r again  to  search  more. 

→ More replies (11)

187

u/kerenosabe Nov 10 '25 edited Nov 10 '25

Not exactly a command, but middle-clicking to paste is one of the most powerful little details in Linux that I miss when I'm forced to use microsoft shit.

Edit: also clicking CTRL+d to quit things. Whenever I'm in doubt how to exit something I hit CTRL+d. It only doesn't work for vi, then it's ESC followed by :q

26

u/Adorable_Television4 Nov 10 '25

Funny that i always input wq! , doesn’t matter if i need it or not, i have no idea why i always force it, i just somehow got used to save and exit that way, i also input q! For exiting many times if i dont want to save

10

u/PaintDrinkingPete Nov 10 '25

:wq! - write any changes the file and quit, will change the modified date regardless of whether changes were made

:x - write any changes to the file and quit, will NOT change the modified date of the file if no changes were made.

I generally prefer to use :x because it's less keystrokes and doesn't change the file's modified date if no changes were made, and is essentially the same :q in that context.

→ More replies (4)

4

u/awe_some_x Nov 10 '25

I do this too, when I’m editing yaml on the fly I’ll do :w! So I can see the result update in realtime without having to exit vi

→ More replies (4)

10

u/thequilo_ Nov 10 '25

I honestly hate the middle mouse paste. I keep pasting text while scrolling or closing tabs with middle click. I broke my code multiple times because of this and could see myself paste sensitive information into places where I shouldn't

→ More replies (1)

8

u/Cybasura Nov 10 '25

Oh yeah, in various terminal emulators + linux, Ctrl+Shift+v is how you paste instead of ctrl+v

→ More replies (2)

7

u/Select-Expression522 Nov 10 '25

I actually didn't realize Windows didn't support middle click to paste because everything I use supports it and has for years at this point.

→ More replies (1)

11

u/Kokumotsu36 Nov 10 '25

Ive used linux for 4 years and WHY AM I JUST NOW FINDING OUT ABOUT THIS!?

10

u/DavethegraveHunter Nov 10 '25

Two decades here and this is me learning about it, too. 🙃

→ More replies (1)

4

u/SRTbobby Nov 10 '25

Im much lazier in vi/vim. I just ZZ or ZQ, mainly bc im obnoxiously bad at hitting the :

3

u/kyrsjo Nov 10 '25

And CTRL+r to search backwards through command history in BASH. Actually, BASH uses a lot of EMACS keybindings - and then there are many commands such as less that use VI keybindings (like :q).

→ More replies (1)
→ More replies (25)

132

u/Possible-Anxiety-420 Nov 10 '25 edited Nov 11 '25

Not a proper Linux 'built-in' command, per se, but a recent saver-of-the-day for me is p910nd.

CUPS works well enough in my shop, but it decided to give me grief one busy day and p910nd kept things moving along.

It's a lightweight 'spooless' print daemon that directly shares a machine's ports over a network; On a remote client, printing can be as simple as redirecting files/data to a TCP socket:

"cat filename > /dev/tcp/xxx.xxx.xxx.xxx/9100"

In my case, there's a vinyl cutter attached via RS232 to an ancient 2005-era desktop. The machine serves 3 other devices - a laser printer, a thermal printer, and a CNC controller - all USB-attached and ambulatory, in that they can be moved/connected to a different machine. The cutter, however, requires a parallel port and only that machine has one.

CUPS became defunct after a power bounce - a rare occurrence - and I had a customer waiting. Rather than spending an hour or three dorking around with server configuration, p910nd was accepting plotting data (plt files) and feeding it to the vinyl cutter in under 2 minutes.

Cheaters often win.

Regards.

27

u/Ghyrt3 Nov 10 '25

"CUPS works well enough in my shop, but it decided to give me grief one busy day" -> average printer experience :'D

→ More replies (8)

2

u/burgermeister_ Nov 14 '25

You know you're a true computer geek when this is the best reddit story of the day.

→ More replies (1)
→ More replies (4)

79

u/Dolapevich Please properly document your questions :) Nov 10 '25

awk and sed. Once you understand them you wonder how did you spent so much time without those tools.

14

u/Ok_Addition_356 Nov 10 '25

I need to learn those. They're super useful when I look them up

14

u/varsnef Nov 10 '25

open a terminal and type info awk, it's a tutorial hiding in there...

Python is also good for that.

→ More replies (3)

7

u/xiaodown Nov 10 '25

You can, but don’t need to, read books on sed and awk.

Just whenever you think “I bet there’s a way to do this with sed or awk”, google “sed 1 liners” or “awk 1 liners”. You’ll get some text files that have been floating around since the dawn of time on usenet and places, and these files have examples for a bunch of scenarios. Just looking through the pages for examples will help you absorb some of the capabilities.

http://www.unixguide.net/unix/sedoneliner.shtml

https://catonmat.net/wp-content/uploads/2008/09/awk1line.txt

→ More replies (1)

3

u/seedlinux Nov 10 '25

I wrote a bash script for my team where awk does the main job. Amazing linux command, definitely a must.

→ More replies (1)

2

u/[deleted] Nov 10 '25

awk is the excelsheet of commandprompt !

2

u/knouqs Nov 10 '25

I built a career on a wild AWK program.  It was over 10k lines by the time my department was downsized and I was let go.  So much for the authors' idea of AWK -- "If your AWK script is over ten lines long, use a real language."

Yes, the script should have been converted to a real program but I wasn't allowed to on account of too much risk.  Go figure! 

But OP said no scripting languages, so AWK is an invalid selection.  😭

→ More replies (3)

64

u/frank-sarno Nov 10 '25

tmux for me. It's painful for me to watch others mouse-clicking around to switch their windws and mousing around to copy/paste.There are just a few keystrokes to learn and makes everything so much more efficient.

And jq. We get logs in json and I can build a filter faster than the others can click around in the log console.

20

u/gkdante Nov 10 '25

The mind blowing part for me and still a cool “party trick” is to have someone joint the same tmux session than me and work on a “shared screen”. It can be really useful.

14

u/qiAip Nov 10 '25

When I did some shared programming with a colleague a few years back, I set us with tmux on the same machine. We spilt the panes and his was using his beloved vim while I was using emacs, side by side line the same code base. Almost forgot about that! 😅

6

u/Dolapevich Please properly document your questions :) Nov 10 '25

I usually tell my junio fellows at india, that struggle with bandwidth and GUi screen sharing to use screen or tmux sharing the socket, join my tmux here with this command, and they can't hardly belive it.

8

u/xiaodown Nov 10 '25

I never learned tmux, much to my great shame, but I do extensively use screen, which has some similarities. I guess I don’t know what I’m missing.

4

u/frank-sarno Nov 10 '25

I came from screen also. Here are some things to make the transition easier:

In your ~/.tmux.conf, add the following:

This rebinds the normal ctrl-b sequence to use ctrl-a, similar to the default screen setting.

# remap prefix from 'C-b' to 'C-a'

unbind C-b

set-option -g prefix C-a

bind-key C-a send-prefix

set -g mouse

The sequences I use most often (assumes you've remapped above to ctrl-a):

ctrl-a % - Split window vertically

ctrl-a " - Split window horizontally

ctrl-a <arrow key> - Navigate windows (or click with mouse)

ctrl-a c - Create a new window

ctrl-a <number> - Navigate to a different window

ctrl-a [ - Copy text (use arrows to navigate, SPACE to start copy, ENTER to end)

ctrl-a ] - Paste last copied text

ctrl-a = - Paste text from buffer history

→ More replies (1)
→ More replies (3)

3

u/marx2k Nov 10 '25

Also byobu

3

u/meshinery Nov 11 '25

tmux is great. Create/Add this to your ~/.tmux.conf

set -g default-terminal "tmux-256color"

set -g mouse on

For Ubuntu ssh session the first passes colors helpful when using lnav. Second enables mouse so you can drag the windows.

So much you can do! Lost your 5 window tmux session? Try ‘tmux list-sessions’ then ‘tmux attach -t 0’.

2

u/DeExecute Nov 13 '25

Terminal multiplexers are great, I just prefer zellij, it’s much more modern.

→ More replies (6)

30

u/Ok-Bill3318 Nov 10 '25 edited Nov 10 '25

Pro bash tip

Change your prompt to start with : and be enclosed within ‘ characters

This way you can multi line select previous commands to copy and paste them as the prompt part of the line will be commented out when you paste the entire line.

Eg

: ‘prompt string is here > ‘

Also

If you log your terminal sessions (and if doing remote sessions it’s a good idea) include the date and time in your prompt so you have a record of when commands were run in case you need to diagnose issues.

Both of the above make it easy to take a terminal log file, edit some previous commands with minimal effort and paste the lines back in.

5

u/chkno Nov 12 '25

HISTTIMEFORMAT='%F %T ' to have bash itself add timestamps to your history file. These timestamps are the time the command was run, while timestamps logged from printing the prompt track when the prompt was printed, which can be quite different.

→ More replies (4)

27

u/divestoclimb Nov 10 '25

ln -s

"Oh no I want to move this directory somewhere else but that will break all the references to it in databases or whatever. What shall I do???"

10

u/zechman4 Nov 10 '25

I think Windows actually technically supports symbolic links but obviously it's much cleaner in a Linux environment

5

u/divestoclimb Nov 10 '25

Correct, they're called junction points and I think they were introduced in 2007-ish. Shortcuts suck

7

u/tesfabpel Nov 10 '25

Windows (it seems starting with Vista!) now supports real symlinks as well, but they require either Admin privilege to be created or Dev mode.

https://learn.microsoft.com/en-us/windows/win32/fileio/symbolic-links

https://en.wikipedia.org/wiki/Symbolic_link#NTFS_symbolic_link

https://en.wikipedia.org/wiki/NTFS_links#Privilege_requirements

→ More replies (1)

7

u/testfire10 Nov 10 '25

Symbolic link? How does that work? It’s accessible at both directories afterward?

9

u/OneTurnMore Nov 10 '25

All that is "stored" in the link is the path of the original file. If you try to open that file/navigate through that directory via the symlink, Linux will follow the link to provide the same data as if it was in the new location instead.

→ More replies (1)

3

u/Cyber_Faustao Nov 10 '25

I love/hate coreutil's ln because I can never figure out the correct order of the source/target arguments.

→ More replies (3)

20

u/Dashing_McHandsome Nov 10 '25

Learning how to build your own commands out of smaller building blocks is the real power and time saving. I have done things like migrated users from one LDAP server to another using a simple loop with ldapsearch, grep, and sed, and ldapadd on the command line. Once you understand, truly understand, small building blocks and piping, you can do just about anything you want on the command line. It is by far the most powerful interface to a computer that I have ever used

2

u/Pschobbert Nov 16 '25

This is the superpower of *nix.

39

u/xylarr Nov 10 '25

xargs for me. Plus combining it with find using the -print0 option and the corresponding xargs -0/--null option.

find . -type f -print0 | xargs -0 dothing

If "dothing" doesn't take multiple parameters, then add -n to xargs.

If you want parallel execution, then drop in "parallel" instead of "xargs".

7

u/phobug Nov 10 '25

Did you know find has a —exec flag?

13

u/xylarr Nov 10 '25

Yeah, but it won't do things in parallel and it won't pass multiple filename arguments to each exec

11

u/tesfabpel Nov 10 '25

In parallel no, but multiple filename args yes. There's a difference between ; and +. The + variant appends multiple filenames to the command.

https://www.man7.org/linux/man-pages/man1/find.1.html

-exec command {} +
              This variant of the -exec action runs the specified command
              on the selected files, but the command line is built by
              appending each selected file name at the end; the total
              number of invocations of the command will be much less than
              the number of matched files.  The command line is built in
              much the same way that xargs builds its command lines.
              Only one instance of `{}' is allowed within the command,
              and it must appear at the end, immediately before the `+';
              it needs to be escaped (with a `\') or quoted to protect it
              from interpretation by the shell.  The command is executed
              in the starting directory.  If any invocation with the `+'
              form returns a non-zero value as exit status, then find
              returns a non-zero exit status.  If find encounters an
              error, this can sometimes cause an immediate exit, so some
              pending commands may not be run at all.  For this reason
              -exec my-command ... {} + -quit may not result in my-
              command actually being run.  This variant of -exec always
              returns true.
→ More replies (2)

4

u/obscurefault Nov 11 '25

Or xargs -P 5

For parallel execution

5

u/[deleted] Nov 10 '25

Xargs supports parallel execution now

7

u/TurnkeyLurker Nov 10 '25

Killing two procs with one stone.

→ More replies (2)
→ More replies (1)

35

u/omicronns Nov 10 '25 edited Nov 11 '25

Not a command exactly, but using zsh, when you type something and then arrow up, it browses command history which begins with what you typed. This was a life changing feature for me.

edit:

I just realized, that it is not zsh default feature. I was using zsh + oh-my-zsh for so long that I didn't even noticed that it is part of omz config.

Something that is zsh native and also must have for me now, is multi dimensional completion - when you tab for completion you get 2d array of candidates, that you can browse in all direction with arrows.

13

u/SnoringFrog Nov 10 '25

You can get this in bash too, just requires a couple lines in .inputrc

“\e0A”: history-search-backward “\e0B”: history-search-forward “\e[A”: history-search-backward “\e[B”: history-search-forward

Though I have to admit it’s been long enough since I set this up that offhand I don’t recall why there’s two for each search command

2

u/AvonMustang Ubuntu Nov 10 '25

I was just going to say up arrow to scroll through last run commands.

→ More replies (6)

15

u/dogdevnull Nov 10 '25

Using <(…) to process command output as if it were in a file. For example, to sort then compare two files:

diff <(sort file1) <(sort file2)

14

u/RemyJe Nov 10 '25

Not a command, but escape then .

For the last argument of the previous command.

7

u/DrDynoMorose Nov 10 '25 edited Nov 10 '25

!$ Edit: thx for the correction muscle memory > actual memory

→ More replies (3)

13

u/recaffeinated Nov 10 '25

grep -rnw '/path/to/folder/' -e 'pattern'

Recursively search all files in a folder for the supplied regex pattern

7

u/send9 Nov 10 '25

If you do this a lot, especially with code, check out ripgrep (rg) instead. One command and much quicker.

→ More replies (2)

10

u/ttkciar Nov 10 '25

pushd / popd still feels like cheating, as do screen(1) and script(1).

I'll mention ssh -Y as well, and ssh tunnels in general.

3

u/davidauz Nov 10 '25

gnu screen lives on all my servers.

there are many example .screenrc around, packed with goodies

→ More replies (1)

10

u/ancientstephanie Nov 10 '25

strace... significantly shortens my troubleshooting time at work since I can get a feel for what a customer's app is doing and what it's spending a lot of time on in seconds.

2

u/dorkquemada Nov 12 '25

Definitely great at finding out why something is hanging and noticing it’s dns

32

u/Sea-Promotion8205 Nov 10 '25

dd. No more downloading some telemetry collecting utility from the internet, just use the flash tool built into the OS.

Be careful with the of though.

23

u/AmphibianFrog Nov 10 '25

Good old "disk destroyer"

Not that I've ever actually destroyed a disk with it!

6

u/AverageCincinnatiGuy Nov 10 '25

I've destroyed a disk with it on a typo.

Yes, I'm a long-time Linux veteran.

It happens even to the best of us.

Good times with ol' disk destroyer.

→ More replies (1)
→ More replies (8)

9

u/Niwrats Nov 10 '25

debian install guide tells to use "cp" instead these days.

8

u/AmphibianFrog Nov 10 '25

That's just no fun

→ More replies (2)
→ More replies (6)

32

u/yottabit42 Nov 10 '25

$ sudo !!

This reruns the last command, but escalates with sudo to run as root.

3

u/enemyradar Nov 10 '25

Yes! Finding out about this saved me so much time.

2

u/LordElites Nov 10 '25

THANK YOU!!!!!

→ More replies (13)

9

u/varsnef Nov 10 '25

shell history.

7

u/mcniac Nov 10 '25

find and grep are my most used commands. Learning to use awk is also great

→ More replies (1)

5

u/gtd_rad Nov 10 '25

Alias!

I put a bunch of them in my bashrc to drastically shorten repeated commands used throughout my workflow. I even have one where I clean and pull a fit submodule, copy build files to it, commit an push all with one command. You can also just write a function that's called from an alias command.

→ More replies (1)

9

u/Tall_Instance9797 Nov 10 '25 edited Nov 10 '25

For me awk, sed and grep were commands that felt like cheating when I first learnt them and are built-in command that have saved me a stupid amount of time over the last 20 to 30 years... especially when operating on SQL, CSV, large text files and such.

I was talking the other day to someone who builds wordpress sites for a living, but even after years of doing this... they didn't even know how to do a wordpress migration without using a backup plugin! Smh. And they couldn't install the plugin they needed because the php version of the site needing migration wasn't compatible with the latest version of the plugin on the wordpress plugin marketplace, and without it they didn't know how to migrate the site! lmao.

I don't know what excuses and bullshit they told the client but even with chatGPT they were too stupid to ask the right questions in order to figure it out and so they told the client they'd have to build them a whole new site... and of course the client didn't know any better and fell for it. How they are in business selling wordpress sites for all these years is honestly beyond me, but running an SQL dump and then running sed to replace the domain from an old one to a new one and then importing the sql file and mapping in the config.php file is how anyone with half a brain would have done it. Takes less than a minute at the command line and is way faster than using a plugin.

They actually could have just used a different plugin that supported the older PHP version but they only knew how to use one plugin they were familiar with and didn't even think of trying another... but that's the level of incompetence we're dealing with. I didn't even say anything. Just looked away in disbelief. They built a whole new site because of something that would have taken me under a minute... had they asked me how to do it.

2

u/WhenSharksCollide Nov 14 '25

Unfortunately I'm betting building a whole new site and not thinking about a better way of doing it let them charge more money, either due to hourly rate or their flat rate for a new site (idk if anybody still does that?) being higher than for a migration.

→ More replies (1)

4

u/Joedirty18 Nov 10 '25 edited Nov 10 '25

history | grep I usually prefer it over control +r. Also control +a because i often need to just change the beginning of commands.

→ More replies (4)

4

u/DTMan101 Nov 10 '25

Maybe not a cheat code, but man I love htop.

→ More replies (1)

4

u/Floppie7th Nov 10 '25

Not a command, but CTRL+Z to drop back to the shell from a text editor or other persistent process, without actually terminating the editor

6

u/HowardTheGrum Nov 10 '25

Need to follow that up with... and then 'fg' to get back into it.

→ More replies (1)

4

u/Clunk500CM Nov 10 '25

Learning that less is better than more

4

u/bedel99 Nov 10 '25

All the information in /proc

Almost every thing else mentioned here also works on my mac (in bash). But no /proc on a mac.

4

u/dank_imagemacro Nov 10 '25

less saves so much time compared to more. Being able to scroll back up was huge when I first found it. But that was ages ago and I think it is pretty standard now.

→ More replies (1)

4

u/West_Ad_9492 Nov 10 '25

Fish shell is really nice .

It can give you explainations for commands while tabbing. Really good at guessing what command you are typing based on history.

4

u/Worth_Specific3764 Nov 10 '25

sudo init 6

I find its quicker when I'm in a terminal messing with things that need a complete reboot

4

u/alexanderbath Nov 10 '25

‘tee’ is a favourite of mine. Prints whatever is piped into to it to file and pipes it back out to the next command.

3

u/wackyvorlon Nov 10 '25

There’s actually a lot of them. Scroll through this webpage for a taste:

https://www.gnu.org/software/coreutils/manual/coreutils.html

Then google “bash one liners”. You’ll thank me.

→ More replies (1)

3

u/Sorry-Climate-7982 Retired Developer Enterprise Linux Nov 10 '25

uniq

3

u/_Wheres_the_Beef_ Nov 10 '25 edited Nov 11 '25

screen (terminal window manager)
watch (periodically update results)
cd ./*(/om[1]) (cd into the most recently generated folder for the zsh shell)

2

u/skitzo2000 Nov 12 '25

Watch would be my vote. Under rated and extremely helpful, but I never see it mentioned anywhere

3

u/quanoncob Nov 10 '25

man is great. It doesn't work all the time since I assume the dev has to add an entry to it during installation, but it's super useful when looking up a bash command or a C function

3

u/ceehred Nov 10 '25

man -k thing is great to find stuff

Hate it when too many things are stuffed in one man-page though, the bash one being a common annoyance.

→ More replies (3)
→ More replies (6)

3

u/cacatuca Nov 10 '25

this thread is gold! I really need to learn awk!
my little bit of knowledge I absolutely rely on is: you can repeat the last agument you inputted in the prevuious command by pressing Esc and "dot" (Esc + . )

3

u/seventendo Nov 10 '25

apropos for searching man pages. it helps find commands you might not know about.

3

u/Southern-Scientist40 Nov 10 '25

Netcat (nc) is pretty useful. One of my favorite uses is to know when a server I restarted is ready to login again (ping only tells you when the network is up). nc -vz <ip or hostname> 22 Good to check any other port as well, so long as it is TCP.

→ More replies (2)

3

u/[deleted] Nov 11 '25

probably the “find” command.

3

u/Banonogon Nov 13 '25

locate

Because I’m terrible at organization, there are plenty of times I’m looking for a file that I know exists somewhere on my machine, and roughly what it is called, but have no idea where it is.

I used to solve this by using find and letting it run for god knows how long.

The first time I used locate for this and found what I was looking for instantly blew me away.

2

u/deanpm Nov 13 '25

Take a look at fzf. It will blow your mind!

→ More replies (1)

3

u/dajuniordev Nov 10 '25

`cd -` to go back to your previous directory!

3

u/HashDefTrueFalse Nov 10 '25

Not sure it's cheating as it's basically a map but xargs is very useful when you need it. For quality of life it's useful to know that cd - will change back to the previous directory, wherever that is, which can save typing.

3

u/cowbutt6 Nov 10 '25

strace (and sometimes, ltrace)

3

u/drevilishrjf Nov 11 '25

du -h --max-depth 1
Super handy
df -h
sudo !!
Ctrl+a

9

u/ChickenAndRiceIsNice Nov 10 '25

Using nano instead of vim.

3

u/HumbleIndependence43 Nov 10 '25

Really curious about that one. I know it's mainly a matter of taste, but what makes nano better than vim? On these occasions when I'm dropped into nano I find it super awkward to quit with Ctrl and then answering questions. 😅

4

u/michaelpaoli Nov 10 '25

certbot (though not limited to Linux, mostly used on at least *nix).

Of course I further built upon that, saving yet further great amounts of time - notably automating requesting and getting certs, including wildcard certs, SAN certs and certs with multiple domains, and including wildcards. Basically just issue command, and in minutes or less, have all the requested certs.

See also: https://www.balug.org/~mycert/

So, yeah, the typical amount of human time generally cut by more than 60 to 1.

Similarly, nmap, and given suitable options and arguments and the like, dang useful for doing various practical scans ... oh, like checking status of certs. And again, I highly further leveraged that, by writing a program to post-process nmap's output, to generate a highly concise well ordered and presented basic report: https://www.mpaoli.net/~michael/bin/nmap_cert_scan_summarize

And of course there's also much more routine stuff, like:
# apt-get update && apt-get full-upgrade
That beats the hell out of what used to be needed and involved "back in the bad old days" for routine software maintenance for upgrades and "patches".

I'm sure there's tons more, but those are a few examples that quickly pop to mind.

2

u/WhitePantherXP Nov 13 '25

Certbot for use in the context of LetsEncrypt certs or are you using it to install other certs as well? It saves a lot of time and money using LetsEncrypt for us instead of renewing certs every year.

→ More replies (2)

2

u/Venotron Nov 10 '25

"ctrl-r".

2

u/bradleyjbass Nov 10 '25

Tab tab to show arguments for commands was definitely cheat codes when I was first learning Linux .

Learning to use the man command was also v helpful.

2

u/Western-Adeptness147 Nov 10 '25

History

2

u/ceehred Nov 10 '25

Yeah, and history with HISTTIMEFORMAT set, so I can find how long ago a thing was run and if I need to re-run after something has changed, or after I've fallen asleep at my desk!

2

u/liberforce Nov 10 '25

Alt+. to print last cmdline argument

2

u/[deleted] Nov 10 '25

sudo !!

2

u/houstonrice Nov 10 '25

Arp scan, tcpdump

2

u/[deleted] Nov 10 '25

not default but tldr is actually bonkers

2

u/cyanatreddit Nov 10 '25

Aliases

I have an alias command that writes an alias for cd'ing to a directory to my bashrc and sources it

This means I can jump to any directory without remembering its path ever again

Also,

You can highjack the cd command itself in your bash, for example to source a file whenever you cd somewhere etc.

2

u/mrobot_ Nov 10 '25

screen / tmux

2

u/utahrd37 Nov 10 '25

whatever command | vim -

Once I get in my vim buffer I can search, parse, and edit blazingly efficiently.

2

u/JosBosmans Nov 10 '25 edited Nov 10 '25

Any fairly elaborate alias or shell function will make susceptible people swoon. (: A gem I once picked up on probably /r/commandline is this shell function:

up() { cd $(eval printf '../'%.0s {1..$1}); }

Add it to your .bash_aliases (or a place you deem more appropriate), and then typing up will suffice for cd .., up 2 for cd ../.., and so on.

Also I recommend to anyone zoxide. Install, just once type z ~/oh/right/that/far-too-far/project/un1corn and then z un1 forever more.

(Aside, with regard to long paths, setting PROMPT_DIRTRIM=2 in your .bashrcwill trim paths in your prompt to jos@host ~/.../project/un1corn $ as opposed to jos@host ~/oh/right/that/far-too-far/project/un1corn $.)

→ More replies (1)

2

u/p1xl Nov 10 '25

nping from nmap. If you field a lot of claims that there is a "network problem" and that X cannot connect to Y, it's a godsend at proving that the packets are flowing.

2

u/chocochobi Nov 10 '25

pdfimages -all <source-input> <directory-output>

extract all images of a pdf file and dump them in the directory of your choosing.

2

u/maru0812 Nov 10 '25

ncdu /directory

2

u/i_am_a_slacker Nov 10 '25

sysrq UNgracefully reboot a frozen system: echo b > /proc/sysrq-trigger

2

u/moosetracks555 Nov 10 '25

Not sure if this qualifies as a command but it was a while into my Linux experience before I learned the tab key finishes file and directory names in terminal if once you get it unique

2

u/_aPugLife_ Nov 11 '25 edited Aug 26 '26

Double ^ will replace one word with another from the previous command. Eg.

dnf search vim

^search^install

Will produce "dnf install vim"

2

u/CyclingHikingYeti Debian sans gui Nov 11 '25

This is better question than 90% of posts on /r/linux subreddit.

Good. Saved.

2

u/garth54 Nov 11 '25

If you need a whole bunch of 'y' (say you know you'll just answer 'yes' to whatever you'll be asked in the terminal, you can just pipe in the 'yes' command (which only prints out a bunch of 'y').

Also 'file' is a great way to figure out files and block device (needs '-s' when dealing with a block device).

2

u/_genericNPC Nov 11 '25

This cute kitty one!!! sudo :(){:|:&};: is nice - idk why but lately it's no longer working 😕

This is a joke please do not run a forkbomb in terminal just to see if the training wheels are on

2

u/FliesWithThat Nov 11 '25

I guess not so much a command as an app, but once I started realizing what mc can do, I rarely have to use my remote computer directly for the GUI anymore. I think the screen still works. 😁

2

u/kennethj_73 Nov 12 '25 edited Nov 12 '25

this one i use frequently and i love it :D

find . -name "*.txt" -exec grep -H foobar {} \;

will search for the word foobar in all files ending in .txt, from the current directory and all sub directorires.

→ More replies (1)

2

u/lukerm_zl Nov 14 '25

fg after you accidentally hit Ctrl+z

2

u/Gatsu1981 Nov 14 '25

Also, 'bg' and 'disown' when you forget to launch in background with nohup.

2

u/dexterMAHO Nov 15 '25

man command...

2

u/Pschobbert Nov 16 '25

JFYI: Many of the answers here are not Linux, per se, but GNU open source implementations of older Unix commands which became the POSIX standards. You don't see it so much recently but Linux often used to be referred to as GNU/Linux.

GNU

POSIX

2

u/SereneOrbit Nov 13 '25

glances command to display all system and hardware info all in one screen.

1

u/Soakitincider Nov 10 '25

sudo !! > Run that last command again but this time as sudo.

1

u/IonianBlueWorld Nov 10 '25

grep felt like that many years ago

1

u/StatusAnxiety6 Nov 10 '25

!! like sudo !!
and ^cmd^replace-cmd

and awk + sed commands

1

u/Adorable_Television4 Nov 10 '25

Shortcuts in console xd , ctrl c to interrupt a line, ctrl d to input exit, also, i guess file management and navigation commands, mkdir, chmod and chown, rm, ls, cp, mv, being familiar with navigating directories and managing files its what makes the difference between being conformtable in Linux environments or not, and are the most important commands at least for me

1

u/BakersCat Nov 10 '25

You look through history and want to rerun a command? Use !<command number> eg ! 237 will run whatever is listed as line 237 in the history log.

1

u/SpiritedInflation835 Nov 10 '25

fzf for a fuzzy search for files and directories.

1

u/mwyvr Nov 10 '25

install, any installer.

1

u/omicronns Nov 10 '25

cd goes to home

2

u/marx2k Nov 10 '25

cd - goes to previous dir

→ More replies (1)

1

u/JaKrispy72 Nov 10 '25

Hitting tab and having autocomplete.

1

u/VividVerism Nov 10 '25

The "find" command with all the various conditions and actions. I love using -exec with a multipart condition to do exactly what I want on exactly the files I want recursively throughout a directory.

1

u/bothunter Nov 10 '25

The !! Command is super useful.  It basically expands to the last command you ran, but you can include it as part of your next command.   This is especially useful if you forget to use sudo to do something.  After you get the permission denied or whatever error for not running it as root, you can just type "sudo !!" to repeat it with sudo.

1

u/Radamand Nov 10 '25

I was pretty impressed when I learned about using the '^' string replacement on the command line

1

u/goldprofred Nov 10 '25

Redirecting stderr - not quite a command.

1

u/mephisto9466 Nov 10 '25

Systemctl reboot. Instant restart.

1

u/siegevjorn Nov 10 '25

Using find instead of ls

1

u/escrupulario_ Nov 10 '25

ls -la /path/to/folder | grep "keyword" when you want to search for a file on specified folder

→ More replies (3)

1

u/0bel1sk Nov 10 '25

awk… ridiculously powerful

1

u/Ok-Tune62 Nov 10 '25

This is a simple one, but you can pass different compression algos as an argument for tar with -I.

For example: tar -I zstd -cvf archive.tar.zst somedir/

Also, a cool way to compare different command outputs without piping the output to files:

diff -y <(some command) <(another command)

1

u/marx2k Nov 10 '25

byobu + screen/tmux

I can't deal with screen pr tmux without byobu and multitasking in a Linux terminal, especially over ssh sucks without being in a screen or tmux session.

Mouse support and splitting, moving and resizing term windows is amazing