Monday, December 12, 2011

How to change Network Interface Speed in Linux?


Network interface speed can be changed using the ethtool command.

Display ethernet card settings:

[root@localhost ~]# ethtool eth0
Settings for eth0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                        
  100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Advertised auto-negotiation: Yes
        Speed: 10Mb/s
        Duplex: Half
        Port: MII
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: pumbg
        Wake-on: g
        Current message level: 0x00000033 (51)
        Link detected: yes


To Change the Network Speed to Duplex as below

# ethtool -s eth0 autoneg off speed 100 duplex full

Friday, December 2, 2011

How to fix Corrupt Yum Auth Cache?


How to fix the corrupted  pickle yum credentials error as below?

# yum update
Loading "rhnplugin" plugin
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in ?
    yummain.main(sys.argv[1:])
  File "/usr/share/yum-cli/yummain.py", line 85, in main
    base.getOptionsConfig(args)
  File "/usr/share/yum-cli/cli.py", line 163, in getOptionsConfig
    disabled_plugins=self.optparser._splitArg(opts.disableplugins))
  File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 183, in _getConfig
    self.plugins.run('init')
  File "/usr/lib/python2.4/site-packages/yum/plugins.py", line 169, in run
    func(conduitcls(self, self.base, conf, **kwargs))
  File "/usr/lib/yum-plugins/rhnplugin.py", line 110, in init_hook
    login_info = up2dateAuth.getLoginInfo()
  File "/usr/share/rhn/up2date_client/up2dateAuth.py", line 211, in getLoginInfo
    login()
  File "/usr/share/rhn/up2date_client/up2dateAuth.py", line 159, in login
    if readCachedLogin():
  File "/usr/share/rhn/up2date_client/up2dateAuth.py", line 120, in readCachedLogin
    data = pickle.load(pcklAuth)
  File "/usr/lib64/python2.4/pickle.py", line 1390, in load
    return Unpickler(file).load()
  File "/usr/lib64/python2.4/pickle.py", line 872, in load
    dispatch[key](self)
  File "/usr/lib64/python2.4/pickle.py", line 894, in load_eof
    raise EOFError
EOFError

It has been fixed by removing the loginAuth.pkl as below.

# rm /var/spool/up2date/loginAuth.pkl

Friday, November 18, 2011

Redis Installation in Linux

     Redis is a open source, advanced key-value store, and is intended as a datastore solution for applications where performance and flexibility are more critical than persistence and absolute data integrity. Installation of redis is very simple.

#cd /usr/src/
#wget http://redis.googlecode.com/files/redis-2.4.2.tar.gz
#tar xzf redis-2.4.2.tar.gz
#cd redis-2.4.2
#make

The binaries that are now compiled are available in the src directory. You have to create an soft link of it as

#ln -s src/redis-server /bin/redis-server
#ln -s src/redis-cli /bin/redis-cli

Start Redis Server as

#redis-server

Now, You can interact with Redis using the built-in client:

#redis-cli
redis> set foo bar
OK
redis> get foo
"bar"

Thursday, November 17, 2011

Installation of OAuth support in PHP of Linux

  OAuth is an authorization protocol built on top of HTTP which allows applications to securely access data without having to store usernames and passwords. And the installion procedure as follow.

#cd /usr/src/
#wget http://pecl.php.net/get/oauth-1.2.2.tgz
#tar jxvf oauth-1.2.2.tgz
#cd oauth-1.2.2
#phpize
#CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ./configure
#make && make install

After installing the OAuth add the extension in php.ini file.

#vim /etc/php.ini

Append the OAuth extension as

extension=oauth.so

Restart apache service to take effect of php.ini

/etc/init.d/httpd restart

Now, You can see the OAuth module in php by running the below command

#php -m | grep oauth

FFMPEG-PHP Installation in Linux

      ffmpeg-php is an extension for PHP that adds an easy to use, object-oriented API for accessing and retrieving information from video and audio files. And the installation procedure as follow.

#cd /usr/src/
#wget http://garr.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.6.0.tbz2
#tar jxvf ffmpeg-php-0.6.0.tbz2
#cd ffmpeg-php-0.6.0
#phpize
#./configure
#make; make install

After installing the ffmpeg-php add the extension in php.ini file.

#vim /etc/php.ini

Append the ffmpeg-php extension as

extension=ffmpeg.so

Restart apache service to take effect of php.ini

#/etc/init.d/httpd restart

Now, You can see the ffmpeg module in php by running the below command

#php -m | grep ffmpeg

Tuesday, November 15, 2011

