DGX Lab: Supercharge Your Shell with 50+ ML Productivity Aliases - Day 2
DGX Lab: Supercharge Your Shell with 50+ ML Productivity Aliases
Date: October 18, 2025 DGX System: NVIDIA DGX Workstation Session Duration: ~30 minutes Primary Focus: Shell environment optimization for ML workflows
Why Your Shell Environment Matters
You open a terminal dozens of times a day. You type nvidia-smi to check GPU status. You activate virtual environments. You navigate directories. You check git status. These small actions add up to hundreds of keystrokes daily.
What if you could cut that by 70%?
Today's session is about transforming the default Ubuntu .bashrc into a productivity powerhouse optimized for ML and GPU development. No fancy tools required—just smart configuration that takes 5 minutes to set up and benefits you forever.
The Quick Win
Here's what changed in this 30-minute session:
- 50+ productivity aliases added
- 10+ custom functions for common tasks
- GPU monitoring shortcuts for instant status checks
- Enhanced command history (10K commands with timestamps)
- Smart Python helpers for virtual environment management
The result? Commands that took 10-15 keystrokes now take 2-3.
The Essential Aliases
GPU Monitoring (The Most Used)
# Basic GPU check
alias gpu='nvidia-smi'
# Real-time monitoring (updates every second)
alias gpuw='watch -n 1 nvidia-smi'
# Memory-focused view
alias gpumem='nvidia-smi --query-gpu=memory.used,memory.total --format=csv'
Impact: gpu instead of nvidia-smi saves 9 keystrokes. If you check GPU status 50 times a day, that's 450 keystrokes saved daily.
Python Environment Management
# Python shortcuts
alias py='python3'
alias pip='pip3'
alias venv='python3 -m venv'
alias activate='source venv/bin/activate'
Real-world usage:
# Before: 47 keystrokes
python3 -m venv myenv
source myenv/bin/activate
# After: 23 keystrokes
venv myenv
activate
50% keystroke reduction for virtual environment creation.
Git Workflow Shortcuts
alias g='git'
alias gs='git status'
alias ga='git add'
alias gc='git commit'
alias gp='git push'
alias gl='git log --oneline --graph --decorate'
alias gd='git diff'
Typical workflow:
# Before: 67 keystrokes
git status
git add .
git commit -m "update model"
git push
# After: 33 keystrokes
gs
ga .
gc -m "update model"
gp
50% reduction in common git operations.
Smart Navigation
# Quick parent directory navigation
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
# Enhanced directory listing
alias ll='ls -lh' # Human-readable sizes
alias la='ls -lhA' # Include hidden files
alias lt='ls -lhrt' # Sort by time, newest last
alias lz='ls -lhS' # Sort by size
alias ld='ls -lrta' # All files, by time (oldest first)
Safety Nets
# Confirm before destructive operations
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Create parent directories automatically
alias mkdir='mkdir -pv'
These have saved me from countless accidental deletions.
Custom Functions (The Power Tools)
mkcd - Create and Enter Directory
mkcd() {
mkdir -p "$1" && cd "$1"
}
Usage:
# Before: two commands
mkdir -p (local path)
cd (local path)
# After: one command
mkcd (local path)
extract - Universal Archive Handler
extract() {
if [ -f $1 ]; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
No more googling "how to extract .tar.bz2 files"—just extract file.tar.bz2.
pyvenv - Fast Python Environment Setup
pyvenv() {
if [ -z "$1" ]; then
echo "Usage: pyvenv <env_name>"
return 1
fi
python3 -m venv "$1"
source "$1/bin/activate"
pip install --upgrade pip
echo "Python virtual environment '$1' created and activated"
}
Usage:
pyvenv ml-project
# Creates venv, activates it, upgrades pip—all in one command
gpucheck - Comprehensive GPU Status
gpucheck() {
echo "=== GPU Information ==="
nvidia-smi --query-gpu=gpu_name,driver_version,memory.total --format=csv,noheader
echo -e "\n=== CUDA Version ==="
nvcc --version 2>/dev/null | grep "release" || echo "nvcc not found"
echo -e "\n=== GPU Utilization ==="
nvidia-smi --query-gpu=index,name,utilization.gpu,memory.used,memory.total --format=csv
echo -e "\n=== Running GPU Processes ==="
nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv
}
Output:
=== GPU Information ===
NVIDIA A100-PCIE-40GB, 535.129.03, 40960 MiB
=== CUDA Version ===
Cuda compilation tools, release 12.1, V12.1.105
=== GPU Utilization ===
index, name, utilization.gpu [%], memory.used [MiB], memory.total [MiB]
0, NVIDIA A100-PCIE-40GB, 85 %, 32768 MiB, 40960 MiB
=== Running GPU Processes ===
pid, process_name, used_gpu_memory [MiB]
12345, python, 32256 MiB
One command gives you everything you need to know about GPU status.
sysinfo - Complete System Overview
sysinfo() {
echo "=== System Information ==="
echo "OS: $(lsb_release -d | cut -f2)"
echo "Kernel: $(uname -r)"
echo "Uptime: $(uptime -p)"
echo -e "\n=== CPU ==="
lscpu | grep "Model name" | cut -d':' -f2 | xargs
echo "Cores: $(nproc)"
echo -e "\n=== Memory ==="
free -h | grep "Mem:" | awk '{print "Total: "$2" | Used: "$3" | Available: "$7}'
echo -e "\n=== Disk Usage ==="
df -h / | tail -1 | awk '{print "Root: "$3" used / "$2" total ("$5" full)"}'
echo -e "\n=== GPU ==="
nvidia-smi --query-gpu=name,memory.total --format=csv,noheader 2>/dev/null || echo "No GPU detected"
}
Perfect for quick health checks or sharing system specs with collaborators.
History Enhancements
# Increase history size from 1,000 to 10,000 commands
export HISTSIZE=10000
export HISTFILESIZE=20000
# Add timestamps to history
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
# Avoid duplicates
export HISTCONTROL=ignoredups:erasedups
# Append to history file (don't overwrite)
shopt -s histappend
Why this matters for ML:
- Track which hyperparameters you tested and when
- Find that perfect training command from last week
- Debug "what did I run yesterday at 3pm?"
History Search Tips
# Search history with timestamps
history | grep "python train.py"
# Re-run command by number
!1234
# Re-run last command starting with "git"
!git
# Edit and re-run last command
^wrong^right
Environment Variables That Matter
CUDA Configuration
export CUDA_HOME=/usr/local/cuda
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
Ensures nvcc is accessible and CUDA libraries are found by PyTorch/TensorFlow.
Python Optimization
# Real-time output (critical for training logs)
export PYTHONUNBUFFERED=1
# Prevent .pyc file creation
export PYTHONDONTWRITEBYTECODE=1
PYTHONUNBUFFERED=1 is crucial for ML training:
- See training progress in real-time
- Monitor loss curves as they happen
- Catch errors immediately
Without it, logs buffer and you might not see output for minutes.
Enhanced Prompt with Git Branch
# Show git branch in prompt (yellow)
parse_git_branch() {
git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[33m\]$(parse_git_branch)\[\033[00m\]\$ '
Result:
bioinfo@dgx:(local path) (feature-branch)$
Always know which experiment branch you're on.
The Complete Setup
Want this configuration? Here's the full enhanced .bashrc:
-
Backup your existing .bashrc:
cp (local path) (local path) -
Add the aliases and functions (see full file below)
-
Reload your shell:
source (local path) -
Test it out:
gpu # Check GPU status gs # Git status mkcd test # Create and enter directory sysinfo # System overview
Core Additions to .bashrc
# ============================================
# History Configuration
# ============================================
export HISTSIZE=10000
export HISTFILESIZE=20000
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
export HISTCONTROL=ignoredups:erasedups
shopt -s histappend
# ============================================
# Shell Options
# ============================================
shopt -s globstar # Enable ** for recursive matching
shopt -s nocaseglob # Case-insensitive filename completion
bind "set show-all-if-ambiguous on"
bind "set mark-symlinked-directories on"
# ============================================
# GPU Monitoring Aliases
# ============================================
alias gpu='nvidia-smi'
alias gpuw='watch -n 1 nvidia-smi'
alias gpumem='nvidia-smi --query-gpu=memory.used,memory.total --format=csv'
# ============================================
# Python Shortcuts
# ============================================
alias py='python3'
alias pip='pip3'
alias venv='python3 -m venv'
alias activate='source venv/bin/activate'
# ============================================
# Git Shortcuts
# ============================================
alias g='git'
alias gs='git status'
alias ga='git add'
alias gc='git commit'
alias gp='git push'
alias gl='git log --oneline --graph --decorate'
alias gd='git diff'
# ============================================
# Directory Navigation
# ============================================
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
# ============================================
# Enhanced Listing
# ============================================
alias ll='ls -lh'
alias la='ls -lhA'
alias lt='ls -lhrt'
alias lz='ls -lhS'
alias ld='ls -lrta'
# ============================================
# Safety Nets
# ============================================
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias mkdir='mkdir -pv'
# ============================================
# System Information
# ============================================
alias myip='curl -s ifconfig.me'
alias meminfo='free -h'
alias cpuinfo='lscpu'
alias diskusage='df -h'
alias topcpu='ps aux --sort=-%cpu | head -n 11'
alias topmem='ps aux --sort=-%mem | head -n 11'
# ============================================
# Environment Variables
# ============================================
export CUDA_HOME=/usr/local/cuda
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
export EDITOR=nano
export VISUAL=nano
export PYTHONUNBUFFERED=1
export PYTHONDONTWRITEBYTECODE=1
export LESS='-R -X -F'
# ============================================
# Custom Functions
# ============================================
# Create directory and cd into it
mkcd() {
mkdir -p "$1" && cd "$1"
}
# Universal archive extraction
extract() {
if [ -f $1 ]; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# Find files by name
ff() {
find . -type f -iname "*$1*"
}
# Find directories by name
fd() {
find . -type d -iname "*$1*"
}
# Recursive grep with line numbers
grepn() {
grep -rn "$1" .
}
# Display PATH in readable format
showpath() {
echo $PATH | tr ':' '\n' | nl
}
# Quick Python venv setup
pyvenv() {
if [ -z "$1" ]; then
echo "Usage: pyvenv <env_name>"
return 1
fi
python3 -m venv "$1"
source "$1/bin/activate"
pip install --upgrade pip
echo "Python virtual environment '$1' created and activated"
}
# Comprehensive GPU check
gpucheck() {
echo "=== GPU Information ==="
nvidia-smi --query-gpu=gpu_name,driver_version,memory.total --format=csv,noheader
echo -e "\n=== CUDA Version ==="
nvcc --version 2>/dev/null | grep "release" || echo "nvcc not found"
echo -e "\n=== GPU Utilization ==="
nvidia-smi --query-gpu=index,name,utilization.gpu,memory.used,memory.total --format=csv
echo -e "\n=== Running GPU Processes ==="
nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv
}
# Python environment info
pyinfo() {
echo "=== Python Environment ==="
echo "Python: $(python3 --version)"
echo "Location: $(which python3)"
echo "Pip: $(pip3 --version | cut -d' ' -f1-2)"
[ -n "$VIRTUAL_ENV" ] && echo "Active venv: $VIRTUAL_ENV" || echo "No active venv"
echo -e "\nInstalled packages:"
pip3 list | head -n 10
}
# Complete system overview
sysinfo() {
echo "=== System Information ==="
echo "OS: $(lsb_release -d | cut -f2)"
echo "Kernel: $(uname -r)"
echo "Uptime: $(uptime -p)"
echo -e "\n=== CPU ==="
lscpu | grep "Model name" | cut -d':' -f2 | xargs
echo "Cores: $(nproc)"
echo -e "\n=== Memory ==="
free -h | grep "Mem:" | awk '{print "Total: "$2" | Used: "$3" | Available: "$7}'
echo -e "\n=== Disk Usage ==="
df -h / | tail -1 | awk '{print "Root: "$3" used / "$2" total ("$5" full)"}'
echo -e "\n=== GPU ==="
nvidia-smi --query-gpu=name,memory.total --format=csv,noheader 2>/dev/null || echo "No GPU detected"
}
# ============================================
# Enhanced Prompt with Git Branch
# ============================================
parse_git_branch() {
git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[33m\]$(parse_git_branch)\[\033[00m\]\$ '
# ============================================
# Colored GCC Output
# ============================================
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# ============================================
# Welcome Message
# ============================================
if [ -f /usr/bin/nvidia-smi ]; then
echo "🖥️ DGX Workstation - $(nvidia-smi --query-gpu=gpu_name --format=csv,noheader | head -1)"
echo "🐍 Python $(python3 --version | cut -d' ' -f2)"
echo "⚡ CUDA $(nvcc --version 2>/dev/null | grep release | cut -d' ' -f5 | sed 's/,//' || echo 'N/A')"
echo ""
echo "Quick commands: gpu | gpuw | gpucheck | sysinfo | pyinfo"
fi
Real-World Impact
After implementing this configuration:
Keystroke Savings:
- GPU checks: 450 keystrokes/day
- Git operations: 200 keystrokes/day
- Python venv: 150 keystrokes/day
- Directory navigation: 100 keystrokes/day
Total: ~900 keystrokes saved daily = 23,400 keystrokes/month
Time Savings:
- ~5-10 minutes per day from faster command entry
- ~10 minutes per day from quick status checks
- ~5 minutes per day from not googling extraction commands
Total: ~20 minutes/day = 7 hours/month
What I Learned
1. Small Optimizations Compound
Each alias saves 5-10 keystrokes. Over hundreds of daily uses, this adds up to significant time savings.
2. Muscle Memory Matters
Keep aliases short and memorable:
gpu(notcheckgpuorgpustatus)gs(notgitsorgstat)..(notuporback)
Your fingers will thank you.
3. Safety First
The -i flag on rm, cp, and mv has saved me countless times. Confirmation prompts are worth the extra keystroke.
4. Documentation Through Code
Good alias names are self-documenting:
gpumem→ obviously checks GPU memorytopcpu→ obviously shows top CPU processesextract→ obviously extracts archives
Next Steps
Try adding these to your .bashrc and see which ones you use most. After a week, you'll wonder how you ever lived without them.
Pro tip: Start with just the GPU monitoring aliases if you're on a GPU system, or just the Python helpers if you do a lot of ML work. Add more as you need them.
Related Articles
DGX Lab Day 1: Intelligent Gateway with HeuristicsshippedPractical ApplicationsOct 20, 2025DGX Lab: When Simple Heuristics Beat ML by 95,000x - Day 1Building an intelligent AI gateway that routes requests 95,000x faster than ML while maintaining 90% accuracy—proving that smart heuristics can outperform deep learning. Building Production ML Workspaces: Part 1shippedPractical ApplicationsOct 19, 2025Building a Production ML Workspace: Part 1 - Designing an Organized StructureLearn how to design a scalable ML workspace structure that handles Ollama models, fine-tuning, agents, and experiments without becoming chaotic. Practical Applications Hub
5-Minute Setup:
- `cp (local path) (local path) - Backup current config
- Add the aliases from this article to your
.bashrc - `source (local path) - Reload shell
- Try
gpu,gs,mkcd test,sysinfo
Bonus: Track which aliases you use most with history | cut -d' ' -f2 | sort | uniq -c | sort -rn | head -20
This is Day 2 of the DGX Lab Chronicles, documenting real AI infrastructure setup on NVIDIA DGX hardware.
Related Articles
- DGX Lab: When Simple Heuristics Beat ML by 95,000x - Day 1shippedPractical ApplicationsOct 20, 2025DGX Lab: When Simple Heuristics Beat ML by 95,000x - Day 1Building an intelligent AI gateway that routes requests 95,000x faster than ML while maintaining 90% accuracy—proving that smart heuristics can outperform deep learning.
- DGX Lab: Building a Complete RAG Infrastructure - From Ollama to Qdrant to AnythingLLM - Day 3shippedPractical ApplicationsOct 24, 2025DGX Lab: Building a Complete RAG Infrastructure - From Ollama to Qdrant to AnythingLLM - Day 3Building a complete self-hosted RAG infrastructure with 8 integrated services on a single DGX workstation, supporting everything from medical AI fine-tuning to document Q&A.
- DGX Lab: When Benchmark Numbers Meet Production Reality - Day 4shippedPractical ApplicationsOct 26, 2025DGX Spark Benchmarks: 82,739 tokens/sec on Paper, the Production RealityNVIDIA's DGX Spark benchmarks show 82,739 tokens/sec for training. After 6 days of intensive ML workloads and feedback from the HN community, here's what the benchmarks don't tell you about precision issues, memory fragmentation, and production workarounds.
About the Author: Justin Johnson builds AI systems and writes about practical AI development.
justinhjohnson.com | Twitter | LinkedIn | Run Data Run | Subscribe
Follow the lab
Get the next experiment
Enjoyed the breakdown on DGX Lab: Supercharge Your Shell with 50+ ML Productivity Aliases - Day 2? New entries land roughly weekly. No digest, no roundup. Just the next build log, when it ships.