About Me

My photo
Kalyan Kumar Pasupuleti B-Tech(Information Technology). • AWS Certified Solutions Architect - Associate • RedHat Certified Engineer(RHCE) • Directory Services and Authentication Certificate of Expertise(LDAP) • Red Hat SELinux Policy Administration Certificate of Expertise(SELinux) • Network Services Security Certificate of Expertise (Network Services) • RedHat Certified Virtualization Administrator(RHCVA) • Red Hat Certified Security Specialist (RHCSS) Working as Cloud DevOps engineer

Thursday, April 28, 2011

Howto random background images in GDM3 - debian 6


Configure GDM3 to display random images from directory upon login screen.

A way to random background images in GDM3 - Debian 6. Should be applicable to other distributions, the only difference being configuration file paths.

If you know of a simpler approach please let us know.

PRECAUTION: I'm just a newbie customizing a family laptop, this may not work, or slow down or expose your system in ways i do not understand.
Follow procedure at your own risk.


1- Creating PostLogin bash script. #as root

cp /etc/gdm3/PostLogin/Default.sample /etc/gdm3/PostLogin/Default

2- Editing PostLogin bash script, this will take a random image from directory and make it the background image #as root

Add the following to /etc/gdm3/PostLogin/Default and adjust the path to point your images directory.
   
#change background image
dir='/your/image/directory'
file=`/bin/ls -1 "$dir" | sort --random-sort | head -1`
path=`readlink -f "$dir/$file"` # Converts to full path
cp $path /wherever/you/want/background.jpg

3- Create the background image and change permissions for all users to change background image when logging out.

touch /wherever/you/want/background.jpg
chmod 777 /wherever/you/want/background.jpg #do not know if this is necessary

4- Editing GDM3 configuration file #as root

edit /etc/gdm3/greeter.gconf-defaults

Uncomment the following line and change background image path

/desktop/gnome/background/picture_filename      /wherever/you/want/background.jpg

Optionally uncomment:
/desktop/gnome/background/picture_options       zoom

And adjust config file to your likings.

5- Restarting GDM3

invoke-rc.d gdm3 reload

/etc/init.d/gdm3 restart

Tweeting through Terminal (Ubuntu)


This is a short tutorial explaining how to post to Twitter using command-line in Linux, without needing to even open up your web browser.

First, install the curl package:

sudo apt-get install curl

