Automatically call 'ls' when the directory is changed:
sudo echo export 'PROMPT_COMMAND='\''[[ $my_currdir != $PWD ]] && ls; my_currdir=$PWD'\''' > ~/.bash_aliases
Reinstall all installed packages with a specific word: (in this case, this line reinstalls all installed packages with the word perl in it)
sudo apt-get --reinstall install $(dpkg --get-selections | grep perl | awk '{print $1}')
(this case, this line reinstalls all installed packages with the word perl in it and not perl-base)
sudo apt-get --reinstall install $(dpkg --get-selections | grep perl | grep -v perl-base | awk '{print $1}')
Update all opkg packages
for pkg in `opkg list-upgradable | cut -d' ' -f1 | grep -v Multiple`; do opkg upgrade $pkg; done
find ~ -size 20MB
Find occurences of ip address by count:
grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' NCL-G2-LOG-1.txt | sort -r | uniq -c | sort -rn | head
Encrypted netcat group chat:
server:
while true; do read -n30 ui; echo $ui |openssl enc -aes-256-cbc -a -k PaSSw; done | nc -l -p 8877 | while read so; do decoded_so=`echo "$so"| openssl enc -d -a -aes-256-cbc -k PaSSw`; echo -e "Incoming: $decoded_so"; done
client:
while true; do read -n30 ui; echo $ui |openssl enc -aes-256-cbc -a -k PaSSw; done | nc $ipaddress 8877 | while read so; do decoded_so=`echo "$so"| openssl enc -d -a -aes-256-cbc -k PaSSw`; echo -e "Incoming: $decoded_so"; done
Centos issues:
when attempting to do an ssh-keygen as a user that is not in the sudoers file you will get a "permission denied" error because SELinux is blocking ssh-keygen. To get SELinux to accept the command without blockage, run the following:
Docker pull all and update all images from repositories:
Macwhen attempting to do an ssh-keygen as a user that is not in the sudoers file you will get a "permission denied" error because SELinux is blocking ssh-keygen. To get SELinux to accept the command without blockage, run the following:
chcon -R -t ssh_home_t ~/.ssh
Docker pull all and update all images from repositories:
docker images | awk 'NR > 1 && $1 !~ /<none>/ {print $1}' | uniq | xargs -n 1 docker pull
dd with a progress bar (requires brew and install pv):
pv -tpreb ~/Desktop/openSuse.img | sudo dd of=/dev/disk2 bs=1m
mount smb share:
mount_smbfs
or
mount -t smbfs
Windows
Flush Windows Updates cache:
Bash scriptsFlush Windows Updates cache:
net stop wuauserv
cd /d %windir%
rd /s SoftwareDistribution
net start wuauserv
Auto extract compressed file (place the following in your bash_profile or bashrc file):
extract() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}