Thursday 31 July 2014

Postfix commands

View the postfix version :
#  postconf  mail_version
mail_version = 2.3.3
Check the postfix installation :
#  postfix check
Show default postfix values :
#  postconf -d
To show non default postfix values :
#  postconf -n
To restart postfix mail server  :
# postfix reload
Flush the mail queue :
#  postfix  flush
Or you can use:
#  postfix  -f
To see mail queue :
#  mailq
( in send mail sendmail -bp )
#  mailq | wc -l
(will give the total no of mails in queue )
To remove all mail from the queue :
#  postsuper -d ALL
To remove all mails in the deferred queue :
#  postsuper -d ALL deferred
To see the mails in a tree structure :
#  qshape
View the mail content :
#  postcat -q  AFD4A228 37C
You will get the above id from mailq . Or you can view the mails from postfix mail spool. Usually postfix will store the mails in /var/spool/postfix/active/ from this location also you can view the mails .  We can change the queue directory from the postfix conf.
Sort by from address :
#  mailq | awk ‘/^[0-9,A-F]/ {print $7}’ | sort | uniq -c | sort -n
To remove all mails sent by user@adminlogs.info from the queue :
#  mailq| grep ‘^[A-Z0-9]‘|grep user@adminlogs.info|cut -f1 -d’ ‘ |tr -d \*|postsuper -d -
To remove all mails being sent using the From address “user@adminlogs.info” :
#  mailq | awk ‘/^[0-9,A-F].*user@adminlogs.info / {print $1}’ | cut -d ‘!’ -f 1 | postsuper -d -
To remove all mails sent by the domain adminlogs.info from the queue :
#  mailq| grep ‘^[A-Z0-9]‘|grep @adminlogs.info|cut -f1 -d’ ‘ |tr -d \*|postsuper -d -

Opevz commands

OpenVz commands
Some of commonly used openvz commands
VZ Information To list all the running/stopped VPS in the node
vzlist -a
To list all the running VPS in the node
vzlist
To display the templates present in the server
vzpkgls
Creating a VPS To create a VPS with VEID 101 and ostemplate fedora-core-4 with vps.basic configuration
vzctl create 101 –ostemplate fedora-core-4 -.config vps.basic
Deleting a VPS To destroy a VPS with VEID 101
vzctl destroy 101
Configuring VPS (The changes are saved in /etc/vz/conf/<VEID>.conf) To automatically boot when a node is up
vzctl set 101 –onboot yes –save
To set hostname
vzctl set 101 –hostname test101.my.org –save
To add an IP address
vzctl set 101 –ipadd 10.0.186.1 –save
To delete an IP address
vzctl set 101 –ipdel 10.0.186.1 –save
To set the name servers
vzctl set 101 –nameserver 192.168.1.165 –save
To set the root password of VPS 101
vzctl set 101 –userpasswd root:password
To set shortname for VPS
vzctl set 101 –name test101 –save
Start/Stop/Restart VPS To start a VPS
vzctl start 101
To start a disabled VPS
vzctl start 101 –force
To stop a VPS
vzctl stop 101
To restart a VPS
vzctl restart 101
To know the status of a VPS
vzctl status 101
To get the details of the VPS like VEID, ClassID, number of processes inside each VPS and the IP addresses of VPS
cat /proc/vz/veinfo
To enter into a VPS 101
vzctl enter 101
To execute a command in VPS 101
vzctl exec 101 command — replace command with the command you need to execute
vzctl exec 101 df -h
Managing Disk Quotas To assign disk quotas – First limit is soft limit, second limit is hard limit
vzctl set 101 –diskspace 10485760 –save  ==>> for setting 10GB
OR
vzctl set 101 –diskspace 1048576 –save   ==>> for setting 1GB
To assign disk inodes
vzctl set 101 –diskinodes 90000:91000 –save
To check the disk quota of a VPS
vzquota stat 101 -t
Managing CPU quota To display the available CPU power
vzcpucheck
To set the number of CPUs available to a VPS
vzctl set 101 –cpus 2 –save
To set the minimum and maximum CPU limits
vzctl set 101 –cpuunits nnnn –cpulimit nn –save
(cpuunits is a an absolute number (fraction of power of the node) and cpulimit is taken as percentage)
Managing memory quota To display memory usage
vzmemcheck -v
To set kmem
vzctl set 101 –kmemsize 2211840:2359296 –save
To set privvmpages
vzctl set 101 –privvmpages 2G:2G –save
Other Commands To copy/clone a VPS
vzmlocal -C <source_VEID>:<desitnation_VEID>
To disable a VPS
vzctl set 101 –disabled yes
To enable a VPS
vzctl set 101 –disabled no
To suspend a VPS
vzctl suspend 101
To resume a VPS
vzctl resume 101
To run yum update on a VPS
vzyum 101 -y update
To install a package using yum on VPS
vzyum 101 -y install package
To install a package using rpm on VPS
vzrpm 101 -ivh package
Refer : http://download.openvz.org/doc/OpenVZ-Users-Guide.pdf