RED5 Server Installation in Linux

         RED5 is open source flash server written in java supports streaming audio/video, recording client streams, shared objects, live stream publishing etc. Here i have describe the procedure for installing Red5 in Linux.

1.Java Installation:

Installation in RPM based Linux such as fedora, centos, redhat :

#yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel

Installation in Debian based Linux  such as Debian, Ubuntu, Kubuntu:

#apt-get install java-package

2.Apache Ant and IVY Installation:

#cd /usr/local/
#wget http://mirrors.isu.net.sa/pub/apache//ant/binaries/apache-ant-1.8.2-bin.tar.bz2
#tar -jxvf apache-ant-1.8.2-bin.tar.bz2
#ln -s apache-ant-1.8.2 ant

#svn co https://svn.apache.org/repos/asf/ant/ivy/core/trunk ivy
#cd ivy
#/usr/local/ant/bin/ant jar
#cp build/artifact/jars/ivy.jar ../ant/lib/

3.REd5 Installation:

#cd /usr/local
#svn checkout http://red5.googlecode.com/svn/java/server/trunk/ red5
#cd red5
#/usr/local/ant/bin/ant prepare
#/usr/local/ant/bin/ant dist
#cp -r dist/conf .
#./red5.sh &

Once you start the red5 server, you can check the Red5 Installation in  the browser using the url as below.

  http://yourip:5080

Thursday, November 10, 2011

What is TTY and PTS in Unix


TTY :

  Teletypewriter originally and now also means any terminal on Linux/Unix systems. It also means any serial port on Unix/Linux systems.

PTS :

 Stands for pseudo terminal slave.

  Main difference between TTY and PTS is the type of connection to the computer. TTY ports are direct connections to the computer such as a keyboard/mouse or a serial connection to the device. PTS connections are SSH connections or telnet connections. All of these connections can connect to a shell which will allow you to issue commands to the computer.

Tuesday, October 18, 2011

Debian or Ubuntu Linux Runlevel Startup Applications with sysv-rc-conf

 sysv-rc-conf is an runlevel configuriation tools just like chkconfig in redhat.

Install sysv-rc-conf :

root@debian:/home/mughil#sudo apt-get install sysv-rc-conf

Run sysv-rc-conf and just follow on screen instructions:

root@debian:/home/mughil#sysv-rc-conf

Description :


             sysv-rc-conf gives an easy to use interface for managing "/etc/rc{run‐   level}.d/" symlinks. The interface comes in two different flavors, one that simply allows turning services on or off and another that allows for more fine tuned management of the symlinks. It's a replacement for programs like ntsysv(8) or rcconf(8).

Tuesday, October 4, 2011

How To install cassandra in Centos 5:

    Here i have displayed the procedure for installing cassandra in centos 5.

First,Install the Necessary Modules needs for the server to support cassandra as follow

#yum -y install gcc-c++ make cmake python-devel bzip2-devel zlib-devel log4cpp-devel git git-core cronolog google-perftools-devel

#yum -y install readline-devel ncurses-devel libtool autoconf expat libevent-devel flex byacc expat-devel   

Perl Modules for Thrift Install :

#yum -y install perl-Bit-Vector perl-Class-Accessor

I have used the latest JDK from SUN.

Download latest SUN JDK from the link. http://www.oracle.com/technetwork/java/javase/downloads/index.html and install it.

#./jdk-6u25-linux-i586-rpm.bin\?e\=1304248293\&h\=560a21a4ea1c9896bcd1df3e02a4520e

Next Download the latest Cassandra version from the link. http://cassandra.apache.org/download/

Here i have used cassandra-0.8 for installation.

#wget http://apache.cyberuse.com//cassandra/0.8.6/apache-cassandra-0.8.6-bin.tar.gz

#tar -zxvf  apache-cassandra-0.8.6-bin.tar.gz

#cp -rf apache-cassandra-0.8.6 /usr/local/cassandra

#ln -s /usr/local/cassandra/conf/ /etc/cassaandra

Installing JNA as follow:

#wget https://github.com/twall/jna/raw/3.3.0/jnalib/dist/jna.jar --no-check-certificate

#chmod 755 jna.jar; cp -rf jna.jar /usr/local/cassandra/lib/.

Installing MX4J as follow:

#wget http://downloads.sourceforge.net/project/mx4j/MX4J%20Binary/3.0.2/mx4j-3.0.2.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmx4j%2Ffiles%2FMX4J%2520Binary%2F3.0.2%2F&ts=1314263784&use_mirror=freefr

#tar -zxvf mx4j-3.0.2.tar.gz

#cd mx4j-3.0.2/lib/ 

#chmod 755 mx4j.jar; cp -rf mx4j.jar /usr/local/cassandra/lib/.

After completing the cassandra installation , then start it as.

#/usr/local/cassandra/bin/cassandra -f &

Wednesday, August 17, 2011

File Backup Commands

   Here the list of commands which are normally used in creation of file backup.

bzip2             A block-sorting file compressor.
cdrecord       Record audio or data Compact Disks from a master.
dd                 Convert and copy a file
fdformat       Low-level formats a floppy disk.
gpg               Encrypt and decrypt data.
gzip               Compress or expand files.
mcopy          Copy MSDOS files to/from UNIX.
mdir              Display an MSDOS directory.
mformat       Add an MSDOS file system to a low-level formatted floppy disk.
mkbootdisk   Creates a stand-alone boot floppy for the running system.
mount           Mount a file system (integrate it with the current file system     
                     by connecting it to a mount point).
rsync             Synchronize directories.
tar                 Tape archiving utility, also used for making archives on disk
                     instead of on tape.
umount         Unmount file systems.

Sunday, August 7, 2011

How to Set and Reset Mysql Root Password

    MySQL root password is the essential task for securing DB. Here i have given some of the ways to set and reset the root password.

1.To set root password for first time:

root@debian:/home/mughil# mysqladmin -u root password NEWPASSWORD

2.To change or update the password:

root@debian:/home/mughil# mysqladmin -u root 'OLDPASSWORD' password 'NEWPASSWORD'

3.To change mysql password for other user:

root@debian:/home/mughil# mysqladmin -u user 'OLDPASSWORD' password 'NEWPASSWORD';

        However, If you forget the root password and login into mysql without username and password to reset the password as follow.

1.First you have to ensure whether mysql is stopped or not:

root@debian:/home/mughil# /etc/init.d/mysql stop
Stopping MySQL database server: mysqld.

2.After the mysql is stopped, you have to start in safe mode:

root@debian:/home/mughil# mysqld_safe --skip-grant-tables &

3.You can login into the mysql and set the password as follow:

root@debian:/home/mughil# mysql --user=root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.49-3 (Debian)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

mysql> update user set Password=PASSWORD('23534')  WHERE User='root';
Query OK, 3 rows affected (0.08 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)

mysql> exit
Bye

      Now, you just need to stop the server, so that you can go back to running a secure MySQL.









Tuesday, August 2, 2011

How to get Hard-Disk serial number using Hdparm?


Hdparm ( get/set hard disk parameters ) can be used to find hard drive serials. If you have several hard drives installed and if you want to list all the model and serial numbers of the installed drive. You can retrieve them using

# hdparm -I /dev/sd? | grep -E “Number|/dev”

Sunday, July 31, 2011

What is Hardware Virtualisation?

    In an computing world Virtualisation is an creation of virtual ( just like an clone ) version related hardware, desktop, server and network.

Goal Of Virtualisation:
  • Centralize administrative tasks.
  • Optimization.
  • Utilization.
  • Improving scalability and work loads.  
Hardware Virtualisation:

                      Creation of virtual machines in hardware virtualisation is act, just like an real computer with an operating system. Resource executed on the virtualisation is away from the underlying hardware resources.

Types of Hardware Virtualisation:
  • Full virtualisation: Almost complete simulation of the actual hardware to allow software, which typically consists of a guest operating system, to run unmodified
  • Partial virtualisation: Some but not all of the target environment is simulated. Some guest programs, therefore, may need modifications to run in this virtual environment.
  • Paravirtualisation: A hardware environment is not simulated; however, the guest programs are executed in their own isolated domains, as if they are running on a separate system. Guest programs need to be specifically modified to run in this environment.                  

Tuesday, July 26, 2011

How to create database and "grant all" perm for an user

   We can create Database in two way, one is using mysqladmin  and other is using mysql prompt.

Method 1: Using mysqladmin

root@debian:# mysqladmin -u root -v create gnu

Method 2 : Using mysqlprompt

root@debian:/home/mughil# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 112
Server version: 5.1.49-3 (Debian)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database foss;
Query OK, 1 row affected (0.02 sec)

After creating db, we have to assign grant perm to  user on the db.

mysql> grant all on foss.* to mughil@localhost identified by 'mughil';
Query OK, 0 rows affected (0.00 sec)

mysql>quit
Bye

Monday, July 25, 2011

List of Linux Audio Software

    Audio software on the Linux platform is becoming very stable and advanced. Here i have try to provide some of the details of the audio application supported in linux.

Audio Players / Music Managers :

