Skip to content

Instantly share code, notes, and snippets.

@andrewhenke
Last active February 12, 2023 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewhenke/0c1ff2858e776ce10fca9cb5d65828e8 to your computer and use it in GitHub Desktop.
Save andrewhenke/0c1ff2858e776ce10fca9cb5d65828e8 to your computer and use it in GitHub Desktop.
Bash Aliases for Linux OS's
## To make sure that your .bash_aliases file is loaded by bash, make sure that you have the following code in your ~/.bashrc file:
# if [ -e $HOME/.bash_aliases ]; then
# source $HOME/.bash_aliases
# fi
#
# If you don't have the above code snippet in your .bashrc file, add it to the file, save it, and then run the command "source ~/.bashrc"
#All the standard automatic color formatting of the typical commands - these are in your .bashrc file by default.
alias ls='ls --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
#JSON parser and pretty-printing tool for the command line
#Usage (Output formatted JSON to command line): jsp [unformatted.json]
#Usage (Output formatted JSON to a file): jsp [unformatted.json] > output.json
#IMPORTANT: You must have Python 3 and json.tool installed BEFORE this alias will work
alias jsp='python3 -m json.tool < '
#List all files in current working directory in a list format
alias ll='ls -alF'
#List all files in current working directory including hidden files and folders
alias la='ls -A'
#Classify all files in current working directory into columns
alias l='ls -CF'
# Ignore errors and warnings, and force the removal of a given file or directory
alias rm='rm -if'
#Copy file or folder from A to B, with interactive prompt
alias cp='cp -i'
#Move file or folder from A to B, with interactive prompt
alias mv='mv -i'
#List all files in current directory including hidden files and folders, in a list, with human-readable file sizes.
alias lsa='ls -alh'
#List all files in currenct directory except for implied . and .. paths
alias lss='ls -A1'
#Show system drive storage information in human-formatted numbers
alias df='df -h'
#Check the systemctl daemon for failed units - format for human interpretation
alias sysstat='systemctl list-units --state=failed --no-pager'
#Returns the current system time in UTC - this is useful for quickly viewing the time in UTC when debugging log information, which is
#often in the UTC format of your system's current time
alias udate='env TZ=UTC date'
#List disk usage for a file or folder in human format [defaults to the current working directory unless file/folder path specified]
alias dff='du -sh'
#Count how many files are in a given directory or filepath - NOTE: count ignores directories but NOT the files inside of them.
alias count='find . -type f | wc -l'
#Find the top level of a Git project, no matter where in said project you are currently working,
#and then to change directory to it, change to the master branch, and perform a Git pull
alias stargit='cd `git rev-parse --show-toplevel` && git checkout master && git pull'
#Return to the root folder of your current GitHub repository
alias gtop='cd `git rev-parse --show-toplevel`'
#Shows the output of the mount command, but pretty prints the response and shows human-formatted storage sizes
alias mount='mount |column -t'
# Parenting changing perms on / #
alias chown='chown --preserve-root'
alias chmod='chmod --preserve-root'
alias chgrp='chgrp --preserve-root'
# Get system memory, cpu usage, and gpu memory info quickly
## pass options to free ##
alias meminfo='free -m -l -t'
## get top process eating memory
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
## get top process eating cpu ##
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'
## Get server cpu info ##
alias cpuinfo='lscpu'
## older system use /proc/cpuinfo ##
##alias cpuinfo='less /proc/cpuinfo' ##
## get GPU ram on desktop / laptop##
alias gpumeminfo='grep -i --color memory /var/log/Xorg.0.log'
alias ichk='find . -printf "%h\n" | cut -d/ -f-2 | sort | uniq -c | sort -rn'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment