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
Spoiler
Debian-Packages available
mtr iputils-tracepath iproute2 zsh httpie aria2 icdiff progress diffoscope atop powertop ntopng ethtool nethogs vnstat ss glances discus dstat logwatch swatch multitail lynis ncdu (du-clone), alias du=“ncdu --color dark -rr -x --exclude .git --exclude node_modules” nnn (fully-featured terminal file manager. It’s tiny, nearly 0-config and incredibly fast. https://github.com/jarun/nnn) slurm calcurse newsbeuter tig (“ncurses TUI for git. It’s great for reviewing and staging changes, viewing history and diffs.”) qalc ttyrec taskwarrior ttytter ranger ipcalc pandoc moreutils googler weechat pdftk abcde dtrx tload ttyload cockpit sar ht (hte Hex Editor) dhex ack (grep-clone) silversearcher-ag (grep-clone) ripgrep (“recursively searches file trees for content in files matching a regular expression. It’s extremely fast, and respects ignore files and binary files by default.”, https://github.com/BurntSushi/ripgrep) exa (statt ls) https://the.exa.website/ (“replacement for ls with sensible defaults and added features like a tree view, git integration, and optional icons.”) fzf (CLI fuzzy finder), alias preview=“fzf --preview ‘bat --color "always" {}’” fd (simple, fast and user-friendly alternative to ‘find’, https://github.com/sharkdp/fd) entr (watch-clone) csvkit (awk-clone) ccze (log coloring) surfraw hexyl (“hex viewer that uses Unicode characters and colour”, https://github.com/sharkdp/hexyl) jq (“awk for JSON. It lets you transform and extract information from JSON documents”, https://stedolan.github.io/jq/) pass (“password manager that uses GPG to store the passwords”, https://github.com/lunaryorn/mdcat) restic (“backup tool that performs client side encryption, de-duplication and supports a variety of local and remote storage backends.”, https://restic.net/) mdp (Markdown Presentation on CLI) grepcidr qrencode caca-utils (show images on the CLI) fbi ( & fbgs) (show images in Framebuffer device) fbcat (take screnshot on framebuffer device) nmap micro (CLI Text Editor, ab Debian 11, https://micro-editor.github.io) masscan (https://github.com/robertdavidgraham/masscan) socat (Nachfolger von netcat, https://www.heise.de/select/ix/2017/11/1509815804306324) dc3dd (patched version of GNU dd with added features for computer forensics) smem (memory reporting tool) free (Show Linux server memory usage) mpstat (Monitor multiprocessor usage on Linux, part of sysstat package) pmap (Montor process memory usage on Linux, part of the procps) monit (Process supervision) oping & noping saidar (Curses-basiertes Programm für die Anzeige von Live-Systemstatistiken) reptyr (Tool for moving running programs between ptys) gron (https://github.com/tomnomnom/gron, makes JSON greppable, kann HTTP-Requests absetzen) jc (https://github.com/kellyjonbrazil/jc, CLI tool and python library that converts the output of popular command-line tools and file-types to JSON or Dictionaries. This allows piping of output to tools like jq and simplifying automation scripts.) bat (cat-clone), alias cat=‘bat’ (“alternative to the common (mis)use of cat to print a file to the terminal. It supports syntax highlighting and git integration.”, https://github.com/sharkdp/bat) ioping (https://github.com/koct9i/ioping, simple disk I/0 latency measuring tool, auch für disk seek rate/iops/avg) vd (Visidata, multipurpose terminal utility for exploring, cleaning, restructuring and analysing tabular data. Current supported sources are TSV, CSV, fixed-width text, JSON, SQLite, HTTP, HTML, .xls, and .xlsx) pdfgrep duf https://github.com/muesli/duf (combined df and du, ncurses-based) nala (apt-alternate, https://gitlab.com/volian/nala, https://christitus.com/stop-using-apt/) iprange tldr rmlint nvtop (https://github.com/Syllo/nvtop, GPUs process monitoring for AMD, Intel and NVIDIA) lf (lf (as in “list files”) is a terminal file manager written in Go with a heavy inspiration from ranger file manager)
** no Deb pkg avail**
oh-my-zsh (http://ohmyz.sh) webmin observium cheat (https://github.com/cheat/cheat, create and view interactive cheatsheets on the command-line.) bropages ipbt / its-playback-time todo earthquake suplemon Newsroom unity ired wpe prettyping (ping), alias ping=‘prettyping --nolegend’ diff-so-fancy (diff-clone) q (query CSV Files with SQL) https://harelba.github.io/q/ gping (ping with a graph in CLI) http-prompt (install via pip) alt (“finding the alternate to a file. E.g. the header for an implementation or the test for an implementation. I use it paired with Neovim”, https://github.com/uptech/alt) chars (“shows information about Unicode characters matching a search term.”, https://github.com/antifuchs/chars) dot (“dotfiles manager. It maintains a set of symlinks according to a mappings file”, https://github.com/ubnt-intrepid/dot) dust (“alternative du -sh. It calculates the size of a directory tree, printing a summary of the largest items.”, https://github.com/bootandy/dust) eva (“command line calculator similar to bc, with syntax highlighting and persistent history.”, https://github.com/NerdyPepper/eva) hyperfine (“command line benchmarking tool. It allows you to benchmark commands with warmup and statistical analysis.”, https://github.com/sharkdp/hyperfine) mdcat (“renders Markdown files in the terminal”, https://github.com/lunaryorn/mdcat) podman (“alternative to Docker that does not require a daemon. Containers are run as the user running Podman so files written into the host don’t end up owned by root. The CLI is largely compatible with the docker CLI.”, https://podman.io/) skim (“fuzzy finder. It can be used to fuzzy match input fed to it. I use it with Neovim and zsh for fuzzy matching file names.”) z (“tracks your most used directories and allows you to jump to them with a partial name.”, https://github.com/rupa/z) alias wetter_graph=‘finger dresden@graph.no’ alias wetter_color=‘curl wttr.in’ alias maps_cli=‘telnet mapscii.me’ https://github.com/say4n/crappybird https://asciicker.com cbonsai https://gitlab.com/jallbrit/cbonsai GNU poke binary editor http://www.jemarch.net/poke / https://git.savannah.gnu.org/cgit/poke.git gdu GoDiskUsage https://github.com/dundee/gdu Cirrus CLI https://github.com/cirruslabs/cirrus- tuxi https://github.com/Bugswriter/tuxi personal CLI assistant ngrep https://github.com/jpr5/ngrep topgrade https://github.com/r-darwish/topgrade ndiff https://nmap.org/ndiff/ compare nmap scans natlas https://github.com/natlas/natlas sift https://sift-tool.org grep-alternative xplr https://github.com/sayanarijit/xplr (hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf) croc https://github.com/schollz/croc (allows any two computers to simply and securely transfer files and folders, great for forensics) slidev https://sli.dev (HTML5 presentations) lfs https://github.com/Canop/lfs (df alternative) vtop (https://github.com/MrRio/vtop) gtop (https://github.com/aksakalli/gtop) up (Ultimate Plumber https://github.com/akavel/up) ttyd (https://github.com/tsl0922/ttyd, Share your terminal over the web) nms (no more secrets, https://github.com/bartobri/no-more-secrets, A command line tool that recreates the famous data decryption effect seen in the 1992 movie Sneakers.) xsv (https://github.com/BurntSushi/xsv, A fast CSV command line toolkit written in Rust.) fx (https://github.com/antonmedv/fx, Terminal JSON viewer) ccat (https://github.com/owenthereal/ccat, colorized cat mit Syntax Highlighting) elta (https://github.com/dandavison/delta, A syntax-highlighting pager for git, diff, and grep output. VORSICHT: Paket einer anderen Software mit gleichem Namen unter Debian Bullseye als Paket verfügbar!) dyff (https://github.com/homeport/dyff, /ˈdʏf/ - diff tool for YAML files, and sometimes JSON) skim (https://github.com/lotabout/skim, Fuzzy finder in Rust) choose (https://github.com/theryangeary/choose, A human-friendly and fast alternative to cut and (sometimes) awk) sd (https://github.com/chmln/sd, wie sed, Intuitive find & replace CLI, mit regex) map (https://github.com/soveran/map)
___
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.