Category: How Tos

How To Articles

  • Fixing USB 3.0 Problems with some VIA/NEC controller cards on Windows 7/8/8.1

    I have been having USB 3.0 device problems for a while now, some of the devices are IOGEAR USB 3.0 Hub, Corsair Voyager GT 3.0 Flash drives and some some others, when I was copying files to the drive, the devices would disappear from my system and copying would fail.
    This problems seems to be the Power Management on Windows.
    Here’s the steps it took to fix the problem:

    1. Go to Control Panel>Device Manager
    2. Expand the “Universal Serial Bus controllers” tree
    3. Right click on “USB Root Hub (xHCI)” and select Properties
    4. Select the “Power Management” tab
    5. Uncheck “Allow the computer to turn off this device to save power”
    6. Click on Ok and close the Device Manager.
  • Controlling the GPU switching of your new Retina MacBook Pro

    gfxcardstatus

    gfxCardStatus is a great tool to help you control which GPU your new Retina MacBook Pro will use. This will also work on other Macs that have a hybird GPU

    For Example, if you are running on battery and are browsing the internet with Chrome or Firefox, the system will switch to the Discrete GPU instead of the Integrated GPU which uses less power. With this tool you can force the system to stay on the Integrated GPU.

    Safari seems to work with MacBooks with the auto switching GPU as it does not force the system to switch to Discrete GPU unless you really need it, For example if you are which Netflik then it will use the Discrete GPU.

    When this app is opened it stays in the top right menu area and you can set this app to open when the system starts up.

    It let you know which GPU is being used, and what application is using the Discrete GPU and it can use the Growl notification system to display messages. It also works great with Mac OS X Mountain Lion and OS X Maverick.

    You can get gfxCardStatu from http://codykrieger.com/gfxCardStatus

  • Setting up a Linux disk quota for users

    Having a disk quota on a shared system is very useful, you can control how much data each user can store on the system. In this tutorial I will assume that you have many partitions on your system, we will work with the home directory partition for your Linux system.

    Do the following:

    Step 1)

    touch /home/aquota.user
    chmod 600 /home/aquota.user

    Step 2)

    Edit the /etc/fstab file, we want to add "usrjquota=aquota.user,jqfmt=vfsv0" as an option for the home partition such that the home partition line looks like the following line:

    /dev/sda7 /home ext3 defaults,usrjquota=aquota.user,jqfmt=vfsv0 1 1

    Step 3)

    You can choose to reboot the system to update the changes we just made or run this command "mount -o remount /home" which will remount the partition with the changes.

    Step 4)

    We need to do a quota check which will calculate how much disk space each user is currently using. So run the following line:

    quotacheck -vuma

    Step 5)

    We need to turn quota on, so run this line:

    quotaon -avu

    Step 6) Last step

    We need to set a quota for each user on the Linux system run edquota followed by the username.

    Example "edquota pywong"

    You should see something like this:

    
    Disk quotas for user pywong (uid 1128):
      Filesystem                   blocks       soft       hard     inodes     soft     hard
      /dev/sda7                    473452    1000000    1500000        476        0        0
      /dev/sdb1                    296004   15000000   20000000        413        0        0
      /dev/sdb2                         0          0          0          0        0        0
    

    When we use the edquota command this will most likely open it using a text editor called vi, you many need to read up on how to use vi for editing if you do not already know how to use it.

    We want to edit the Filesystem line that matches our line for the home directory, in this case it’s the line with /dev/sda7, we want to edit the soft column and the hard column. 1000000 = 1GB and 1500000 = 1.5GB. You want the hard quota to be bigger than the soft quota, when user hit the soft quota they will get warning and if they hit the hard quota they will get error messages and the system will not let the user write anymore files.

  • Clearing cached memory on Linux systems

    The Linux OS the tends keep Cached memory because the it decides that the Cached memory is being used and is needed which can lead to memory issues and slow down your system.

    To fix this problem you can force the system to free up the stored Cached memory.

    Create a script called /usr/local/bin/clearcache.sh with the following two lines:

    
    #!/bin/sh
    sync; echo 3 > /proc/sys/vm/drop_caches
    

    run "crontab -e" and add the following line:

    
    0 * * * * /usr/local/bin/clearcache.sh
    

    Also make the script executable by running “chmod +x /usr/local/bin/clearcache.sh”

    This should clear the Cached memory every hour.

  • Delete all files 7 days old within a directory

    This will delete all files and directories old than 7 days within /tmp or other directory you specify, it will only look for files within that directory and not sub-directories.

    find /tmp/ -maxdepth 1 -mtime +7 -exec rm -rf {} ;

    • -maxdepth mean how deep to look for files.
    • -mtime means the modified time.

    This will list all the files that the first command would have deleted without actually deleting the files.

    find /tmp/ -maxdepth 1 -mtime +7

    Be very careful with the first command, it could render your system useless and delete other files. Do not use “/tmp/.*”, it could delete files outside of your directroy.

  • Protecting SSH from brute force attacks using iptables

    Protecting yor SSH server from brute force attacks will reduce the chance of someone gussing your password to your server or workstation. One way of doing that is to use IPTables, another way is to change the default port your SSH server is listening on, in this artical I will be show you how to do the IPTables route.

    Put the following in /etc/sysconf/iptables and /etc/sysconf/ip6tables:

    -A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -m recent --set --name SSH
    -A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -m recent --update --seconds 60 --hitcount 5 --rttl --name SSH -j DROP
    -A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT

    restart iptables

    /bin/systemctl restart iptables.service
    /bin/systemctl restart ip6tables.service

    This will drop connections after it has failed 5 times within the last 60 seconds.

  • Using Rsync to backup over SSH

    Backup up a system with full read only permissions as root on a remote host and with snapshots.

    The Backup server will be the one running the backup script and the remote host will be the client machine.

    Without the validate-rsync script and the sender option, someone with your private key could erase your machine.

    This will create a ssh private and public key

    
    ssh-keygen -t rsa -b 2048 -f /root/cron/nas-rsync-key
    

    Copy the public key to /root/.ssh/authorized_keys on the remote host.

    add the following line in front of the key on /root/.ssh/authorized_keys

    
    from="192.168.1.50",command="/root/cron/validate-rsync" [YOUR KEY HERE]
    

    Create a file /root/cron/validate-rsync and make it excutable

    
    #!/bin/sh
    
    case “$SSH_ORIGINAL_COMMAND” in
    *&*)
    echo “Rejected”
    ;;
    *(*)
    echo “Rejected”
    ;;
    *{*)
    echo “Rejected”
    ;;
    *;*)
    echo “Rejected”
    ;;
    *< *)
    echo “Rejected”
    ;;
    *`*)
    echo “Rejected”
    ;;
    *|*)
    echo “Rejected”
    ;;
    rsync –server –sender*)
    $SSH_ORIGINAL_COMMAND
    ;;
    *)
    echo “Rejected”
    ;;
    esac
    

    Backup script to backup the home directory:

    
    #! /bin/sh
    HOME="/media/Backup"
    KEY=/root/cron/nas-rsync-key
    date=`date "+%Y-%m-%d"`
    rsync -avP -e "ssh -i $KEY" --link-dest=$HOME/current [email protected]:/home $HOME/$date/
    

    For more details see http://troy.jdmz.net/rsync/index.html

  • Honda Civic 2012 Oil Filters

    The following Oil Filters work with the Honda Civic 2012 excluding the Si and hybrid.

    • PH7317
    • TG7317
    • K&N PS1010
    • Bosch W0133-1638275
    • Mobil 1 M1-110

    This car uses 0w-20 full synthetic oil.

  • Custom firmware for Asus RT-AC66U

    Merlin has a custom Asuswrt firmware for the RT-AC66U router which can be found at its new home at http://www.mediafire.com/asuswrt-merlin/#

    With this firmware Merlin adds some needed feature that Asus lefted out see below.

    Using IPv6 can be a pain without a firewall between you and the world. This is one of the reasons I like Merlin’s version of the firmware,
    You can create a file /jffs/scripts/firewall-start on the router to run a custom firewall rules at start up.

    Here’s an example of what that file would look like for IPv6 6in4 tunnel with ip6tables:

    ip6tables -A INPUT -j DROP
    ip6tables -I FORWARD 2 -m state --state RELATED,ESTABLISHED -j ACCEPT

    # Allowed inbound rules here, such as this one:
    ip6tables -I FORWARD 2 -p tcp -m state --state NEW -i v6in4 --dport 22-j ACCEPT

    ip6tables -A FORWARD -i v6in4 -o br0 -p all -j DROP
    ip6tables -A FORWARD -i br0 -o any -p all -j ACCEPT
    ip6tables -A FORWARD -i br0 -o v6in4 -p all -j ACCEPT
    ip6tables -A FORWARD -i any -o br0 -p all -j ACCEPT
    ip6tables -A FORWARD -j DROP

     

    Here is a list of features that Asuswrt-merlin brings over the original firmware:
    System:
       – Based on the 3.0.0.4.246 source release from Asus
       – Various bugfixes (like the crash on VPN/NAT Loopback access of LAN devices)
       – Persistent JFFS partition
       – User scripts that run on specific events
       – Cron jobs
       – Customized config files for router services
       – LED control – put your Dark Knight in Stealth Mode by turning off all LEDs
    Disk sharing:
       – Act as a Master Browser
       – Act as a WINS server
       – Optionally use shorter share names (folder name only)
       – Disk spindown after user-configurable inactivity timeout
    Networking:
       – WakeOnLan web interface (with user-entered preset targets)
       – SSHD
       – Allows tweaking TCP/UDP connection tracking timeouts
       – CIFS client support (for mounting remote SMB share on the router)
       – Layer7 iptables matching
       – User-defined options for WAN DHCP queries (required by some ISPs)
       – Improved NAT loopback (based on code from phuzi0n from the DD-WRT forums)
       – Dual WAN support (both failover and load
         balancing supported) (EXPERIMENTAL) (RT-N66U, RT-AC66U)
       – OpenVPN client and server, based on code originally written by
         Keith Moyer for Tomato and reused with his permission. (RT-N66U, RT-AC66U)
       – Option to control Spanning-Tree Protocol support.
    Web interface:
       – Clicking on the MAC address of an unidentified client will do a lookup in
         the OUI database (ported from DD-WRT).
       – Optionally save traffic stats to disk (USB or JFFS partition)
       – Display monthly traffic reports
       – Display active/tracked network connections
       – Name field on the DHCP reservation list and Wireless ACL list
       – System info summary page
       – Wireless client IP, hostname, rate and rssi on the Wireless Log page
       – Wifi icon reports the state of both radios
    Thank you Merlin for your hard work in creating this firmware.
  • Using Google Authenticator on Ubuntu for SSH

    Run:

    $ apt-get update
    $ apt-get -yy install gcc mercurial libpam0g-dev git
    $ git clone https://code.google.com/p/google-authenticator/
    $ cd google-authenticator/libpam
    $ make install

    Edit /etc/ssh/sshd_config file and change the ChallengeResponseAuthentication from no to yes

    edit /etc/pam.d/common-auth so it looks like

    # here are the per-package modules (the "Primary" block)
    auth required pam_google_authenticator.so
    auth [success=1 default=ignore] pam_unix.so nullok_secure
    # here's the fallback if no module succeeds

    Run google-authenticator as the user you want to use two factor authentication on.
    Paste the generated URL into your browser and a QRCode will be generated.
    Scan the QR code with the Google Authenticator app on your iPhone.
    Reboot the server and test.