Subscribe:

Ads 468x60px

Pages

Tuesday, June 28, 2011

Installing and configuring the Postfix mail server


Postfix provides for easier administration, allows increased security, and supports virtual domains. It is also the default mail program on RHEL6. It is the outgoing mail server.


Step 1. To verify that Postfix is installed or not
# rpm -qa | grep postfix


If the package isn’t installed then install it
# yum install –y postfix


Step 2. To start service during system boot time
# chkconfig postfix on


Step 3. Nedd to Stop the sendmail service because you are going to use Postfix in place of the default Sendmail:
# service sendmail stop


Step 4. Need to off sendmail service during system boot if the service is on:
# chkconfig sendmail --list
# chkconfig sendmail off


Step 6. Change the default mail program to Postfix:
# alternatives --config mta
There are 2 programs which provide ‘mta’.
Selection Command
----------------------------------------------
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.postfix
Enter to keep the current selection[+], or type selection number: 2


Step 7. Verify that the current default for mail is Postfix:
# alternatives --display mta | grep current


Edit the master.cf file:
# vim /etc/postfix/main.cf


Step 2. Change the following options:
myhostname = server1.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks = 192.168.1.0/24, 127.0.0.0/8


configure DNS server with the correct MX records before you start the Postfix service.


Step 3. Check sytax of config file:
# postfix check




Step 4. Start the Postfix service:
# service postfix start


Step 1.To open TCP port 25 for the SMTP service
# iptables -I INPUT 5 -p tcp -m tcp --dport 25 -j ACCEPT


Step 2. Save the rule:
# service iptables save


Step 3. Restart the iptables service:
# service iptables restart
Read more...

Email Service

The email system is divided into three different parts: 
1. MUA
2. MDA
3. MTA.


Mail User Agent(MAU):
It deals specifically with end users. It is what they use to type and read emails they receive. The MUA is a mail client of some sort, such as Thunderbird or Evolution. 


Mail Delivery Agent (MDA):
It handles the delivery of mail from the receiving mail server to the spool where the mail sits
until an MUA picks it up for the user. 


Mail Transfer Agent (MTA):
It is responsible for moving mail from one server to another until it arrives at its destination.
Read more...

Monday, June 27, 2011

Description of /etc/fstab fields

There are 5 fields present in the /etc/fstab:

1. Label - Lists the device to be mounted.



2. Mount Point - The directory where the filesystem will be mounted.


3. Filesystem Format - Describes the filesystem type. Valid filesystem types include ext,ext2, ext3, ext4, swap, msdos, vfat, proc, tmpfs, is09660, nfs and smb.


4. Dump value - It should be either 0 or 1. A value of 1 means that data is automatically saved to disk by the dump command when you exit linux.data should be backed up (also called dumping) before a system shutdown or reboot occurs. This field commonly uses a value of 1. A value of 0 might be used if the file system is a temporary storage space for files, such as /tmp.


5. Filesytem check order - It determines the order that filesystem are checked by fsck during the boot process. The root directory (/) filesystem should be set to 1, and other local filesystems should be set to 2. Removable filesystems such as /mnt/cdrom should be set to 0, which means that they are not checked during the linux boot process.

Read more...

Friday, June 24, 2011

Backup MySql server database using bash script

Create the bash shell script for taking the My Sql server database backup
#vim mysqlbackup.sh
#!/bin/sh
# backup mysql databases shell script

DATE=$(date +%Y-%m-%d)
MYSQL=$(which mysql)
MYSQLDUMP=$(which mysqldump)
MYSQL_USER="root"
MYSQL_PASS="password"
HOSTNAME=$(hostname)
GZIP=$(which gzip)
ARG="-u $MYSQL_USER -p$MYSQL_PASS"
DATABASES=$($MYSQL $ARG -s -e "SHOW DATABASES;")
BACKUP_PATH="/home/backup/$DATE/mysql"


! [ -d $BACKUP_PATH ] && mkdir -p $BACKUP_PATH

for DB in $DATABASES
do
BACKUP_FILE="$BACKUP_PATH/$HOSTNAME-mysql-$DB-$DATE.sql.gz"
$MYSQLDUMP $ARG $DB | $GZIP -9 > $BACKUP_FILE
done
:wq
Read more...

