5 Essential Ops Hacks: Master sh, History Timestamps, File Transfer, Screen, and Mermaid Diagrams
This guide shares five practical operations tips—understanding the ambiguous "sh" command, adding timestamps to Bash history, copying files across servers without passwords, managing multiple terminals with Screen, and creating diagrams with Mermaid—to boost daily efficiency.
1. The confusing “sh”
When running install scripts like curl -sfL https://get.k3s.io | sh, the sh command may point to different shells depending on the distribution.
Debian/Ubuntu derivatives: sh is dash (lightweight shell).
RHEL/CentOS: sh usually links to bash (POSIX‑compatible mode).
Alpine Linux: sh points to BusyBox’s implementation.
Check the actual link with ls -l /bin/sh. If the script relies on Bash‑specific features, invoke bash explicitly.
2. Adding timestamps to history
The default history command shows no date or time. Add the line export HISTTIMEFORMAT="%F %T" to ~/.bashrc. %F prints the full date (YYYY‑MM‑DD) and %T prints the time (HH:MM:SS). After reloading, history displays entries with timestamps.
3. Copying files across servers without passwords
Two methods:
Use nc (netcat): on the source machine run nc -l 10017 < abc.sh, on the target run nc 1.1.1.1 10017 > abc.sh.
Use Python’s simple HTTP server: on the source run python -m SimpleHTTPServer 10010, then download with wget http://1.1.1.1:10010/abc.sh or via a browser.
4. Managing multiple terminal windows with Screen
screenlets you run several terminal sessions inside a single window, detach them, and reattach later. Example to start a session: screen -S [session_name] ping baidu.com. List sessions with screen -ls.
5. Generating diagrams with Mermaid
Mermaid is a JavaScript‑based tool that creates flowcharts, sequence diagrams, Gantt charts, etc., from Markdown‑style text. It can be combined with DeepSeek to produce full‑lifecycle ops diagrams.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Efficient Ops
This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
