Last active
March 15, 2018 13:28
-
-
Save lnfnunes/dacd7b028c0d9b4223a6 to your computer and use it in GitHub Desktop.
Linux commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -------------------------------------------------- | |
// Files and folders | |
-------------------------------------------------- // | |
// Copy specific file type keeping the folder structure | |
rsync -a --prune-empty-dirs --include '*/' --include '*.txt' --exclude '*' source/. dest | |
Ref: http://unix.stackexchange.com/a/83596 | |
// Single line loop for repeated tasks with some variations on the command | |
arr=('jhon' 'jane' 'mike'); for name in "${arr[@]}"; do echo "$name"; done | |
// Set chmod for a folder and all of its subfolders and files | |
find /folder -type d -exec chmod 755 {} \; | |
Ref: http://stackoverflow.com/a/11512211 | |
// Change entire folder/files permissions and ownership | |
chown -R username:group directory | |
Ref: http://askubuntu.com/a/6727 | |
// Compare the size of two directories? | |
diff <(du -sh folder1) <(du -sh folder2) | |
Ref: http://stackoverflow.com/a/12560286/1946632 | |
// Find out the web server user | |
lsof -i tcp:80 | |
Ref: http://stackoverflow.com/a/18724971 | |
// Create symbolic link (soft) | |
ln -s source/folder /folder | |
// -------------------------------------------------- | |
// Killing a proccess running on especific port | |
-------------------------------------------------- // | |
// OPT-1 | |
netstat -vanp tcp | grep 8000 | awk '{print $9}' | xargs kill -9 | |
// OPT-2 | |
// Discover pid | |
netstat -antp | grep {programName} | |
// Kill program by pid | |
kill -TERM {pid} | |
// -------------------------------------------------- | |
// Extending logical volume disk | |
-------------------------------------------------- // | |
https://wiki.archlinux.org/index.php/LVM | |
// -------------------------------------------------- | |
// Cleanup (remove cache, ununsed and old files) | |
-------------------------------------------------- // | |
http://br.ccm.net/faq/7272-fazer-uma-limpeza-no-ubuntu-residuos-de-configuracao-pacotes | |
// Find recursively (and optionally delete) files by extension | |
find . -name "*.bak" -iname | |
find . -name "*.bak" -iname -type f -delete | |
Referecen: https://goo.gl/UBgQ7h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment