Posts by Iizuki
An exclamation mark followed by space in the beginning of a pipeline will negate the final exit code of the pipeline. Here's an example in Bash. Echoing $? will print out the exit code of the prev...
How to find the exact path to an executable file present in your PATH. I.e. commands you can call by just their names. E.g. what executable gets called when I type find and hit enter? $ hypotheti...
GNU which does the trick: $ which find /usr/bin/find It's very likely already installed.
There's a sha1sum tool in GNU coreutils. Here's $ sha1sum emptyfile da39a3ee5e6b4b0d3255bfef95601890afd80709 emptyfile Note the spaces and the filename (emptyfile in this case) in the output...
dmidecode can do this. Here's an example output from my system: # dmidecode --type 2 Getting SMBIOS data from sysfs. SMBIOS 3.1.1 present. Handle 0x0002, DMI type 2, 15 bytes Base Board Info...
How to apply a logical not to a shell command, e.g. in a Bash script? So if the command exited with 0 (success) I would like it to be changed to a non-zero value, and if it exited with a non-zero ...
ip a command will conveniently show the addresses assigned to your network interfaces, but oftentimes this is not what the internet sees your machine as. So how to find your public IP address from...
How to get the number of lines in a file? I.e. for a file like this: Line one Line 2 Final line I would like to do something like this: $ count-lines /path/to/the/file/above 3
xmllint from xmllib2 can do this: $ output-dirty-xml | xmllint --format - The dash in the end tells xmllint to read from stdin instead of a file. Source: manpage
How to convert a json file to yaml? Technically json is already valid yaml, but I'm talking about the characteristic easy-to-read yaml formatting with indentation and minimal quotes.
GPG stores keys inside an internal database of some sort. How to export your public key in the familiar -----BEGIN PGP PUBLIC KEY BLOCK----- format so that it can be imported to other software? E.g...
How to display details about a site's certificate using CLI tools?
Keep both your / and /home on the SSD, and then create the /data partition on your HDD. You could link individual directories from home as you say, but I usually create just one link to the HDD ro...
How to list tags of a container in container registry using CLI tools? Kinda like you would browse them visually in dockerhub.
Surely there exists a command to print out the system's mother board model? Opening up the chassis is not an option.
With yq: $ yq --output-format yaml . file.json > file.yaml . is a filter which is applied to the data, but since . just stands for the document root, this means that the data is passed throu...
This is how to save it to a file: $ gpg --export --armor key-id > my-key.pub --armor stands for the format with printable characters.
They are defined in the Desktop Entry Specification. In fact there are also %f and %F options. They tell the desktop manager how the program handles multiple files. Like if I select a bunch of fil...
Desktop files always have either %u or %U as an argument for the program being launched. E.g. here's a line from my firefox.desktop: Exec=/usr/lib/firefox/firefox %u What does it mean?
Sometimes your programs fail because the network port they are trying to use is already in use by some other process. How to find out what this other process is?
The preexec function is called right before executing commands, so it's the place to do this sorta things. This solution is adapted from Dan Berindei's original answer (CC BY-SA 3.0) to a related ...
How to configure ZSH shell to print a timestamp on the right hand side of the prompt line when executing a command? I don't want to display the time prior to executing a command. Here's about how ...
You've just run df -h and are shocked how little disk space you got left. You'd like to find where all the space has gone. How to find big(est) files and directories on your system? (So that you c...
How to open a port when using firewalld as the system firewall?
Cisco's OpenDNS (nothing to do with open source) has this magic domain myip.opendns.com which resolves to your own public IP address when looked up with standard DNS tools. For example with dog (o...