Skip to content

Instantly share code, notes, and snippets.

@mclang
Created January 27, 2026 14:54
Show Gist options
  • Select an option

  • Save mclang/b4a121700b34f42d9fd40b72bdd76230 to your computer and use it in GitHub Desktop.

Select an option

Save mclang/b4a121700b34f42d9fd40b72bdd76230 to your computer and use it in GitHub Desktop.
Bash Aliases for Bash Servers
#
# Collection of basic Bash configuration and aliases that
# make working with Bash on infrequently accessed servers bearable.
#
# Can be downloaded into any server having this in the user's `.bashrc`:
# if [ -f ~/.bash_aliases ]; then
# . ~/.bash_aliases
# fi
#
# Set sensible LC values:
export LANG='en_US.UTF-8' # The default used when corresponding 'LC_' is not set.
export LANGUAGE='en_GB:en_US' # Higher priority than LANG for messages. Can have several values, e.g 'fi:sw:en'.
export LC_COLLATE='en_US.UTF-8' # Because CASE SENSITIVE file/directory sort of `C` is complete BS!
# Use 'fi_FI.UTF-8' for most things if available
if locale -a 2> /dev/null | grep -iq 'fi_FI.UTF-8'; then
export LC_NUMERIC='fi_FI.UTF-8'
export LC_TIME='fi_FI.UTF-8'
export LC_MONETARY='fi_FI.UTF-8'
export LC_PAPER='fi_FI.UTF-8'
export LC_MEASUREMENT='fi_FI.UTF-8'
fi
# Works with GNU coretools an uutil replacements like `ls`:
export TIME_STYLE='long-iso'
# Color all the things:
alias lZ='ls -hlZ -F --color=auto --group-directories-first'
alias la='ls -A -F --color=auto --group-directories-first'
alias ll='ls -ho -F --color=auto --group-directories-first'
alias ls='ls -F --color=auto'
alias grep='grep --color=auto'
alias diff='diff --color=auto'
# Docker commands
if command -v docker >/dev/null 2>&1; then
if docker info >/dev/null 2>&1; then
DOCKER_CMD="docker"
else
DOCKER_CMD="sudo docker"
fi
alias dps="$DOCKER_CMD ps --format 'table {{.ID}}\t{{.Names}}\t{{.Status}}\t{{.Ports}}'"
unset DOCKER_CMD
fi
# Journalctl
if command -v journalctl >/dev/null 2>&1; then
alias journalctl='journalctl -o short-iso --no-hostname'
fi
# Safety & Verbosity
alias rm='rm -I'
# Server Stats
alias df='df -h -x "devtmpfs" -x "tmpfs" -x "overlay"'
alias duh='du -d 1 -h | sort -h'
alias mem='free -m -l -t'
alias myip="curl ifconfig.me"
alias ports='ss -tulanp'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment