Saturday, July 10, 2010

Using Sendmail to Relay Mails from Your MSP/ISP in Centos, RHEL, Ubuntu and Other Linux Distros

Do you want to relay mails from your local sendmail server to your ISP. Just follow the below steps

Open sendmail.mc using default editor vi, edit, emacs
# vi /etc/mail/sendmail.mc

define(`SMART_HOST',`[smtp.yourisphost.com]')
FEATUREdnl

Save the File and exit
Open the File authinfo (If not Present Create a New File).


vi /etc/mail/authinfo
Add the following Line
"AuthInfo:smtp.yourisphost.com "U:UsernamefromISP" "P:passwordfromISP" "M:LOGIN PLAIN"

Save the File and Exit

Just run the below commands to recreate the sendmail.cf file

# cd /etc/mail/
# m4 sendmail.mc > sendmail.cf

Make Map will recreate the database for authinfo to be used in sendmail

# makemap hash /etc/mail/authinfo < /etc/mail/authinfo

Restart the Sendmail Service and check if All's Good !!!

# /etc/init.d/sendmail restart


echo '/map authinfo AuthInfo:smtp.yourisphost.com' | /usr/sbin/sendmail -bt



Sent Mail Check in Logs

Enjoy.....

Comment if issues or modification required.

Finding First Instance of the Pattern Using Grep in Linux

Grep in Linux
Have you ever faced a problem grepping (Parsing) for a pattern from a file, Definately being a Linux Administrator you have done it several times but have you came across a situation where from a huge file you only have to parse the first instance of the pattern, grepping the whole file for a pattern will be tedious and will be using more system resources especially when you are doing it using a script (Using Loop for, while, until)

The easy solution to tackle the problem is to use grep with inbuilt option which will display only the first instances instead of checking the whole file and than printing the first line using head command.


Command :
grep -m 1 "pattern" filename.txt


The "-m" option when passed with grep will search for the first matching pattern from the file and print the output same-way if you want to look for first 2 instances pass option "grep -m 2 "pattern" yourfilename.log"

Enjoy...

Friday, July 9, 2010

Blocking Specific Sender to Specific Recipient or IPs Spamming Using Sendmail in Linux

Maintaining a MailServer is really a all time headache for Mail Server Admins, specifically to prevent SPAM relayed from you Server or delivered to your server.

In this article we would use some inbuilt feature of Sendmail to block users from sending mail to specific users or domains, this can be attained in many ways but i have done it in the below manner. For any issues please comment at the bottom of the post.

Sendmail is Oldest Mail transfer agent used by major of the MSP's (Mail Service Providers) all over the world, with its huge forum, mailing list and IRC Support and help it has gained high name within its competitors.

When Do i need to block a user or IP?
Reasons Are Many
1. Spamming done from your domain.
2. Spamming happening from outside to your server.
3. Spamming from a particular IP.
4. Wants to reject relaying mail for a user (Used incase allowed to just fetch mails, no sending allowed)
5. Any Many More...........

To block the user or IP we will be using access file / database included in the sendmail, Access Database provides a single, central database with rules to accept, reject, and discard messages based on the sender name, address, or IP number. It is enabled with the access_db configuration feature.

1. Enable the Access Database in Sendmail
You have to make add or declare the following lines in your sendmail.mc file

FEATURE(`access_db')

The above line added in the sendmail.mc enables use of the access database, and enables the default database type and path as:

hash /etc/mail/access

2. Create the access Database
Edit the File /etc/mail/access, the entries should be inorder

key value

The lefthand column is the key which is composed of a prefix and an address expression, this can contain hostname, email address, IP address, networks etc

The righthand column contains the value, which can be keywords or values that determine what should be done with the item described on the left or in a layman langauge the action to be executed, the preferable values are OK, RELAY, REJECT, DISCARD, SKIP, ERROR:XYZ text.

Eg :

spam@goo.gle.com REJECT
10.0.0.35 REJECT
192.168.1.100/255.0.0.0 REJECT
From:spammer@somedomain.com REJECT
To:trusteddomain.org RELAY
Connect:2trusteddomain.com OK
Connect:ashwin.com RELAY
From:good@domain.com OK
From:anotherbaddomain.com REJECT

To be able to block specific sender to specific recipient you need to add the following line in sendmail.mc to enable compat.
FEATURE(`check_compat')


Then make the following entries in access file (Location : /etc/mail/access)

Compat:extsender@mydomain.com<@>recipient@outdomain.com DISCARD


After confirming all the entries as per your requirement in access file, we have to recreate the access in hash database for which execute the below command

cd /etc/mail

makemap hash access < access

m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf


Restart the sendmail service
/etc/init.d/sendmail restart


Testing

telnet to_your_mailserver_ip 25
mail from:internaluser@example.com
Ok
rcpt to:spam@goo.gle.com
REJECTED


Enjoy..

Thursday, July 8, 2010

Packet Capturing and Analayzing packets Using TCPDUMP on Centos, Fedora, Ubuntu and other Linux Distros

Many a times Linux System Admin2 face problem in network latency, connectivity the servers hampers the services which impact to the business. Using linux basic tools can not really solve it but you can identify the issues faced by the host to host or host to the device.

Here we will be using tcpdump tool to capture packet after which you can analyse the data and conclude with errors host.
If you have installed linux properly tcpdump is by default installed on to your system, and if not you can install it finding the relevant packages for your distros

RPM Based Linux can google for "tcpdump +rpm" and Debian can google for "tcpdump +deb", you will get enough results to finish installing the TCPDUMP package onto your system.

After installing, check if tcpdump is installed successfully executing the below command

 #>which tcpdump


Should return the binary location of the package installed

/usr/sbin/tcpdump


After confirming you can run tcpdump with various options passing to the command to check for the options

[root@ashwin ~]# tcpdump --help
tcpdump version 3.9.8
libpcap version 0.9.8
Usage: tcpdump [-aAdDeflLnNOpqRStuUvxX] [-c count] [ -C file_size ]
[ -E algo:secret ] [ -F file ] [ -i interface ] [ -M secret ]
[ -r file ] [ -s snaplen ] [ -T type ] [ -w file ]
[ -W filecount ] [ -y datalinktype ] [ -Z user ]
[ expression ]


We will be capturing packets for 2 minutes and analyze for any issues with hosts connecting to and from.

Running the below command will capture all the packets transferring between the hosts through the Network Interface Cards and will be redirected to a file

tcpdump -n -i bond0 -e -vvv > output.log


Once you have captured packets for 5 minutes press Ctrl + z to end and proceed with analyzing the file "output.log"


Example :

2.39.omserv > 11.240.240.141.nfs: ., cksum 0x1eba (correct), 156:156(0) ack 28961 win 30782
18:41:21.397883 00:a0:98:10:7a:05 > 00:21:5a:4c:a6:3e, ethertype IPv4 (0x0800), length 1514: (tos 0x0, ttl 64, id 26738, offset 0, flags [DF], proto: TCP (6), length: 1500) 11.240.240.141.2049 > 11.240.240.39.33554432: reply ERR 1448

In the above line its clear that a partition is mounted on the host using NFS protocol from other hosts having IP 11.240.240.141 which is having issues while transferring data to host bearing IP 11.240.240.39 Error "reply ERR 1448"

You can find great detail in the output of tcpdump, Also you can use wireshark to read the output.txt and get a better clarity of the data transmission hence lot of network latency can be resolved.

Enjoy.

Packet Capturing and Analayzing packets Using TCPDUMP on Centos, Fedora, Ubuntu and other Linux Distros

Tuesday, June 29, 2010

Solved : Lock table is out of available locker entries - Yum install, yum upgrade

Recently faced a issue while installing a package using yum


[root@back ~]# yum install mod-security
rpmdb: Lock table is out of available locker entries
rpmdb: Unknown locker ID: 3077
error: db4 error(22) from db->close: Invalid argument
error: cannot open Packages index using db3 - Cannot allocate memory (12)
error: cannot open Packages database in /var/lib/rpm
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 164, in _getConfig
self._conf = config.readMainConfig(startupconf)
File "/usr/lib/python2.4/site-packages/yum/config.py", line 685, in readMainConfig
yumvars['releasever'] = _getsysver(startupconf.installroot, startupconf.distroverpkg)
File "/usr/lib/python2.4/site-packages/yum/config.py", line 752, in _getsysver
idx = ts.dbMatch('provides', distroverpkg)
TypeError: rpmdb open failed


Googling and Searching on this topic got it resolved

[root@back ~]# ll /var/lib/rpm/
Basenames __db.000 __db.002 Dirnames Group Name Providename Pubkeys Requireversion Sigmd5
Conflictname __db.001 __db.003 Filemd5s Installtid Packages Provideversion Requirename Sha1header Triggername
[root@back ~]# ll /var/lib/rpm/
Basenames __db.000 __db.002 Dirnames Group Name Providename Pubkeys Requireversion Sigmd5
Conflictname __db.001 __db.003 Filemd5s Installtid Packages Provideversion Requirename Sha1header Triggername


[root@back ~]# rm /var/lib/rpm/_db.00*
rm: cannot lstat `/var/lib/rpm/_db.00*': No such file or directory
[root@back ~]# rm /var/lib/rpm/__db.00*
rm: remove regular empty file `/var/lib/rpm/__db.000'? y
rm: remove regular file `/var/lib/rpm/__db.001'? y
rm: remove regular file `/var/lib/rpm/__db.002'? y
rm: remove regular file `/var/lib/rpm/__db.003'? y

[root@back ~]# rpm --rebuilddb


[root@back ~]# yum install mod-security
utterramblings 100% |=========================| 951 B 00:00
primary.xml.gz 100% |=========================| 22 kB 00:00
utterrambl: ################################################## 64/64
extras 100% |=========================| 2.1 kB 00:00
primary.sqlite.bz2 100% |=========================| 184 kB 00:38
updates 100% |=========================| 1.9 kB 00:00
primary.sqlite.bz2 100% |=========================| 254 kB 00:28
base 100% |=========================| 2.1 kB 00:00
primary.sqlite.bz2 100% |=========================| 1.6 MB 00:17
c5-testing 100% |=========================| 1.9 kB 00:00
addons 100% |=========================| 951 B 00:00
Setting up Install Process
Parsing package install arguments
No package mod-security available.
Nothing to do
[root@back ~]# yum install mod_security
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package mod_security.i386 0:2.5.9-1.jason.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
mod_security i386 2.5.9-1.jason.1 utterramblings 1.2 M

Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 1.2 M
Is this ok [y/N]: y
Downloading Packages:
(1/1): mod_security-2.5.9 100% |=========================| 1.2 MB 00:03
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 0d4306ef
Importing GPG key 0x0D4306EF "Jason Litka (http://www.jasonlitka.com) " from http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: mod_security ######################### [1/1]

Installed: mod_security.i386 0:2.5.9-1.jason.1
Complete!


This problem occurs when rpm accesses the Berkeley database files, it makes temporary locker entries within the tables while it searches for data. If you control-c your rpm processes often, this issue will occur much sooner because the locks are never cleared.

Solved Lock table is out of available locker entries - Yum install, yum upgrade

Solved : Lock table is out of available locker entries - Yum install, yum upgrade

Recently faced a issue while installing a package using yum
[root@back ~]# yum install mod-security
rpmdb: Lock table is out of available locker entries
rpmdb: Unknown locker ID: 3077
error: db4 error(22) from db->close: Invalid argument
error: cannot open Packages index using db3 - Cannot allocate memory (12)
error: cannot open Packages database in /var/lib/rpm
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 164, in _getConfig
self._conf = config.readMainConfig(startupconf)
File "/usr/lib/python2.4/site-packages/yum/config.py", line 685, in readMainConfig
yumvars['releasever'] = _getsysver(startupconf.installroot, startupconf.distroverpkg)
File "/usr/lib/python2.4/site-packages/yum/config.py", line 752, in _getsysver
idx = ts.dbMatch('provides', distroverpkg)
TypeError: rpmdb open failed

Googling and Searching on this topic got it resolved
[root@back ~]# ll /var/lib/rpm/
Basenames __db.000 __db.002 Dirnames Group Name Providename Pubkeys Requireversion Sigmd5
Conflictname __db.001 __db.003 Filemd5s Installtid Packages Provideversion Requirename Sha1header Triggername
[root@back ~]# ll /var/lib/rpm/
Basenames __db.000 __db.002 Dirnames Group Name Providename Pubkeys Requireversion Sigmd5
Conflictname __db.001 __db.003 Filemd5s Installtid Packages Provideversion Requirename Sha1header Triggername

[root@back ~]# rm /var/lib/rpm/_db.00*
rm: cannot lstat `/var/lib/rpm/_db.00*': No such file or directory
[root@back ~]# rm /var/lib/rpm/__db.00*
rm: remove regular empty file `/var/lib/rpm/__db.000'? y
rm: remove regular file `/var/lib/rpm/__db.001'? y
rm: remove regular file `/var/lib/rpm/__db.002'? y
rm: remove regular file `/var/lib/rpm/__db.003'? y

[root@back ~]# rpm --rebuilddb

[root@back ~]# yum install mod-security

utterramblings 100% |=========================| 951 B 00:00

primary.xml.gz 100% |=========================| 22 kB 00:00

utterrambl: ################################################## 64/64

extras 100% |=========================| 2.1 kB 00:00

primary.sqlite.bz2 100% |=========================| 184 kB 00:38

updates 100% |=========================| 1.9 kB 00:00

primary.sqlite.bz2 100% |=========================| 254 kB 00:28

base 100% |=========================| 2.1 kB 00:00

primary.sqlite.bz2 100% |=========================| 1.6 MB 00:17

c5-testing 100% |=========================| 1.9 kB 00:00

addons 100% |=========================| 951 B 00:00

Setting up Install Process

Parsing package install arguments

No package mod-security available.

Nothing to do

[root@back ~]# yum install mod_security

Setting up Install Process

Parsing package install arguments

Resolving Dependencies

--> Running transaction check

---> Package mod_security.i386 0:2.5.9-1.jason.1 set to be updated

--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================

Package Arch Version Repository Size

=============================================================================

Installing:

mod_security i386 2.5.9-1.jason.1 utterramblings 1.2 M
Transaction Summary

=============================================================================

Install 1 Package(s)

Update 0 Package(s)

Remove 0 Package(s)
Total download size: 1.2 M

Is this ok [y/N]: y

Downloading Packages:

(1/1): mod_security-2.5.9 100% |=========================| 1.2 MB 00:03

warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 0d4306ef

Importing GPG key 0x0D4306EF "Jason Litka (http://www.jasonlitka.com) " from http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

Is this ok [y/N]: y

Running rpm_check_debug

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

Installing: mod_security ######################### [1/1]
Installed: mod_security.i386 0:2.5.9-1.jason.1

Complete!

This problem occurs when rpm accesses the Berkeley database files, it makes temporary locker entries within the tables while it searches for data. If you control-c your rpm processes often, this issue will occur much sooner because the locks are never cleared.

Saturday, June 5, 2010

How to Install Mod Security on Linux Centos 5.4, Fedora 11-12

ModSecurity is a free open source Firewall for Web application which can help you to guard against Intrusion on your webservers like local file inclusion attacks, Cross Site Scripting, and SQL injection vulnerabilities and many more.

The easiest way to install mod_security is using yum, to get the latest package of modsecurity refer to jason litka rpms.
Lets Start

Install the gpg Key

You need to be Root to run this:

[ashwin@ashwin ~]$ rpm –import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka


Create a File

[ashwin@ashwin ~]$ touch /etc/yum.repos.d/utterramblings.repo

Open the File using your favorite editor and add the contents

[ashwin@ashwin ~]$ vim /etc/yum.repos.d/utterramblings.repo

[utterramblings]
name=Jason’s Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

Save the File and exit

Now you can Install Mod-Security

[root@ashwin ~]# yum install mod_security
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package mod_security.i386 0:2.5.9-1.jason.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
mod_security            i386       2.5.9-1.jason.1  utterramblings    1.2 M

Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 1.2 M
Is this ok [y/N]: y
Downloading Packages:
(1/1): mod_security-2.5.9 100% |=========================| 1.2 MB    00:03
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 0d4306ef
Importing GPG key 0x0D4306EF "Jason Litka (http://www.jasonlitka.com) <jasonlitka@verizon.net>" from http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: mod_security                 ######################### [1/1]

Installed: mod_security.i386 0:2.5.9-1.jason.1
Complete!

Great You have installed mod security Restart HTTPD service and Roll. Check the Logs and you will find the magic.

Issues :

1. Starting httpd: httpd: Syntax error on line 210 of /etc/httpd/conf/httpd.conf: Syntax error on line 3 of /etc/httpd/conf.d/mod_security.conf: Cannot load /etc/httpd/modules/mod_security2.so into server: /etc/httpd/modules/mod_security2.so: undefined symbol: ap_get_server_banner

Solution :

[root@ashwin ~]#  yum remove httpd mod_perl mod_perl-devel mod_security
[root@ashwin ~]#  mv /etc/yum.repos.d/CentOS-Base.repo /tmp ( move base centos repo to /tmp )
[root@ashwin ~]#  yum install httpd ( This will install apache from utterramblings.repo )
[root@ashwin ~]#  yum install mod_perl mod_perl-devel
[root@ashwin ~]#  yum install mod_security

Sunday, May 9, 2010

Step by Step Installing mod_security from Source in Linux Centos5.4, Fedora12 Howto

To Install mod Security from the source go to the Website of Mod security and download the packages
[superuser@ashwin modse]# get http://www.modsecurity.org/download/modsecurity-apache_2.5.12.tar.gz

–2010-05-05 15:19:12– http://www.modsecurity.org/download/modsecurity-apache_2.5.12.tar.gz

Saving to: `modsecurity-apache_2.5.12.tar.gz’

100%[=======================================>] 1,392,209 1235.9Mb/s in 5s

2010-05-05 15:19:18 (1235.7 MB/s) – `modsecurity-apache_2.5.12.tar.gz’ saved [1392209/1392209]

[superuser@ashwin modse]# tar -zxf modsecurity-apache_2.5.

To see the Full Tutorial:

Step by Step Installing mod_security from Source in Linux Centos5.4, Fedora12 Howto

Thursday, May 6, 2010

Howto Add New User, New Group and modify Users, Groups in Linux - Centos5.4, Fedora 11 - Part 1

Adding users in Linux helps you from giving all user Administrative (root access) rights if the system is used by Multiple people. Its one of the basic command but still very important which need to studied in much details, The More detail you know about adding user and adding group modifying existing users and groups may lead with excellent system administration skills and also help you with securing system. There are many attributes to read when we learn about useradd and groupadd command in linux. In this article we will go indepth of Adding, Modifying User and groups and also discussing about various parameters while using these commands.

Adding New User in Linux

Adding a new user to your linuxbox is as simple as running a command with a argument which is the username to be created

[root@ashwin ~]# useradd ashwin


Great You have created a new user but now into the technical details how does the user gets the home directory, how is the UID,GID set, how the default shell is assigned and other different features gets assigned when addding a user.

When you add a user immediately some files are checked if the user is already present Files

1. /etc/passwd
2. /etc/groups
3. /etc/shadows

If the user is not present in the above 3 files the next step is to look for another set of files which by default assign values to a newly added user the file which is looked is
 # cat /etc/login.defs 


The above file contains all the default parameter like, UID, GID to be set for new user, Home Directory (If not specified explicitly). Now once the user is added the home directory is created in /home/username by default and assigned a unique UID,GID. When you see the contents of /home/username you will find files

[ashwin@ashwin ~]$ ll -a /home/ashwin/
-rw-r--r--. 1 root root 18 2009-04-08 16:16 .bash_logout
-rw-r--r--. 1 root root 176 2009-04-08 16:16 .bash_profile
-rw-r--r--. 1 root root 124 2009-04-08 16:16 .bashrc
-rw-r--r--. 1 root root 500 2009-04-10 17:22 .emacs
drwxr-xr-x. 2 root root 4096 2009-03-18 06:22 .gnome2
drwxr-xr-x. 4 root root 4096 2010-03-19 12:20 .mozilla
-rw-r--r--. 1 root root 658 2009-03-02 22:50 .zshrc

Now from where these files came from, yes this files are copied to every newly added user from the /etc/skel folder.


[ashwin@ashwin ~]$ ll -a /etc/skel/
-rw-r--r--. 1 root root 18 2009-04-08 16:16 .bash_logout
-rw-r--r--. 1 root root 176 2009-04-08 16:16 .bash_profile
-rw-r--r--. 1 root root 124 2009-04-08 16:16 .bashrc
-rw-r--r--. 1 root root 500 2009-04-10 17:22 .emacs
drwxr-xr-x. 2 root root 4096 2009-03-18 06:22 .gnome2
drwxr-xr-x. 4 root root 4096 2010-03-19 12:20 .mozilla
-rw-r--r--. 1 root root 658 2009-03-02 22:50 .zshrc


Now a Bit more depth on useradd, we'll now discuss some parameters while adding a new user to change the default home directory, UID, GID, Default Shell Login, Password

The Following arguments can be used to the command useradd

-b, --base-dir BASE_DIR base directory for the new user account
home directory
-c, --comment COMMENT set the GECOS field for the new user account
-d, --home-dir HOME_DIR home directory for the new user account
-D, --defaults print or save modified default useradd
configuration
-e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
-f, --inactive INACTIVE set password inactive after expiration to INACTIVE
-g, --gid GROUP force use GROUP for the new user account
-G, --groups GROUPS list of supplementary groups for the new user account
-h, --help display this help message and exit
-k, --skel SKEL_DIR specify an alternative skel directory
-K, --key KEY=VALUE overrides /etc/login.defs defaults
-l, do not add the user to the lastlog and faillog databases
-m, --create-home create home directory for the new user account
-M, do not create user's home directory(overrides /etc/login.defs)
-N, --no-user-group do not create a group with the same name as the user
-o, --non-unique allow create user with duplicate (non-unique) UID
-p, --password PASSWORD use encrypted password for the new user account
-r, --system create a system account
-s , --shell SHELL the login shell for the new user account
-u, --uid UID force use the UID for the new user account
-U, --user-group create a group with the same name as the user
-Z, --selinux-user SEUSER use a specific SEUSER for the SELinux user mapping



    Examples


1. Add user with home directory in /opt/username

[root@ashwin ~]# useradd -d /opt/ username

2. Add user with defined home directory UID, GID

[root@ashwin ~]# useradd -d /opt/ -u 800 -g 800 username


3. Defining password while adding a new user

[root@ashwin ~]# useradd -d /opt/ -u 800 -g 800 -p password username

4. Defining the login shell for the new user account

[root@ashwin ~]# useradd -d /opt/ -u 800 -g 800 -p password -s /bin/sh username

[root@ashwin ~]# useradd -d /opt/ -u 800 -g 800 -p password -s /bin/nologin username

Explore around with the parameters you would find many features in it.

Also Look For Parts Two to know more depth knowledge of User and Group adding in Linux

Wednesday, May 5, 2010

Step by Step Installing mod_security from Source in Linux Centos5.4, Fedora12 Howto

To Install mod Security from the source go to the Website of Mod security and download the packages
[superuser@ashwin modse]# get http://www.modsecurity.org/download/modsecurity-apache_2.5.12.tar.gz

--2010-05-05 15:19:12-- http://www.modsecurity.org/download/modsecurity-apache_2.5.12.tar.gz

Saving to: `modsecurity-apache_2.5.12.tar.gz'

100%[=======================================>] 1,392,209 1235.9Mb/s in 5s

2010-05-05 15:19:18 (1235.7 MB/s) - `modsecurity-apache_2.5.12.tar.gz' saved [1392209/1392209]

[superuser@ashwin modse]# tar -zxf modsecurity-apache_2.5.12.tar.gz
[superuser@ashwin modse]# cd modsecurity-apache_2.5.12

Stop Apache httpd
[superuser@ashwin modse]# service httpd stop
[superuser@ashwin apache2]# /configure --with-apxs=/path/to/httpd-2.x.y/bin/apxs

Compile with:
[superuser@ashwin apache2]# make

Optionally test with:
[superuser@ashwin apache2]# make test

Optionally build the ModSecurity Log Collector with:
[superuser@ashwin apache2]# make mlogc

Install the ModSecurity module with:
[superuser@ashwin apache2]# make install

If you get the below error you need to recompile apache with DSO and APXS

configure: looking for Apache module support via DSO through APXS
configure: error: couldn't find APXS

Solution
[superuser@ashwin modse]# get http://apache.siamwebhosting.com/httpd/httpd-2.2.15.tar.gz
[superuser@ashwin modse]# cd httpd-2.2.15
[superuser@ashwin httpd-2.2.15]# ./configure --enable-so --with-pcre
[superuser@ashwin httpd-2.2.15]# make
[superuser@ashwin httpd-2.2.15]# make install

Now Change you directory to /your/path/mod-security/apache2/
Install MOD-Security
[superuser@ashwin apache2]# make install

Congratulation you have successfully installed mod-security now to make it work add the following lines in your apache configuration file
[superuser@ashwin apache2]# vi /etc/httpd/conf/httpd.conf
LoadFile /usr/lib/libxml2.so
LoadFile /usr/lib/liblua5.1.so

# Load the ModSecurity module with:
LoadModule security2_module modules/mod_security2.so

Now Restart Apache Service and you ready to Go
superuser@ashwin apache2]# service httpd start

Thursday, April 15, 2010

Email Marketing In India - How Do I Choose One from Many

Email Marketing In India




As the name say Email used for marketing communications. it is nothing but broadcasting of emails to the general public who can be potential customer or are already your customers.In this article we'll discuss Emailing Marketing in India.

India being the quickest revenue generating country for a new product launch and also being the HIGHEST ROI (Return on Investment) country entrepreneurs have kept an eagles eye launching their product/services publicly. As computer reach in India increased a lot in the last 5 years there it has became easier for marketers to plan out strategies while being cost effective and fruitful. As Email marketing has made people Night Millionaires it has been a big time headache for consumers and end users receiving hundreds or even thousands of SPAM mail landing into their Mailbox. These have made life of MSP's (Mail Service Providers), ISP's (Internet Service providers) to be on the toes every second and tighten the security of the services provided. Also their are many legitimate mails which land up in Users SPAMBOX which is due to some users in the network sending unsolicited commercial email and the IP getting listed in the SPAM Sources.

To select and judge the best in business Email marketing companies you should always check the following points:

1. Server Locations
2. Deliverable of mail
3. Handling Queues
4. Reports
5. Support (Prefer Local Support)
6. Track Record of Company (Google it out for Review You will get the Best)

Advantages
E-mail marketing (on the Internet) is popular with companies for several reasons:

  • An exact return on investment can be tracked ("track to basket") and has proven to be high when done properly. E-mail marketing is often reported as second only to search marketing as the most effective online marketing tactic.

  • Advertisers can reach substantial numbers of e-mail subscribers who have opted in (i.e., consented) to receive e-mail communications on subjects of interest to them.

  • Over half of Internet users check or send e-mail on a typical day.


Disadvantages

  • A report issued by the e-mail services company Return Path, as of mid-2008 e-mail deliverability is still an issue for legitimate marketers. According to the report, legitimate e-mail servers averaged a delivery rate of 56%; twenty percent of the messages were rejected, and eight percent were filtered.

  • Companies considering the use of an e-mail marketing program must make sure that their program does not violate spam laws such as the United States' Controlling the Assault of Non-Solicited Pornography and Marketing Act (CAN-SPAM),the European Privacy and Electronic Communications Regulations 2003, or their Internet service provider's acceptable use policy.

  • As of there are less Strict Spam Laws in India


Companies That has being into the business for long and gained lot of trust in the Email Marketing Industries in India
1. Quantumlink Communications Pvt. Ltd.
They have a state of art Service Name MAILDIRECT managed by Highly skilled team of System Administrators backed up with Professional Support and highly motivated Sales team which cares for your ROI.

MailDirect is hosted on high-end servers, which ensures high-speed Internet connectivity, resulting in extremely low delivery times and zero choke of your bandwidth. Companies can only upload your message and the list, all the rest is done through a very intuitive browser-based interface on the server and your Email / SMS communication campaign is ready to roll.

You can Download Brochure Here

Visit the Company Website at www.qlc.in

2. EMAIL Marketing in India
Best in its class for Bulk Mailing
Visit http://www.emailmarketingindia.com

Friday, April 9, 2010

Howto Install RED5 Flash Media Server in Fedora 11, Centos 5.4, Redhat

Red5 is an Open Source Flash Media Server written in Java that supports:

* Streaming Audio/Video (FLV and MP3)
* Recording Client Streams (FLV only)
* Shared Objects
* Live Stream Publishing
* Remoting (AMF)

This is a reverse engineered open source project which aims to produce a feature-complete implementation written in Java. It os one of the Full implementation RTMP servers other than:

Adobe Flash Media Server,
Onlinelib VCS Video Communication Server
Wowza Media Server
WebORB Integration Server
haXeVideo

In this tutorial we'll learn howto installRED5 on Centos 5.4,Fedora, Redhat and other Linux Distribution, There are many ways to achieve this but this is how i installed RED5 Media Server on Fedora 11.

Red5 Requires Java Development Kit (JDK) to run so you have to install Java onto the system,You can acheive this in 2 ways
1. Either Use Yellow DOG Updater
# yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel


OR

Download JDK and Compile
cd /usr/java 
IF /usr/java cannot be found
mkdir /usr/java
Go to the Link and Download http://java.sun.com/javase/downloads/widget/jdk6.jsp and Download jdk-6u19-linux-i586.bin

mv /home/ashwin/Download/jdk-6u19-linux-i586.bin /usr/java/

chmod +x jdk-6u19-linux-i586.bin
./jdk-6u19-linux-i586.bin

You will see
JAVA_HOME="/usr/java/jdk1.6"
export JAVA_HOME
echo $JAVA_HOME


Great Now you have installed JAVA now proceed

Another Important requirement is ANT (It is a Apache Project) which we require to compile the RED5 Code, Good News is you dont need to compile ANT as it is already in binary format Just extract and install it in /usr/java


#cd /home/ashwin/
#w.get http://mirrors.kahuki.com/apache/ant/binaries/apache-ant-1.8.0-bin.tar.bz2
#tar -jxf apache-ant-1.8.0-bin.tar.bz2
#mv apache-ant-1.8.0 /usr/local/ant


Now we need to Export the JAVA and ANT Environment Variables which would help us in installing and proper running if RED5 Server


export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/lib/jvm/java
export PATH=$PATH:/usr/local/ant/bin
export CLASSPATH=.:$JAVA_HOME/lib/classes.zip


vi /etc/bashrc

# ALSO Put the Above Here
export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/lib/jvm/java
export PATH=$PATH:/usr/local/ant/bin
export CLASSPATH=.:$JAVA_HOME/lib/classes.zip



Now download the latest RED5 CODE from the site to build


cd /home/ashwin/
svn checkout http://red5.googlecode.com/svn/java/server/trunk/ red5
mv red5 /usr/local/
cd /usr/local/red5
ant prepare
ant dist


You would you screen scrolling and you are not able to understand anything "CHILL" All is well and RED5 Media Server is getting compiled, AT the END you would SEE

BUILD SUCCESSFUL

If you see this you have made it you have done 95% of the work. Now copy the conf directory from dist/ and test the red5 installation.

cp -r dist/conf .
./red5.sh


STARTING, STOPPING,RESTARTING RED5 Media Server
I have created a Init Script Click Here

INIT Script to Start,STOP, RESTART RED5 Media Server

Start RED5

/etc/init.d/red5 start


TESTING RED5

Go TO your Browser Address Bar and Type

http://your.ip.address:5080

Check Out the Demos
http://your.ip.address:5080/demos/


ISSUE

When you run ./red5.sh, it will show you Installer service created. Thats mean everything runs fine and red5 server is up. But if you went to port_tester.swf using demos above or your application shows connections FAILS, this is an issue of RTMPT and RTMPTS. You can see it by running


/usr/local/red5/red5.sh

output trancated

[INFO] [main] org.red5.server.tomcat.TomcatLoader – RTMPT server bean was not found
[INFO] [main] org.red5.server.tomcat.TomcatLoader – RTMPS server bean was not found

output truncated

If you see this you have to uncomment the RTMPT and RTMPTS TomcatLoader in/usr/local/red5/conf/red5-core.xml



vi /usr/local/red5/conf/red5-core.xml

Search for a lines



Remove the from end of


Same goes for RTMPS



Remove the from end of




Restart the red5 services and connection fails problem will be fixed.

Init Script to Start, Stop, Restart RED5 Media Server

Click Here Howto Install RED5 Flash Media Server in Fedora 11, Centos 5.4, Redhat

RED5 is Open Source Media Flash Server, Highly Scalable and Customizable

Just Copy the Code in

vi /etc/init.d/red5


COPY the Below Code

#!/bin/sh
# Author : Ashwin
# Description: Red5 Media Flash streaming server

PROG=red5
RED5_HOME=/usr/local/red5
DAEMON=$RED5_HOME/$PROG.sh
PIDFILE=/var/run/$PROG.pid

# Source function library
. /etc/rc.d/init.d/functions

[ -r /etc/sysconfig/red5 ] && . /etc/sysconfig/red5

RETVAL=0

case “$1″ in
start)
echo -n $”Starting $PROG: ”
cd $RED5_HOME
$DAEMON >/dev/null 2>/dev/null &
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo $! > $PIDFILE
touch /var/lock/subsys/$PROG

fi
[ $RETVAL -eq 0 ] && success $”$PROG startup” || failure $”$PROG startup”
echo
;;
stop)
echo -n $”Shutting down $PROG: ”
killproc -p $PIDFILE
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROG
;;
restart)
$0 stop
$0 start
;;
status)
status $PROG -p $PIDFILE
RETVAL=$?
;;
*)
echo $”Usage: $0 {start|stop|restart|status}”
RETVAL=1
esac

exit $RETVAL



chmod 755 /etc/init.d/red5

Test It

/etc/init.d/red5 start
/etc/init.d/red5 stop
/etc/init.d/red5 restart

Tuesday, April 6, 2010

Howto setup local yum repository on RedHat Fedora12 Centos5.4

This article is about Setting up a Local yum repository to be used for local network. Local Yum Repository can save internet bandwidth downloading all your packages from the local repository over FAST LAN Network.

If You want to use it in your network the best option to be used is using Httpd - Apache so the yum repository will be acessible via web.

Step 1
Check if Httpd is installed and running

[root@localhost ~]# ps ax | grep http

3617 ? Ss 0:00 /usr/sbin/httpd
3621 ? S 0:00 /usr/sbin/httpd
3622 ? S 0:00 /usr/sbin/httpd
3623 ? S 0:00 /usr/sbin/httpd
3624 ? S 0:00 /usr/sbin/httpd
3625 ? S 0:00 /usr/sbin/httpd
3626 ? S 0:00 /usr/sbin/httpd
3627 ? S 0:00 /usr/sbin/httpd
3628 ? S 0:00 /usr/sbin/httpd
3629 ? S 0:00 /usr/sbin/httpd

If it is not running then Start HTTPD

[root@localhost ~]# /etc/init.d/httpd start

OR

[root@localhost ~]# service httpd start


and if you haven't installed httpd yet then you can do it by

[root@localhost ~]# yum install httpd


Now make httpd start at every system boot automatically by putting it in system Startup.

[root@localhost ~]# chkconfig --levels 235 httpd on

Start apache
[root@localhost ~]# /etc/init.d/httpd start
OR
[root@localhost ~]# service httpd start


How to Build the Repository
We will use Apache's default Document root to store the packages, Default DocumentRoot for apache is "/var/www/html".

Create a dir in the Document Root named yum. We will create two more directories
base-pkg : This would contain all the packages of the Linux Distribution you are making repository for.
updates : This would contain all the update packages for your Linux Distribution

[root@localhost ~]# mkdir /var/www/html/yum
[root@localhost ~]# mkdir /var/www/html/yum/base-pkg
[root@localhost ~]# mkdir /var/www/html/yum/updates


BUILDING YOU REPOSITORY

To build you yum repository the easy way is copy all the contents from the Linux Distribution DVD/CD Media to the repository location in this case /var/www/html/yum, Make sure that you copy all the contents (Packages) into the base-pkg directory. If you have a Media follow the Steps Below


[root@localhost ~]# mount /dev/cdrom /mnt
[root@localhost ~]# cp -v /mnt/Packages/* /var/www/html/yum/base-pkg/
[root@localhost ~]# umount /mnt


