Boost Your Linux Productivity: 4 Essential Terminal Tricks and Custom Commands
This guide presents four practical Linux techniques—including fast directory navigation with the bd command, multi‑terminal management using Terminator, efficient file editing with Vim and custom shell scripts—to streamline your workflow, enhance productivity, and create a personalized, elegant development environment.
Linux has become the most popular operating system among developers. This article introduces four highly practical tips to improve your efficiency and comfort when working in Linux.
1. Elegant and Smooth Directory Navigation
1.1 bd command
Quickly jump to a specific parent directory in Bash without typing long paths like cd ../../... For example, if you are in /home/radia/work/python/tkinter/one/two and want to go to python, run: bd python You can also type a prefix of the directory name; if multiple matches exist, the nearest one is chosen: bd p Installation of the bd command:
sudo wget --no-check-certificate -O /usr/bin/bd https://raw.githubusercontent.com/vigneshwaranr/bd/master/bd
sudo chmod +rx /usr/bin/bd
echo 'alias bd=". bd -si"' >> ~/.bashrc
source ~/.bashrcTo enable case‑sensitive matching, use -s instead of -si in the alias.
1.2 Common cd command tricks
Running cd without arguments returns to the home directory ( cd ~).
cd
cd ~cd - returns to the previous directory.
cd -1.3 Custom command to jump to frequently used directories
Define a shortcut (e.g., cl) to jump directly to a common directory. Example: cl Resulting behavior is shown in the following animation:
2. Multi‑Terminal Operations
Split the terminal screen into multiple windows to reduce mouse usage and boost efficiency. Terminator is recommended. sudo apt-get install terminator After installation, open Terminator with CTRL+ALT+T or by searching for it. You can split the screen into three panes, rename the lower‑left pane to “log”, and adjust pane sizes with mouse dragging or shortcuts CTRL+SHIFT+↑↓←→. Multiple tabs can be opened with CTRL+SHIFT+T, and tabs can be renamed for easy identification.
Lower‑left pane: real‑time serial log.
Upper‑left pane: compile code and view errors.
Right pane: edit code and browse files.
Common shortcuts:
CTRL+SHIFT+T – open a new tab.
CTRL+SHIFT+E – vertical split.
CTRL+SHIFT+O – horizontal split.
ALT+↑↓←→ – switch between panes in the same tab.
CTRL+PAGEUP / PAGEDOWN – switch between tabs.
Shortcuts can be remapped to suit personal habits, e.g., using ALT+H and ALT+L for tab switching.
3. File Editing
3.1 Recommended Markdown editor
Typora is a powerful, aesthetically pleasing Markdown editor. Installation commands:
wget -qO - https://typora.io/linux/public-key.asc | sudo apt-key add -
# add Typora's repository
sudo add-apt-repository 'deb https://typora.io/linux ./'
sudo apt-get update
# install typora
sudo apt-get install typoraTypora can be used for note‑taking and knowledge‑base management.
Official site: https://www.typora.io
3.2 Code editing and viewing with Vim
Vim is a highly regarded code editor, though its configuration can be complex. A ready‑made Vim configuration is provided.
Installation: sudo apt-get install vim Extract the provided vim-config.tar to the home directory: tar -xvf vim-config.tar -C ~ After installation, Vim shows a file list on the left (toggle with F3) and a function list on the right (toggle with F9). Use CTRL+W to move between panes and h/j/k/l for cursor navigation.
Press Enter on a function to jump to its definition. Press Enter on a file to open it; i or s splits the window horizontally or vertically.
3.2.1 Generating tags for fast navigation
Run ctags -R * (or specify languages) in the project root to create a tags file. Then use CTRL+] to jump to a definition and CTRL+T to return.
ctags -R *
# or specify languages
ctags --languages=c,c++,java -R3.2.2 Other useful Vim features
The provided configuration enables mouse support for easier initial use, though disabling it later can improve efficiency.
To disable mouse support, edit ~/.vimrc and comment out the line set mouse=a:
vim ~/.vimrc
" set mouse=a4. Custom Shell Commands
4.1 Implementing the cl command
Add an alias to ~/.bashrc:
echo 'alias cl="cd /home/radia/work/linux/linux-3.16.6/"' >> ~/.bashrc
source ~/.bashrcAfter sourcing, cl instantly jumps to the specified directory.
4.2 Creating a more complex env_switch command
Write a script env_switch.sh that accepts a scenario (A or B) and an action (start or stop). Example usage:
env_switch A start # start software A1, A2, A3
env_switch A stop # stop software A1, A2, A3
env_switch B start # start software B1, B2, B3
env_switch B stop # stop software B1, B2, B3Script content (simplified with echo placeholders):
#!/bin/bash
function env_switch() {
if [ $1 = "A" ]; then
echo "A1,A2,A3"
if [ $2 = "start" ]; then
echo "will be opened"
elif [ $2 = "stop" ]; then
echo "will be closed"
fi
elif [ $1 = "B" ]; then
echo "B1,B2,B3"
if [ $2 = "start" ]; then
echo "will be opened"
elif [ $2 = "stop" ]; then
echo "will be closed"
fi
fi
}Make the script executable and source it from ~/.bashrc so the function becomes a regular command:
chmod +x env_switch.sh
echo 'source /home/radia/cmd/env_switch.sh' >> ~/.bashrc
source ~/.bashrc4.3 Revisiting the bd command
The bd command is a small script (about 50 lines) that can be customized further to automate repetitive tasks, illustrating how writing personal scripts continuously improves workflow efficiency.
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.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
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.