Xen commnads

Xen Daemons
For the Xen server to function properly, the below daemons must be running on the VM server.
xend : This is the Xen server control daemon. This daemon must be running to start and manage thevirtual machines. The administrative interface of xend is “xm”. The xend daemon can be customized using the configuration file /etc/xen/xend-config.sxp.
xendomains : This daemon helps on starting the guests automatically when the host server boots up. The Xen guest config file has to be placed in /etc/xen/auto/ for the xendomains to pickup and boot the guests when the server boots up.
libvirtd: This daemon allows the administrators to access the hypervisors and the virtual machinesusing management tools like “virsh” and “virt-install”.
Here are some more xm and virsh commands for creating, managing, and troubleshooting xen virtual machines.
List the guest domains:  The command “xm list” displays the information of all running domains. The “–long” option displays full information on running guests.
[root@unixfoo-xen-adm01 ~]# xm list
Name                                ID   Mem  VCPUs    State   Time(s)
Domain-0                            0   2048     8     r—–  45645.8
guest04                             4   4096     2     -b—-    343.4
guest05                             5   4096     2     -b—-    896.4
guest06                             3   4096     2     r—–   2244.1
[root@unixfoo-xen-adm01 ~]#
In the output of “xm list”
·         Name – represents the domU guest VM name
·         ID -represents the domain ID
·         Mem – represents the amount of memory allotted to the guest domain (in MB)
·         VCPUs – represents the number of virtual CPUs assigned to a domain.
·         State – represents the running state of the guest OS.
o    r – running. The domain is currently running on a CPU.
o    b – blocked. The domain is currently not running.
o    p – paused. The domain is paused using “xm pause” command.
o    c – crashed . The domain has crashed and terminated abruptly
o    d – dying . The domain is the process of shutdown or crash.
·         Time – represents the total runtime of the domain as accounted by the Xen server.
Starting a guest domain: The command “xm  create” is used to startup a Xen guest.  This command creates a guest based on the configuration file storage in /etc/xen.
[root@unixfoo-xen-adm01 ~]# xm create guest06
Using config file “/etc/xen/guest06?.
Started domain guest06
[root@unixfoo-xen-adm01 ~]#
If the Xen configuration file is not stored in /etc/xen, the file name with full path should be specified in “xm create” command.
Shutdown a guest: The command “xm shutdown” is used to shutdown an Xen guest gracefully.
[root@unixfoo-xen-adm01 ~]# xm shutdown guest06
[root@unixfoo-xen-adm01 ~]# xm list
Name                                ID   Mem  VCPUs    State   Time(s)
Domain-0                            0   2048     8     r—–  45645.8
guest04                             4   4096     2     -b—-    343.4
guest05                             5   4096     2     -b—-    896.4
[root@unixfoo-xen-adm01 ~]#
Rebooting a guest: The command “xm reboot” is used to reboot a Xen domU guest.
Terminate a guest: The command “xm destroy” is used to immediately terminate an Xen domU guest virtual machine.
Status monitoring
·         xm uptime        – Displays uptime for a domain
·         xm top            – Monitors a host and its domains in real time
·         xm list             – Displays domain information
·         xm info            – Displays host information
·         xm vcpu-list     – Lists domain virtual processors
·         xm network-list – List virtual network interfaces for a domain.
·         virsh nodeinfo   – Gives basic information about the node.
·         virsh cpuinfo
Troubleshooting
·         xm console     – Attaches to a domain console
·         xm dump-core – Dumps core of a specific domain
·         xm dmesg       – Reads and/or clears the xend daemon’s message buffer
·         xm log            – Gives Xend log
·         virsh dominfo   – Returns basic information about the domain
·         virsh dumpxml  – Gives domain informations as an XML.
Xen Performance tuning
·         xm mem-max – Sets the maximum amount of memory for a domain
·         xm mem-set  – Sets the current memory usage for a domain
·         xm vcpu-set  – Sets the number of active processors for a domain
Other commands
·         xm rename   – Renames a domain
·         xm sysrq      – Sends a system request to a domain
·         xm block-list – Lists virtual block devices for a domain

