Latest 100 public snipts »
bhubbard's
snipts
showing 1-20 of 86 snipts
-
∞ State
<!-- Without Codes --> <select name="state"> <option>Alabama</option> <option>Alaska</option> <option>Arizona</option> <option>Arkansas</option> <option>California</option> <option>Colorado</option> <option>Connecticut</option> <option>Delaware</option> <option>Florida</option> <option>Georgia</option> <option>Hawaii</option> <option>Idaho</option> <option>Illinois</option> <option>Indiana</option> <option>Iowa</option> <option>Kansas</option> <option>Kentucky</option> <option>Louisiana</option> <option>Maine</option> <option>Maryland</option> <option>Massachusetts</option> <option>Michigan</option> <option>Minnesota</option> <option>Mississippi</option> <option>Missouri</option> <option>Montana</option> <option>Nebraska</option> <option>Nevada</option> <option>New Hampshire</option> <option>New Jersey</option> <option>New Mexico</option> <option>New York</option> <option>North Carolina</option> <option>North Dakota</option> <option>Ohio</option> <option>Oklahoma</option> <option>Oregon</option> <option>Pennsylvania</option> <option>Rhode Island</option> <option>South Carolina</option> <option>South Dakota</option> <option>Tennessee</option> <option>Texas</option> <option>Utah</option> <option>Vermont</option> <option>Virginia</option> <option>Washington</option> <option>West Virginia</option> <option>Wisconsin</option> <option>Wyoming</option> </select> <!-- With Codes --> <select name="state"> <option value="AL">Alabama</option> <option value="AK">Alaska</option> <option value="AZ">Arizona</option> <option value="AR">Arkansas</option> <option value="CA">California</option> <option value="CO">Colorado</option> <option value="CT">Connecticut</option> <option value="DE">Delaware</option> <option value="FL">Florida</option> <option value="GA">Georgia</option> <option value="HI">Hawaii</option> <option value="ID">Idaho</option> <option value="IL">Illinois</option> <option value="IN">Indiana</option> <option value="IA">Iowa</option> <option value="KS">Kansas</option> <option value="KY">Kentucky</option> <option value="LA">Louisiana</option> <option value="ME">Maine</option> <option value="MD">Maryland</option> <option value="MA">Massachusetts</option> <option value="MI">Michigan</option> <option value="MN">Minnesota</option> <option value="MS">Mississippi</option> <option value="MO">Missouri</option> <option value="MT">Montana</option> <option value="NE">Nebraska</option> <option value="NV">Nevada</option> <option value="NH">New Hampshire</option> <option value="NJ">New Jersey</option> <option value="NM">New Mexico</option> <option value="NY">New York</option> <option value="NC">North Carolina</option> <option value="ND">North Dakota</option> <option value="OH">Ohio</option> <option value="OK">Oklahoma</option> <option value="OR">Oregon</option> <option value="PA">Pennsylvania</option> <option value="RI">Rhode Island</option> <option value="SC">South Carolina</option> <option value="SD">South Dakota</option> <option value="TN">Tennessee</option> <option value="TX">Texas</option> <option value="UT">Utah</option> <option value="VT">Vermont</option> <option value="VA">Virginia</option> <option value="WA">Washington</option> <option value="WV">West Virginia</option> <option value="WI">Wisconsin</option> <option value="WY">Wyoming</option> </select>
-
∞ Check VPS memory
#!/bin/bash bean=`cat /proc/user_beancounters` guar=`echo "$bean" | grep vmguar | awk '{ print $4;}'` burst=`echo "$bean" | grep privvm | awk '{ print $5;}'` priv=`echo "$bean" | grep privvm | awk '{ print $2;}'` let total=guar/256 let used=priv/256 let burst=burst/256 echo "VPS memory usage:" echo "Used: $used MB" echo "Total: $total MB" echo "Burstable to: $burst MB"
-
∞ Change Linux hostname without reboot
vim /etc/hostname vim /etc/hosts hostname new-hostname
-
∞ Set dns servers
vi /etc/resolv.conf nameserver <dns1_ip_address> nameserver <dns1_ip_address>
-
∞ Find all files in /etc owned by root that have been modified within the last day
find /etc -user root -mtime -1
-
∞ Basic Unix/Linux Installation
./configure make make install dpkg -i pkg.deb – install a package (Debian) rpm -Uvh pkg.rpm – install a package (RPM)
-
∞ send direct message on twitter in linux terminal
curl -u username:password -d user="reciever" text="the message" http://twitter.com/direct_messages/new.xml
-
∞ Configuring Linux Plesk to drop external MySQL connections
Taken from http://www.europheus.com/?p=64 By default, your MySQL server can be wide open to the internet accepting connections from everyone. With some brute force and bad passwords on your part, there will be a hack party in your database. The best thing to do is to block all external connections to your MySQL port (3306) and allow only internal (localhost) connections. This will allow your web applications to continue to run while rejecting all outsiders. And if needed, you can allow one or more external static IPs to connection, however this is not addressed here. Using the Plesk firewall module is one way to block external connections, however it is simply a lame web interface to the iptables command. The best way to block external connections is to run the following commands as root. # this command makes sure everything on localhost works iptables -A INPUT -p all -s localhost -d localhost -j ACCEPT # block all external connection attempts to MySQL iptables -A INPUT -p tcp –destination-port 3306 -j REJECT /etc/init.d/iptables save /etc/init.d/iptables restart #check the new definitions iptables –list Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all — localhost.localdomain localhost.localdomain REJECT tcp — anywhere anywhere tcp dpt:mysql reject-with icmp-port-unreachable Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination You can test your work from another server by running: nmap -
∞ Upgrading Spamassassin on Plesk servers
#Found at http://www.europheus.com/?p=59 Upgrading Spamassassin on a Plesk server is not difficult and can take only a few minutes. This example describes upgrading from Spamassassin version 2.64 to version 3.1.7 on Plesk 7.5 To get the current version of Spamassassin on your server type: spamassassin –version To get the latest version of Spamassassin go here http://spamassassin.apache.org/ Once you have downloaded the tar or zip file, unzip / untar the archive on your server and execute the following commands. cd Mail-SpamAssassin-* perl Makefile.PL [option: add -DSPAMC_SSL to $CFLAGS to build an SSL-enabled spamc] make make install [as root] While in the Mail-SpamAssassin directory, you should run the included tests. These tests will let you know if you are missing any modules or if the versions are too old. spamassassin -t < sample-nonspam.txt > nonspam.out spamassassin -t < sample-spam.txt > spam.out Here you may see warnings for several items, for example IO::Socket::INET6 Simply enter this into google and you should find the module to download. These are usually .tar files and you simply untar them and follow the instructions in the README or related text files. Next you will need to modify the startup script to deal with commandline parameter changes. Edit the file /etc/init.d/spamassassin and find SPAMDOPTIONS Remove the parameter –a and save the file. Next you will need to modify configuration scripts to deal with changes. Edit the file /etc/mail/spamassassin/local.cf Comment out (or delete) the rewrite_subject and subject_tag fields and replace them with the rewrite_header field. required_hits 7 # rewrite_subject 1 # subject_tag *****SPAM***** rewrite_header Subject ****SPAM(_SCORE_)**** report_safe 0 Next you will need to make the same changes for each mailbox that has it’s own config file. Check for the user_prefs file in each mailbox for each domain. /var/qmail/mailnames/domainname/mailname/user_prefs Finally you should restart spamassassin /etc/init.d/spamassassin restart /etc/init.d/psa-spamassassin restart -
∞ Script to find domains which have mail enabled, then disable them
#!/bin/bash # This script finds all sites that have the mail service on - and then it turns it off. SiteList=`egrep 'Server(Name)' /var/www/vhosts/*/conf/httpd.include|awk '{print $3}'|grep -v www.*|grep -v '^.*\..*\..*$'|sed 's/:80//'|sed 's/:443//'|sort -u`; for Site in $SiteList do Result=`/usr/local/psa/bin/domain -i $Site | grep 'Mail service' | awk '{print $3}'`; if [ $Result == On ]; then Command=`/usr/local/psa/bin/domain -u $Site -mail_service false` echo "Turning Off Mail Service: $Site"; fi done
-
∞ not centos packages
# Want to query all those packages installed from 3rd party repositories, not CentOS? rpm -qa --qf '%{NAME} %{VENDOR}\n' | grep -v CentOS
-
∞ Rpm permissions
# Have you managed to completely mess up file permissions for a given package? Not a problem, because RPM has you covered. rpm --setperms <packagename> -
∞ View the Package Changelog
# View the Changelog # Because CentOS and the upstream vendor have backported security patches, the version numbers can often be misleading when you look for CVE fixes. Checking the changelog of a package is a good way to see if the fix has been implemented. Once again, rpm comes to the rescue. rpm -q --changelog <packagename> | less # Using less isn't necessary, but for some packages like the kernel, the changelog can be quite long. Using less helps to make things more readable.
-
∞ Query Package Install Order and Dates
# Query Package Install Order and Dates # Useful after an upgrade to find old packages that were not upgraded. rpm -qa --last >~/RPMS_by_Install_Date # Review the end of the output file in "less" to find all RPMS older than the install date. Can also grep for specific packages and see when they were installed.
-
∞ mchk with spam
/usr/local/psa/admin/sbin/mchk --with-spam
-
∞ Display last reboot
last reboot | head -1
-
∞ Last system boot
who –b
-
∞ Clear out history
history -c #w ill clear the entire bash history. # To only clear the current session history use: history -r.
-
∞ Clear the command history and screen when you log out
#There is a simple solution to this problem, open your ~/.bash_logout file: vi ~/.bash_logout #Append any one of the following command: /usr/bin/clear_console #OR /usr/bin/clear
-
∞ Securely remove files
#Securely delete a file called /home/vivek/login.txt: shred -u ~/login.txt #You can add a final overwrite with zeros to hide shredding: shred -u -x ~/login.txt


