#!/bin/bash``` #modified by dbi on 16/10/2019 alias ..='cd ..' ## Move up one dir alias ...='cd ../..' ## up two alias ....='cd ../../..' ## up three alias -- -='cd -' ## Go to previous directory alias cd..='cd ..' ## Go to parent directory even if space is forgotten alias aptfnd='apt-cache search' ## Search for package (e.g., aptfnd nginx) alias aptins='sudo apt-get install -V' alias aptinst='sudo apt-get install -V' ## Install package (e.g., aptins nginx) alias aptpurge='sudo apt-get remove --purge' ## Completely remove packages, including conf files (e.g., aptpurge nginx) alias aptrm='sudo apt-get remove' ## Remove a package (e.g., aptrm nginx) alias aptuu='sudo apt update && sudo apt upgrade -y' ## Update the upgrade alias c='clear' alias cp='cp -iv' ## Warn before overwriting existing file and show what was copied by default alias cpf='cp -fv' ## Force overwriting existing file and show what was copied by default alias cpn='cp -nv' ## Copy only non existing files in destination alias cpu='cp -uv' ## Copy only new files to destination in case of existing alias grep='grep --color=auto' ## Colorize the grep command output for ease of use (good for log files)## alias egrep='egrep --color=auto' ## Colorize the grep command output for ease of use (good for log files)## alias fgrep='fgrep --color=auto' ## Colorize the grep command output for ease of use (good for log files)## alias histg='history | grep' ## Make searching history with grep easier (also helpful because it shows command numbers) alias lh='ls -ld .* --color=auto' ## Show hidden files ## alias l.='ls -ld .* --color=auto' ## Show hidden files ## alias ll='ls -lha' ## Use a long listing format ## alias ls='ls --color=auto' alias mkdir+='mkdir -pv' ## Make adding any parent directories a default behavior and show every directory creation alias mv='mv -iv' ## Prompt for confirmation before overwriting existing files, regardless of file permissions and show what was copied by default alias mvf='mv -fv' ## Do not prompt for confirmation before overwriting existing files and show what was copied by default alias mvn='mv -nv' ## Do not overwrite existing files at the target and show what was copied by default alias mount='mount |column -t' ## Make mount command output pretty and human readable format alias pkgfiles='dpkg --listfiles' ## List files installed to your system from package-name (e.g., pkgfiles nginx) alias ports='netstat -tulanp' ## Show open ports alias prok='ps ax | grep' ## Look for a specific process ex: process firefox alias redo='sudo $(history -p !!)' alias rm='rm -I --preserve-root' ## do not delete / or prompt if deleting more than 3 files at a time alias rmr='rm -rfv' ## Remove (force removal of folders and show what was done) alias slog='tail -f -n 150 /var/log/syslog' alias speedtest='curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -' alias stail='sudo tail -f -n 150' alias systail='sudo tail -f -n 150 /var/log/syslog' alias wanip='wget http://ipecho.net/plain -O - -q ; echo' alias wget='wget -c' ## Resume download tip() { if [[ $@ == "" ]]; \ then command echo 'Param required: Command, word or concept'; \ else command curl https://cheat.sh/"$@"; fi; } rclone() { if [[ $@ == "-U" ]]; \ then command curl https://rclone.org/install.sh | sudo bash; \ else command rclone "$@"; fi; } #updates rclone to latest version by executing the command source ~/.bashrc function mv+ () { dir="$2" # Include a / at the end to indicate directory (not filename) tmp="$2"; tmp="${tmp: -1}" [ "$tmp" != "/" ] && dir="$(dirname "$2")" [ -a "$dir" ] || mkdir -p "$dir" && mv "$@" } # ------------------------------------ # System Power # ------------------------------------ alias restart='sudo shutdown –r now' alias shutdown='sudo shutdown –h now' if [ $UID -ne 0 ]; then alias reboot='sudo reboot' alias update='sudo apt-get upgrade -y' fi # ------------------------------------ # Backup Operations # ------------------------------------ alias bck='dcexec borgmatic borgmatic --verbosity 1 --files' alias bcklast='dcexec borgmatic borgmatic list --archive latest' alias bcklist='dcexec borgmatic borgmatic list' ## ------------------------------------ # Docker aliases and function # ------------------------------------ # Ideas from https://github.com/tcnksm/docker-alias alias dkit='docker run -i -t' # Run interactive container, (e.g., $dki debian:jessie /bin/bash) function dkcmd() { docker exec -it $1 /bin/bash; } # Open container shell (e.g., $dki debian:jessie /bin/bash) alias dkpsa='docker ps -a' # Show all containers, including stopped ones alias dkps='docker ps' # Show list of running containers # ******************************************************************************* #https://github.com/htpcBeginner/docker-traefik/blob/master/.bash_aliases.example # ******************************************************************************* # DOCKER TRAEFIK 2 alias dcfixsecrets='sudo chown -R root:root /opt/appdata/secrets ; sudo chmod -R 600 /opt/appdata/secrets' alias dclogs='cd /opt/appdata/ ; sudo docker-compose -f /opt/appdata/docker-compose-t2.yml logs -tf --tail="50" ' alias dcrun='cd /opt/appdata/ ; sudo docker-compose -f /opt/appdata/docker-compose-t2.yml ' alias dcdown='dcrun stop' alias dcpull='cd /opt/appdata ; sudo docker-compose -f /opt/appdata/docker-compose-t2.yml pull' alias dcrec='dcrun up -d --force-recreate' alias dcrestart='cd /opt/appdata ; sudo docker-compose -f /opt/appdata/docker-compose-t2.yml restart ' alias dcstart='dcup' alias dcstop='dcdown' alias dcup='dcrun up -d' # DOCKER Standards Commands alias dkdelimages='sudo docker rmi $(docker images -q)' alias dkdf='sudo docker system df' alias dkerase='dkstopcont ; drmcont ; ddelimages ; dvolprune ; dsysprune' alias dkexec='sudo docker exec -ti' alias dkex='dkexec' # Execute interactive container, (e.g., $dex base /bin/bash) alias dkid='docker ps -l -q' # Return most recent container ID alias dkimg='docker images' # Get images alias dkip="docker inspect --format '{{ .NetworkSettings.IPAddress }}' " #alias dkip='"'docker --format '{{ .NetworkSettings.IPAddress }}''"' # Get container IP (e.g., dip 47d57c66ab05) alias dklogs='sudo docker logs -tf --tail="50" ' alias dkprune='dkdelimages ; dvolprune ; dsysprune' alias dkps='sudo docker ps -a' alias dkrm='dcrun rm' alias dkrestartall='sudo docker restart $(sudo docker ps -aq)' alias dkstartall='sudo docker start $(sudo docker ps -aq)' alias dkstopcont='sudo docker stop $(sudo docker ps -aq)' alias dkstopall='sudo docker stop $(sudo docker ps -aq)' alias dkrmcont='sudo docker rm $(sudo docker ps -aq)' alias dkvolprune='sudo docker volume prune' alias dksysprune='sudo docker system prune -a' dcsh() { if command sudo docker exec "$@" /bin/bash >/dev/null 2>&1; \ then command sudo docker exec -ti "$@" /bin/bash; \ else command sudo docker exec -ti "$@" /bin/ash; fi; } # Open a bash/ash shell in a container name provided dcid() { if command sudo docker ps -aqf name=$@ 2>&1; \ then command sudo docker ps -aqf name=$@ 2>&1; \ else command echo ID Not Found; fi; } # Open a bash/ash shell in a container name provided # NETWORKING alias portsused='sudo netstat -tulpn | grep LISTEN' # FILE SIZE AND STORAGE alias free='free -h' alias fdisk='sudo fdisk -l' alias uuid='sudo vol_id -u' alias ll='ls -alh' alias dirsize='sudo du -hx --max-depth=1'