What do you advice for shell usage?
- Do you use bash? If not, which one do you use? zsh, fish? Why do you do it?
- Do you write
or
? Do you write fish exclusive scripts?
- Do you have two folders, one for proven commands and one for experimental?
- Do you publish/ share those commands?
- Do you sync the folder between your server and your workstation?
- What should’ve people told you what to do/ use?
- good practice?
- general advice?
- is it bad practice to create a handful of commands like
podup
andpoddown
that replacepodman compose up -d
andpodman compose down
orpodlog
aspodman logs -f --tail 20 $1
orpodenter
forpodman exec -it "$1" /bin/sh
?
Background
I started bookmarking every somewhat useful website. Whenever I search for something for a second time, it’ll popup as the first search result. I often search for the same linux commands as well. When I moved to atomic Fedora, I had to search for rpm-ostree
(POV: it was a horrible command for me, as a new user, to remember) or sudo ostree admin pin 0
. Usually, I bookmark the website and can get back to it. One day, I started putting everything into a .bashrc
file. Sooner rather than later I discovered that I could simply add ~/bin
to my $PATH
variable and put many useful scripts or commands into it.
For the most part I simply used bash. I knew that you could somehow extend it but I never did. Recently, I switched to fish because it has tab completion. It is awesome and I should’ve had completion years ago. This is a game changer for me.
I hated that bash would write the whole path and I was annoyed by it. I added PS1="$ "
to my ~/.bashrc
file. When I need to know the path, I simply type pwd
. Recently, I found starship which has themes and adds another line just for the path. It colorizes the output and highlights whenever I’m in a toolbox/distrobox. It is awesome.
bash
, because I never had the time to learn anything else.#!/usr/bin/env bash
shebang.bash
is just fine for me, though I’ve customized it using Starship and created some aliases to have colored/pretty output where possible.shellcheck
before running your scripts in production, err on the side of caution,set -o pipefail
. There are best practices guides for Bash, use those and you’ll probably be fine.set -x
inside your Bash script orbash -x scriptname
on the CLI for debugging. Remember that you can always fallback to interactive CLI to test/prepare commands before you put them into your script. Think before you type. Test. Optimize only what needs optimization. Use long options for readability. And remember: Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows your address.Oh, I also “curate” a list of Linux tools that I like, that are more modern alternatives to “traditional” Linux tools or that provide information I would otherwise not easily get. I’ll post i
Tools
Debian-Packages available
no Deb pkg avail
___
Rest of the list:
Tools pt. 2
DNS tools:
Good stuff for pentesters and security researchers:
### .bashrc ### CUSTOM FUNCTIONS # https://www.linuxjournal.com/content/boost-productivity-bash-tips-and-tricks ftext () { grep -iIHrn --color=always "$1" . | less -R -r } duplicatefind (){ find -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | \ xargs -I{} -n1 find -type f -size {}c -print0 | \ xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate } generateqr (){ # printf "$@" | curl -F-=\<- qrenco.de printf "$@" | qrencode -t UTF8 -o - }
My brian has too little ram to process the list of packages 😂 good to know the rest!
Neither does mine, but, I keep it to test a new tool from time to time.
Rest of the list:
Spoiler
crush (https://github.com/liljencrantz/crush, Crush is a command line shell that is also a powerful modern programming language. Kann u.a. SQL-Statements) xxh (https://github.com/xxh/xxh, Bring your favorite shell wherever you go through the ssh.) starship (https://starship.rs, Shell-Prompt anpassen mit Nerdfont) q (https://github.com/natesales/q, A tiny & colorful command line DNS client with support for UDP, TCP, DoT, DoH, DoQ and ODoH.) gping (https://github.com/orf/gping, Ping, but with a graph) broot (https://github.com/Canop/broot, A new way to see and navigate directory trees : https://dystroy.org/broot) dust (https://github.com/bootandy/dust, intuitive du colored) dutree (https://github.com/nachoparker/dutree, a tool to analyze file system usage written in Rust) lsd (https://github.com/Peltoche/lsd, next-gen ls) mcfly (https://github.com/cantino/mcfly, Fly through your shell history using neural nets) procs (https://github.com/dalance/procs, A modern replacement for ps written in Rust, color, human readable, multi-column keword search) bottom (https://github.com/ClementTsang/bottom, top replacement, cross-platform graphical process/system monitor, zoom support) btop++ (https://github.com/aristocratos/btop, resource monitor CPU, RAM, IO, processes, IN SCHICK!!!, C+±continuation of bpytop https://github.com/aristocratos/bpytop) musikcube (https://github.com/clangen/musikcube, cross-platform, terminal-based music player, audio engine, metadata indexer, and server in c++ with an ncurses TI, incl.Android App) viu (https://github.com/atanunq/viu, Terminal image viewer with native support for iTerm and Kitty, auch animated gif) glow (https://github.com/charmbracelet/glow, Render markdown on the CLI) falsisign (https://gitlab.com/edouardklein/falsisign, For bureaucratic reasons, a colleague of mine had to print, sign, scan and send by email a high number of pages. To save trees, ink, time, and to stick it to the bureaucrats, I wrote this script.) ponysay (https://github.com/erkin/ponysay, wie cowsay mit bunten Ponies) sniffnet (https://github.com/GyulyVGC/sniffnet, cross-platform application to monitor your network traffic with ease, Debian-Pakete von GitHub verfügbar) netop (https://github.com/ZingerLittleBee/netop, monitor network traffic with bpf) corefreq (https://github.com/cyring/CoreFreq, CPU monitoring software for 64-bits Processors.) ctop (https://github.com/bcicen/ctop, Top-like interface for container metrics) dua (https://github.com/Byron/dua-cli, View disk space usage and delete unwanted data, fast.) dust (https://github.com/bootandy/dust, A more intuitive version of du in rust) helix editor lnav (https://github.com/tstack/lnav Log navigator) bottom (github.com/ClementTsang/bottom, another cross-platform graphical process/system monitor) broot (https://github.com/Canop/broot, a different than ranger/lf approach to navigating folders) mdr (https://github.com/michaelmure/mdr, a markdown viewer) eza (https://github.com/eza-community/eza, modern ls, with cool features like file icons) ouch (https://github.com/ouch-org/ouch, It’s a CLI tool for compressing and decompressing for various formats. such as .tar .zip 7z .gz .xz .lzma .bz .bz2 .lz4 .sz .zst .rar) spotify-tui (https://github.com/Rigellute/spotify-tui, Spotify CLI frontend (Spotify via terminal)) toilet (http://caca.zoy.org/wiki/toilet, turn text into ASCII art)
.bashrc
CUSTOM FUNCTIONS
https://www.linuxjournal.com/content/boost-productivity-bash-tips-and-tricks
ftext () grep -iIHrn --color=always “$1” . duplicatefind () find -not -empty -type f -printf “%s\n” -n1 find -type f -size }c -print0 generateqr () # printf “$@”
DNS tools: -viewdns.info -dnslytics.com -dnsspy.io -leafdns.com -dnsdumpster.com -intodns.com -www.zonecut.net/dns -xip.io -nip.io -ptrarchive.com -www.whatsmydns.net -ceipam.eu/en/dnslookup.php -spyse.com/tools/dns-lookup -www.buddyns.com/delegation-lab
Good stuff for pentesters and security researchers: -contained.af -cryptohack.org -0x00sec.org -hack.me -chall.stypr.com -crackmes.one -hackxor.net -tryhackme.com -ctftime.org -ctflearn.com -picoctf.org