Skip to content

Instantly share code, notes, and snippets.

@sibinx7
Last active March 1, 2020 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sibinx7/7584b09a52490c24d17897e7da27867c to your computer and use it in GitHub Desktop.
Save sibinx7/7584b09a52490c24d17897e7da27867c to your computer and use it in GitHub Desktop.
Linux shell scripts
  • lsof -i:<PORT NAME>
  • kill $(lsof -t -i:<PORT NAME>)

Add Git branch name on Termianl

# Add Git branch and color scheme
function parse_git_branch () {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[01;33m\]$(__git_ps1)\[\033[01;34m\] \$\[\033[00m\] '
# export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[01;33m\]$(__git_ps1)\[\033[01;34m\] \$\[\033[00m\] '
# EOF GIT BRANCH

Show numeric value of Permission on Linux

stat --format '%a' <file>
sudo sysctl -w vm.drop_caches=3

Display all running ports

sudo lsof -i
sudo netstat -lptu
sudo netstat -tulpn

Source list and Other repo details

/etc/apt

File Permissions

sudo chgrp -R www-data ./center-7chip/storage/
sudo chmod -R ug+rwx ./center-7chip/storage/

Batch renaming

Rename files

ls | cat -n | while read n f; do  mv "$f" "< NEW FILE NAME>"; done

Increase watch

fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment