Archivio mensile:ottobre 2018

I miei alias preferiti

Questi sono alcuni alias che preferisco inserire nei miei server ubuntu-like.

Il tutto da inserire in:

nano ~/.bashrc


alias halt='reboot'
#alias reboot='reboot -f'
alias ll='ls -al'
alias aggiorna='apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y && apt-get autoremove --purge && apt-get autoclean -y'
alias poweroff='reboot'
alias shutdown='reboot'

Script per autogenerare file host

Questo è uno script da poter installare sulla propria macchina server, per autogenerare (con un bel cron) file host da poter poi scaricare con uno script impostato nel vostro router.

Questo per avere file host sempre aggiornati.


rm -rf /opt/ads/*

# Perform work in temporary files

# Obtain various hosts files and merge into one
wget -qO - >> $temphosts1
wget -qO - >> $temphosts1
wget -qO - >> $temphosts1
wget -qO - "" >> $temphosts1
wget -qO - >> $temphosts1
wget -qO - >> $temphosts1

# Do some work on the file:
# 1. Remove MS-DOS carriage returns
# 2. Delete all lines that don't begin with
# 3. Delete any lines containing the word localhost because we'll obtain that from the original hosts file
# 4. Replace with because then we don't have to wait for the resolver to fail
# 5. Scrunch extraneous spaces separating address from name into a single tab
# 6. Delete any comments on lines
# 7. Clean up leftover trailing blanks
# Pass all this through sort with the unique flag to remove duplicates and save the result

sed -e 's/\r//' -e '/^!d' -e '/localhost/d' -e 's/' -e 's/ \+/\t/' -e 's/#.*$//' -e 's/[ \t]*$//' < $temphosts1 | sort -u > /opt/ads/hosts

rm /var/www/MIOSITO/hosts.txt
ln /opt/ads/hosts /var/www/MIOSITO/hosts.txt

exit 0