Next, create a script anywhere in your $PATH, for example twitter.sh inside ~/bin, where ~ is your home directory (make sure ~/bin is included in your $PATHvariable, in case echo $PATH doesn't return it, edit~/.bashrc and add a line like this: export PATH=/home/USER/bin/:$PATH).

The script twitter.sh should contain the following:

#!/bin/bash
curl -u USER:PASS -d status="$*" http://twitter.com/statuses/update.xml > /dev/null
echo "Message sent!"

Replace USER and PASS with your Twitter username and password, and then make the script executable:

chmod 755 ~/bin/twitter.sh

And now test it:

twitter.sh Hello, world! This is a test.

So just use it as:

twitter.sh YOUR MESSAGE

Wget


Wget is nice little piece of software that everyone should know. With it you can check site, download from FTP an entire collection of files or a photo gallery. Just open your terminal and these steps

GNU Wget is a free software package for retrieving files using HTTP, HTTPS and FTP, the most widely-used Internet protocols. It is a non-interactive commandline tool, so it may easily be called from scripts, cron jobs, terminals without X-Windows support, etc.
GNU Wget has many features to make retrieving large files or mirroring entire web or FTP sites easy, here are some interesting options.



All these commands must be used from linux terminal.

Basic use download a package knowing its http (or ftp) URL:

wget http://kernel.org/pub/linux/kernel/v2.6/patch-2.6.23.bz2

Using Wget for Recursive Downloads

wget -r http://my.site.todownload.com/

The -r command tells wget to recursively download everything from the listed url.

Using Wget for Recursive Downloads but limit the number of levels to 2

wget -r -l2 http://my.site.todownload.com/

Now the -r does the same as above the -l tells wget to limit to that
number of levels here 2 levels deep (otherwise the defualt is 5)

Using Wget for Recursive Downloads but limit the type of files you want to download

wget -r -A.pdf -R.htm http://my.site.todownload.com/

This one tells wget to do a recursive get and Accept all files with .pdf extension and reject all files with .htm extension

Using Wget for Recursive Downloads from a FTP with authentication

wget -r ftp://username:password@my.site/path/to/download

Here you tell wget to download from FTP with userid and password

Using Wget to check dead link on your site

wget spider -r -o log.txt http://yourdomain.com

In this example we tell Wget to act like a web spider (Wget will
behave as a Web spider, which means that it will not download the
pages, just check that they are there), and put results in the file
log.txt, so you can open it and search for a list of broken links.

Using Wget to download a photo gallery

for i in `seq -w 1 100`; do wget http://www.mysite.com/images/DSCF00$i.jpg; done

In this example we run a cycle that go from 1 to 100 and every time
download a different URL, really useful for quickly download a gallery
with no links.

Finally, I forgot to tell you that wget is also usable by Mac and Windows (requires Cygwin)

Wednesday, April 27, 2011

[How-To] Install yum on CentOS 4??


WARNING: According to eApps policy if you edit any system files manually, they might not support the changes you have made. Use at your own risk.

NOTE: If SQLite is installed in HSPc, do NOT uninstall it after having done this.

SSH into your VPS as root and follow these instructions.

Firstly, create a source directory to work from:

mkdir /usr/local/src/yum
cd /usr/local/src/yum

Then, download the following packages:


wget http://mirror.centos.org/centos/4/apt/i386/RPMS.os/python-urlgrabber-2.9.8-2.noarch.rpm
wget http://mirror.centos.org/centos/4/apt/i386/RPMS.os/python-sqlite-1.1.7-1.2.1.i386.rpm
wget http://mirror.centos.org/centos/4/apt/i386/RPMS.os/python-elementtree-1.2.6-5.el4.centos.i386.rpm
wget http://mirror.centos.org/centos/4/apt/i386/RPMS.os/python-urlgrabber-2.9.8-2.noarch.rpm
wget http://mirror.centos.org/centos/4/apt/i386/RPMS.os/yum-2.4.3-3.el4.centos.noarch.rpm
wget http://mirror.centos.org/centos/4/apt/i386/RPMS.os/sqlite-3.3.6-2.i386.rpm



Now install them:


rpm -Uvh *.rpm


Finally, update your system:


yum -u update


All done! Now if you want to install an application, just run:


yum -y install application


[OPTIONAL] You may also want to delete the source directory:


rm -rf /usr/local/src/yum

How to Install Firefox 4 in Fedora, RHEL and CentOS?


Mozilla Firefox 4 has finally been released after such a long development cycle, when compared to the development of the recent releases of Internet Explorer and Google Chrome.
For those who have been waiting all this time. It can be painful waiting for the new version of Firefox to show up on the default repositories.
Here is a way to install the new Firefox 4 without having to wait,


  • Backup Firefox Settings

  • Take a backup of your current Firefox user profile and settings. Even though it’s generally safe to skip this step, as the settings will stay on the computer even if your uninstall Firefox. It’s always better to be safe then sorry.
    tar cvzf firefox-backup.tar.gz ~/.mozilla


  • Install Third-Party Spot Repository

  • Install the Spot Repository. Third party repositories generally are updated faster then the default repositories. So sometimes third party repositories are needed if you wanted the latest software as soon as they are released.
    su -c 'wget http://repos.fedorapeople.org/repos/spot/firefox4/fedora-firefox4.repo -O /etc/yum.repos.d/fedora-firefox4.repo'


  • Remove Current Firefox Installation (Optional)

  • Remove your current Firefox installation. If you plan on having more then one Firefox installation then you can skip this step.
    su -c 'yum remove firefox'


  • Enable the Repository

  • The repository will need to be enabled before we can use it.
    su -c 'yum –enablerepo fedora-firefox4'
    


  • Install New Firefox 4

  • Install the new Firefox 4 package onto your system and enjoy!!
    su -c 'yum install firefox4'
    
    Screenshot-Firefox web browser - Mozilla Firefox 4
    Share

    Tuesday, April 19, 2011

    LDAP Basics


    Nowdays LDAP is used everywhere for Authentication or crucial information management purpose. In this Article I have tried to explain basics of LDAP and also OpenLDAP basic configuration. Please let me know your queries and comments on it. Thanks.

    LDAP & OpenLDAP

    LDAP - Lightweight Directory Access Protocol.
    OpenLDAP - Server which operates on LDAP for eg. Microsoft AD

    1. Stores & organize information in directory i.e. in hierarchical manner and provides access to it
    2. Eg. Domain Name System. DNS is a most successful implementation of Directory service over Internet

    Directory Structure -
    1. Directory service stores information in Directory Structure. The diagram of Directory structure is called Directory Information Tree.
    2. A Directory is a tree of Entries
    3. An entry is set of attributes
    4. An attribute is has a Name and one or more value
    5. Attributes are Defined in Schema
    6. Each entry has an Unique Identifier i.e. DN

    Five Major Characteristics of Directory Service -
    1. Higly optimized for reads
    2. Information can be stored in Distributed model
    3. Can extend types of information to be stored
    4. Replication
    5. Advance search capabilities

    Difference between Databases and Directory Services
     Many people ask that can we use Database instead of Directory Service

    SN                       Databases                                                 Directory Services

    1.    Information has more writes and reads            More reads only, very less writes
    2.   Transactions, rollbacks,                                    Transactions, rollbacks, write locks      write locks are more important                          are less important
    3.   More Overheads                                               Less Overheads

    What is LDAP ?
    1. Originally created by Tim Howes, Steve Kille and Wingyik Yeong in 1993. Later Tim & Steve improved it and started LDAPv3
    2. Application Protocol for reading & editing directories over an IP network
    3. LDAP is itself a Binary Protocol. Binary Protocol means, a protocol which is expected to read by machine than a human being.
    4. Lightweight Directory Access Protocol
    5. Lightweight in comparison with x.500 Directory Services

    LDAP vs X.500:
    Main difference in LDAP and X.500 is LDAP uses TCP stack and X.500 uses OSI stack. Thats the reason LDAP is lightweight.

    Uses of LDAP:
    • Machine Authentication
    • User/System Groups
    • User Resource Management
    • Address Book
    • Organization Representation
    • Assets Tracking
    • Telephony Information Store
    • Application Configuration Store

    Directory Information Tree:
    LDAP stores information in Directory Structure. Pictorial view of Directory Structure is called Directory Information Tree. See Below Figure:

                                                            dn: dc=example,dc=com

                                                                          |
                                                                          |
                                    -------------------------------------------------------- 
                                    |                                                                         |
                                    |                                                                         |
    dn: ou=groups,dc=example,dc=com                    dn:ou=people,dc=example,dc=com
                                                                                                              |
                                                                                                              |                                         
                                                                      dn: cn=neelesh,ou=people,dc=example,dc=com

    Directory Structure: 
      • A Directory is a tree of Directory Entries
      • An Entry consists of a set of Attributes
      • An Attribute has a Name and one or more values.
      • The attributes are defined in Schemas
      • Each entry has unique Identifier i.e. DN, consists of RDN

    OpenLDAP:
    Please note that in our example we have used OpenLDAP as a LDAP server.
    Please visit www.openldap.org for more details.


    Features of OpenLDAP:
    1. It is open source
    2. Free to use
    3. Simple Authentication and Security Layer (SASL) support
    4. Access Control
    5. Implements LDAPv3

    Components of OpenLDAP:
    1. slapd - OpenLDAP server daemon
    2. slapd.conf  OpenLDAP configuration file
    3. Schemas - To define Attributes
    4. Libraries  Required to slapd. Normally they are under /usr/lib/ldap
    5. Backend - Banckend Database. We use BDB here. Located at /var/lib/ldap
    6. LDIF  LDAP Interchange Format. It is used for Importing and exporting information stored in Directory
    7. LDAPcleint  Used to connect LDAP server and operate it. Eg. ldapsearch, ldapadd, ldapdelete etc.

      slapd
       1. LDAP server daemonBinary
      2. Normally located under /usr/sbin
      3. To invoke you can directly call slapd on bash prompt



         slapd.conf
         I have divided slapd.conf into 4 Parts
         1. Schema Inclusion
         2. Backend DB & Directory Specific
         3. Access Control
         4. Other

         Schemas
          1. Schemas are used to define Attributes
         2. It adds extendibility of LDAP
         3. We can customize or add schemas
         4. Generally Schema files are stored under /etc/ldap/schema

             Schema Files                                                   Description
           core.schema                          OpenLDAP core (required)
           cosine.schema                       Cosine and Internet X.500 (useful)
           inetorgperson.schema           InetOrgPerson (useful)
           misc.schema                          Assorted (experimental)
           nis.schema                             Network Information Services (FYI)
           openldap.schema                   OpenLDAP Project (experimental)


         Libraries or modules
         
         - Generally libraries are stored under /usr/lib/ldap
         - It adds functionality and makes OpenLDAP modular

         Backend DB

         - OpenLDAP uses mainly following 2 embedded databases to store information
                - BDB Berkely DB Transactional Backend
                - HDB Hierarchical variant of BDB
         - DB is stored under /var/lib/ldap

         LDIF
          - LDAP interchange format
         - Collection of entries separated by new line
         - Mapping attribute names to values
         - It is used to import or export information from LDAP directory

         LDAPclient
          - LDAP client is used to connect to LDAP server
         - You can add, edit, delete Directory entries

         Important Terminologies
         - Distinguished Name (DN) & Relative Distinguished Name (RDN)
           DN is like the absolute path between root of File System and file
           RDN is like Filename
           Eg.
           Entry ---- > dn: cn=admin,dc=example,dc=com
           In above entry
           DN is cn=admin,dc=example,dc=com
           RDN is cn=admin

          1. Attributes
             - Attributes are used to store the values
             - Attributes can be one or more values
             - Attributes are defined in Schema Files
             - In LDIF files, Declare Attribute by following way:
                   objectClass: organizationalUnit
             In above example objectClass is Attribute and organizationalUnit is value.

           2. objectClass Attributes
              - Compulsory attribute with atleast one value
              - It acts as a template for the data to be stored