Now we need a tool "createrepo" which would create a repository for the linux distibution. By default it is comes installed with all Distribution of linux, but if its not installed use yum to install it.
Check if createrepo is installed
[root@localhost ~]# which createrepo
/usr/bin/createrepo


If you get the above result skip the next step and start Building the repository if its not installed then install it
[root@localhost ~]# yum install createrepo


Now Run the createrepo tool

[root@localhost ~]# createrepo /var/www/html/yum/base-pkg/

[root@localhost ~]# ls -l /var/www/html/yum/base-pkg/repodata/
-rw-r--r-- 1 root root 2227275 2010-02-18 11:51 filelists.xml.gz
-rw-r--r-- 1 root root 6487453 2010-02-18 11:51 other.xml.gz
-rw-r--r-- 1 root root 747714 2010-02-18 11:51 primary.xml.gz
-rw-r--r-- 1 root root 951 2010-02-18 11:51 repomd.xml

The Second step building repository is updating your updates directory for all new packages. Go to the Main website of the Linux Distribution you are preparing repostory for and check the updates link or use the below links

CENTOS : rsync://centos.arcticnetwork.ca/centos/5.4/updates/i386/RPMS/
FEDORA : rsync rsync://mirror.aarnet.edu.au/fedora/linux/updates/12/i386/

As per you distribution rsync the data to the updates directory
FOR CENTOS RUN
[root@localhost ~]# rsync -avrt rsync://centos.arcticnetwork.ca/centos/5.4/updates/i386/RPMS/ --exclude=debug/ /var/www/html/yum/updates/
FOR CENTOS RUN
[root@localhost ~]# rsync -avrt rsync://mirror.aarnet.edu.au/fedora/linux/updates/12/i386/ --exclude=debug/ /var/www/html/yum/updates/


To get the updates regularly you can put the above command inthe crontab so that you updates directories are updated periodically

[root@localhost ~]# crontab -e 
* * 2 * * rsync -avrt rsync://centos.arcticnetwork.ca/centos/5.4/updates/i386/RPMS/ --exclude=debug/ /var/www/html/yum/updates/


You have created local yum repository, now to make clients on your network to use the local repository, create a file mylocal.repo in /etc/yum.repos.d

[root@localhost ~]# vim /etc/yum.repos.d/mylocal.repo
Add the Following Lines

[base-local]
name=Centos $releasever - $basearch
failovermethod=priority
baseurl=http://192.168.1.1/yum/base-pkg/
enabled=1
gpgcheck=0

[updates-local]
name=Centos $releasever - $basearch - Updates
failovermethod=priority
baseurl=http://192.168.1.1/yum/updates/
enabled=1
gpgcheck=0


THAT's IT, Now you can update all your packages over high Speed Lan connectivity instead of Internet.

Thursday, March 25, 2010

Quick Understanding Linux Cron in under 3 Minutes

What is Cron?
In Layman Languages, cron is a Task scheduler used in Linux operating System (but with Great Powers if used with it Complete functionality) developed by Paul Vixie. You can schedule a specific task to be run every minute,hour,day,month.

Majorly cron is used to automate jobs daily without human intervention or manual running of command. Cron can be configured using configuration files which resides in "/etc", changes to which can be done only by the Administrator. Cron also has the feature to run commands using particular user.
Crontab entries