Installing and configuring the VNC(Virtual Networked Computing) server


VNC, or Virtual Networked Computing, is a way of controlling a remote computer just as though you are sitting in front of it. In the Windows world it is also known as remote desktop but it's normally referred to as VNC in the Linux world.

Local System:
Step1: Check if the package is installed or not
#rpm -qa | grep vnc

Step2 : Install the package if you did not get any output
#yum install tigervnc* -y

Step3 : Add atleast one VNC user
#vim /etc/sysconfig/vncserver
##Add the Following lines at last of the file
VNCSERVERS=”2: student”
VNCSERVERARGS[2]=”-geometry 800*600”

Note: you can add as many as user you like. And geometry sets the size

Save and Exit
:wq


Step4 : Add user student with assign password
#useradd student
#passwd student

Step5 : Login to student user
#su – student

Step6 : Assign the vnc servers password
#vncpasswd

And logout from user
#exit

Step7 : On the service at booting time
#chkconfig vncserver on

Step8 : Now start the apache service
#service vncserver restart

Step9 : check the vncserver port number
#netstat –ntlp | grep 590

Step10 : check the vncserver process running or not
#ps –ef | grep –i vnc

Remote System:
Step11 : Connect from remote machine using the local machine ip and
#vncviewer <remote systems ip>:<desktopnumber>
#vncviewer 192.168.0.254:2

Enter the password of the student user

Read more...

Thursday, June 23, 2011

Install and Configure Apache - IP Based - Part1

Follow below steps :
To install and check if the web server is running with default test page. 
The following requirement is:
The ip address of the system is 192.168.0.110 
Site name is www.ip.com and 
Admin mail id is root@example.com and 
The apache home directory is /var/www/html.

Step1: Check if the package is installed or not
#rpm -qa | grep httpd

Step2 : Install the package if you did not get any output
#yum install httpd

Step3: Check if the package is installed or not
#rpm -qa | grep httpd



Step4: Check configuration files
#rpm -ql httpd
or
#rpm -qc httpd


Step5 : Edit the configuration file
#vim /etc/sysconfig/httpd/conf/httpd.conf
##Modify the following things ###
ServerName <IP address>:80
DocumentRoot /var/www/html

##Define the Virtual Host##
##Copy last 7 line and paste it and Modfy as shown below##
<VirtualHost <SystemIPaddress>:80>
          ServerName www.ip.com
          ServerAdmin root@example.com
          DocumentRoot /var/www/html
          DirectoryIndex index.html
          <Directory /var/www/html>
               Order allow,deny
                Allow from all
          </Directory>
          ErrorLog logs/example.com-error_log
          AccessLog logs/example.com-access_log common
</VirtualHost>


#Save and exit
:wq



Step6 : Create the index file
# cat > /var/www/html/index.html
This is my first ip based web access site.
<ctrl+c>

Step7 : Check the syntax error of configuration file
#httpd -t

Step8 : Check the syntax error of configuration file
#vim /etc/hosts
<SystemipAddress>  www.ip.com

Step9 : On the service at booting time
#chkconfig httpd on

Step10 : Check if the web server is running or not by accessing local host
#elinks www.ip.com
or
#firefox www.ip.com
Read more...

Wednesday, June 22, 2011

403 Forbidden or No Permission to Access


403 Forbidden or No Permission to Access

This type of error is occurred due to permissions or .htaccess error.

Permissions:

The 403 Forbidden error means that your file has bad permissions. Directories and folders must be 755. Executable scripts within the cgi-bin folder must be 755. Images, media, and text files like HTML should be 755 or 644.


Hidden files (dot files):

If you see "client denied by server configuration" in your Error Logs, then this usually means bad file permissions, but could also mean that the visitor is trying to look at a hidden file, like the .htaccess file. You cannot look at that file in your browser, or any file name that starts with a dot.
e.g. http://domain.com/.htaccess will always result in a 403 error.
Read more...

Tuesday, June 21, 2011

Restore SELinux security labels context to html files

Issue: I stored my HTML pages in the root filesystem(/) then i was copied those file to apache home directory(/var/www/html). When i was accessing these pages from browser, it is showing error. Not displaying the page. Problem was Selinux Blocking the context of the apache files. How do I set back the file security contexts to specific files or directories under SElinux enabled kernel?



