Install Wireless Broadcom Driver for Fedora 21

Run the following commands as root

rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

Update the system and then download the driver.

yum update
yum install kmod-wl

When the above commands finish reboot the computer

reboot

How To “Unblock” an IP from cPHulk from the Command Line

cPHulk uses a MySQL database to keep track of different IP’s to block, white list, black list, etc.

When there have been X amount of failed login attempts from an IP, cPHulk adds an entry for the IP in the brutes table.

To “unblock” the IP we need to delete the entry.

open up the cPHulk MySQL database.

root@localhost [~]# mysql cphulkd

If your interested you can view all tables that cPHulk uses.

show tables;

Take a look at all the IP’s in the brutes table.

SELECT IP FROM brutes;

example:

mysql> SELECT IP FROM brutes;
+---------------+
| IP            |
+---------------+
| 30.134.41.221 |     <--  IP we want to unblock
| 31.134.40.251 |
+---------------+
2 rows in set (0.00 sec)

mysql>

To unblock the IP we just need to delete the row that has the IP address we want.

mysql> DELETE FROM brutes WHERE IP="30.134.41.221";

It should return the following.

mysql> DELETE FROM brutes WHERE IP="30.134.41.221";
Query OK, 1 row affected (0.00 sec)

mysql>

Exit MySQL.

mysql> exit
Bye
root@localhost [~]#

 

How To Install Ubiquiti AirVision on Debain 7.5

Download the airVision Debian deb from Ubiquiti’s website.

http://www.ubnt.com/download/

Next upload the airvision.deb file to your server.

Install prerequisites

apt-get install openjdk-7-jre-headless

Install airVision

dpkg -i unifi-video_3.0.8~Debian7_amd64.deb

Once it finishes installing open up a web browser and go to https://yourserverip:7443 to finish setting up the controller

How To Install Ubiquiti mFi controller on Debain(7.5.0) Linux

Add the following line to /etc/apt/sources.list

deb http://dl.ubnt.com/mfi/distros/deb/debian debian ubiquiti

Add GPG keys

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv C0A52C50
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

Update the system

sudo apt-get update

Install the mFi software

sudo apt-get install mfi

Once it is finished installing you should be able to browse to https://yourserverip:6443 to access the mFi web page.

How To Install Ubiquiti’s UniFi Controller on Debian Linux

First add the following line to /etc/apt/sources.list

deb http://www.ubnt.com/downloads/unifi/distros/deb/debian debian ubiquiti

Next add the GPG key for UniFi and mongo-10

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv C0A52C50
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

Update the system

sudo apt-get update

Install the UniFi software

sudo apt-get install unifi-rapid

Once it is finished installing you should be able to browse to https://yourserverip:8443 to access the UniFi web page.

How to Create a Local Storage Repository for XenServer

Find your hard drive and or partition.

cat /proc/partitions

The above command should give you a list of all the HDD’s and partitions on the system.

Find the UUID of the disk with the following command

ll /dev/disk/by-id

Find the UUID of your XenServer.

xe host-list

Create the storage repository.

 xe sr-create content-type=user device-config:device=/dev/disk/by-id/"Disk UUID" host-uuid="Host UUID" name-label=”Local Storage 2” shared=false type=lvm

example:

[root@XenServer ~]# cat /proc/partitions
major minor #blocks name

3 0 22378 loop0
6 0 285474816 sda   <--- Main HHD is is here, shows total size of disk
8 1 4193297 sda1 
8 2 4193297 sda2       
8 3 244085167 sda3  <--- This is the partition we need
252 0 4096 dm-0
252 1 105070592 dm-1
253 0 104857600 tda
253 1 4363264 tdb
[root@XenServer ~]# ll /dev/disk/by-id/
total 0
lrwxrwxrwx 1 root root 9 Oct 13 20:38 scsi-56234c232c92f371217ce8549f51e0nf1 -> ../../sda
lrwxrwxrwx 1 root root 10 Oct 13 20:38 scsi-56234c232c92f371217ce8549f51e0ff1-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Oct 13 20:38 scsi-56234c232c92f371217ce8549f51e0ff1-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Oct 13 20:38 scsi-56234c232c92f371217ce8549f51e0ff1-part3 -> ../../sda3   <-- This is the UUID for the partition
lrwxrwxrwx 1 root root 9 Oct 13 20:38 usb-Dell_Virtual_CDROM_1028_123456 -> ../../sr1
[root@XenServer ~]# xe host-list
uuid ( RO)                : dce4e7fe-8342-bd11-12c8-83caac124a4b   <--- UUID for XenServer
          name-label ( RW): XenServer001
    name-description ( RW): Default install of XenServer

[root@XenServer ~]# xe sr-create content-type=user device-config:device=/dev/disk/by-id/scsi-56234c232c92f371217ce8549f51e0ff1-part3 host-uuid=dce4e7fe-8342-bd11-12c8-83caac124a4b name-label="Local Storage" shared=false type=lvm

 

How to View Installed Programs in linux

Debian Based Distros

The below command should work for Debain, Ubuntu, and the Raspberry Pi Raspbian.

dpkg --get-selections

 

RPM Based Distros

The following works on Fedora, CentOS, ReHat.

rpm -qa

 

The above commands return all of the packages installed on a system.  If you want to look for a specific program or package you can use grep to filter the results.

rpm -qa | grep program

or

dpkg --get-selections | grep program

SNMP and Shell Script

First you will need to make sure SNMP is installed.

apt-get install snmpd snmp snmp-mibs-downloader

You’ll need to configure a new snmpd.conf file with

snmpconf

Run through the steps and when your done replace your current snmpd.conf file in /etc/snmp/ with the new one.

Now open up your new snmpd.conf file

vi /etc/snmp/snmpd.conf

and add the following to the bottom of the file.

extend myshscript /path/to/your.sh

Save and close the file and restart the snmpd service.

service snmpd restart

Now we need to find the OID of our new data point.  Do this by running

snmpwalk -v2c -c public localhost .1.3.6.1.4.1.8072.1.3.2

It should display something similar to the following.

root@localhost:/etc/snmp# snmpwalk -v2c -c public localhost .1.3.6.1.4.1.8072.1.3.2
iso.3.6.1.4.1.8072.1.3.2.1.0 = INTEGER: 1
iso.3.6.1.4.1.8072.1.3.2.2.1.2.4.118.111.108.116 = STRING: "/etc/snmp/volt.sh"
iso.3.6.1.4.1.8072.1.3.2.3.1.4.4.118.111.108.116 = INTEGER: 0
iso.3.6.1.4.1.8072.1.3.2.4.1.2.4.118.111.108.116.1 = STRING: "14.3"
root@localhost:/etc/snmp#

The OID we are interested in is the one on the last line.  If you run a snmpwalk command with the OID you should get your data point.

root@localhost:/etc/snmp# snmpwalk -v2c -c public localhost 1.3.6.1.4.1.8072.1.3.2.4.1.2.4.118.111.108.116.1
iso.3.6.1.4.1.8072.1.3.2.4.1.2.4.118.111.108.116.1 = STRING: "14.3"
root@localhost:/etc/snmp#

All that’s left is to add the OID to your SNMP monitor.  If You run into issues with your SNMP server not monitoring the OID, you might need do what I did in the above command, replace the beginning of the OID “iso.” with a “1”.

 

How to Create a LVM Logical Volume in Linux

First we need to create the Physical Volume.  Change “/dev/sda2” to your drive.

pvcreate /dev/sda2

Next we create the Volume Group.  You can change “VGname” to something else if you so desire.

vgcreate VGname /dev/sda2

And finally, create the Logical Volume.  The Logical Volume’s name will be home.  Change as needed.

lvcreate -l %100FREE -n home VGname

The above command will create a Logical Volume that uses all the free space avaliable in the Volume Group.  If you want the Logical Volume to be a specific size,  change “-l 100%FREE” to “-L 60G”.  Where “60G” is the size in GB.
Example:

lvcreate -L 60G -n home VGname

Your Logical Volume should be setup now.  You can list all your Logical Volumes with

lvdisplay

You may need to format the new logical volume to mount it.  Replace VGname and LVname for the Volume Group name and the Logical Volume name.

mkfs.ext4 /dev/VGname/LVname

Mount it with

mount /dev/VGname/LVname /mount/point

Some Basic MySQL Commands

Enter Mysql

mysql -u root -p

Create Database

create DATABASE testdb;

Select Database

use testdb;

Delete Database

drop DATABASE testdb;

Drop Table

drop table table_name;

Show Tables

show tables;

Show data in table

SELECT * FROM table_name;

Create Table

CREATE TABLE contacts_table (id INT, name VARCHAR(20), email VARCHAR(20));

Insert data into table

INSERT INTO contacts_table (id,name,email) VALUES(2,"John","John83@incredigeek.com");

List one row in table

SELECT * FROM table_name LIMIT 1;

Delete Row in Table

DELETE FROM table_name WHERE row_name=data_to_delete;

Delete all “users” from a WordPress database that do not contain admin in the username.

DELETE FROM `wp-users` WHERE user_login NOT LIKE "%admin%"

Add Auto Increment to Table

ALTER TABLE  `table_name` ADD  `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;

Create table with Date and Time timestamp

CREATE TABLE table_name (id INT, timeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP);

Show MySQL Users

select * from mysql.users;

Create MySQL User

GRANT ALL ON mysqldb.* TO username@localhost IDENTIFIED BY 'password';

Delete MySQL user

DROP USER 'username'@'localhost';

Add Column to the end of MySQL Table

ALTER TABLE mysqltable ADD email VARCHAR(60);

Add Column to the begging of MySQL Table

ALTER TABLE mysqltable ADD email VARCHAR(60) FIRST;

Insert Column after Specific Column in MySQL Table

ALTER TABLE mysqltable ADD email VARCHAR(60) AFTER columnname;