| --------------------------------------------------------------    Minutes (00 - 59)
|    ------------------------------------------------------    Hours (00 - 24)
|    |    ----------------------------------------------    Day of Month (01 - 30)
|    |    |    --------------------------------------    Month (01 - 12)
|    |    |    |    ------------------------------  Day of Week (0 - 6) (Sunday = 0)
|    |    |    |    |    ----------------------    User to the Run the Command
|    |    |    |    |    |        ------    Command / Script to be Executed
|    |    |    |    |    |        |

*    *    *    *    *    root    /home/linuxmaza.com/htdocs/scripts/Stats_Update.sh

If you are a lazy System Adminstrator and Dont want to write the whole entry, cron has several special entries which are shortcuts for specifying a Complete entry.
You can specify entries as below

Entry       ||    Description          ||    Equivalent To
=====================================================
@reboot     Run once, at startup.     None
@yearly     Run once a year     0 0 1 1 *
@annually     (same as @yearly)     0 0 1 1 *
@monthly     Run once a month     0 0 1 * *
@weekly     Run once a week     0 0 * * 0
@daily         Run once a day         0 0 * * *
@midnight     (same as @daily)     0 0 * * *
@hourly     Run once an hour     0 * * * *

Operators in Cron
There are way of specifying multiple date and time in a field which can be overcomed using Operators in cron.

  • The comma (',') operator specifies a list of values, for example: "1,3,4,7,8" (Spaces between the values are not accepted)

  • The dash ('-') operator specifies a range of values, for example: "1-6", which is equivalent to "1,2,3,4,5,6"

  • The asterisk ('*') operator specifies all possible values for a field. For example, an asterisk in the hour time field would be equivalent to 'every hour' (depending on other values entered in other fields).

  • The Forward Slash ('/') operator is used to SKIP a given number of values. "Say the value we used is 5" "For Example, "*/5" in the hour time field is equivalent to "0,5,10,15,20" and so on.


Cron Advantages :
1. Can Handle Multiuser
2. Cron enables users to schedule jobs to run automatically at a certain time or date.
3. Automate daily System Administration tasks
4. Operators in Cron saves time and confusion while creating many crons.
5. Support for Special entries using (@reboot, @yearly, @monthly, @weekly, @hourly, @midnight, @daily).


Some Examples
1. If you want to run a task every Hour

0 * * * * root w > /var/log/mysystemstats.log
OR
@hourly root w > /var/log/mysystemstats.log

Above entry would run the "w" command at the start of every hour and redirect the output to "/var/log/mysystemstats.log"

2. Scheduling a cron job running every 15 minutes to delete apache Logs

15 * * * * echo " " > /var/log/httpd/access_log

3. Run a job every 5 hours
* 0,5,10,15,20 * * * echo " " > /var/log/httpd/access_log

Sunday, March 21, 2010

Script to Check IP on SPAM Sources and getting EMAIL and SMS alerts.

As a System Administrators "The Key to a good performing Server is Good IP Reputation"

Maintaining a MAIL Servers or Web Servers is big time for System Admins,there is always a big fear for your IP getting Blacklisted on different SPAM sources due to which mails originated from your server either are not accepted or deffered by the Recipient Server.It would of great help if we get timely EMAIL as well as SMS alerts of IP getting blacklisted. This would make servers perform well as BOUNCES do use system resources which impact on system overall performance (Explaining Which in this article is OUT OF SCOPE.)

You can get this by Paying a Handsome amount of money to a Service Provider or DO MY way. I have written a Shell script using which you can get timely alerts as your IP gets blacklisted. You can put the script in crontab to run every Hour or so.

To START with Copy the script onto you system

# mkdir dnsbl && cd dnsbl

# vim dnsbl_check.sh


Copy the Below Script

#!/bin/bash

# Date: Mar 20,2010
# Author: Ashwin Muni
# Purpose: Check the IP Against Major SPAM Sources.

## Uncomment to Debug
# set -x

# Variables
tmp_file='/tmp/dnsbl'

#IN_DNSBL=127.0.0.[2-6]
#IN_DNSBL=127.0.0.
IN_DNSBL='127.0.0.2|127.0.0.3|127.0.0.4|127.0.0.5|127.0.0.6|127.0.0.7|127.0.0.8|127.0.0.9|127.0.0.10|127.0.0.'
DIG=`which dig`
MAIL_ADMIN="test@example.com ashwin@linuxmaza.com"

###################################################

# SCRIPT START

> $tmp_file

echo "Below IPs are Listed" >> $tmp_file

if [ "$#" == 1 ]; then

for i in `cat rbllist.txt`; do
IP_REV=`echo $1 | awk -F\. '{ print $4"."$3"."$2"."$1 }'`
$DIG $IP_REV.$i | grep $IN_DNSBL

if [ $? == '0' ]; then
#echo "$1 Listed on $i"
echo -e "\033[31m \033[1m PROBLEM : Listed on $i \033[0m \033[22m"
echo "################################ Attention : $1 Listed on $i" >> $tmp_file
else
echo -e "Not Listed on $i : \033[32m \033[1m OK \033[22m \033[0m "
echo "$1 Not Listed on $i" >> $tmp_file
fi
done

echo -e "\033[31m \033[1m ===================$1 is LISTED ON BELOW SPAM SOURCES====================== \033[0m \033[22m"

cat $tmp_file | mail -s "DNSBL REPORT FOR $1" $MAIL_ADMIN

else

echo -e "\t\t\t\t\033[31m \033[1m Enter Proper Arguments:\n Script Usage :\n /bin/sh $0 IP.ADD.RE.SS \033[0m \033[22m"

# EOF

################################################


Save the file Using ":wq"

Make necessary changes in the Script like the System Admin email address to sent Emails.

You will need the SPAM sources to check which you can find Here MAJOR SPAM SOURCES

Copy all the SPAM Sources and paste it in a txt file named "rbllist.txt"

# vi rbllist.txt


Should show you all the Major SPAM Sources for Checking your IPs.

Note: The script and the rbllist.txt should exist in the Same directory.

Once done we will give executable permission to the script which allows us to run it.

# chmod 755 dnsbl_check.sh


OR

# chmod +x dnsbl_check.sh


Now Run the Script

#./dnsbl_check.sh 100.200.100.200


You can put the script in crontab to run it regularly.

MAJOR SPAM Sources where your IPs can get blacklisted which could affect your service.

MAJOR SPAM Sources where your IPs can get blacklisted which could affect your service. Most of the Players in the market like Yahoo, Google, Hotmail use this for stopping huge SPAM to their servers. Many appliances do the same to STOP SPAM.

SPAM Sources

3y.spam.mrs.kithrup.com
access.redhawk.org
all.rbl.kropka.net
all.spamblock.unit.liu.se
assholes.madscience.nl
blackholes.five-ten-sg.com
blackholes.intersil.net
blackholes.mail-abuse.org
blackholes.sandes.dk
blackholes.uceb.org
blackholes.wirehub.net
blacklist.sci.kun.nl
blacklist.spambag.org
bl.borderworlds.dk
bl.csma.biz
block.dnsbl.sorbs.net
blocked.hilli.dk
blocklist2.squawk.com
blocklist.squawk.com
bl.redhatgate.com
bl.spamcannibal.org
bl.spamcop.net
bl.starloop.com
bl.technovision.dk
cart00ney.surriel.com
cbl.abuseat.org
dev.null.dk
dews.qmail.org
dialup.blacklist.jippg.org
dialup.rbl.kropka.net
dialups.mail-abuse.org
dialups.visi.com
dnsbl-1.uceprotect.net
dnsbl-2.uceprotect.net
dnsbl-3.uceprotect.net
dnsbl.ahbl.org
dnsbl.antispam.or.id
dnsbl.cyberlogic.net
dnsbl.kempt.net
dnsbl.njabl.org
dnsbl.solid.net
dnsbl.sorbs.net
dsbl.dnsbl.net.au
duinv.aupads.org
dul.dnsbl.sorbs.net
dul.ru
dun.dnsrbl.net
dynablock.njabl.org
dynablock.wirehub.net
fl.chickenboner.biz
forbidden.icm.edu.pl
form.rbl.kropka.net
hil.habeas.com
http.dnsbl.sorbs.net
http.opm.blitzed.org
intruders.docs.uu.se
ip.rbl.kropka.net
korea.services.net
l1.spews.dnsbl.sorbs.net
l2.spews.dnsbl.sorbs.net
lame-av.rbl.kropka.net
list.dsbl.org
mail-abuse.blacklist.jippg.org
map.spam-rbl.com
misc.dnsbl.sorbs.net
msgid.bl.gweep.ca
multihop.dsbl.org
no-more-funn.moensted.dk
ohps.bl.reynolds.net.au
ohps.dnsbl.net.au
omrs.bl.reynolds.net.au
omrs.dnsbl.net.au
opm.blitzed.org
op.rbl.kropka.net
orbs.dorkslayers.com
orid.dnsbl.net.au
or.rbl.kropka.net
orvedb.aupads.org
osps.bl.reynolds.net.au
osps.dnsbl.net.au
osrs.bl.reynolds.net.au
osps.dnsbl.net.au
osrs.bl.reynolds.net.au
osrs.dnsbl.net.au
owfs.bl.reynolds.net.au
owfs.dnsbl.net.au
owps.bl.reynolds.net.au
owps.dnsbl.net.au
pdl.dnsbl.net.au
probes.dnsbl.net.au
proxy.bl.gweep.ca
psbl.surriel.com
pss.spambusters.org.ar
rbl.cluecentral.net
rblmap.tu-berlin.de
rbl.rangers.eu.org
rbl.schulte.org
rbl.snark.net
rbl.triumf.ca
rdts.bl.reynolds.net.au
rdts.dnsbl.net.au
relays.bl.gweep.ca
relays.bl.kundenserver.de
relays.dorkslayers.com
relays.mail-abuse.org
relays.nether.net
relays.visi.com
ricn.bl.reynolds.net.au
ricn.dnsbl.net.au
rmst.bl.reynolds.net.au
rmst.dnsbl.net.au
rsbl.aupads.org
satos.rbl.cluecentral.net
sbl.csma.biz
sbl.spamhaus.org
sbl-xbl.spamhaus.org
smtp.dnsbl.sorbs.net
socks.dnsbl.sorbs.net
socks.opm.blitzed.org
sorbs.dnsbl.net.au
spam.dnsbl.sorbs.net
spam.dnsrbl.net
spamguard.leadmon.net
spam.olsentech.net
spamsites.dnsbl.net.au
spamsources.dnsbl.info
spamsources.fabel.dk
spamsources.yamta.org
spam.wytnij.to
spews.dnsbl.net.au
t1.bl.reynolds.net.au
t1.dnsbl.net.au
ucepn.dnsbl.net.au
unconfirmed.dsbl.org
vbl.messagelabs.com
vox.schpider.com
web.dnsbl.sorbs.net
whois.rfc-ignorant.org
will-spam-for-food.eu.org
wingate.opm.blitzed.org
xbl.spamhaus.org
zombie.dnsbl.sorbs.net
ztl.dorkslayers.com

