Cheat Sheet
Bash kommandoer med eksempler.
Colorize with pearl
## Colorise aaa OR bbb red
tail -f filename | perl -pe "s/(aaa|bbb)/\e[1;31m\1\033[0m/g"
##Colorise aaa OR bbb red OR ccc green
tail -f filename | perl -pe "s/(aaa|bbb)/\e[1;31m\1\033[0m/g || s/(ccc)/\e[0;32m\1\033[0m/g"Chmod
# StickyBit - only the owner of the file are allowed to delete the file
chmod o+t /folder/ #set stickyBit on "other" group
chmod o-t /folder/ #remove stickyBit from folder
chmod 1775 /folder/ #set stickybit + rwx permission in number format
# Set group ID - all future created folder or files will be owned by the same group as the folder it was created in
chmod g+s /folder/ #set group ID for folder
chmod g-s /folder/ #Remove group ID for folder
chmod 2775 /folder/ #Set group ID for folder in numeric mode
# Set User ID - primarily used for scripts, the script will be run as the owner regardless of who initiate the script
chmod u+s /script/ #Set user ID for script
chmod u-s /script/ #remove user ID for script
chmod 4775 /script/ #Set user ID for script in numeric mode
# spesific permissions per user
setfacl -m u:username:rwx /folder/ #full access
setfacl -m u:username:--- /folder/ #no access
setfacl -m g:groupname:r-x /folder/ #set access for group
setfacl -x u:username /folder/ #Remove spesific permissions for this user (or group)
setfacl -b /folder/ #Remove ALL spesific permissions for folder
setfacl -m d:u:username:rwx /folder/ #Set default ACL - all new files under this folder will inherit the ACL configured for this folder
getfacl /folder/ # to see details of ownershipGrep
## Print file1 men ekskuder alle linjer som begynner på #
grep -v '^#' file1One response
-
random

Leave a Reply
You must be logged in to post a comment.