Gnu
5 Sep 2024
"teethis" script is one of the most useful tools I've created
tee
is a GNU tool to piggy back stout off of a pipe. The following example shows the basic pattern for using it, where the stout is printed to the terminal and written to a log file.
|
|
“teethis” script #
I frequently want to run shell scripts where I can see both the stdout and stderr immediately while preserving the output to refer to later. While the tee
command to do this is relatively simple, it can be a pain to type over and over again, so I created the following teethis script.
27 Aug 2024
`apropos` is an overlooked Linux command
Search for Linux command that does what you need #
Sometimes the challenge of using the Linux command line is knowing what commands you need to do certain things.
The apropos
command lets you search the available commands by matching key words.
|
|
The command checks all of the installed man pages and package descriptions, however there are circumstances where this could leave out some relevant commands.
27 Nov 2023
Manually customize bash terminal prompt look
The prompt text that bash interprets and uses is set with the PS1
environment variable and is usually specified in ~/.bashrc
. I have been manually tweaking my bash prompt look and feel to make some of my work project use-case tasks easier. The combination of default style changes, and specific prompt elements added for active environment or sourced environments should make terminal-based project management a little easier.
A little searching allowed me to discover this website that allows you to interactively customize the prompt contents and style with common components. https://bash-prompt-generator.org/
3 Nov 2023
Installation #
|
|
Installation with apt
#
|
|
Installation with dnf
#
|
|
Usage #
|
|
Send to remote machine over SSH #
|
|
Styling with HTML #
HTML tags are supported for styling the notification messages, even including images, although the result is not styled in the case of notifications in the rofication setup used by default in the i3wm-based regolith-desktop DE.
3 Apr 2023
Reproducible Scientific Python Using Containers
Use Microsoft’s VSCode editor (code
), Docker Containers, and other open-source tools for scientific Python software collaboration, development, and use on Linux and Windows. Securely connect offices, remote workers, storage resources, compute resources, and the cloud with Tailscale as a replacement for traditional VPN.
System Packages #
VSCode Editor #
Download Visual Studio Code from Microsoft.
For a Debian-based GNU/Linux distribution like Ubuntu or Pop OS, the .deb can be installed with sudo dpkg -i code_$version_amd64.deb
.
27 Mar 2023
The many layers of software dependencies within containers can add extra security considerations. Luckily there are a number of tools like Trivy and Docker scan
to scan Docker images for vulnerabilities.
[Trivy is a] Scanner for vulnerabilities in container images, file systems, and Git repositories, as well as for configuration issues and hard-coded secrets
Trivy can be installed with the following commands on Debian-based Linux distros, including WSL environments.
15 Dec 2022
`diff` Also Compares Directories
Short post so that I can remember this everytime I need to do something similar!
Using diff
on more than individual files
#
The quick and dirty explaination is that the GNU/Linux diff
command has an -r
flag to recursively compare two folders. The command help indicates that it is shorthand for the full --recursive
flag, which might be easier to remember.
|
|
Example #
In the following example, “Only in” shows that particular files are only found in one of the folders. By default, matching files are not shown. If a file can be found in both folders and the two versions differ, the normal diff
output is provided along with the modified times. All together these details provide a good summary of what a user might want to know when comparing two directories.
24 Mar 2022
Bad Hacks to Find Linux Drive Device from UUID
On linux, you can’t count on the devices listed under /dev/sd*
or /dev/xvd*
, to have the same names or order. With the UUID (which is how /etc/fstab
usually specifies how to mount the root system device), the /dev
device name can be determined using the blkid
command and some hacky bash.
|
|
However, you might need to do something like start a Docker container with your main system device connected using docker run --device=...
, and so the following also works in this specific case looking for the device mounted at the local machine’s /
.
19 Aug 2021
Useful Docker Patterns (On GNU/Linux)
To easily copy files from a Docker image when you dont want to start a container, you can do the following:
|
|
Sometimes it is useful to compare the output of a command between two Docker images, especially comparing different versions of a particular image:
|
|
I have both these command patterns saved as executable Bash shell scripts on my system path as cp_docker
and diff_docker_cmd
respectively.
10 Feb 2021
There many GNU/Linux command line tools that provide continuously updated statistics or information like iotop
, nload
, and top
. However, it is often necessary to see the output of another simple command or complex chain of tools, updated in real-time.
watch
is a Linux command that does just that, and by doing so, is incredibly useful for continuously monitoring the output of any Linux terminal command. Usage of the watch
command is incredibly simple, as the following example monitoring the currently running tsp
task in the task-spooler queue demonstrates.
1 Jan 0001
If you find you are using commands like sleep
to run a one-off task at a specific time, then meet the GNU at
command.
at
will allow you to specify a time to run a specific command, and accepts a wide range of different formats including “now + 4 hours”, “noon”, and “next tuesday”. The command will read commands from stdin or using the -f
to specifiy a file to be executed using the default /bin/sh
.