Check you IP if is blacklisted using a script SPAM-IP Reputation Check Script

Sunday, March 7, 2010

Top Linux Admin Interview Questions and answers asked in TOP IT industries : Question Bank 06

Linux Admin Interview Questions and Answers


Questions consists of Linux Admin Interview Questions and Answers, Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Questions BANK 06


# What command can you use to review boot messages?

# What file defines the levels of messages written to system log files?

# What account is created when you install Linux?

# While logged on as a regular user, your boss calls up and wants you to create a new user account immediately. How can you do this without first having to close your work, log off and logon as root? Choose one:
a. Issue the command rootlog.
b. Issue the command su and type exit when finished.
c. Issue the command su and type logoff when finished.
d. Issue the command logon root and type exit when finished.

# Which file defines all users on your system? Choose one:
a. /etc/passwd
b. /etc/users
c. /etc/password
d. /etc/user.conf

# There are seven fields in the /etc/passwd file. Which of the following lists all the fields in the correct order? Choose one:
a. username, UID, GID, home directory, command, comment
b. username, UID, GID, comment, home directory, command
c. UID, username, GID, home directory, comment, command
d. username, UID, group name, GID, home directory, comment

# Which of the following user names is invalid? Choose one:
a. Theresa Hadden
b. thadden
c. TheresaH
d. T.H.

# In order to prevent a user from logging in, you can add a(n) ________at the beginning of the password field.

# The beginning user identifier is defined in the _________ file.

# Which field is used to define the user’s default shell?

# Bob Armstrong, who has a username of boba, calls to tell you he forgot his password. What command should you use to reset his command?

# Your company has implemented a policy that users’ passwords must be reset every ninety days. Since you have over 100 users you created a file with each username and the new password. How are you going to change the old passwords to the new ones? Choose one:
a. Use the chpasswd command along with the name of the file containing the new passwords.
b. Use the passwd command with the -f option and the name of the file containing the new passwords.
c. Open the /etc/passwd file in a text editor and manually change each password.
d. Use the passwd command with the -u option.

Friday, March 5, 2010

Top Linux Admin Interview Questions and answers asked in TOP IT industries : Question Bank 05

Linux Admin Interview Questions and Answers

Questions consists of Linux Admin Interview Questions and Answers, Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Questions BANK 05


# As the system administrator you need to review Bob’s cronjobs. What command would you use? Choose one:
a. crontab -lu bob
b. crontab -u bob
c. crontab -l
d. cronq -lu bob

# In order to schedule a cronjob, the first task is to create a text file containing the jobs to be run along with the time they are to run. Which of the following commands will run the script MyScript every day at 11:45 pm? Choose one:
a. * 23 45 * * MyScript
b. 23 45 * * * MyScript
c. 45 23 * * * MyScript
d. * * * 23 45 MyScript

# Which daemon must be running in order to have any scheduled jobs run as scheduled? Choose one:
a. crond
b. atd
c. atrun
d. crontab

# You want to ensure that your system is not overloaded with users running multiple scheduled jobs. A policy has been established that only the system administrators can create any scheduled jobs. It is your job to implement this policy. How are you going to do this? Choose one:
a. create an empty file called /etc/cron.deny
b. create a file called /etc/cron.allow which contains the names of those allowed to schedule jobs.
c. create a file called /etc/cron.deny containing all regular usernames.
d. create two empty files called /etc/cron.allow and /etc/cron.deny

# You notice that your server load is exceptionally high during the hours of 10 am to 2 noon. When investigating the cause, you suspect that it may be a cron job scheduled by one of your users. What command can you use to determine if your suspicions are correct? Choose one:
a. crontab -u
b. crond -u
c. crontab -l
d. crond -l

# One of your users, Bob, has created a script to reindex his database. Now he has it scheduled to run every day at 10:30 am. What command should you use to delete this job. Choose one:
a. crontab -ru bob
b. crontab -u bob
c. crontab -du bob
d. crontab -lu bob

# What daemon is responsible for tracking events on your system?

# What is the name and path of the default configuration file used by the syslogd daemon?

# You have made changes to the /etc/syslog.conf file. Which of the following commands will cause these changes to be implemented without having to reboot your computer? Choose one:
a. kill SIGHINT `cat /var/run/syslogd.pid`
b. kill SIGHUP `cat /var/run/syslogd.pid`
c. kill SIGHUP syslogd
d. kill SIGHINT syslogd

# Which of the following lines in your /etc/syslog.conf file will cause all critical messages to be logged to the file /var/log/critmessages? Choose one:
a. *.=crit /var/log/critmessages
b. *crit /var/log/critmessages
c. *=crit /var/log/critmessages
d. *.crit /var/log/critmessages

# You wish to have all mail messages except those of type info to the /var/log/mailmessages file. Which of the following lines in your /etc/syslogd.conf file would accomplish this? Choose one:
a. mail.*;mail!=info /var/log/mailmessages
b. mail.*;mail.=info /var/log/mailmessages
c. mail.*;mail.info /var/log/mailmessages
d. mail.*;mail.!=info /var/log/mailmessages

# What is the name and path of the main system log?

# Which log contains information on currently logged in users? Choose one:
a. /var/log/utmp
b. /var/log/wtmp
c. /var/log/lastlog
d. /var/log/messages

# You have been assigned the task of determining if there are any user accounts defined on your system that have not been used during the last three months. Which log file should you examine to determine this information? Choose one:
a. /var/log/wtmp
b. /var/log/lastlog
c. /var/log/utmp
d. /var/log/messages

# You have been told to configure a method of rotating log files on your system. Which of the following factors do you not need to consider? Choose one:
a. date and time of messages
b. log size
c. frequency of rotation
d. amount of available disk space

# What utility can you use to automate rotation of logs?

# You wish to rotate all your logs weekly except for the /var/log/wtmp log which you wish to rotate monthly. How could you accomplish this. Choose one:
a. Assign a global option to rotate all logs weekly and a local option to rotate the /var/log/wtmp log monthly.
b. Assign a local option to rotate all logs weekly and a global option to rotate the /var/log/wtmp log monthly.
c. Move the /var/log/wtmp log to a different directory. Run logrotate against the new location.
d. Configure logrotate to not rotate the /var/log/wtmp log. Rotate it manually every month.

# You have configured logrotate to rotate your logs weekly and keep them for eight weeks. You are running our of disk space. What should you do? Choose one:
a. Quit using logrotate and manually save old logs to another location.
b. Reconfigure logrotate to only save logs for four weeks.
c. Configure logrotate to save old files to another location.
d. Use the prerotate command to run a script to move the older logs to another location.

Top Linux Admin Interview Questions and answers asked in TOP IT industries : Question Bank 04

Linux Admin Interview Questions and Answers

All Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Questions BANK 04

# You enter the command cat MyFile | sort > DirList & and the operating system displays [4] 3499 What does this mean? Choose one
a. This is job number 4 and the PID of the sort command is 3499.
b. This is job number 4 and the PID of the job is 3499.
c. This is job number 3499 and the PID of the cat command is 4.
d. This is job number 4 and the PID of the cat command is 3499.

# You attempt to log out but receive an error message that you cannot. When you issue the jobs command, you see a process that is running in the background. How can you fix this so that you can logout? Choose one
a. Issue the kill command with the PID of each running command of the pipeline as an argument.
b. Issue the kill command with the job number as an argument.
c. Issue the kill command with the PID of the last command as an argument.
d. Issue the kill command without any arguments.

# You have been given the job of administering a new server. It houses a database used by the sales people. This information is changed frequently and is not duplicated anywhere else. What should you do to ensure that this information is not lost? Choose one
a. Create a backup strategy that includes backing up this information at least daily.
b. Prepare a proposal to purchase a backup server
c. Recommend that the server be made part of a cluster.
d. Install an additional hard drive in the server.

# When planning your backup strategy you need to consider how often you will perform a backup, how much time the backup takes and what media you will use. What other factor must you consider when planning your backup strategy? _________

# Many factors are taken into account when planning a backup strategy. The one most important one is how often does the file ____________.

# Which one of the following factors does not play a role in choosing the type of backup media to use? Choose one:
a. How frequently a file changes
b. How long you need to retain the backup
c. How much data needs to be backed up
d. How frequently the backed up data needs to be accessed

# When you only back up one partition, this is called a ______ backup. Choose one
a. Differential
b. Full
c. Partial
d. Copy

# When you back up only the files that have changed since the last backup, this is called a ______ backup. Choose one
a. Partial
b. Differential
c. Full
d. Copy

# The easiest, most basic form of backing up a file is to _____ it to another location.

# When is the most important time to restore a file from your backup? Choose one
a. On a regular scheduled basis to verify that the data is available.
b. When the system crashes.
c. When a user inadvertently loses a file.
d. When your boss asks to see how restoring a file works.

