Monday, October 8, 2012

Fixing the Windows MBR using a Ubuntu Live CD or USB

The method to fix the MBR is:
1. Boot the machine using the Live USB/CD.
2. Install lilo
sudo apt-get install lilo

3. Fix the MBR using lilo using the command:
sudo lilo -M /dev/sda mbr
Reboot your system, Bingo works like charm!!!!

Monday, January 23, 2012

How To Disable Linux USB Drive

For security’s sake, IT auditor and security team normally request system administrator to disable or turn off USB mass storage device to minimize risk of data theft.

Now, let’s see how to disable USB mass storage device on Redhat Linux (RHEL 5.2 particularly; should be applicable to other Linux distributions too):
  1. Login as root,
     
  2. Open /etc/modprobe.d/no-usb for edit (create this file if it’s not exists),
     
  3. Append this line to the no-usb file (in step-2) and save it:
    install usb-storage /bin/true 

Reboot server to enforce change. To confirm USB mass storage support has disabled, just execute lsmod | grep -i usb or try plug in USB drive to confirm.

Tuesday, December 27, 2011

Using Iptables to JBoss run as non-root.

Configuring an iptables firewall on Ubuntu Hardy Heron server

Introduction

In this article we'll set up a simple firewall on an Ubuntu 8.04 server. The firewall has two purposes:

  1. Block all ports except the few which are used to provide services
  2. Map incoming port 80 to port 8080, so that our Java web servers can run as non-root

And all this must be done on a remote server, so we have to do it in a way that doesn't lock us out.

Wednesday, June 22, 2011

HowTo: Read Your SD card with your UBUNTU

"Ubuntu doesn't detect SD Card automatically, Here’s how to get it working, so that it will auto mount any SD card inserted into the slot."

Imp: Make sure your is detected, Get the details on Card Reader.
$ lspci | grep Card

Do the following things.
1. Backup the file /etc/modules
sudo cp /etc/modules /etc/modules.bak

Tuesday, June 14, 2011

How To Remove Windows Genuine Authentication

Have you updated your copy of Windows and received the "This copy of Windows is not genuine" notification. Have you ever wondered how to get rid of it?
The Windows Genuine Advantage notification checks if you have a genuine copy of Windows registered to that computer. It allows you to update your computer with the Windows updates. If you have installed it, and you do not have a genuine copy of Windows XP installed, then you may notice an icon at the bottom of your window before you Login. It will make you wait three seconds before allowing you to login.

Oracle Password Reset

From Oracle FAQ
ORAPWD is a utility used to create a password file for an Oracle Database.
Run orapwd utility before:
    * setting REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE|SHARED
    * Grant OSDBA/OSOPER to users
Check V$PWFILE_USERS to see who was granted OSDBA/OSOPER access.

Create a new password file:
orapwd file=orapwSID password=oracle entries=5
If the password file already exists:
orapwd file=orapwSID password=oracle entries=5 FORCE=Y
The FORCE parameter is available starting from Oracle 10g.

Friday, May 27, 2011

Howto install Bugzilla on Linux

Howto install Bugzilla on Ubuntu.

Assumptions: 
Ubuntu is already installed and configured on your target machine.
The machine is connected to the Internet you can browse the World Wide Web.
Here are the main steps:
  1. Install Per l(5.8.1 or above)
  2. Install MySQL
  3. Install Apache2
  4. Install Bugzilla 3.2
  5. Install Perl modules
  6. Bugzilla using apache

Thursday, December 23, 2010

How to restore Grub from a live Ubuntu cd.

How to restore Grub from a live Ubuntu cd.

Boot into the live Ubuntu cd. This can be the live installer cd or the older live session Ubuntu cds.
When you get to the desktop open a terminal and enter.

Code:
sudo grub
This will get you a "grub>" prompt (i.e. the grub shell). At grub>. enter these commands
Code:
find /boot/grub/stage1
This will return a location. If you have more than one, select the installation that you want to provide the grub files.
Next, THIS IS IMPORTANT, whatever was returned for the find command use it in the next line (you are still at grub>. when you enter the next 3 commands)

Code:
root (hd?,?)
Again use the value from the find command i.e. if find returned (hd0,1) then you would enter root (hd0,1)
Next enter the command to install grub to the mbr

Code:
setup (hd0)
Finally exit the grub shell
Code:
quit
That is it. Grub will be installed to the mbr.
When you reboot, you will have the grub menu at startup.

Thursday, November 18, 2010

CentOS / Redhat: Create Software RAID 1 Array

Recently, I've added another 73GB SAS disk to my Linux server after the installation. I've 30GB empty partition on old hard disk. How do I convert old /dev/sda3 and new /dev/sdb1 (both 30GB) into RAID 1 to improve NFS server speed and reliability?