Audacious Semi-lightweight audio player with a WinAmp/XMMS-like skinnable GUI.
Amarok KDE audio player offering a wealth of features, yet intuitive to use.
Banshee Music management and playback software for GNOME.
BMPx Compact media player, the successor to the Beep Media Player.
Exaile Music player aiming to be similar to KDE's Amarok, but for GTK+.
JuK Jukebox and music manager for the KDE desktop.
gmusicbrowser Jukebox for large collections of mp3/ogg/flac/mpc files.
Listen Player which helps you to organize your music collection.
Quod Libet Music management program.
Rhythmbox Integrated music management application, originally inspired by Apple's iTunes.
Songbird Provides a uniquely open approach to Internet digital media network services.

DJ Tools :

Mixxx Digital DJ system, for wave, ogg and mp3 files.
terminatorX Realtime audio synthesizer that allows you to "scratch".

Music Clients for the MPD (Music Player Daemon):

Ario GTK2 client.
GMPC Optimised to work on low end machines and over slow networks.
Sonata Lightweight GTK+ music client.

Recording / Editing :

Audacity Digital audio editor.
Ardour Digital audio workstation program.
Jokosher Simple yet powerful multi-track studio.
Sweep Audio editor and live playback tool.
Traverso DAW Multitrack audio recording and editing program.

Composition & Music Notation :

LilyPond Produce musical scores that are engraved with traditional layout rules.
Rosegarden Sophisticated MIDI (and audio) sequencer and notation editor.
MuseScore Graphical WYSIWYG music score typesetter.

Sequencers :

Breakage Intelligent drum machine designed to play complex, live breakbeat performances.
MusE Qt-based MIDI/audio sequencer.
Qtractor Audio/MIDI multi-track sequencer written in C++ around the Qt4 toolkit.
LMMS Alternative to popular (but commercial) programs like FL Studio, Cubase and Logic.
Hydrogen Advanced drum machine.
Seq24 Loop based MIDI sequencer.

Synthesizers & Samplers :

Fluidsynth Real-time software synthesizer based on the SoundFont 2 specifications.
Bristol Emulation package for a number of different 'classic' synthesisers.
LinuxSampler Professional grade software audio sampler.
SooperLooper Live looping sampler.

Tools :

JAMin State-of-the-art realtime mastering processor.
Kid3 Edit ID3v1 and ID3v2 tags in MP3 files in an efficient way.
Sonic Visualiser Inspect and analyse the contents of music audio files.
Sound Juicer Lean CD ripper using GTK+ and GStreamer.
Streamripper Records shoutcast-compatible streams.

Sound Servers / Daemons :

JACK Low-latency audio server daemon.
MPD Allows remote access for playing music and managing playlists.
PulseAudio Networked sound server project

How To Check Reverse DNS Lookup

       People can remember Domain Name rather than ip-address.For an example www.debian.org than their ip-address 206.12.19.7.There are two types DNS, Forward DNS and Reverse DNS.

Forward DNS : Networks use the Domain Name System to determine the IP address associated with a domain name.


Reverse DNS : Reverse DNS lookup is the inverse process, the resolution of an IP address to its designated domain name.

dig is the command to make the DNS Queries.

root@debian:~# dig +noall +answer debian.org

Output :

debian.org.        3547    IN    A    206.12.19.7
debian.org.        3547    IN    A    128.31.0.51

+noall, +answer option tell the dig command to report only the answer of the DNS query and skip the rest of the output.

Reverse DNS can be checked in two method, one with the -x option passing to the dig command and other host command.

Method 1:

root@debian:~# dig  +noall +answer -x  128.31.0.51

Output :

51.0.31.128.in-addr.arpa. 1745    IN    PTR    senfl.debian.org.


Method 2:

root@debian:~# host  128.31.0.51

Output :

51.0.31.128.in-addr.arpa domain name pointer senfl.debian.org.

Common Uses of Reverse DNS :

1.Anti-spam
2.Network troubleshooting
3.Avoid spammers and phishers using a forward confirmed reverse DNS etc

Thursday, July 21, 2011

How To Check Disk Usage in Linux System

df command will show the overall disk usage of the system.

#df -h

Output:

Filesystem            Size   Used     Avail    Use%    Mounted on
/dev/sda1              39G    35G      2.5G      94%      /
tmpfs                 283M          0    283M        0%      /lib/init/rw
udev                  279M    188K    278M        1%      /dev
tmpfs                 283M    156K    283M       1%      /dev/shm

