Plesk 11: Important Command Line functions, shortcuts, and scripts

Posted on April 21, 2013

Here are a handfull of extremely time saving commands that you can execute on your Plesk server. Hopefully these will be very helpful if you are ever in a bind.

Enable spam assassin on all accounts on server

mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -Ns -e "SELECT CONCAT_WS('@',mail.mail_name,domains.name)FROM domains,mail,accounts WHERE domains.id=mail.dom_id AND accounts.id=mail.account_id" | xargs -I {} ./spamassassin -u {} -status true -hits 7 -action move

Setup a new customer via command line

/usr/local/psa/bin/./customer --create username -name 'name' -passwd 'password' -country US -phone 123456 -email hosting@domain.com

Setup a new Domain via command line

/usr/local/psa/bin/./subscription --create domain.com  -owner 'sellyourmotor' -service-plan 'planyouwanttouse' -login username -passwd 'password' -ip 10.x.x.x

Add a forwarding domain to a subscription via command line

/usr/local/psa/bin/./subscription --create domain.com -owner 'username' -service-plan 'planyouwanttouse' -login username -passwd 'password' -hosting true -ip 10.x.x.x -hst_type std -target_url http://www.domaintoforwardto.com

Update all domains to use AtMail webmail

mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -Ns -e "select name from domains" | xargs -I {} /usr/local/psa/bin/./subscription_settings -u {} -webmail atmail

Switch all sites service plan

mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -Ns -e "select name from domains" | xargs -I {} /usr/local/psa/bin/./subscription --switch-subscription {} -service-plan "planyouwanttouse"

Change all sites rotation logs

mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -Ns -e "select name from domains" | xargs -I {} /usr/local/psa/bin/./site -u {} -log_bysize 10M -log-max-num-files 2

Change all sites to awstats

mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -Ns -e "select name from domains" | xargs -I {} /usr/local/psa/bin/./site -u {} -webstat awstats

add google apps DNS to domain

/usr/local/psa/bin/./dns -a domain.com -mx '' -mailexchanger ASPMX.L.GOOGLE.COM -priority 1
/usr/local/psa/bin/./dns -a domain.com -mx '' -mailexchanger ALT1.ASPMX.L.GOOGLE.COM -priority 5
/usr/local/psa/bin/./dns -a domain.com -mx '' -mailexchanger ALT2.ASPMX.L.GOOGLE.COM -priority 5
/usr/local/psa/bin/./dns -a domain.com -mx '' -mailexchanger ASPMX2.GOOGLEMAIL.COM -priority 10
/usr/local/psa/bin/./dns -a domain.com -mx '' -mailexchanger ASPMX3.GOOGLEMAIL.COM -priority 10
/usr/local/psa/bin/./dns --add domain.com -cname mail -canonical ghs.google.com
/usr/local/psa/bin/./dns --add domain.com -cname docs -canonical ghs.google.com
/usr/local/psa/bin/./dns --add domain.com -cname calendar -canonical ghs.google.com
/usr/local/psa/bin/./dns --add domain.com -cname webmail -canonical ghs.google.com

Log into MySQL with root / admin account via command line

mysql -uadmin -p`cat /etc/psa/.psa.shadow`

Create or Update an E-Mail account

/usr/local/psa/bin/./mail --create/update email@address.com.au -passwd abc123 -mailbox true

View Email Account Password on Plesk domain

mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -Ns -e "SELECT CONCAT_WS('@',mail.mail_name,domains.name), '-',accounts.Password FROM domains LEFT JOIN mail ON domains.id = mail.dom_id LEFT JOIN accounts ON mail.account_id = accounts.id where domains.name like '%DOMAIN.COM%';"


#All accounts

mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -Ns -e "SELECT CONCAT_WS('@',mail.mail_name,domains.name), '-',accounts.Password FROM domains LEFT JOIN mail ON domains.id = mail.dom_id LEFT JOIN accounts ON mail.account_id = accounts.id;"

#Alternate method

mysql -uadmin -p`cat /etc/psa/.psa.shadow`
use psa

SELECT mail.mail_name, domains.name from mail LEFT OUTER JOIN domains ON domains.id = mail.dom_id;

#Select your account with the username / domain

SELECT accounts.id, mail.mail_name, accounts.password, domains.name FROM domains LEFT JOIN mail ON domains.id = mail.dom_id LEFT JOIN accounts ON mail.account_id = accounts.id where mail.mail_name = 'email account(e.g info)' and domains.name = 'domain' INTO OUTFILE 'file_name';

One Comment

Leave a Reply

Your email address will not be published.

Contact Us

Have a question? Send us a message. We'll get back to you soon.

captcha

Share
Tweet
Pin
Share