Skip to content

Instantly share code, notes, and snippets.

@christiangalsterer
Last active February 28, 2018 16:42
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 christiangalsterer/67a9fd8e12db59ea34f874a168c0760c to your computer and use it in GitHub Desktop.
Save christiangalsterer/67a9fd8e12db59ea34f874a168c0760c to your computer and use it in GitHub Desktop.

base64 endoded username:password

echo -n 'username:password' | openssl base64

count files and folder following symbolic links

ls -LRX1 2>/dev/null | wc -l

Proper handling of errors and uninitialized variables

set -euxo pipefail

-e: exit immediately if command failes -u: handles unset variables as errors -x: Prints the command before execution, nice for debugging -o pipefail: This particular option sets the exit code of a pipeline to that of the rightmost command to exit with a non-zero status, or zero if all commands of the pipeline exit successfully.

Create base64 encoded username:password

echo -n 'admin:admin123' | openssl base64

Run command in background and detached from current username

nohup <COMMAND> &>/dev/null &

Change permission for files in sub directories

find <PATH> -type f -print -exec chmod 600 {} \;

Change permission for files with specific permission in sub directories

find <PATH> -type f -perm 777 -print -exec chmod 600 {} \;

Synchrone folders between servers excluding some directories

/usr/bin/rsync -az --delete --exclude "**/workspace" -e ssh root@<HOSTNAME>:<PATH> <PATH-1> >>/var/log/rsync.log.0 2>&1

Aliases

alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias gcm='git checkout master'
alias gfap='git fetch --all --prune'
alias gpf='git push -f'
alias gpoh='git push origin HEAD'
alias gproh='git pull --rebase origin HEAD'
alias gprom='git pull --rebase origin master'
alias grep='grep --color=auto'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment