November 20, 2008

Adding A User In MySQL

Do you need to quickly add a specific user with access to only a certain table? Issue this command as a root or admin user:

GRANT ALL ON testdb.* TO 'testuser'@'localhost' IDENTIFIED BY 'pass1';

You can also limit user’s privileges to specific ip addresses or domains in case you need to access your databases from a different host.

GRANT ALL ON *.* TO 'testuser'@'remote.farmsoftstudios.com' IDENTIFIED BY 'pass1';

November 17, 2008

Find The Version Of CentOS/RHEL Without Rebooting

Want to know if you have CentOS 4.5 or 5.0? Issue this command:
cat /etc/redhat-release
That file contains the needed version information.

[root@localhost ~]# cat /etc/redhat-release
CentOS release 5 (Final)

October 10, 2008

Mounting a Samba (SMB) Share in CentOS

Need to mount a samba share on your CentOS server from the command line?

Create a directory on the root:
mkdir /sharename

Then mount the share:

mount -t cifs //<servername>/<sharename> /sharename

if you type df -h you should see that your share is now mounted on the mountpoint that you created earlier.

August 20, 2008

Blocking a certain IP address with iptables

To block an ip address from accessing your linux box, you can use the following iptables rule:
iptables -A INPUT -s 222.124.24.131 -j DROP

If you just need to block a certain port (i.e. port 22 for SSH), you would do it like so:

iptables -A INPUT -s 222.124.24.131 -p tcp --destination-port 22 -j DROP

July 9, 2008

Installing VMWare Tools in CentOS 5.x

Notice: This involves some command-line editing, and could potentially cause damage to your system.  Do not follow these commands if you don’t understand what they do.  I am not liable for any damages to your property.

If you’re like me, you’ve doubtless struggled with installing ESX 2.5’s VMWare Tools in the later releases of CentOS (v5.x). There is some sort of bug in the vmware-config-tools.pl script that gets installed by the main vmware-tools-installer, and tells you that your kernel-headers do not match your running kernel.

  1. From VMware ESX VirtualCenter: go to VM> Install VMware Tools
  2. From the VM: mount the virtual cd drive
    mount /dev/cdrom /mnt/
  3. Extract VMware Tools to /tmp/
    tar -C /tmp -zxvf /mnt/VMwareTools-5.6.3-12345.tar.gz
  4. Unmount the virtual cd drive
    umount /mnt
  5. Now run the installer
    cd /tmp/vmware-tools-distrib
    ./vmware-install.pl
  6. When asked Do you want to run vmware-config-tools.pl?, answer “No”.

After following the above instructions, you can then proceed to the following steps. Just be sure that your kernel headers *do* actually match before disabling the check below.  You can check that by comparing the results of these two commands:
uname -r # running kernel
rpm -q kernel-devel # installed kernel headers

If you open the file in nano (or gEdit if you have the GUI installed), search (ctrl-w in nano) for  ”load into the running kernel.” Go up six lines from that where you should see this if statement:

if (not ($header_version_uts eq $gSystem{'uts_release'})) {

Take the “not” out, so that the line looks like this:

if (($header_version_uts eq $gSystem{'uts_release'})) {

Save the file, and re-run it, violá! It’s installed.

Thanks to