Tuesday, April 8, 2014

Sendmail Error : NOQUEUE: SYSERR(root): No local mailer defined NOQUEUE: SYSERR(root): QueueDirectory (Q) option must be set

Error using m4 macro while building sendmail.cf from sendmail.mc on RHEL 6 / CentOS 6 flavors?

[root@cent1]# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
m4:/etc/mail/sendmail.mc:10: cannot open `/usr/share/sendmail-cf/m4/cf.m4': No such file or directory
[root@cent1]#

The above error is because the package sendmail-cf is not installed.


You will have the below error messages on the /var/log/maillog file also. 

sendmail[3215]: gethostbyaddr(10.0.3.15) failed: 2
sendmail[3215]: NOQUEUE: SYSERR(root): No local mailer defined
sendmail[3215]: NOQUEUE: SYSERR(root): QueueDirectory (Q) option must be set

The above error is because the sendmail.cf is not configured properly. 

Fix is to install the package sendmail-cf, build sendmail.cf from sendmail.mc and restart sendmail service.

Install the sendmail-cf

# yum install -y sendmail-cf


Comment the entry which makes the sendmail listens only to loopback address as below by adding "dnl" on /etc/mail/sendmail.mc

# vi /etc/mail/sendmail.mc
dnl # DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

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

# service sendmail restart

Check if sendmail is started properly.

[root@cent1 ~]# netstat -tulnp |  grep -i :25
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      3748/sendmail
[root@cent1 ~]#

Hope this helps.
Jk


Change Default MTA in RHEL 6 / Cent OS 6

By default Postfix is set as the default mail transfer agent in Redhat Enterprise Linux 6 and Cent OS 6 flavors.

However you can change the default Mail transfer Agent in RHEL 6 using the below commands.

* Install Sendmail if not yet installed.

# yum install sendmail -y

Change the default MTA.

# alternatives --config mta

There are 2 programs which provide 'mta'.
  Selection    Command
-----------------------------------------------
 + 1           /usr/sbin/sendmail.postfix
*  2           /usr/sbin/sendmail.sendmail
Enter to keep the current selection[+], or type selection number: 2
#

Congrats, now your default MTS is changed from postfix to Sendmail.

Regards,
Jk

Thursday, October 10, 2013

How to configure Veritas Volume Manager VxVM 6.0.2

The disks should be discovered by OS before it can be added to Veritas Volume Manager.


1. List the disks detected by VxVM.

# vxdisk -o alldgs list


Eg :

[root@rhel61 ~]# vxdisk -o alldgs list
DEVICE       TYPE            DISK         GROUP        STATUS
sda          auto:none       -            -            online invalid
sdb          auto:none       -            -            online invalid
sdc          auto:cdsdisk    mydg01       mydg         online
sdd          auto:cdsdisk    mydg02       mydg         online
[root@rhel61 ~]#

sda and sbd are not configured / initialized for VxVM; where as sdc and sdd are initialized and added to a disk group.


2. Initialize disks.

vxdisksetup -i [attributes]

# vxdisksetup -i sdc
# vxdisksetup -i emc0_dd1

Initializing a disk will create Privae and Public regions in the disks, Meta data is stored in private region and public reagion is available for general purpose data usage. 32 MB is reserved for private region.

Friday, July 5, 2013

Configure DNS Client in Solaris 11.1

Solaris 11.1 saw a lot of changes. A number of configurations has been moved from config files to Service Management Framework , SMF.

To enable DNS client you should be come an Administrator.

1. List the current DNS Client configuration.

root@solaris11.1:~# svccfg -s network/dns/client listprop config
config                      application
config/value_authorization astring     solaris.smf.value.name-service.dns.client
config/domain              astring     Home
config/nameserver          net_address
root@solaris11.1:~#


2. Update the SMF repository with the DNS server name. Let 192.168.1.1 and 192.168.1.2 be the primary and secondary DNS server.

root@solaris11.1:~# svccfg -s network/dns/client setprop config/nameserver = net_address: "(192.168.1.1 192.168.1.2)"
root@solaris11.1:~#

3. change the Domain name.
root@solaris11.1:~# svccfg -s network/dns/client setprop config/domain = astring: '("solaris.local")'
root@solaris11.1:~#

4. Change the search domains.
root@solaris11.1:~# svccfg -s network/dns/client setprop config/search = astring: '("solaris.local" test.solaris.local)'
root@solaris11.1:~#

5. Update the Name resolution order.
root@solaris11.1:~# svccfg -s name-service/switch setprop config/host = astring: '("files dns mdns")'
root@solaris11.1:~#

6. Review the modified DNS client configuration
root@solaris11.1:~# svccfg -s network/dns/client listprop config
config                      application
config/value_authorization astring     solaris.smf.value.name-service.dns.client
config/domain              astring     solaris.local test.solaris.local
config/nameserver          net_address 192.168.1.1 192.168.1.2
root@solaris11.1:~#

root@sol1:~# svccfg -s name-service/switch listprop config
config                      application
config/default             astring     files
config/value_authorization astring     solaris.smf.value.name-service.switch
config/host                astring     "files dns mdns"
config/printer             astring     "user files"
root@sol1:~#

Jayakrishnan

Wednesday, June 12, 2013

Cut command reference

Cut is a simpler alternative to the sed command. Cut is also very efficient and flexible..

The examples specified below is from Solaris 11.1 and  RedHat Enterprise Linux 6.4, however most of the Linux / Unix distributions supports the cut command.

We shall use the below file for our examples.

root@sol1:~/jk# cat testfile.txt
This is a test file to demonstrate "cut" command.
Cut can be used for line filtering.
Cut is simpler than awk and sed commands.
root@sol1:~/jk#


1. Select a field from a file.
You can combine -f and -d to print required field. -f specifies the field and -d specified the delimiter to be used to find the filed.

root@sol1:~/jk# cut -d':' -f1 /etc/passwd | head -5
root
daemon
bin
sys
adm
root@sol1:~/jk#


2. Select multiple fields from a file.
To select multiple fields use comma separated numbers with -f.

root@sol1:~/jk# cut -d' ' -f 1,5 testfile.txt
This file
Cut for
Cut awk
root@sol1:~/jk#
Here 'space' is the delimiter.


3. Select Column of characters.
To print selected column or character from a file use -c option.

root@sol1:~/jk# cut -c2 testfile.txt
h
u
u
root@sol1:~/jk#
 
As you can see, h,u,u are the 2nd character on each line.


4.  Select column of characters using range.
 
To print from 3rd character to the end :

root@sol1:~/jk# cut -c3- testfile.txt
is is a test file to demonstrate "cut" command.
t can be used for line filtering.
t is simpler than awk and sed commands.
root@sol1:~/jk#

To print till 5th character :

root@sol1:~/jk# cut -c-5 testfile.txt
This
Cut c
Cut i
root@sol1:~/jk#

To print from 5th character to 10th character.
 
root@sol1:~/jk# cut -c5-10 testfile.txt
 is a
can be
is sim
root@sol1:~/jk#

Whole lines will be print if no number is specified before or after '-'.

root@sol1:~/jk# cut -c- testfile.txt
This is a test file to demonstrate "cut" command.
Cut can be used for line filtering.
Cut is simpler than awk and sed commands.
root@sol1:~/jk#

5. Print fields only when the delimiter specified is present.

If the delimiter specified is not present in the file, cut will print the whole lines.

root@sol1:~/jk# cut -d'|' -f1 /etc/passwd | head -5
root:x:0:0:Super-User:/root:/usr/bin/bash
daemon:x:1:1::/:
bin:x:2:2::/usr/bin:
sys:x:3:3::/:
adm:x:4:4:Admin:/var/adm:
root@sol1:~/jk#

Use '-s' to prevent this behaviour.

root@sol1:~/jk# cut -d'|' -s -f1 /etc/passwd | head -5
root@sol1:~/jk#

6. To select all fields except the ones specified.
Use --complement to invert cut's behavior. Note '--complement' is not available in Solaris.

root@sol1:~/jk# cut -d' ' --complement -f1,3 testfile.txt
is test file to demonstrate "cut" command.
can used for line filtering.
is than awk and sed commands.
root@sol1:~/jk#


7. Change output delimiter for ease of reading.
You can use '--output-delimiter' to custom specify the delimiter to print. Note : --output-delimiter is not available in Solaris.

root@rhel:~/jk# grep "/bin/bash" /etc/passwd | cut -d':'  -s -f1,6,7 --output-delimiter='#'
root#/root#/usr/bin/bash
root@rhel:~/jk#

You can also use the escape characters as follows. For changing the delimiter to "new line":

root@sol1:~/jk# grep "/bin/bash" /etc/passwd | cut -d':'  -s -f1,6,7 --output-delimiter=$'\n'
root
/root
/usr/bin/bash
root@sol1:~/jk#

Remember to use "$" as the escape character.

Cut is a very cool and simple utility. Master it !!

JK.

Thursday, April 25, 2013

Set Setuid, Setgid and Sticky bit in Linux

Special permissions on files and directories in linux are : SetUID, SetGID and Sticky bit.

With the help of “chmod” command  we can implement the special permissions on file and directories.

SUID / Set User ID : A program is executed with the file owner's permissions (rather than with the permissions of the user who executes it).

SGID / Set Group ID : Files created in the directory inherit its GID, i.e When a directory is shared between the users , and sgid is implemented on that shared directory , when these users creates  directory, then the created directory has the same gid or group owner of its parent directory.

Sticky Bit :  It is used mainly used on folders in order to avoid deletion of a folder and its content by other user though he/she is having write permissions. If Sticky bit is enabled on a folder, the folder is deleted by only owner of the folder and super user(root). This is a security measure to suppress deletion of critical folders where it is having full permissions by others.

Assign IP Address and Gateway in Linux from Command Line

if config command is used to assign the ip address to a lan card from the command or from the terminal.

Syntax :

 # ifconfig [-v] [-a] [-s]  [interface]

Options :
  • -a :    display all interfaces which are currently available, even if down
  • -s :    display a short list (like netstat -i)
  • -v :   be more verbose for some error conditions
interface : The name of the interface.  This is usually a driver name followed by a unit number, for example eth0 for  the  first Ethernet interface. If your kernel supports alias interfaces, you can specify them with eth0:0 for the first alias of eth0. One can use them to assign a second address. To delete an alias interface use ifconfig eth0:0 down.