Backup all databases

#!/bin/bash
mysqldump -uroot -pPASSWORD –all-databases > /home/db/all-database.sql

Plesk backend files

PLESK LINUX FILE LOCATIONS
Log Files
Apache logs location on Plesk:
/var/log/httpd/access_log
/var/log/httpd/error_log
Apache Suexec logs location on Plesk:
/var/log/httpd/suexec_log
Access and Error logs for a specific account / user / website on Plesk:
/var/www/vhosts/domain.tld/statistics/logs/access_log
/var/www/vhosts/domain.tld/statistics/logs/error_log
Server logs location on Plesk:
/var/log/messages
Named (Bind) logs location on Plesk:
/var/log/messages
Mysql logs location on Plesk:
/var/lib/mysql/server.hostname.err or the path defined at /etc/my.cnf
WatchDog logs location on Plesk:
/usr/local/psa/var/modules/watchdog/log/monit.log
Mail logs including Qmail and Postfix location on Plesk:
/usr/local/psa/var/log/maillog
Ftp logs on location Plesk:
/var/log/messages
SSH logs location on Plesk:
/var/log/secure
Tomcat logs location on Plesk:
/var/log/tomcat5/catalina.out
Mailman logs location on Plesk:
/var/log/mailman/
Cronjob Logs:
/var/log/cron
Horde Logs:
/var/log/psa-horde/psa-horde.log
Plesk Access and Error logs location:
/usr/local/psa/admin/logs/httpsd_access_log
/var/log/sw-cp-server/error_log
Linux Plesk Backend Files
Plesk root directory : /usr/local/psa
Version : /usr/local/psa/version
Admin password is stored : /etc/psa/.psa.shadow
Plesk configuration file : /etc/psa/psa.conf
Restart Plesk : /etc/rc.d/init.d/plesk restart
Apache
Main httpd configuration file : /etc/httpd/conf/httpd.conf
Plesk httpd : /etc/httpd/conf.d/zz010_psa_httpd.conf
Include conf files are under : /etc/httpd/conf.d (depends on the location specified in main httpd)
Startup script for plesk apache : /usr/local/psa/admin/bin/httpsdctl start
Apache main log files under : /var/log/httpd
PHP
Php configuration file : /etc/php.ini
Php extension modules are taken from : /etc/php.d
Named
Conf file located : /var/named/run-root/etc/named.conf
DB record : /var/named/run-root/var/domain.com
Log file : /var/log/messages
Service to restart : /etc/init.d/named restart
FTP
Conf file : /etc/proftpd.conf
Log file : /var/log/messages
Mysql
Databases are located at : /var/lib/mysql
Configuration file : /etc/my.cnf
Mysql log : /var/log/mysqld.log
Mail Server
Location of qmail directory : /var/qmail
Mail directory of a domain : /var/qmail/mailnames/domain.com
Mail log : /var/log/maillog or /usr/local/psa/var/log/maillog
Home directory of a domain
Home directory : /var/www/vhosts/domain.com
Httpd conf file of a domain : /var/www/vhosts/domain.com/conf/httpd.include
document root directory : /var/www/vhosts/domain.com/httpdocs
Document root directory of secure website : /var/www/vhosts/domain.com/httpdsdocs
Subdomains are created under : /var/www/vhosts/domain.com/subdomains
Domain specific logs are under : /var/www/vhosts/domain.com/statistics/ logs
==============================================
To log in to plesk use
https: :8443
There are four login levels for plesk
They are
1) Administrator
2)Client/Reseller
3) Domain owner
4) Email user
Each level has got its own functions
Administrator
This login is used to by hosting administators to manage the server items . Client/reseller,Domain owner,Email user creation can be done by using this account.
Note : We cannot use the root password for login to this account as in Cpanel. To login to this account use
Username : admin
Password : (will be stored in fiel /etc/psa/.psa.shadow )
Client/Reseller
This is the second tier account . Domain owner accounts and Email user accounts can be managed from this account.
Domain owner
Everything related to one domain can be managed by using this account. usually client/reseller creates a Domain owner account.
mail user
This is the fourth tier account. Here users are allowed to manage their mail account. Only mail related functions are allowed here such as sending mails ,seting spam filters etc.
Software componets of plesk.
The following software components are used with plesk.
DNS server : bind
Webserver : Apache
FTP server : proftpd
Mail server : Mysql,mssql,postgresql
IMAP/POP : courier-IMAP
Mailing list: Mailman
Statistical softwares : Webalizer, AWstats
Types of hosting
In plesk, 3 modes of hosting are avaliable
They are
Physical hosting
The domain is actually hosted on that server.
Standard Hosting
Here url is redirected such that browser url will be changed to destination url
Frame forward
Here also redirection takes place. But browser url doesnot change
PSA DATABASE
*****************
Plesk has a database called psa. We can use the administrator username(admin) and password to login to psa database.
>Tables in psa database are
1. Domains
2. Clients
3. db_users
4.db_bases
5. disk_spaces
6.mail
7.lockout
8. web_users
Backup
> To back up all data
/plesk_installation_directory/bin/pleskbackup all
name>
> To back up all user accounts with all users’ sites,
/plesk_installation_directory/bin/pleskbackup clients

