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
#exit if user is not root | |
[ "$(id -u)" != "0" ] && { echo "Must be run as root! Aborting"; exit 1;} |
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
YYYYMMDDhhmmss=$(date +%Y%m%d%H%M%S) | |
echo $YYYYMMDDhhmmss | |
# will output 20120604164021 |
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
[[ "hello" =~ ^h.[a-z]{2,3}[^[:digit:][:alpha:]]$ ]] && echo "match" |
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
# I want to *snoop* the stdout(1) and stderr(2) of the process named 'ntfsresize' | |
# (run as root) | |
strace -p $(pidof "ntfsresize") -e trace=write 2>&1 | grep 'write(1' | |
# Explanation: | |
# | |
# -p $(pidof "ntfsresize") | |
# Apply strace to the process named "ntfsresize" | |
# If you want to trace a bash script, use instead $(pidof -x "script-name.sh") | |
# |
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
sudo adduser user_x group_z | |
# and now logout/relogin for changes to take effect |
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
#PROLOGUE: all this should be run as root, otherwise stated | |
#update && upgrade: | |
apt-get update && apt-get upgrade -y | |
#create a new user | |
adduser user_x | |
#create group admin (funny enough, it does not exist, although its accounted in the /etc/sudoers file): | |
addgroup --system admin |
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
# See "man 5 crontab" | |
# | |
# Instead of the first five fields, one of eight special strings may appear: | |
# string meaning | |
# ------ ------- | |
# @reboot Run once, at startup. | |
# @yearly Run once a year, "0 0 1 1 *". | |
# @annually (same as @yearly) | |
# @monthly Run once a month, "0 0 1 * *". | |
# @weekly Run once a week, "0 0 * * 0". |
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
#Become user_x, with a login environment | |
su - user_x |
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
#Run command as user_x, within a login environment | |
sudo -u user_x -i echo This is my command and should not be quoted |
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
#Add this to /etc/fstab | |
/dev/sda1 /Windows ntfs-3g defaults,uid=1000,gid=1000,dmask=027,fmask=137 0 0 |