Commonly used linux commands

September 11, 2018 - Lesezeit: ~1 Minute
# Emit tab in shell format: %x09
# Double tabs: %x09%x09

# last 10 commands used
history 10

# Following changes of a file
tail -200f test_file.txt

# Find file
find . -type f -name *.xml | xargs grep 123456

# List txt-files in folder
ls *.txt

# Hard stop process
kill -9 <process_code>

# Indent xml file and output to new file
cat input.xml | xmllint --format - >> formatted_output.xml

Commonly used aliases in Linux / Unix Shell commands

Juli 8, 2018 - Lesezeit: ~1 Minute
# show aliases
alias
# remove alias
unalias <your_alias>
# clear screen
alias c='clear'
# colored listing
alias ls='ls -F --color=auto --show-control-chars'

#############
# Git aliases
#############

# show unstaged files
alias gs='git add -A -n'
# show git graph
alias gg="git log --graph --abbrev-commit --decorate --format=format:'%C(cyan)%h%x09%x09%C(reset) - %C(dim white)(%ar)%x09%x09%C(reset)%C(bold green)%d%C(reset) %C(white)%s%C(reset) %C(bold yellow)- %an%C(reset)' --all"

Set up GitLab project

März 9, 2018 - Lesezeit: 2 Minuten
On GitLab
  1.     setup an user account for free on https://gitlab.com/users/sign_in
    If you decide to use social login, don’t forget to set up an username and a password, since you will need it for pushing the project later on.
  2.     Log in and create new empty private project (no README).
  3.     Folow the next steps on your local machine
On your local command line
Git global setup
cd ~
cat .gitconfig
git config --global user.name "Hoang"
git config --global user.email "joe@hohohoho.com"
Create a new repository
git clone https://gitlab.com/<your_username>/<your_project>.git
cd <your_project>
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

Existing folder
cd existing_folder
git init
git remote add origin https://gitlab.com/<your_username>/<your_project>.git
git add .
git commit -m "Initial commit"
git push -u origin master
Existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.com/<your_username>/<your_project>.git
git push -u origin --all
git push -u origin --tags