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
shcommand may point to different shells depending on the distribution.
Debian/Ubuntu derivatives:
shis
dash(lightweight shell).
RHEL/CentOS:
shusually links to
bash(POSIX‑compatible mode).
Alpine Linux:
shpoints to BusyBox’s implementation.
Check the actual link with
ls -l /bin/sh. If the script relies on Bash‑specific features, invoke
bashexplicitly.
2. Adding timestamps to history
The default
historycommand shows no date or time. Add the line
export HISTTIMEFORMAT="%F %T"to
~/.bashrc.
%Fprints the full date (YYYY‑MM‑DD) and
%Tprints the time (HH:MM:SS). After reloading,
historydisplays 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.shor 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.
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.