Solution: If files or directories copied from source to destination then you need to restore back SELinux security labels.
Use restorecon command to set file security contexts. This command is primarily used to set the security context (extended attributes) on one or more files. It can be run at any time to correct errors, to add support for new policy, or with the -n option it can just check whether the file contexts are all as you expect.

Create a html file in the root file system(/)
# cat > index.html
This is my 1st html page
ctrl+c


Move the index.html file to /var/www/html location
# mv index.html /var/www/html/


To view SELinux label
# ls -ldz /var/www/html/index.html


To re-label all the files under the correct security context:
# restorecon -Rv /var/www/html/index.html


Whereas 
-R: Change files and directories file labels recursively
-v: Show changes in file labels.


To view SELinux label
# ls -ldz /var/www/html/index.html
Read more...

Monday, June 20, 2011

Disable the Telnet server

To disable the Telnet server:
Go to the /etc/xinetd.d/telnet and make disable = Yes. Start the xinetd service.


#vi /etc/xinetd.d/telnet
Disable = Yes
:wq


# service xinetd restart
Read more...

Difference between the IMAP, POP and Exchange ActiveSync

The difference between the IMAP, POP and Exchange ActiveSync:


Each of these email protocols operates on a web-based system to transfer messages from a server. In addition, each one supports most, if not all, email clients. So, no matter what email client you choose, you can access your email on a remote server.


IMAP: 
       IMAP supports both online and offline account access. It provides advanced sync features, and lets you view and manage messages without removing them from the server. Therefore, any changes you make are saved and reflected from all locations.


POP:
      The POP protocol lets you read email messages without a constant Internet connection. POP downloads the messages from your server to your local computer or phone. While you can save a copy of the messages on your server, changes made from the local device are not saved on the server.


Exchange ActiveSync:
       The Exchange ActiveSync® protocol provides a robust syncing tool for all of your email, calendar, contacts, and other communications between your desktop, mobile device, or Internet connection. With your Hosted Exchange Email account and your Exchange ActiveSync-enabled phone, you have secure access to communications from anywhere.


referred from: http://community.godaddy.com/help/5231/making-sense-of-email-clients-desktop-and-mobile
Read more...

Taking Back of Outlook


To prevent data loss, we recommend backing up your email. You can easily and routinely back up your data by exporting your PST file.
The PST file stores your email messages, attachments, folder structure, contacts, calendar items, and more. A backed up PST file is easy to import in the event of any data loss.

To Back Up Your Emails to a New PST File

  1. Launch Outlook®.
  2. Click File, and then select Import and Export.
  3. Click Export to a file, and then click Next.
  4. Click Personal Folder File (.pst), and then click Next.
  5. Click the top folder, select Include subfolders, and then click Next.
  6. Type or browse to the folder where you want to save the new file, and name the file.
  7. Click Finish.
Read more...

Process Management


Process:
Any application that runs on a Linux system is assigned a process ID or PID. This is a numerical representation of the instance of the application on the system. In most situations this information is only relevant to the system administrator who may have to debug or terminate processes by referencing the PID. Process Management is the series of tasks a System Administrator completes to monitor, manage, and maintain instances of running applications.

Type of Process: 
1. Interactive Process  
2. System Process (daemon)

Interactive Process:
    The processes that are invoked by a user and can interact with the user is called Interactive processes. Interactive processes can be classified into foreground and background processes. Foreground process is the process that you are currently interacting with, and is using the terminal as its stdin (standard input) and stdout (standard output). Background process is not interacting with the user and can be in one of two states – paused or running.

Example of  Interactive process: 
The following example will show how foreground and background processes are running.
1. Logon as root.
# su -

2. Run [cd \]
# cd \

3. Run [vi]
# vi data.txt

4. Press [ctrl + z]. This will pause vi
Ctrl + z

5. Type [jobs]
# job
Notice:  vi is running in the background

7. Type [fg %1]. This will bring the first background process to the foreground.
# fg %1

8. Close vi 
:q

System Process:
The process that runs on Linux is a system process or Daemon (day-mon). Daemon is the term used to refer to process’ that are running on the computer and provide services but do not interact with the console. Most server software is implemented as a daemon. Apache, Samba, and inn are all examples of daemons.

