Author: peter

  • Hello world!

    Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

  • 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

  • Google Chromecast

    chromecast

    Chromecast is the easy way to enjoy online video and anything from the web on your TV. Plug it into any HDTV and control it with your existing smartphone, tablet or computer browser. It currently only works with Netflix, Hulu Plus, You Tube, and Google Play. Google will be adding more provides in the near future.

    It comes with the Chromecast adapter, power supply, usb cable, HDMI extension cable. I would recommend using the power supply it comes with instead of using the power of the USB port on your TV, this will allow the TV to be turned on and have the input source switch to the correct HDMI port using your smartphone or tablet.

    So far Netflix streaming takes a few seconds to load but hopefully Google and Netflix will be working on making it fast to load. Also Chromecast works over WiFi so much should you have good receptions in the area you plan to deploy this.

    I would recommend this for both Android users and iOS users, I have it and it been great. I am happy I got this instead of a new BluRay player which would have cost me a lot more. Chromecast is just $35 and it’s a great value.

     

    Update 11/6/2013:

    Chromecast new supports Pandora which is great, so now you can play your favorite music player on the TV.

    Get it here at Amazon: Google Chromecast HDMI Streaming Media Player

  • Google Chromecast

    chromecast

    Chromecast is the easy way to enjoy online video and anything from the web on your TV. Plug it into any HDTV and control it with your existing smartphone, tablet or computer browser. It currently only works with Netflix, Hulu Plus, You Tube, and Google Play. Google will be adding more provides in the near future.

    It comes with the Chromecast adapter, power supply, usb cable, HDMI extension cable. I would recommend using the power supply it comes with instead of using the power of the USB port on your TV, this will allow the TV to be turned on and have the input source switch to the correct HDMI port using your smartphone or tablet.

    So far Netflix streaming takes a few seconds to load but hopefully Google and Netflix will be working on making it fast to load. Also Chromecast works over WiFi so much should you have good receptions in the area you plan to deploy this.

    I would recommend this for both Android users and iOS users, I have it and it been great. I am happy I got this instead of a new BluRay player which would have cost me a lot more. Chromecast is just $35 and it’s a great value.

     

    Update 11/6/2013:

    Chromecast new supports Pandora which is great, so now you can play your favorite music player on the TV.

    Get it here at Amazon: Google Chromecast HDMI Streaming Media Player