Some of the options we can pass into the df command is as follow:

        -a, --all
              include dummy file systems
       -B, --block-size=SIZE
              use SIZE-byte blocks
       --total
              produce a grand total
       -h, --human-readable
              print sizes in human readable format (e.g., 1K 234M 2G)
       -H, --si
              likewise, but use powers of 1000 not 1024
       -i,  --inodes
              list inode information instead of block usage
       -k    like --block-size=1K
       -l,  --local
              limit listing to local file systems
       --no-sync
              do not invoke sync before getting usage info (default)
       -P, --portability
              use the POSIX output format
       --sync invoke sync before getting usage info
       -t, --type=TYPE
              limit listing to file systems of type TYPE
       -T, --print-type
              print file system type
       -x, --exclude-type=TYPE
              limit listing to file systems not of type TYPE
       -v     (ignored)


du command is used to estimate the specific usage of file or directory

# du -sch my_ntop_goes_here/

Output:

16M    my_ntop_goes_here/
16M    total

Some of the options we can pass into the du command is

       -a,  --all
               write counts for all files, not just directories
       -B,  --block-size=SIZE
               use SIZE-byte blocks
       -b,  --bytes
               equivalent to `--apparent-size --block-size=1'
       -c,  --total
              produce a grand total
       -D, --dereference-args
              dereference only symlinks that are listed on the command line
       -H    equivalent to --dereference-args (-D)
       -h, --human-readable
              print sizes in human readable format (e.g., 1K 234M 2G)
       --si  like -h, but use powers of 1000 not 1024
       -k    like --block-size=1K
       -l,  --count-links
              count sizes many times if hard linked
       -m   like --block-size=1M
       -L, --dereference
              dereference all symbolic links
       -P, --no-dereference
              don't follow any symbolic links (this is the default)
       -0, --null
              end each output line with 0 byte rather than newline
 

Monday, July 18, 2011

How To Check The Memory Usage in Debian / Fedora System

Free is one the linux command to display the total amount of free and used physical memory and swap memory in the system, as well as the buffers used by the kernel.

Display memory in MB :

$ free -m

Output :
                          total    used    free    shared   buffers    cached
Mem:                   564     495      68              0           67          147
-/+ buffers/cache:            280    283
Swap:                 1101        8   1093

Display total memory in an line:

$ free -mt

Output :
                          total    used    free    shared   buffers    cached
Mem:                   564     495      68              0           67          147
-/+ buffers/cache:            280    283
Swap:                 1101        8   1093
Total:                1666       557   1109

Some of the OPTIONS we can pass in free command as below :

-b Display the amount of memory in bytes.
-c count
Display the result count times. Requires the -s option.
-g Display the amount of memory in gigabytes.
-k Display the amount of memory in kilobytes. This is the default.
-l Show detailed low and high memory statistics.
-m Display the amount of memory in megabytes.
-o Display the output in old format, the only difference being this
option will disable the display of the "buffer adjusted" line.
-s Continuously display the result delay seconds apart. You may
actually specify any floating point number for delay, usleep(3)
is used for microsecond resolution delay times.
-t Display a line showing the column totals.
-V Display version information.

Saturday, July 16, 2011

How to Set the Static IP In Command Line

RED Hat / Fedora Linux :

     Login as root, Change the directory to /etc/sysconfig/network-scripts/

# cd /etc/sysconfig/network-scripts/

      Here you can find the Ethernet configuration file such as ifcfg-eth0, ifcfg-eth1.Using any one of the favorite editor, you can edit or append the Ethernet configuration file.

# vim ifcfg-eth0

Edit/Append as follow:

DEVICE=eth0
BOOTPROTO=static
HWADDR=00:30:48:57:A6:2M
IPADDR=192.168.0.2
NETMASK=255.255.255.0
ONBOOT=yes

     After modification , save and close the file.

To Set Gateway and Hostname :

   Change to the directory /etc/sysconfig/ and edit network file.

#vim network

NETWORKING=yes
HOSTNAME=host.example.com
GATEWAY=192.168.0.1

To Set Nameserver :

    Change the directory /etc/ and edit the resolv.conf file

#vim resolv.conf

search dns-search-path
nameseever dns1.ip-address
nameserver dns2.ip-address

    After updating the ip-address, gateway and the nameserver restart the network service.

# /etc/init.d/network restart

Debian / Ubuntu Linux :


   Main Network Configuration Files is /etc/network/interfaces. Using any one of the favorite editor, you can edit or append the Ethernet configuration file.

#vim /etc/network/interfaces

Edit/Append as follow:

iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254

     After modification , save and close the file

To Set Nameserver :

   Change the directory /etc/ and edit the resolv.conf file

#vim resolv.conf

search dns-search-path
nameseever dns1.ip-address
nameserver dns2.ip-address

    After updating the ip-address, gateway and the nameserver restart the network service.

#/etc/init.d/networking restart