# As a system administrator, you are instructed to backup all the users’ home directories. Which of the following commands would accomplish this? Choose one
a. tar rf usersbkup home/*
b. tar cf usersbkup home/*
c. tar cbf usersbkup home/*
d. tar rvf usersbkup home/*

# What is wrong with the following command? tar cvfb / /dev/tape 20 Choose one
a. You cannot use the c option with the b option.
b. The correct line should be tar -cvfb / /dev/tape20.
c. The arguments are not in the same order as the corresponding modifiers.
d. The files to be backed up have not been specified.

# You need to view the contents of the tarfile called MyBackup.tar. What command would you use? __________

# After creating a backup of the users’ home directories called backup.cpio you are asked to restore a file called memo.ben. What command should you type?

# You want to create a compressed backup of the users’ home directories so you issue the command gzip /home/* backup.gz but it fails. The reason that it failed is that gzip will only compress one _______ at a time.

# You want to create a compressed backup of the users’ home directories. What utility should you use?

# You routinely compress old log files. You now need to examine a log from two months ago. In order to view its contents without first having to decompress it, use the _________ utility.

Top Linux Admin Interview Questions asked in TOP IT industries : Question Bank 3

Linux Admin Interview Questions and Answers

Questions consists of Linux Admin Interview Questions and Answers, Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Questions BANK 03


# When typing at the command line, the default editor is the _____________ library.

# You typed the following at the command line ls -al /home/ hadden. What key strokes would you enter to remove the space between the ‘/’ and ‘hadden’ without having to retype the entire line? Choose one
a. Ctrl-B, Del
b. Esc-b, Del
c. Esc-Del, Del
d. Ctrl-b, Del

# You would like to temporarily change your command line editor to be vi. What command should you type to change it?

# After experimenting with vi as your command line editor, you decide that you want to have vi your default editor every time you log in. What would be the appropriate way to do this? Choose one
a. Change the /etc/inputrc file
b. Change the /etc/profile file
c. Change the ~/.inputrc file
d. Change the ~/.profile file

# You have to type your name and title frequently throughout the day and would like to decrease the number of key strokes you use to type this. Which one of your configuration files would you edit to bind this information to one of the function keys?

# In your present working directory, you have the files maryletter memo1 MyTelephoneandAddressBook What is the fewest number of keys you can type to open the file MyTelephoneandAddressBook with vi? Choose one
a. 6
b. 28
c. 25
d. 4

# A variable that you can name and assign a value to is called a _____________ variable.

# You have installed a new application but when you type in the command to start it you get the error message Command not found. What do you need to do to fix this problem? Choose one
a. Add the directory containing the application to your path
b. Specify the directory’s name whenever you run the application
c. Verify that the execute permission has been applied to the command.
d. Give everyone read, write and execute permission to the application’s directory.

# You telnet into several of your servers simultaneously. During the day, you sometimes get confused as to which telnet session is connected to which server. Which of the following commands in your .profile file would make it obvious to which server you are attached? Choose one
a. PS1=’\h: \w>’
b. PS1=’\s: \W>’
c. PS1=’\!: \t>’
d. PS1=’\a: \n>’

# Which of the following environment variables determines your working directory at the completion of a successful login? Choose one
a. HOME
b. BASH_ENV
c. PWD
d. BLENDERDIR

# Every time you attempt to delete a file using the rm utility, the operating system prompts you for confirmation. You know that this is not the customary behavior for the rm command. What is wrong? Choose one
a. rm has been aliased as rm -i
b. The version of rm installed on your system is incorrect.
c. This is the normal behavior of the newest version of rm.
d. There is an incorrect link on your system.

# You are running out of space in your home directory. While looking for files to delete or compress you find a large file called .bash_history and delete it. A few days later, it is back and as large as before. What do you need to do to ensure that its size is smaller? Choose one
a. Set the HISTFILESIZE variable to a smaller number.
b. Set the HISTSIZE to a smaller number.
c. Set the NOHISTFILE variable to true.
d. Set the HISTAPPEND variable to true.

# In order to display the last five commands you have entered using the history command, you would type ___________.

# In order to display the last five commands you have entered using the fc command, you would type ___________.

# You previously ran the find command to locate a particular file. You want to run that command again. What would be the quickest way to do this? Choose one
a. fc -l find fc n
b. history -l find history n
c. Retype the command
d. fc -n find

# Using command substitution, how would you display the value of the present working directory? Choose one
a. echo $(pwd)
b. echo pwd
c. $pwd
d. pwd | echo

# You need to search the entire directory structure to locate a specific file. How could you do this and still be able to run other commands while the find command is still searching for your file? Choose one
a. find / -name filename &
b. find / -name filename
c. bg find / -name filename
d. &find / -name filename &

# In order to create a file called DirContents containing the contents of the /etc directory you would type ____________.

# What would be displayed as the result of issuing the command ps ef? Choose one
a. A listing of the user’s running processes formatted as a tree.
b. A listing of the stopped processes
c. A listing of all the running processes formatted as a tree.
d. A listing of all system processes formatted as a tree.

# What utility can you use to show a dynamic listing of running processes? __________

# The top utility can be used to change the priority of a running process? Another utility that can also be used to change priority is ___________?

# What key combination can you press to suspend a running job and place it in the background?

# You issue the command jobs and receive the following output: [1]- Stopped (tty output) pine [2]+ Stopped (tty output) MyScript How would you bring the MyScript process to the foreground? Choose one:
a. fg %2
b. ctrl-c
c. fg MyScript
d. ctrl-z

Top Linux Admin Interview Questions asked in TOP IT industries : Question Bank 2

Top Linux Admin Interview Questions and Answers

Questions consists of Linux Admin Interview Questions and Answers, Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Questions BANK 02


# What command is used to remove the password assigned to a group?

# You changed the GID of the sales group by editing the /etc/group file. All of the members can change to the group without any problem except for Joe. He cannot even login to the system. What is the problem? Choose one:
a. Joe forgot the password for the group.
b. You need to add Joe to the group again.
c. Joe had the original GID specified as his default group in the /etc/passwd file.
d. You need to delete Joe’s account and recreate it.

# You need to delete the group dataproject. Which two of the following tasks should you do first before deleting the group?
A. Check the /etc/passwd file to make sure no one has this group as his default group.
B. Change the members of the dataproject group to another group besides users.
C. Make sure that the members listed in the /etc/group file are given new login names.
D. Verify that no file or directory has this group listed as its owner.
Choose one: a. A and C b. A and D c. B and C d. B and D

# When you look at the /etc/group file you see the group kmem listed. Since it does not own any files and no one is using it as a default group, can you delete this group?

# When looking at the /etc/passwd file, you notice that all the password fields contain ‘x’. What does this mean? Choose one:
a. That the password is encrypted.
b. That you are using shadow passwords.
c. That all passwords are blank.
d. That all passwords have expired.

# In order to improve your system’s security you decide to implement shadow passwords. What command should you use?

# What file contains the default environment variables when using the bash shell? Choose one:
a. ~/.profile
b. /bash
c. /etc/profile
d. ~/bash

# You have created a subdirectory of your home directory containing your scripts. Since you use the bash shell, what file would you edit to put this directory on your path? Choose one:
a. ~/.profile
b. /etc/profile
c. /etc/bash
d. ~/.bash

# Which of the following interprets your actions when typing at the command line for the operating system? Choose One
a. Utility
b. Application
c. Shell
d. Command

# What can you type at a command line to determine which shell you are using?

# You want to enter a series of commands from the command-line. What would be the quickest way to do this? Choose One
a. Press enter after entering each command and its arguments
b. Put them in a script and execute the script
c. Separate each command with a semi-colon (;) and press enter after the last command
d. Separate each command with a / and press enter after the last command

# You are entering a long, complex command line and you reach the right side of your screen before you have finished typing. You want to finish typing the necessary commands but have the display wrap around to the left. Which of the following key combinations would achieve this? Choose One
a. Esc, /, Enter
b. /, Enter
c. ctrl-d, enter
d. esc, /, ctrl-d

# After typing in a new command and pressing enter, you receive an error message indicating incorrect syntax. This error message originated from.. Choose one
a. The shell
b. The operating system
c. The command
d. The kernel

Top Linux Admin Interview Questions asked in TOP IT industries

Hey Guys, AFRAID of interviews

DONT Worry prepare the following questions before Interview. I have managed to prepare some questions sets. Practice this and i'm sure you would crack a L1/L2/L3 Linux Administrator Job Easily. All the questions are taken from the top IT brands interviews.

Linux Admin Interview Questions and Answers, Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Questions BANK 01

# You attempt to use shadow passwords but are unsuccessful. What characteristic of the /etc/passwd file may cause this? Choose one:
a. The login command is missing.
b. The username is too long.
c. The password field is blank.
d. The password field is prefaced by an asterick.

# You create a new user account by adding the following line to your /etc/passwd file. bobm:baddog:501:501:Bob Morris:/home/bobm:/bin/bash Bob calls you and tells you that he cannot logon. You verify that he is using the correct username and password. What is the problem? Choose one:
a. The UID and GID cannot be identical.
b. You cannot have spaces in the line unless they are surrounded with double quotes.
c. You cannot directly enter the password; rather you have to use the passwd command to assign a password to the user.
d. The username is too short, it must be at least six characters long.

# Which of the following tasks is not necessary when creating a new user by editing the /etc/passwd file? Choose one:
a. Create a link from the user’s home directory to the shell the user will use.

b. Create the user’s home directory
c. Use the passwd command to assign a password to the account.
d. Add the user to the specified group.

# You create a new user by adding the following line to the /etc/passwd file bobm::501:501:Bob Morris:/home/bobm:/bin/bash You then create the user’s home directory and use the passwd command to set his password. However, the user calls you and says that he cannot log on. What is the problem? Choose one:
a. The user did not change his password.
b. bobm does not have permission to /home/bobm.
c. The user did not type his username in all caps.
d. You cannot leave the password field blank when creating a new user.

# When using useradd to create a new user account, which of the following tasks is not done automatically. Choose one:
a. Assign a UID.
b. Assign a default shell.
c. Create the user’s home directory.
d. Define the user’s home directory.

# You issue the following command useradd -m bobm But the user cannot logon. What is the problem? Choose one:
a. You need to assign a password to bobm’s account using the passwd command.
b. You need to create bobm’s home directory and set the appropriate permissions.
c. You need to edit the /etc/passwd file and assign a shell for bobm’s account.
d. The username must be at least five characters long.

# You have created special configuration files that you want copied to each user’s home directories when creating new user accounts. You copy the files to /etc/skel. Which of the following commands will make this happen? Choose one:
a. useradd -m username
b. useradd -mk username
c. useradd -k username
d. useradd -Dk username

# Mary has recently gotten married and wants to change her username from mstone to mknight. Which of the following commands should you run to accomplish this? Choose one:
a. usermod -l mknight mstone
b. usermod -l mstone mknight
c. usermod -u mknight mstone
d. usermod -u mstone mknight

# After bob leaves the company you issue the command userdel bob. Although his entry in the /etc/passwd file has been deleted, his home directory is still there. What command could you have used to make sure that his home directory was also deleted? Choose one:
a. userdel -m bob
b. userdel -u bob
c. userdel -l bob
d. userdel -r bob

# All groups are defined in the /etc/group file. Each entry contains four fields in the following order. Choose one:
a. groupname, password, GID, member list
b. GID, groupname, password, member list
c. groupname, GID, password, member list
d. GID, member list, groupname, password

# You need to create a new group called sales with Bob, Mary and Joe as members. Which of the following would accomplish this? Choose one:
a. Add the following line to the /etc/group file: sales:44:bob,mary,joe
b. Issue the command groupadd sales.
c. Issue the command groupadd -a sales bob,mary,joe
d. Add the following line to the /etc/group file: sales::44:bob,mary,joe
Linux Admin Interview Questions and Answers, Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Checking if MYSQL is 32Bits or 64Bits?

Do you know MYSQL installed on your system is MYSQL 32Bit or MYSQL 64Bit.


You can achieve this in Different Ways. The best command i found was "file"

Find the MYSQLD location

# which mysqld
/bin/mysqld


# file /bin/mysqld
/bin/mysqld: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped


FOR 64 Bit this would show

# file /bin/mysqld
/usr/sbin/mysqld: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), stripped


The other way to find is using mysql to find it
MYSQL on 32 Bit System

mysql> SHOW GLOBAL VARIABLES LIKE 'version_compile_machine';
+-------------------------+-------+
| Variable_name | Value |
+-------------------------+-------+
| version_compile_machine | i686 |
+-------------------------+-------+
1 row in set (0.00 sec)


MYSQL on 64 Bit System
mysql> show variables like 'version_compile_machine';
+-------------------------+--------+
| Variable_name | Value |
+-------------------------+--------+
| version_compile_machine | x86_64 |
+-------------------------+--------+


We can also check if the mysqld binary are linked to which library
MYSQL on 32bit System
[root@localhost ~]# ldd /bin/mysqld
linux-gate.so.1 => (0x00df0000)
libpthread.so.0 => /lib/libpthread.so.0 (0x007cf000)
libdl.so.2 => /lib/libdl.so.2 (0x007c9000)
librt.so.1 => /lib/librt.so.1 (0x007fd000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x0490d000)
libnsl.so.1 => /lib/libnsl.so.1 (0x0032e000)
libm.so.6 => /lib/libm.so.6 (0x007a0000)
libc.so.6 => /lib/libc.so.6 (0x0065a000)
/lib/ld-linux.so.2 (0x00637000)


MYSQL on 64 Bit System
# ldd /usr/local/mysql/libexec/mysqld
linux-vdso.so.1 => (0x00007fff6d5ff000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007ff3650d3000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007ff364ebc000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007ff364bb0000)
libdl.so.2 => /lib/libdl.so.2 (0x00007ff3649ac000)
librt.so.1 => /lib/librt.so.1 (0x00007ff3647a3000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x00007ff36456b000)
libnsl.so.1 => /lib/libnsl.so.1 (0x00007ff364353000)
libm.so.6 => /lib/libm.so.6 (0x00007ff3640d0000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007ff363eb9000)
libc.so.6 => /lib/libc.so.6 (0x00007ff363b66000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff3652ef000)


Another Method is using "ELFREAD"
MYSQL on 32 Bit System

[root@localhost ~]# readelf -h /bin/mysqld
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x81805a0
Start of program headers: 52 (bytes into file)
Start of section headers: 39507760 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 9
Size of section headers: 40 (bytes)
Number of section headers: 44
Section header string table index: 41


MYSQL on 64 Bit System

[root@localhost ~]# readelf -h /bin/mysqld
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x4e5a30
Start of program headers: 64 (bytes into file)
Start of section headers: 7548008 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 9
Size of section headers: 64 (bytes)
Number of section headers: 32
Section header string table index: 31

Monday, February 22, 2010

How to start Python Simple Httpd Server for Simple File Sharing

Do you want to share a file and dont have any prior knowledge of setting up WebServer or FTP Server or even dont know about other file sharing protocols knowledge. This Issues can be resolved using Python Language.

How to Do that?

1. As Root go to the location which you want to Share to the External Users.

[root@localhost ~]# cd /tmp

2. Run the Python Command with a Defined port or default will be used (Port 8000).

[root@localhost tmp]# python -m SimpleHTTPServer 19000 &

Note :
a) To Run the Command in background use "&" at the end.
b) In the above case the Port number is set to be 19000.

3. From the Remote System In the browser Type in the IPaddress:Portno you have used. Now you can see the contents of the /tmp directory
http://ip.addr.ess:19000

4. Yeppie Thats it !!!! you are now sharing your files without setting up WebServer or any FTP Server or any knowledge of system administration.

How to sent Message through Terminal to a Login users In Fedora, Centos, RedHat, Ubuntu.

You can broadcast a message using WALL -- How to broadcast a Message through Terminal to Login users How To but what if you want to sent message to only a particular user logged into the system or different Messages to Different users. Yes its possible using write command.

Before using write command Check if it is avaliable in you system. From the terminal Run

[root@localhost ~]# which write

which should give
[root@localhost ~]# which write
/usr/bin/write


If write is not installed Install bsdmainutil package

Once Installed to sent message to a particular user we need to know which users are currently logged into the System

[root@localhost ~]# w

USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
ashwin :0 - 15Feb10 ?xdm? 7:56m 0.21s /usr/bin/gnome-session
ashwin pts/1 :0.0 11:34 22.00s 1.08s 0.01s gnome-terminal
demo1 pts/2 :0.0 11:58 11.00s 1.07s 1.2s gnome-terminal
demo2 pts/3 :0.0 01:58 8.00s 0.16s 1.8s gnome-terminal
ashwin pts/4 :0.0 12:58 1:47 4.02s 0.02s bash


Now you have the list of users logged in.

METHOD 1
[root@localhost ~]# write ashwin pts/4
Your Message 1
Your Message 2
Your Message 3
Once Done

“Terminate the write by ctrl+D.”


The User "ashwin" would see the message into the console as

[ashwin@localhost ~]$
Message from ashwin@localhost (as root) on pts/2 at 12:49 ...
Your Message 1
Your Message 2
Your Message 3
EOF


METHOD 2
[ashwin@localhost ~]$ echo "Test Message Using Write from http://linuxmaza.com" > /dev/pts/3

The above command will display a message to User "demo2" on the console.

Write Command Runs on all linux distros and installed by default in Fedora, Centos. Please refer the documentation if it is not installed under you linux distribution.

How to broadcast a Message through Terminal to Login users In Fedora, Centos, RedHat, Ubuntu

Do you want to sent message to all logged in users in your system (This works great when you are a System Administrator and many users are logged into same System)?

If you are Running Any Linux Distribution like Fedora, Centos, RedHat, Ubuntu you can send or broadcast message to all user logged in using "WALL" command. To use it on the command line / Terminal.

METHOD 1
========

[root@localhost ~]# wall "Your message Goes here"


Now all users can see the Message Broadcasted by You

[ashwin@localhost tmp]$
Broadcast message from root (pts/2) (Mon Feb 22 12:10:35 2010):

Your message Goes here


METHOD 2
========
[shankar@localhost ~]$ wall [Press Enter]
Write You Message Here.
Testing Wall OutPut On All Terminals.
Finished


Press Ctrl + D for EOF (End of File)

[root@localhost ~]#
Broadcast message from shankar (pts/3) (Mon Feb 22 12:14:55 2010):

Write You Message Here.
Testing Wall OutPut On All Terminals.
Finished


All Users can view the Message on their Terminal as below

[root@localhost ~]#
Broadcast message from shankar (pts/3) (Mon Feb 22 12:14:55 2010):

Write You Message Here.
Testing Wall OutPut On All Terminals.
Finished


Limitations of Wall :
1. The total length of the message is limited to 22 lines.
2. Broadcasted Messages are limited to The System Itself.

Advantages of Wall
1. During an Activity / Crisis on the system all users can be notified immediately
2. No need to Send Email to the users who are Logged into the System.

Wednesday, February 17, 2010

Mounting SSH Server Using FUSE

FUSE which stands for Filesystem in Userspace has brought a host of features to mount a remote filesystem using various protocols like SSH, FTP. FUSE allows non privileged users to develop their own filesystem without even modifying the Kernel, basically fuse is module which play a role of bridge between user space and the kernel.

To Mount a remote partition locally. Run the Command (You Dont Need To be Root User to Run this Command).

root# sshfs user@hostname:path_of_directory_to_be_mounted mount_to_point

root# sshfs ashwin@192.168.1.10:/home/ashwin /mnt/

If You are using a specific port for connecting to your SSH Server use -p Option

root# sshfs -p 10234 ashwin@192.168.1.10:/home/ashwin /mnt/

where 10234 is the port running SSH Service
Important Note : To Mount other Partition like /var, /opt, /root you have to mount being a root user ofthe remote machine.

root# cd /mnt

root# ls

msrv2826d0.1.tmp
keyring-0sIxHo keyring-K0zJSJ msrv2832d0.1.tmp
keyring-16cIRa keyring-kJqkFX mysqlbin.000085
keyring-1h8sea keyring-kzkqpE mysqlbin.000086
keyring-1M5nUH keyring-lyNVMO mysqlbin.000087
keyring-2i7woO keyring-m0dxjd mysqlbin.000088
keyring-4hSFtb keyring-m1xNam mysqlbin.000089
keyring-68PwBN keyring-mTgrKf mysqlbin.000092
keyring-7JY4q3 keyring-NDLFUc mysqlbin.000093
keyring-7zjMDV keyring-nt2Ygk mysqlbin.index


Enjoy, you have mounted a remote directory locally that to on secured transmission.