Webmin backend files

WEBMIN AND ITS IMPORTANT BACK END FILES
Webmin
———-
root                          /usr/libexec/webmin
mimetypes                /usr/libexec/webmin/mime.types
logfile                      /var/webmin/miniserv.log
errorlog                   /var/webmin/miniserv.error
pidfile                      /var/webmin/miniserv.pid
WEBMIN_CONFIG    /etc/webmin
WEBMIN_VAR          /var/webmin
userfile                    /etc/webmin/miniserv.users
keyfile                     /etc/webmin/miniserv.pem
passwd file              /etc/shadow
config file               /etc/webmin/config
APACHE Web Server
——————
Default server:
Configuration file     /etc/httpd/conf/httpd.conf
Document root         /var/www/html
Logs                       /etc/httpd/logs/
start command        /etc/rc.d/init.d/httpd start
mime types             /etc/mime.types
apachectl path        /usr/sbin/apachectl
httpd path              /usr/sbin/httpd
httpd dir                /etc/httpd
Virtual Server:
name based server having customized Document root and ports.
BIND DNS SERVER
—————–
configuration file       /etc/named.conf
db file locations         /var/named
named path               /usr/sbin/named
start command          /etc/rc.d/init.d/named start
slave directory           /var/named/slaves
RNDC conf file          /etc/rndc.conf
DB file name format : mydomainname.org.hosts
DATABASE – MySQL
——————-
Configuration file         /etc/my.cnf
datadir                        /var/lib/mysql
socket                         /var/lib/mysql/mysql.sock
basedir                       /var/lib
pid-file                       /var/run/mysqld/mysqld.pid
stop cmd                    /etc/rc.d/init.d/mysqld stop
mysqldump                /usr/bin/mysqldump
start cmd                   /etc/rc.d/init.d/mysqld start
mysql data                 /var/lib/mysql
mysqlimport              /usr/bin/mysqlimport
mysqlshow                /usr/bin/mysqlshow
mysql binary             /usr/bin/mysql
mysqladmin              /usr/bin/mysqladmin
USERMIN
————-
usermin_dir              /etc/usermin
FTP – ProFTPD Server
———————
Configuration file       /etc/proftpd.conf
ScoreboardFile           /var/run/proftpd.score
TransferLog               /var/log/proftpd/xferlog
TLSRSACertificateKey /usr/share/ssl/certs/proftpd.pem
TLSLog                     /var/log/proftpd/tls.log
ExtendedLog              /var/log/proftpd/access.log
FTP users                  /etc/ftpusers
start cmd                  /etc/init.d/proftpd start
proftpd path             /usr/sbin/proftpd
Start up script           /etc/init.d/proftpd
MAIL SERVER -Sendmail
———————-
configuration file      /etc/mail/sendmail.cf
sendmail mc             /etc/mail/sendmail.mc
mail dir                   /var/spool/mail
sendmail path          /usr/sbin/sendmail
relay domains          /etc/mail/relay-domains
mailertable              /etc/mail/mailertable.db
virtusers                  /etc/mail/virtusertable.db
Access db                /etc/mail/access.db
AliasFile                 /etc/aliases
Error Header           /etc/mail/error-header
Queue Directory       /var/spool/mqueue
Status File               /var/log/mail/statistics
Dead LetterDrop      /var/tmp/dead.letter
PidFile                   /var/run/sendmail.pid
DefaultAuthInfo       /etc/mail/default-auth-info (Default authentication information for outgoing connections)
trusted-users           /etc/mail/trusted-users (users that can send mail as others without a warning)
Startup command    /etc/init.d/sendmail
PHP
——–
php_ini                  /etc/php.ini
DOVECOT
——–
init script              /etc/init.d/dovecot
pid file                 /var/run/dovecot/master.pid
dovecot path         /usr/sbin/dovecot
config file            /etc/dovecot.conf

