I’ve been setting up a new Proxmox server and messing around with VMs, and wanted to know what kind of useful commands I’m missing out on. Bonus points for a little explainer.
Journalctl | grep -C 10 'foo' was useful for me when I needed to troubleshoot some fstab mount fuckery on boot. It pipes Journalctl (boot logs) into grep to find ‘foo’, and prints 10 lines before and after each instance of ‘foo’.
lower the monitor black for my tired eyes
xrandr --output eDP-1 --gamma .7:.7:.7when I forget to include sudo in my command:
sudo !!Also if you make a typo you can quickly fix it with ^, e.g.
ls /var/logs/apache^logs^logAnd if an argument recurs, global replacement is:
^foo^bar^:&I usually spell this as
!!:gs/foo/bar/(in bash). Is there a functional difference?!command history can also take line and word selectors. I type something like!-2:2surprisingly often.I honestly have no idea! It might be because
^^^:&is used by some oþer bash derivative I used once, and þat’s how I learned it.Yeah, I use !-# a bunch too, just not wiþ global replacement. I’m most often just redo-ing some action wiþ a couple of file extensions.
To add to this one, it also supports more than just the previous command (which is what !! means), you can do like
sudo !453to run command 453 from your history, also supports relative like!-5. You can also use without sudo if you want which is handy to do things like!lsfor the last ls command etc. Okay one more, you can add:pto the end to print the command before running it just in case like!systemctl:pwhich can be handy!Absolutely wild stuff, there. Thanks for knowledge sharing!
Hah I am glad it was helpful! Glad to share, I always felt like half the point of learning is to share what you learned. That is one of my favorite “hidden gems” for lack of a better term that can be a real time saver.
Bonus just for more fun: you can use
cd -to switch back to the directory you were last in after changing directories, it toggles the top two paths in the stack. It is similar to how pushd/popd work if you have you used those. I use that one a ton, there are fancier tools now but that one works everywhere.Oh also, anyone on a Mac needs to know about pbcopy, Linux has xclip and I don’t remember what the Wayland analog is.
If you use
fish, you just need to pressAlt+S.Similar-ish for quickly editing last command:
fc
I learned about this through Bread On Penguins, she did a vid on useful commands
with zsh, you can use it, and then press space to have the !! replaced by the previous command to be able to edit it :)
You can do this on bash too if you add
bind Space: magic-spaceto your bashrc/profile
Just use thefuck. My alias is set to “fu” for work. It’s amazing.
I forget where I got it. But mine will do this if I double tap ESC after I sent the command without sudo. Very useful.
I should probably figure out what it was I added to do this.
Doesn’t issue the command. Have to hit enter. Useful to verify it’s the right command first.
With the way bash history can work Id be worried about running sudo rm -rf ./* by mistake.
I use $_ a lot, it allows you to use the last parameter of the previous command in your current command
mkdir something && cd $_
nano file
chmod +x $_As a simple example.
If you want to create nested folders, you can do it in one go by adding -p to mkdir
mkdir -p bunch/of/nested/folders
Good explanation here:
https://koenwoortman.com/bash-mkdir-multiple-subdirectories/qSometimes starting a service takes a while and you’re sitting there waiting for the terminal to be available again. Just add --no-block to systemctl and it will do it on the background without keeping the terminal occupied.
systemctl start --no-block myservice
For interactive editing, the keybind
alt+.inserts the last argument from the previous command. Using this instead of $_ has the potential to make your shell history a little more explicit. (vim $_isn’t as likely to work a few commands later, butvim actual_file.shmight)You can also press
alt+.multiple times to cycle through all recent argumentsYes, definitely and I do run into that when I search my history
I just press M-.
I’m not sure what you mean. I gave 3 different commands…
You can use M-. instead of $_ to insert last param of last command. You can also access older commands’ param by repeated M-. just like you would do for inserting past commands with up arrow or C-p
I really hope I remember this one long enough to make it a habit
I have my .bashrc print useful commands with a short explanation. This way I see them regularly when I start a new session. Once I use a command enough that I have it as part of my toolkit I remove it from the print.
That is really useful! Thanks for the tip!
Ctrl-z to suspend the running program.
bgto make it continue running in the background.jobsto get an overview of background programs.fgto bring a program to the foreground.and
disownto keep background jobs alive when you close the terminal.
Absolute favourite is
|the pipe command.The watch command is very useful, for those who don’t know, it starts an automated loop with a default of two seconds and executes whatever commands you place after it.
It allows you to actively monitor systems without having to manually re-run your command.
So for instance, if you wanted to see all storage block devices and monitor what a new storage device shows up as when you plug it in, you could do:
watch lsblkAnd see in real time the drive mount. Technically not “real time” because the default refresh is 2 seconds, but you can specify shorter or longer intervals.
Obviously my example is kind of silly, but you can combine this with other commands or even whole bash scripts to do some cool stuff.
Ooooh cool, I think this explains how they have our raid monitor set up at work! I keep forgetting to poke through the script
Yeah, it’s a neat little tool. I used it recently at my work. We had a big list of endpoints that we needed to make sure were powered down each night for a week during a patching window.
A sysadmin on my team wrote a script that pinged all of the endpoints in the list and returned only the ones that still were getting a response, that way we could see how many were still powered on after a certain time. But he was just manually running the script every few minutes in his terminal.
I suggested using the watch command to execute the script, and then piping the output into the sort command so the endpoints were nicely alphabetical. Worked like a charm!
sudo shutdown 0
Prevents 99% of bugs and mistakes
ctrl+r on bash will let you quickly search and execute previous commands by typing the first few characters usually.
it’s much more of a game changer than it first meets the eye.
And I believe shift+r will let you go forward in history if you’re spamming ctrl+r too fast and miss whatever you’re looking for
Just tested this out, it’s ctrl+shift+r
find /path/to/starting/dir -type f -regextype egrep -regex 'some[[:space:]]*regex[[:space:]]*(goes|here)' -exec mv {} /path/to/new/directory/ \;I routinely have to find a bunch of files that match a particular pattern and then do something with those files, and as a result,
findwith-execis one of my top commands.If you’re someone who doesn’t know wtf that above command does, here’s a breakdown piece by piece:
find- cli tool to find files based on lots of different parameters/path/to/starting/dir- the directory at which find will start looking for files recursively moving down the file tree-type f- specifies I only wantfindto find files.-regextype egrep- In this example I’m using regex to pattern match filenames, and this tellsfindwhat flavor of regex to use-regex 'regex.here'- The regex to be used to pattern match against the filenames-exec-execis a way to redirect output in bash and use that output as a parameter in the subsequent command.mv {} /path/to/new/directory/-mvis just an example, you can use almost any command here. The important bit is{}, which is the placeholder for the parameter coming fromfind, in this case, a full file path. So this would read when expanded,mv /full/path/of/file/that/matches/the/regex.file /path/to/new/directory/\;- This terminates the command. The semi-colon is the actual termination, but it must be escaped so that the current shell doesn’t see it and try to use it as a command separator.
It isn’t a command but an application. I cannot do my work without it.
screenI prefer tmux, but yes. Both do a great job in helping me manage my terminal sessions.
What can I say. I’m old.
Scrolling in screen is superior to tmux imo
Scrolling is tmux is what I hate about it. I would prefer to use tmux since I’m use to it. But if someone can explain to me why I can’t just use my scroll wheel on my mouse.
As I understand it, the issue is that tmux invents its own terminal emulator functionality that conflicts with the existing terminal it runs within, while screen simply defers scroll functionality to the terminal emulator.
tmux is based
Tmux is good because I can have a little window with a bonsai in it and another little window for the matrix. Sometimes I even leave a window for typing in commands.
Based is fetch.
Stop trying to make fetch happen
are you using a maintained alternative? Distros started to remove it from their repos years ago because it was not maintained anymore afaik
I have no idea where you got that from. 5.0.1 is from August 2025.
maybe they resumed development then, it was removed from Ubuntu and RHEL repos about 5 years ago when I had to look for an alternative
I’m a big enjoyer of pushd and popd
so if youre in a working dir and need to go work in a different dir, you can pushd ./, cd to the new dir and do your thing, then popd to go back to the old dir without typing in the path again
Nice! I didn’t know that one.
You can also cd to a directory and then do
cd -to go to the last directory you were in.I love these.
pushd can also take a path so that you don’t have to do a cd after
I only recently started using
C-rto search in the command history. Game changer!Want an even bigger game changer? fzf combined with control-r.
Enjoy.
https://atuin.sh/ does one better. history with context: $PWD, $HOST, time. There’s a bunch of other bells and whistles, but they’re easy to ignore to get an noninvasive upgrade to ctrl+R
This guy searches!
Yessir! Fzf is pretty much indispensable to me now.
Never seen ads in a read me before
Those projects contribute the bulk of funds for the development of fzf.
It’s normal to credit them and I’ve seen that done on multiple open source projects.
Credit ≠ Ads
Those are ads. It’s cringe.
Ok. Let’s go with it being ads. It’s a free open source project that’s absolutely worth using. Are you going to crucify them for it? Wanna donate for its development?
If they show me ads to donate? Fuck no.
ncis useful. For example: if you have a disk image downloaded on computer A but want to write it to an SD card on computer B, you can run something likeuser@B: nc -l 1234 | pv > /dev/$sdcardAnd
user@A: nc B.local 1234 < /path/to/image.img(I may have syntax messed up–also don’t transfer sensitive information this way!)
Similarly, no need to store a compressed file if you’re going to uncompress it as soon as you download it—just pipe
wgetorcurltotarorxzor whatever.I once burnt a CD of a Linux ISO by
wgeting directly tocdrecord. It was actually kinda useful because it was on a laptop that was running out of HD space. Luckily the University Internet was fast and the CD was successfully burnt :)parallel, easy multithreading right in the command line. This is what I wish was included in every programming language’s standard library, a dead simple parallelization function that takes a collection, an operation to be performed on the members of that collection, and optionally the max number of threads (should be the number of hardware threads available on the system by default), and just does it without needing to manually set up threads and handlers.inotifywait, for seeing what files are being accessed/modified.tail -F, for a live feed of a log file.script, for recording a terminal session complete with control and formatting characters and your inputs. You can then cat the generated file to get the exact output back in your terminal.screen, starts a terminal session that keeps running after you close the window/SSH and can be re-accessed withscreen -x.Finally, a more complex command I often find myself repeatedly hitting the up arrow to get:
find . -type f -name '*' -print0 | parallel --null 'echo {}'Recursively lists every file in the current directory and uses parallel to perform some operation on them. The
{}in the parallel string will be replaced with the path to a given file. The'*'part can be replaced with a more specific filter for the file name, like'*.txt'.I can recommend tmux also as an alternative to screen
should be the number of hardware threads available on the system by default
No, not at all. That is a terrible default. I do work a lot on number churning and sometimes I have to test stuff on my own machine. Generally I tend to use a safe number such as 10, or if I need to do something very heavy I’ll go to 1 less than the actual number of cores on the machine. I’ve been burned too many times by starting a calculation and then my machine stalls as that code is eating all CPU and all you can do is switch it off.
echo 'dXIgbW9tCmhhaGEgZ290dGVtCg==' | base64 -dOr
base64 -d <<< 'dXIgbW9tCmhhaGEgZ290dGVtCg=='Can’t remember if
<<<is POSIX or not, but pretty sure it works in bash and zsh.FTR,
<<<is a bashism. it’s a nice one, though.
Good one, very useful




















