Unlock Hidden Linux Terminal Tricks: Send Output, Reload .bashrc, and More
This guide explores advanced Linux terminal techniques—including sending command output between terminal windows, efficiently reloading .bashrc, using alert aliases for long‑running tasks, leveraging the terminal as a calculator, and mastering subshells, command chaining, and brace expansion—to boost developer productivity.
Why Use the CLI Over a GUI?
Programmers often prefer the command‑line interface (CLI) because it keeps their hands on the keyboard, avoiding repetitive mouse clicks required by graphical user interfaces (GUIs). Mastering the terminal can dramatically increase development efficiency.
Sending Output to Another Terminal Window
Each GUI terminal instance is linked to a pseudo‑terminal device file under /dev/pts. Listing these devices shows the available terminals: ls /dev/pts When only one terminal is open you typically see ptmx and 0. The current terminal uses /dev/pts/0. To write directly to that terminal you can run: echo "Hello!" > /dev/pts/0 Replace 0 with the target pseudo‑terminal number to send output to another open window.
Efficiently Reloading .bashrc
Aliases and environment variables defined in a session disappear when the terminal closes. Persist them in .bashrc so they are executed each time a new Bash shell starts.
To apply changes without opening a new window you can:
Source the file: source ~/.bashrc Replace the current shell: exec bash Both methods are faster than launching a fresh terminal.
Audible Alerts for Long‑Running Tasks
When a command like sleep 5 finishes, you can trigger a beep: sleep 5; printf "\a" If your speakers are muted, define an alert alias in .bashrc:
# Add to ~/.bashrc
alias alert='notify-send --urgency=low -i "$( [ $? = 0 ] && echo terminal || echo error )" "$(history|tail -n1|sed -e "s/^ *[0-9]* *//;s/[;&|] *alert$//")"'Then use sleep 10; alert to get a desktop notification.
Using the Terminal as a Calculator
The bc -l command opens a command‑line calculator with floating‑point support. It also allows variables, complex expressions, and math functions. For quick arithmetic you can also use Python:
python3 -c "import math; print(2 * math.pi * 7)"Subshells, Command Combination, and Brace Expansion
Bash lets you run commands in an isolated subshell, e.g.: (cd backend && npm i) Set environment variables for a single command without affecting the current shell: PORT=5000 ./linuxmi.py Combine commands with &&, ||, |, or ;. Use command substitution to pass file lists: ./linuxmi.py `find . -name "*.txt"` Brace expansion generates sequences or multiple strings, for example:
mkdir linuxmi/{linux,debian,ubuntu,fedora}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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