Any process can become a daemon as long as it is run in the background, and does not interact with the user. A simple example using the [gedit] command. This will list all text editor window separately on the computer. This command can be set to run in the background by typing [gedit&], and although technically you have control over the shell prompt, you will be able to do little work as the screen displays the output of the process that you have running in the background. 

Notice: The standard pause (ctrl+z) and kill (ctrl+c) commands.

1. View linux process
Show process launched for the current linux user
$ ps
Show process launched for a linux user
$ ps -u username
View all the running linux process
$ ps aux
To see a process tree
$ pstree
To see the processes in real time

2. Stop temporarily processes
$ bigjob
^Z (CRTL+Z)

To see the stopped linux processes 
$ jobs
   [1]+ Stopped bigjob

Kill an stopped process
$ kill %1
   [1]+ Killed bigjob
Resume the linux process
$ fg 1

3. Foreground and background linux processes
To start a process in  background mode
$ bigjob &

See process
$jobs
  [1]+  Running bigjob

Put it in foreground mode
$fg 1

ps command:
The ps command is the used to manage running processes and can be used for many things including viewing the status of your computer and knowing how well the computer is performing.

Some common ps commands: 
View display currently running process on this terminal.
ps

All current processes on this terminal, by all users.
# ps –a

All processes not assigned to a terminal (daemons).
ps –x 

To get information about all running process
# ps –ag

To kill all process except your shell
# kill 0

Start a process in background
# linux-command &

To get all the details regarding the running process.
# ps aux

To check a particular process.
# ps ax | grep process-name

To see currently running processes and there memory usage.
# top

To see currently running processes in a tree structure.
# pstree 

4 killing linux  processes
·          kill -1 pid.    Restart  the process 
·          kill -9  pid .  kill the process
·          kill -15  pid  End  the process 

System calls used for Process management:
  • Fork () :- Used to create a new process
  • Exec() :- Execute a new program
  • Wait():- wait until the process finishes execution
  • Exit():- Exit from the process
  • Getpid():- get the unique process id of the process
  • Getppid():- get the parent process unique id
  • Nice():- to bias the existing property of process  
Signals:
 Various Signals are:
Signal Name
Number
Description
SIGHUP
1
Hangup (POSIX)
SIGINT
2
Terminal interrupt (ANSI)
SIGQUIT
3
Terminal quit (POSIX)
SIGILL
4
Illegal instruction (ANSI)
SIGTRAP
5
Trace trap (POSIX)
SIGIOT
6
IOT Trap (4.2 BSD)
SIGBUS
7
BUS error (4.2 BSD)
SIGFPE
8
Floating point exception (ANSI)
SIGKILL
9
Kill(can't be caught or ignored) (POSIX)
SIGUSR1
10
User defined signal 1 (POSIX)
SIGSEGV
11
Invalid memory segment access (ANSI)
SIGUSR2
12
User defined signal 2 (POSIX)
SIGPIPE
13
Write on a pipe with no reader, Broken pipe (POSIX)
SIGALRM
14
Alarm clock (POSIX)
SIGTERM
15
Termination (ANSI)
SIGSTKFLT
16
Stack fault
SIGCHLD
17
Child process has stopped or exited, changed (POSIX)
SIGCONT
18
Continue executing, if stopped (POSIX)
SIGSTOP
19
Stop executing(can't be caught or ignored) (POSIX)
SIGTSTP
20
Terminal stop signal (POSIX)
SIGTTIN
21
Background process trying to read, from TTY (POSIX)
SIGTTOU
22
Background process trying to write, to TTY (POSIX)
SIGURG
23
Urgent condition on socket (4.2 BSD)
SIGXCPU
24
CPU limit exceeded (4.2 BSD)
SIGXFSZ
25
File size limit exceeded (4.2 BSD)
SIGVTALRM
26
Virtual alarm clock (4.2 BSD)
SIGPROF
27
Profiling alarm clock (4.2 BSD)
SIGWINCH
28
Window size change (4.3 BSD, Sun)
SIGIO
29
I/O now possible (4.2 BSD)
SIGPWR
30
Power failure restart (System V)

Read more...