Add Non Sudoer Account to the Sudoer User Group

Sunday, 29. July 2012

If you ever wanted to add a new non-sudoer account to sudoer group, here is the simple steps to help you achieve just that.

Log in to your server/machine as root.

Navigate and open the sudoers file

nano /etc/sudoers #Use your preferred editor
 
#OR AS RECOMMENDED:
 
sudo visudo #Better as it checks for syntax errors.

Once the file is opened, navigate to the bottom of the file until you find the line like this below..

## Allow root to run any commands anywhere
root    ALL=(ALL)	ALL
..

Underneath this last line, add the account details you want make sudoer

useraccount ALL=(ALL)	NOPASSWD:ALL

NOTE the “NOPASSWD”.
This simply allows the new account to use/call the sudo commands without having to type the password.

Save the file, and restart your terminal session again.

** NOTE
Some time you may have to delete the following entry in order to make things working.. do this if the first steps still gives you the same error.

Scroll right at the bottom and look for this line:

#includedir /etc/sudoers.d

Remove it! Restart session and you should be OK!

Enjoy!

Remove Everything After Character Pattern Preg_Replace Regex expression

Monday, 23. July 2012

A little snippet that simply removes everything after a matched pattern using preg_replace regular expression.

Example

# remove everything after TEL: symbol
$address = "John Scott, Leeds, UK. TEL: 000111-234 345";
# new address
$new_address = preg_replace('/TEL:.*/i', '', $address, -1, $count);

Enjoy!

Apply Zend Security Patch To Magento Installation Via SSH

Thursday, 19. July 2012

Here is a nice and quick way to apply the Zend Security Patch to your Magento install via SSH (command terminal)

Note:
Patch is only necessary for the versions less than CE Magento 1.7.0.2
This solution is for Magento CE 1.5.0.0 to 1.7.0.1. Change the patch file to match your version. More info here:
important-security-update-zend-platform-vulnerability

Command Line script

wget http://www.magentocommerce.com/downloads/assets/1.7.0.2/CE_1.5.0.0-1.7.0.1.patch && patch -p0 -i CE_1.5.0.0-1.7.0.1.patch

Enjoy!