Directadmin backend files

Below is the configuration of direct Admin Back End configuration Files.
BACKEND FILES
———
CONF FILES /etc/httpd/conf/httpd.conf
LOG FILES /var/log/httpd/error.log
START/STOP /usr/
local/etc/rc.d/httpd start/stopScripts /usr/local/directadmin/scripts/
DNS:-
———
CONF FILE /var/named/etc/namedb/named.conf
DB FILES /etc/namedb/domain.db
START/STOP /usr/local/etc/rc.d/named start/stop
MAIL:-
——–
CONF FILE /etc/exim.conf
LOG FILES /var/log/exim/
START/STOP /usr/local/etc/rc.d/exim start/stop
MAIL DIRECTORY /var/
spool/virtual/
EMAIL PASSWORD: /etc/virtual/acrilicos.com/passwd
Domain specific Mail settings: /etc/virtual/acrilicos.com
DATABASE:-
—————–
MYSQL PASSWORD: /usr/local/directadmin/conf/mysql.conf
CONF FILE /etc/my.cnf
DATABASE PATH /usr/local/mysql/data/
START/STOP /usr/local/etc/rc.d/mysqld start/stop
FTP:-
——-
CONF FILE /etc/
proftpd.conf
START/STOP /usr/local/etc/rc.d/proftpd start/stop
DOMAINS
————————-
/etc/virtual/domains
/etc/virtual/domainowners
Email Alias: /etc/virtual/acrilicos.com/
aliases
Email QUota: /etc/virtual/acrilicos.com/quota
/etc/virtual/acrilicos.com/autoresponder.conf
Email account password: /etc/virtual/acrilicos.com/passwd
/etc/virtual/acrilicos.com/filter
/etc/httpd/conf/extra/directadmin-vhosts.conf
emailspoolvirtual=/var/spool/virtual
emailvirtual=/etc/virtual
ftpconfig=/etc/proftpd.conf
ftppasswd=/etc/proftpd.passwd
ftpvhosts=/etc/proftpd.vhosts.conf
mysqlconf=/usr/local/directadmin/conf/mysql.conf
namedconfig=/etc/named.conf
nameddir=/var/named
templates=/usr/local/directadmin/data/templates


Log File paths
Last Modified: Nov 25, 2012, 12:04 pm
The first place you should go when trying to debug a problem is the log file for that program.   The list of Log Files are as follows:
DirectAdmin:
/var/log/directadmin/error.log
/var/log/directadmin/errortaskq.log
/var/log/directadmin/system.log
/var/log/directadmin/security.log
Apache:
/var/log/httpd/error_log
/var/log/httpd/access_log
/var/log/httpd/suexec_log
/var/log/httpd/fpexec_log
/var/log/httpd/domains/domain.com.error.log
/var/log/httpd/domains/domain.com.log
/var/log/messages (generic errors)
Proftpd:
/var/log/proftpd/access.log
/var/log/proftpd/auth.log
/var/log/messages (generic errors)
PureFTPd:
/var/log/pureftpd.log
Dovecot and vm-pop3d:
/var/log/maillog
/var/log/messages
named (bind):
/var/log/messages
exim:
/var/log/exim/mainlog
/var/log/exim/paniclog
/var/log/exim/processlog
/var/log/exim/rejectlog
(on FreeBSD, they have “exim_” in front of the filenames)
mysqld:
RedHat:
/var/lib/mysql/server.hostname.com.err
FreeBSD and Debian:
/usr/local/mysql/data/server.hostname.com.err
crond:
/var/log/cron
To view a log file, run:
less /var/log/filename
Where /var/log/filename is the path of the log you wish to view.  If the log is too large you can use the “tail” command:
tail -n 30 /var/log/filename
Where 30 is the number of lines from the end you wish to view.