RAID devices are virtual devices created from two or more real block devices. Linux supports RAID1 and other levels. You need to have same size partition on both disks i.e. on second disk create partitions exactly the same size as those on the first disk, and set the type as fd (Linux raid autodetect). You need to use the following commands to create RAID 1.

Find Command Exclude Directories From Search Pattern

How do I exclude certain directories while using the find command under UNIX or Linux operating systems?

You can use the find command as follows to find all directories except tmp directory:
find /path/to/dest -type d \( ! -name tmp \) -print
Find all directories except tmp and cache:
find /path/to/dest -type d \( ! -name tmp \) -o \( ! -name cache \) -print
The -prune option make sure that you do not descend into directory:
find /path/to/dest -type d \( ! -name tmp \) -o \( ! -name cache -prune \) -print
You can find all *.pl find except in tmp and root directory, enter:
find /  \( ! -name tmp \) -o \( ! -name root -prune \)  -name "*.pl" -print


Monday, November 8, 2010

Postfix masquerading or changing outgoing SMTP email or mail address

Address rewriting allows changing outgoing email ID or domain name itself. This is good for hiding internal user names. For example:
SMTP user: tom-01
EMAIL ID: tom@domain.com
Server name: server01.hosting.com


However when tom-01 send an email from shell prompt or using php it looks like it was send from tom-01@server01.hosting.com
In some cases internal hosts have no valid Internet domain name, and instead use a name such as localdomain.local or something else. This can be a problem when you want to send mail over the Internet, because many mail servers reject mail addresses with invalid domain names to avoid spam.
Postfix MTA offers smtp_generic_maps parameter. You can specify lookup tables that replace local mail addresses by valid Internet addresses when mail leaves the machine via SMTP.


Open your main.cf file
# vi /etc/postfix/main.cf
Append following parameter
smtp_generic_maps = hash:/etc/postfix/generic
Save and close the file. Open /etc/postfix/generic file:
# vi /etc/postfix/generic
Make sure tom-01@server01.hosting.com change to tom@domain.com
tom-01@server01.hosting.com tom@domain.com
Save and close the file. Create or update generic postfix table:
# postmap /etc/postfix/generic
Restart postfix:
# /etc/init.d/postfix restart
When mail is sent to a remote host via SMTP this replaces tom-01@server01.hosting.com by tom@domain.com mail address.

You can use this trick to replace address with your ISP address if you are connected via local SMTP.

Friday, October 22, 2010

Howto: Linux kill and logout users

There is a package called procps. It includes various useful (read as nifty) utilities. One of such utility is skill which is responsible to send a signal to users and process such as:
  • Halt user terminal
  • Kill user and logout
Also note that these are utilities to browse the /proc filesystem, which is not a real file system but a way for the kernel to provide information about the status of entries in its process table.

Task: How to halt/stop user called didi

Type the skill command as follows:
# skill -STOP -u didi
You muse be root to stop other users.

Task: How to resume already halted user called didi

Send CONT single to user didi, type the following command:
# skill -CONT -u didi

Task: How to kill and logout user called didi

You can send KILL single, type the following command:
# skill -KILL -u didi

Task: Kill and logout all users

The ultimate command to kill and logout all users, type the following command:
# skill -KILL -v /dev/pts/*



Please note that send users warning message or logout notice using wall command to avoid data loss.

Tuesday, October 19, 2010

How to configure kannel --SMS & WAP gateway

Kannel is an open source WAP  and SMS gateway.  With the help of kannel ,one can connect with the operators SMSC to send and receive SMS.

Kannel  also operates as Push Proxy Gateway , or PPG, making possible for content servers to send data to the phones.

HowTo: Reset Mysql root password

We can reset the Mysql database server password with following 5 easy steps.


1) Stop the MySQL server demon process.
#/etc/init.d/mysql stop
2) Start the MySQL (mysql) server/daemon process with the --skip-grant-tables option so that it will not prompt for password
#mysqld_safe - -skip-grant-tables &
3) Connect to mysql server as the root user
#mysql -u root
4) Setup new root password
mysql> use mysql;
mysql> update user set password=PASSWORD("anypassword") where User='root';
mysql> flush privileges;
mysql> quit
5) Exit and restart MySQL server
/etc/init.d/mysql stop
/etc/init.d/mysql start


Linux: Seach & Replace String in any/multiple files

Search & Replace in multiple files:
perl -n -i -e 's/originalword/newword/i; print;' *.txt
Where *.txt means all the files in the directory having extension .txt.
Search & Rrplace in single file:
a) sed -i s/originalword/newword/g filename.txt
b) replace originalword newword <original.txt >new.txt
Replace command always creates new file with new replaced string.