sudo -u <user> bash -c "<command to execute>"
cut -d: -f1 /etc/passwd
getent group | grep name_of_user
Note: this uses du
which can get slow.
du -sh * | sort -h
references: http://robert.penz.name/622/ncdu-is-better-than-calling-du-hs-multiple-times/
Requires the package ncdu
.
ncdu -xq <dir name>
From http://stackoverflow.com/a/2860103/682912
git log | while read x; do
# do something on $x
done
From http://stackoverflow.com/a/6121114/682912
VAR=/home/me/mydir/file.c
DIR=$(dirname "${VAR}")
echo "${DIR}"
# /home/me/mydir
basename "${VAR}"
file.c
command -v foo >/dev/null 2>&1 || { echo "I require foo but it's not installed. Aborting." >&2; exit 1; }
(This requires Ghostscript 'gs') http://askubuntu.com/a/256449
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
source: http://stackoverflow.com/a/13864829/682912
if [[ -z $VAR ]]; then
echo "variable NOT set"
fi
if [[ "$foo" =~ "$bar" ]]; then
echo $foo contains $bar
fi
openssl rand -base64 16 | md5 |head -c16;echo
apg -a 1 -n 4 -m 8 -x 12 -s -d
From http://stackoverflow.com/a/14203146/682912
while getopts "h?vf:" opt; do
case "$opt" in
h|\?)
show_help
exit 0
;;
v) verbose=1
;;
f) output_file=$OPTARG
;;
esac
done
Reference: sivel/speedtest-cli
wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod +x speedtest-cli
./speedtest-cli
Example:
for var_name in AWS_ACCESS_KEY AWS_SECRET_KEY; do
# use the value of $AWS_ACCESS_KEY, $AWS_SECRET_KEY etc
echo "${!var_name}"
done
Edit the ~/.inputrc
file.
"\e[1;5C": forward-word # ctrl + right
"\e[1;5D": backward-word # ctrl + left