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’.
Not a command but the tab key for auto complete. This made it much easier for me.
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.
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
ripgrep
cd `pwd`for when you want to stay in a dìr that gets deleted and recreated.
cat /proc/foo/exe > program cat /proc/foo/fd/bar > fileto undelete still-running programs and files still opened in running programs
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.
systemd-run lets you run a command under some limitations, ie
systemd-run --scope -p MemoryLimit=1000M -p CPUQuota=20% ./heavyduty.shulimit can also be used to define limits, but for a user rather than a process. This could protect you against, ie, a fork bomb
rpm-ostree status
rpm-ostree reset
rpm-ostree rebase
idk i love rpm-ostree man
Journalctl | grep -C 10 'foo'was useful for me when I needed to troubleshoot some fstab mount fuckery on boot.Ha! Remember back when there was no fstab fuckery? Good times. But you have a massive init blob slowly eating other services and replacing them with shitty replicants like this embarrassment (ohai root NFS) and all of us Unix people are chuckling in our reduced-fuckery ‘hell’.
echo 'dXIgbW9tCmhhaGEgZ290dGVtCg==' | base64 -dGood one, very useful
Running Wine is the command I’ve used the most probs, you can tell I haven’t touched the thing in months.
Something that really improved my life was learn to properly use
find,grep,xargsandsed. Besides that, there are these two little ‘hacks’ that are really handy at times…1- find out which process is using some local port (i.e. the modern netstat replacement):
$ ss -ltnp 'sport = :<port-number>'2- find out which process is consuming your bandwidth:
sudo nethogsI always just do
ss -ltnp | grep <port-number>, which filters well enough for my purposes and is a bit easier to remember…
when 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^:&
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 :)
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.










