Some of these are for mac and some are for linux!
- Reset current project state completely -
git reset --hard
- Connect to a remove server -
ssh name@0.0.0.0
- Search shell history -
history | grep search-term
- Wander -
cd..
- List files -
ls -al
- Search for a file by name recursively (current directory) -
find . -name filename.txt
history | grep searchString
ssh-keygen
ssh-keygen -t rsa -b 4096 -o -a 100
find . -print | wc -l
find . -type f -name "*.jpg" -exec convert "{}" -quality 50 -resize 255 "{}.tmp" \;
find . -iname "*.jpg.tmp" -exec bash -c 'mv "$0" "${0//\.thm\.jpg/thm\.jpg}"' {} \;
find . -iname "*.mustache" -exec bash -c 'mv "$0" "${0%\.mustache}.php"' {} \;
for file in *
do
echo $file
new=$(echo $file | sed -e 's/\?[0-9]*$//')
mv -v "$file" "$new"
done
find . -type d -name .git -prune -o -mmin -30 -type f -print
wget -r -p -U Mozilla <url>
function str_replace( $1, $2 ){ find . -type f -print0 | xargs -0 sed -i 's/$1/$2/g' }
find . -type f -print0 | xargs -0 sed -i 's/<?=/<?php echo /g';
find . -type f -print0 | xargs -0 sed -i 's/<?/<?php/g';
find . -type f -print0 | xargs -0 sed -i 's/phpphp/php/g';
du -hsx * | sort -rh | head -10
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
yes "$(seq 1 255)" | while read i; do printf "\x1b[48;5;${i}m\n"; sleep .01; done
Add a user:
useradd -m -g users -s /bin/bash -p $(echo your_password | openssl passwd -1 -stdin) your_username
Delete a user:
userdel username
Recursively search files for a string:
grep -r "your string" .
Recursive string replace:
find . -type f -print0 | xargs -0 sed -i 's/<search>/<replace>/g'
apachectl -t -D DUMP_VHOSTS
Credit to Mason Frakes @ github.com/Novemburr
function permissions() {
echo 'who should own the directory tree?';
read owner;
sudo chown -R $owner:$owner $1;
sudo find $1 -type d -exec chmod 755 {} \;
sudo find $1 -type f -exec chmod 644 {} \;
}
alias perms='permissions';
du -a -h --max-depth=1 | sort -hr
weather(){ curl -s "http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=${@:-74133}"|perl -ne '/<title>([^<]+)/&&printf "%s: ",$1;/<fcttext>([^<]+)/&&print $1,"\n"';}