Linux

...now browsing by category

 

Linux bond or team multiple network interfaces cards (NICs) into single bonded interface

Friday, September 4th, 2009

Finally today I had implemented NIC bonding (bind two NICs so that it works as a single device for load balancing and/or fault tolerance).  The idea here is to improve performance by pumping out more data from both NICs via NIC bonding/teaming

This box act as datastore server for my test VMware environment.  Each virtual machine is run on top of an ESXi box, and the storage is stored on this server.  Each virtual disk is anywhere between 15GB and 50GB.  Since the virtual disks are stored on a separate piece of hardware from the virtualizing hardware, we must have a high level of throughput for our network traffic.  I am using CentOS 5.3 for the purpose of this document.  This process should readily work for most if not all Red Hat based distro’s.  Click to continue »

Funny Linux Commands

Monday, February 23rd, 2009

Hope you enjoy these humorous commands. Go ahead and try them, they really do work.

% cat "food in cans"
cat: can't open food in cans

% nice man woman
No manual entry for woman.

% "How would you rate Quayle's incompetence?
Unmatched ".

% Unmatched ".
Unmatched ".

% [Where is Jimmy Hoffa?
Missing ].

% ^How did the sex change operation go?^
Modifier failed.

% If I had a ( for every $ the Congress spent, what would I have?
Too many ('s.

% make love
Make: Don't know how to make love. Stop.

% sleep with me
bad character

% got a light?
No match.

% man: why did you get a divorce?
man:: Too many arguments.

% !:say, what is saccharine?
Bad substitute.

% %blow
%blow: No such job.

% \(-
(-: Command not found.

$ PATH=pretending! /usr/ucb/which sense
no sense in pretending!

$ drink matter
matter: cannot create

Howto: Mount NTFS Partition in Read-Write mode in Linux

Saturday, February 21st, 2009

If you are having issues mounting your ntfs partition you will need to add a couple of rpms to make it happen.

You will need these rpm’s installed to make it happen:

fuse, fuse-ntfs-3g, dkms, dkms-fuse

Before installing these you need to install dag’s rpm repo.  You can download the rpm for CentOS 5.* and RHEL 5.* here

Tip: Use wget from the directory you want to put the file in to download it so you don’t have to download locally then upload to your server.

install the rpm by issuing:

# rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm

Once rpmforge has been added to yum, install the ntfs rpm’s by issuing:

# yum install fuse fuse-ntfs-3g dkms dkms-fuse

That will install all the needed software to mount your NTFS volume in rw mode.

next find where the NTFS partition is:

# fdisk -l | grep -i ntfs
/dev/sdd1   *           1       60800   488375968+   7  HPFS/NTFS

Now that we know where the NTFS partition is, lets create a mount point.
# mkdir /mnt/ntfs

now lets mount it up:
# mount -t ntfs-3g /dev/sdd1 /mnt/ntfs

That should have your ntfs partition mounted to /mnt/ntfs

Change to the directory and list the contents:
# cd /mnt/ntfs
# ls

Mount iso in Linux

Tuesday, February 10th, 2009

An ISO image is an archive file (disk image) of an optical disc using a conventional ISO (International Organization for Standardization) format. ISO image files typically have a file extension of .ISO. The name “ISO” is taken from the ISO 9660 file system used with CD-ROM media, but an ISO image can also contain UDF file system because UDF is backward-compatible to ISO 9660.

You can mount an ISO images via the loop device under Linux. It is possible to specify transfer functions (for encryption/decryption or other purposes) using loop device.

But, how do you mount an ISO image under Linux? You need to use mount command as follows:

Procedure to mount ISO images under Linux

1) You must login as a root user, if not root user then switch to root user using following command:
$ su -

2) Create the directory i.e. mount point:
# mkdir -p /mnt/disk

3) Use mount command as follows to mount iso file called disk1.iso:
# mount -o loop disk1.iso /mnt/disk

4) Change directory to list files stored inside an ISO image:
# cd /mnt/disk
# ls -l

More about loop device

A loop device is a pseudo-device that makes a file accessible as a block device. Loop devices are often used for CD ISO images and floppy disc images. Mounting a file containing a filesystem via such a loop mount makes the files within that filesystem accessible. They appear in the mount point directory using above commands.

Linux creating CD-ROM ISO image

Monday, December 22nd, 2008

dd is a perfect tool for copy a file, converting and formatting according to the operands. It can create exact CD-ROM ISO image.

This is useful for making backup as well as for hard drive installations require a working the use of ISO images.

How do I use dd command to create an ISO image?

Put CD into CDROM

Do not mount CD. Verify if cd is mounted or not with mount command:

# mount

If cd was mouted automatically unmout it with umount command:

# umount /dev/cdrom

OR

# umount /mnt/cdrom

Create CD-ROM ISO image with dd command:

