I use bash, because I never had the time to learn anything else.
Like @jlsalvador said, I use the #!/usr/bin/env bash shebang.
Nope
Also nope
Nope. Shell scripts reside in Git repos on Gitlab/Gitea/Forgejo and are checked out using Ansible playbooks onto the servers as necessary.
For scripts? Python. Read this blog post by the great @isotopp. For interactive use? bash is just fine for me, though I’ve customized it using Starship and created some aliases to have colored/pretty output where possible.
Use 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.
Be prepared to shave yaks. Take breaks, touch grass, pet a dog. Use set -x inside your Bash script or bash -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.
Nope, it’s absolutely not bad practice to create aliases to save you some typing in interactive shell. You shouldn’t use them inside your scripts though, because they might/will not be available in other environments.
I switched to fish because it has tab completion Yeah, so does Bash, just install it.
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
ToolsDebian-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. 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.”, github.com/BurntSushi/ripgrep) - exa (statt ls) 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’, github.com/sharkdp/fd) -entr (watch-clone) - csvkit (awk-clone) - ccze (log coloring) - surfraw -hexyl (“hex viewer that uses Unicode characters and colour”, github.com/sharkdp/hexyl) -jq (“awk for JSON. It lets you transform and extract information from JSON documents”, stedolan.github.io/jq/) -pass (“password manager that uses GPG to store the passwords”, github.com/lunaryorn/mdcat) - restic (“backup tool that performs client side encryption, de-duplication and supports a variety of local and remote storage backends.”, 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, micro-editor.github.io) - masscan (github.com/robertdavidgraham/masscan) - socat (Nachfolger von netcat, 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 (github.com/tomnomnom/gron, makes JSON greppable, kann HTTP-Requests absetzen) - jc (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.”, github.com/sharkdp/bat) - ioping (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 github.com/muesli/duf (combined df and du, ncurses-based) - nala (apt-alternate, gitlab.com/volian/nala, christitus.com/stop-using-apt/) - iprange - tldr - rmlint - nvtop (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 (ohmyz.sh) - webmin - observium - cheat (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) 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”, github.com/uptech/alt) - chars (“shows information about Unicode characters matching a search term.”, github.com/antifuchs/chars) - dot (“dotfiles manager. It maintains a set of symlinks according to a mappings file”, github.com/ubnt-intrepid/dot) - dust (“alternative du -sh. It calculates the size of a directory tree, printing a summary of the largest items.”, github.com/bootandy/dust) - eva (“command line calculator similar to bc, with syntax highlighting and persistent history.”, github.com/NerdyPepper/eva) - hyperfine (“command line benchmarking tool. It allows you to benchmark commands with warmup and statistical analysis.”, github.com/sharkdp/hyperfine) - mdcat (“renders Markdown files in the terminal”, 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.”, 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.”, github.com/rupa/z) - alias wetter_graph=‘finger dresden@graph.no’ - alias wetter_color=‘curl wttr.in’ - alias maps_cli=‘telnet mapscii.me’ - github.com/say4n/crappybird- asciicker.com- cbonsai gitlab.com/jallbrit/cbonsai- GNU poke binary editor www.jemarch.net/poke / git.savannah.gnu.org/cgit/poke.git- gdu GoDiskUsage github.com/dundee/gdu- Cirrus CLI github.com/cirruslabs/cirrus-- tuxi github.com/Bugswriter/tuxi personal CLI assistant - ngrep github.com/jpr5/ngrep- topgrade github.com/r-darwish/topgrade- ndiff nmap.org/ndiff/ compare nmap scans - natlas github.com/natlas/natlas- sift sift-tool.org grep-alternative - xplr github.com/sayanarijit/xplr (hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf) - croc github.com/schollz/croc (allows any two computers to simply and securely transfer files and folders, great for forensics) - slidev sli.dev (HTML5 presentations) - lfs github.com/Canop/lfs (df alternative) - vtop (github.com/MrRio/vtop) - gtop (github.com/aksakalli/gtop) - up (Ultimate Plumber github.com/akavel/up) - ttyd (github.com/tsl0922/ttyd, Share your terminal over the web) - nms (no more secrets, github.com/bartobri/no-more-secrets, A command line tool that recreates the famous data decryption effect - seen in the 1992 movie Sneakers.) - xsv (github.com/BurntSushi/xsv, A fast CSV command line toolkit written in Rust.) - fx (github.com/antonmedv/fx, Terminal JSON viewer) - ccat (github.com/owenthereal/ccat, colorized cat mit Syntax Highlighting) - delta (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 (github.com/homeport/dyff, /ˈdʏf/ - diff tool for YAML files, and sometimes JSON)
Tools pt. 2- skim (github.com/lotabout/skim, Fuzzy finder in Rust) - choose (github.com/theryangeary/choose, A human-friendly and fast alternative to cut and (sometimes) awk) - sd (github.com/chmln/sd, wie sed, Intuitive find & replace CLI, mit regex) - map (github.com/soveran/map, Map lines from stdin to commands, gemütliche Variante von xargs mit einfacherer Syntax und weniger Funktionsumfang) - crush (github.com/liljencrantz/crush, Crush is a command line shell that is also a powerful modern programming language. Kann u.a. SQL-Statements) - xxh (github.com/xxh/xxh, Bring your favorite shell wherever you go through the ssh.) - starship (starship.rs, Shell-Prompt anpassen mit Nerdfont) - q (github.com/natesales/q, A tiny & colorful command line DNS client with support for UDP, TCP, DoT, DoH, DoQ and ODoH.) - gping (github.com/orf/gping, Ping, but with a graph) - broot (github.com/Canop/broot, A new way to see and navigate directory trees : dystroy.org/broot) - dust (github.com/bootandy/dust, intuitive du colored) - dutree (github.com/nachoparker/dutree, a tool to analyze file system usage written in Rust) - lsd (github.com/Peltoche/lsd, next-gen ls) - mcfly (github.com/cantino/mcfly, Fly through your shell history using neural nets) - procs (github.com/dalance/procs, A modern replacement for ps written in Rust, color, human readable, multi-column keword search) - bottom (github.com/ClementTsang/bottom, top replacement, cross-platform graphical process/system monitor, zoom support) - btop++ (github.com/aristocratos/btop, resource monitor CPU, RAM, IO, processes, IN SCHICK!!!, C+±continuation of bpytop github.com/aristocratos/bpytop) - musikcube (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 (github.com/atanunq/viu, Terminal image viewer with native support for iTerm and Kitty, auch animated gif) - glow (github.com/charmbracelet/glow, Render markdown on the CLI) - falsisign (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 (github.com/erkin/ponysay, wie cowsay mit bunten Ponies) - sniffnet (github.com/GyulyVGC/sniffnet, cross-platform application to monitor your network traffic with ease, Debian-Pakete von GitHub verfügbar) - netop (github.com/ZingerLittleBee/netop, monitor network traffic with bpf) - corefreq (github.com/cyring/CoreFreq, CPU monitoring software for 64-bits Processors.) - ctop (github.com/bcicen/ctop, Top-like interface for container metrics) - dua (github.com/Byron/dua-cli, View disk space usage and delete unwanted data, fast.) - dust (github.com/bootandy/dust, A more intuitive version of du in rust) - helix editor - lnav (github.com/tstack/lnav Log navigator) - bottom (github.com/ClementTsang/bottom, another cross-platform graphical process/system monitor) - broot (github.com/Canop/broot, a different than ranger/lf approach to navigating folders) - mdr (github.com/michaelmure/mdr, a markdown viewer) - eza (github.com/eza-community/eza, modern ls, with cool features like file icons) - ouch (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 (github.com/Rigellute/spotify-tui, Spotify CLI frontend (Spotify via terminal)) - toilet (caca.zoy.org/wiki/toilet, turn text into ASCII art) 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 bash ### .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 “%sn” | 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 - }
General Advice for shell scripts
What do you advice for shell usage?...
Top comment gets to choose my hostname
After nuking my old install, I am in need of a hostname. Top comment chooses it.