# dd if=/dev/cdrom of=/tmp/cdimg1.iso

Where,

  • if=/dev/cdrom: Read from /dev/cdrom (raw format)
  • of=/tmp/cdimg1.iso: write to FILE cdimg1.iso i.e. create an ISO image

Now you can use cdimg1.iso for hard disk installation or as a backup copy of cd. Please note that dd command is standard UNIX command and you should able to create backup/iso image under any UNIX like operating system.

Stop Bashing LINUX!

Friday, December 12th, 2008

I was sent this link today…
http://www.msnbc.msn.com/id/28039226/?pg=7#Tech_JerkGadgets

This is my response:
Linus is my homeboy. And yes, my mastery does excuse my “neck-beard”

I’m sick of how people complain about how hard Linux is. windows is just as hard… it’s just that people put forth the effort to learn it because “That’s what everyone uses”. They know windows and are comfortable with it and therefore Linux is too hard. OK, Linux may be a bit harder, but when it runs it runs… it doesn’t crap out for some unapparent reason like windows. it doesn’t get attacked by “In the wild” viruses. The only thing attacking it is script kiddies that think they’re hackers using a windows box. 99.99% of those attacks a so far from unsuccessful it’s ridiculous… the other 0.11% is an actual person that knows what they’re doing … probably using some attack application they wrote on a UNIX based system in perl, python or C.

if windows is so great, why is it that all the banking institutions run UNIX based servers for their highly sensitive transactions? why is it that the military servers run UNIX based servers? why is it that all your big phone systems have a UNIX based cluster under it? Wait they don’t I know of a particular one that was written on windows server 2003… and it crashes ALL the time, and they’re always chasing their tails trying to figure out why. at least Ma Bell knows better.

If UNIX/Linux breaks it’s because someone did something wrong or a piece of hardware actually failed and needs to be replaced… it doesn’t break “Just because it needs a reboot”.

Installing and configuring MySQL on Linux

Friday, December 5th, 2008

I will be doing this on a Red Hat based distro, but should be very similar on a Debian or bsd style box.

First install mysql and mysql-server:
yum install mysql mysql-server

After the install has completed, start mysqld:
/etc/init.d/mysqld start

After that you need to login and set a root password. (It is BLANK by default)
mysqladmin -u root password 'new-password'

I would recommend changing ‘new-password’ to something you are not using anywhere else and not the one you are planning on using as the actual root password since this command can be viewed in the bash history and anyone with access to your box can read your shell history.

The next step is to login to the console and change it to what you want it to actually be. This step will not record the password in the shell history.

Login to mysql with the following command:
mysql -h localhost -u root -p

Don’t put the password after -p, if you do it will be recorded in the shell history. If you leave off the -p it will error saying no password used. Enter the command as above and it will prompt you for the password.

Now lets update the password:
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('new-password') WHERE user='root';
mysql> FLUSH PRIVILEGES;

Now you can either go forth and set other user accounts from here or simply type ‘exit’ to exit the command line interface. If you have installed phpmyadmin or mysqllcc, or any other of the mysql admin tools, you may also go now and use those to do your db administration.

Fix for “Metadata file does not match checksum” error

Monday, November 24th, 2008

When running yum, you get the error:

Metadata file does not match checksum


Run:

yum clean all

host is not allowed to connect to this mysql server — Resolved

Wednesday, November 5th, 2008

When setting up a new mysql server, if you want to manage it from another machine, you will have to grant that machine access.  If you don’t, you may get an error that says: “host is not allowed to connect to this mysql server“.  This is how you fix it:

Log in to mysql on the mysql server:

[root@mysql-server nss]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 118
Server version: 5.0.45 Source distribution

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

Grant permissions for root to connect to this server from your management machine. You can replace hostname with the IP Address if you’d like.
mysql> GRANT ALL PRIVILEGES ON *.* TO root@'hostname' IDENTIFIED BY 'root-passwd-goes-here' ;
Query OK, 0 rows affected (0.00 sec)

We’re all done so exit:
mysql> exit
Bye

Linux User Accounting Tools

Thursday, October 30th, 2008

Here is a list of commands you can use to get data about user logins:

who Shows a listing of currently logged-in users.
w Shows who is logged on and what they are doing.
last Shows a list of last logged-in users, including login time, logout time, login IP address, etc.
lastb Same as last, except that by default it shows a log of the file /var/log/btmp, which contains all the bad login attempts.
lastlog This command reports data maintained in /var/log/lastlog, which is a record of the last time a user logged in.
ac Prints out the connect time in hours on a per-user basis or daily basis etc. This command reads /var/log/wtmp.

dump-utmp
  Converts raw data from /var/run/utmp or  /var/log/wtmp into ASCII-parsable format.
Also check the /var/log/messages, /var/log/secure, and /var/log/syslog files.