First we’ll need to log in to WHM. Under DNS Functions, select Edit DNS Zone. Choose the domain for the zone in which you wish to edit. Add an A record mapped to asterisk (wildcard) for the subdomain and the IP Address the site is hosted on. You likely already have A records for ftp, webmail, etc. just model this new one after those.
You should now be able to enter any subdomain on your domain, but it will not likely find your main site. So now we need to set that up.
Step 2: ServerAlias
Log in to your server via SSH and go open /etc/httpd/conf/httpd.conf (I’ll assume you know your way around linux via command line as well as vi or some other editor)
*Note: wherever you see example.com you should expect to see your domain name that you are setting up
Now, we could edit this file and make everything work, but there is a problem with that. Look at the top ofthe document and you should see something like this:
Direct modifications to the Apache configuration file may be lost upon subsequent regeneration of the configuration file. To have modifications retained, all modifications must be checked into the configuration system by running:
/usr/local/cpanel/bin/apache_conf_distiller –update
To see if your changes will be conserved, regenerate the Apache configuration file by running:
/usr/local/cpanel/bin/build_apache_conf
and check the configuration file for your alterations. If your changes have been ignored, then they will need to be added directly to their respective template files.
Basically what it’s saying is don’t edit this file directly because you’re changes may be lost.
Do a search for the domain you are adding the wildcard to. You should find the VirtualHost set up for your domain. Here is mine:
# DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.
<VirtualHost 67.225.128.241:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /home/example/public_html
ServerAdmin webmaster@example.com
UseCanonicalName Off
Options -ExecCGI -Includes
RemoveHandler cgi-script .cgi .pl .plx .ppl .perl
CustomLog /usr/local/apache/domlogs/example.com combined
CustomLog /usr/local/apache/domlogs/example.com-bytes_log “%{%s}t %I .\n%{%s}t %O .”
## User example # Needed for Cpanel::ApacheConf
<IfModule !mod_disable_suexec.c>
SuexecUserGroup example example
</IfModule>
# To customize this VirtualHost use an include file at the following location
# Include “/usr/local/apache/conf/userdata/std/2/example/example.com/*.conf”
</VirtualHost>
Notice the highlighted lines. This is where we are going to create a file. We are going to create a file at:
/usr/local/apache/conf/userdata/std/2/example/example.com/ServerAlias_wildcard.conf
(you can give it any name you want really)
*Hint: You may need to create the directories first, run this command:
mkdir -p /usr/local/apache/conf/userdata/std/2/example/example.com/
So really, you don’t need to edit anything it httpd.conf, we just needed some info.
Inside of the ServerAlias_wildcard.conf file, enter this line:
ServerAlias *.example.com
Now, you’ll need to rebuild the httpd.conf file per the instructions at the top of that file by running the following command:
/usr/local/cpanel/bin/build_apache_conf
If you open your /etc/httpd/conf/httpd.conf file again you should see that your VirtualHost for your domain as changed slightly:
<VirtualHost 67.225.128.241:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /home/example/public_html
ServerAdmin webmaster@example.com
UseCanonicalName Off
Options -ExecCGI -Includes
RemoveHandler cgi-script .cgi .pl .plx .ppl .perl
CustomLog /usr/local/apache/domlogs/example.com combined
CustomLog /usr/local/apache/domlogs/example.com-bytes_log “%{%s}t %I .\n%{%s}t %O .”
## User example # Needed for Cpanel::ApacheConf
<IfModule !mod_disable_suexec.c>
SuexecUserGroup example example </IfModule>
Include “/usr/local/apache/conf/userdata/std/2/example/example.com/*.conf”
</VirtualHost>
Step 3: Restart Apache
The last step required is to restart apache. I suppose there are a number of ways to do this. As long as we are logged in to SSH, we might as well just run the command:
service httpd restart
Now, give it a try. you should be aby to access something like http://whatever.example.com and still see your main page.
]]>dd if=/dev/sdX of=MBR.bck bs=512 count=1
Please note that you have to replace /dev/sdX with your actual drive. This can be /dev/sda, /dev/hda, etc.
How to restore de MBR record
dd if=MBR.bck of=/dev/sdX bs=512 count=1
Again you have to replace /dev/sdX with your actual drive.
If you also want to keep a human readable copy of the partition table you can run:
fdisk -l > part.table
I hope it helps !
]]>
First of all I will start by telling you what you can do using the “screen” command.
Many times as a linux sysadmin you will need to run multiple commands at once. You are probably doing this by opening multiple ssh sessions but there is a better way to do it !
Also as a sysadmin you probably had to run a command or script that is taking hours to finish like a rsync. This usually requires you to keep the ssh session open as if you close it the command or script will also be closed.
If you ever faced any of those problems then it’s probably time to learn about the screen command.
Screen - makes it possible to run multiple full-screen pseudo-terminals from one real terminal, and lets you manipulate and save your screen input and output, copy and paste between windows.
In this tutorial I will only present how you can run a command that is taking hours to complete in a screen.
First of all make sure that you have screen installed. If you don’t you can install it using yum, apt-get or any other package manager that you might have on your server.
yum install screen
Now type in:
screen
This will start a new screen for you. You could also name you screen using the -S option. Something like:
screen -S 1
In this case I named the screen “1″.
The screeen will look like any other ssh window.
You can now type in your command that you want to run.
If you want to detach from the screen and still keep the command running you can do this by pressing:
Ctrl-a d (that is press Ctrl-a, release and press d)
If you want to reatach to a screen you simply type in:
screen -r
Other options that you have when you are in a screen are:
Ctrl-a c
Ctrl-a n
For more help on this you can use:
man screen
Hope it helps!
If you have any questions just leave a comment.
1. froze messages to recipient root@host.localhost.com
/usr/sbin/exiqgrep -i -r root@host.localhost.com | /usr/bin/xargs exim -Mf
2. delete frozen messages
/usr/sbin/exiqgrep -z -i | /usr/bin/xargs exim -Mrm
3. delete messages older than X hours (X in seconds)
/usr/sbin/exiqgrep -o X -i | /usr/bin/xargs exim -Mrm
4. total messages in queue
/usr/sbin/exiqgrep | /usr/sbin/exiqsumm | grep TOTAL
For other very useful commands, please visit: http://www.skillett.com/index.php/258/hands-on-with-an-exim-cheatsheet. Thanks Keiron.
or for just a table:
mysqldump –skip-add-locks –skip-lock-tables database table > database.table.sql
Hope this help.
Here it is:
adddns - Adds a DNS zone.
addfpmail - Add frontpage mail extensions to all domains without them.
addfpmail2 -Add frontpage mail extensions to all domains without them.
addnetmaskips - Add the netmask 255.255.255.0 to all IPs that have no netmask.
addnobodygrp - Adds the group nobody and activates security.
addpop - Add a Pop Account.
addservlets - Add JSP support to an account (requires tomcat).
addstatus - (Internal use never called by user).
adduser - Add a user to the system.
admin - Run WHM Lite.
apachelimits - Add rlimits to Apache
betaexim - Installs the latest version of exim.
biglogcheck - looks for logs nearing 2 gigabytes in size
bsdcryptoinstall - Installs crypto on FreeBSD.
bsdldconfig - Configures the proper lib directories in FreeBSD.
bsdpkgpingtest - Tests the connection speed for downloading FreeBSD packages.
buildbsdexpect - Install expect on FreeBSD.
buildeximconf - Rebuilds exim.conf.
buildpostgrebsd-dev - Installs postgresql on FreeBSD.
checkbadconf - Checks /usr/local/apache/conf/httpd.conf for bad users.
checkbsdgroups - Checks and repairs proftpd ownership on FreeBSD.
checkccompiler - Checks to make sure the C compiler works on your system.
checkfpkey - Checks for the FrontPage suid key
checkgd - Checks to see if GD is built.
checkinterchange - (Internal use).
checklibssl - Checks to make sure the proper libssl symlinks exist.
checkmaxclients - Checks to see if apache has reached the maximum clients allowed.
checkoldperl - Checks to see if the version of Perl on your system is old.
checkrsync - Checks to make sure rsync is up to date.
checksuexecpatch - Checks to see if mailman has been patched for suexec.
checksuspendpages - Checks to see if suspend pages are properly named.
checkup2date - Makes sure up2date is set up properly (RedHat)
checkyum - Makes sure yum is set up properly.
chkpaths - Makes sure /usr/sbin/chown has a symlink to /bin/chown
chownpublichtmls - Change ownership of all users web space to them, which is useful for converting to suexec. Files owned by nobody are deleted.
chpass - Change password.
ckillall - Allows you to kill a process (used like killall).
ckillall2 - Allows you to kill a process.
cleanbw - Cleans up old bandwidth logs.
cleandns8 - Clean up named.conf.
cleangd - Cleans up old GD installs and reinstalls GD
cleanmd5 - Fix CPAN md5 problems.
cleanmsglog - cleans exim’s msglog
cleanupmysqlprivs - Cleans up improper mySQL privileges.
compilers - Disables the usage of compilers for unprivileged users.
convert2maildir - Converts mail from mbox to maildir format and installs courier impap and pop (cpimap is removed).
courierup - Updates/Installs Courier
cpbackup - Runs backups.
distupgrade - Upgrades RedHat to the newest version (for testing only)
dnscluster - Enables DNS clustering.
dnsqueuecron - Adds a cron job to dump the DNS queue.
dnstransfer - Only if the server has a DNS master (sync with DNS master).
downgradefp - Downgrades FrontPage Extensions (to 5.0-0)
dropmysqldb - Drops a mySQL database.
easyapache - Upgrade Apache
editquota - Change a users quota.
enablechkservdwebmail - Enable service checking of webmaild.
enablefileprotect - Protects home directories if file protection is built in apache.
ensurepkg - Installs a FreeBSD package.
ensurerpm - Installs a rpm.
exim3 - Installs exim 3.
exim4 - Installs exim 4.
exim4-rh73test - Installs exim release #260. (RedHat only)
eximcron - Creates a cron job for exim_tidy_db.
eximlocalsend - Enables/Disables exim local sending.
exim_tidydb - Cleans the exim message log.
eximup - Installs/Updates exim.
fetchgd - Includes libg.so.
findhacks - Search for common Trojan Horses.
findoddrootprocesses - Lists root processes that may need to be checked out.
findphpversion - Check to see if your php version file is up to date.
findtrojans - Exhaustive Trojan Horse search.
fixallcartswithsuexec - Fixes permissions on carts when using suexec.
fixallinterchangeperm - Fixes permissions on all users’ Interchange Shopping Carts.
fixbinpath - Makes sure all bin file paths are correct.
fixbuggynamed - Updates bind to solve any problems with bugs.
fixcommonproblems - Attempt to fix the most common problems.
fixetchosts - Fixes problems with /etc/hosts
fixeverything - Fix common problems and quotas.
fixfpwml - Fix for .wml errors with frontpage.
fixheaders - Run if nothing compiles errors with .h files on compile.
fixinterchange - Reinstall interchange Perl modules.
fixinterchangeperm - fix permissions on a user’s interchange cart.
fixipsnm - Same as addnetmask ips, but Perl though.
fixlibnet - Reinstall Bundle::libnet (Perl).
fixlocalhostwithphp - Change /etc/hosts to work better with PHP 4.2.0 + MySQL.
fixmailman - Updates and restarts mailman.
fixmailmanwithsuexec -
fixmuse - Reinstalls muse.
fixmysql - Fixes problems with mySQL.
fixmysqlbsd - Fixes problesm with mySQL on FreeBSD.
fixnamed - Updates bind to handle many DNS zones (more than 512).
fixndc - Repair redhat’s broken named.conf on 7.2.
fixoldlistswithsuexec - Run after enabling suexec on the server to change the URLs that Mailman gives out to ones that don’t give a 500 internal server error.
fixperl - Symlink /usr/local/bin/perl /usr/bin/perl.
fixperlscript - Makes sure a perlscript includes all corresponding modules.
fixpop - Fix a POP account and reset password.
fixproftpdconf - Fixes problems with /usr/local/etc/proftpd.conf
fixproftpddupes - Updates proftpd.
fixquotas - Fix quotas.
fixrndc - Fixes named.conf to prevent rndc staus failed.
fixspamassassinfailedupdate - Reinstalls a failed spamassassin update.
fixsubdomainlogs - Run if subdomain logs don’t show up in cPanel.
fixsuexeccgiscripts - Fix CGI scripts that are broken after suexec installed.
fixvaliases - Fix permisions on valiases.
fixwebalizer - Repair a Webalizer that has stopped updating.
fp3 - Updates the fpexe3 patch.
fpanonuserpatch - Updates FrontPage extensions to include the anonymous user patch.
ftpcheck - Checks for FTPSSL.
ftpquaotacheck - Runs quota checking for all ftp users.
ftpup - Updates your ftp server.
fullhordereset - Resets Horde and displays the current Horde password.
futexfix - Fixes problesm with futex.
futexstartup - Starts futex.
gcc3 - Installs gcc-3.3.3
gencrt - Generate a .crt and .csr file.
grpck - Checks to see if grpck is working properly.
hdparmify - Enable dma/irq/32bit HD access, which speeds up IDE drives.
hdparmon - Turns on hdparm.
initacls - Mounts your file systems with ACL support (make sure your kernel supports ACLs)
initfpsuexec - Enable FrontPage suexec support.
initquotas - Turn on quota support on new drives.
initsslhttpd - Make sure HTTP starts with SSL.
initsuexec - Turn on suexec support if suexec is installed.
installcgipm - Installs CGI.pm
installdbi - Install Bundle::DBD::mysql.
installfpfreebsd - Installs FrontPage 5 Extensions on FreeBSD.
installfpgentoo - Installs FrontPage on Gentoo.
installgd - Builds GD.
installpkg - Installs a FreeBSD package.
installpostgres - Installs PostrgeSQL.
installrpm - Installs a rpm.
installspam - Install SpamAssassin.
installssl - Add a SSL vhost.
installzendopt - Install zend optimzer.
installzendopt-freebsd - Install zend optimizer on a freebsd machine.
isdedicatedip - Checks an ip to see if it is dedicated.
killacct - Delete an account.
killbadrpms - Security script that kills insecure RPMs from the server.
killdns - Delete a DNS zone.
killdrrootvhost - Removes the document root for a virtual host.
killndbm - Remove the broken NDBM_File module from 7.2.
killpvhost - Removes a virtual host from proftpd.conf.
killspamkeys - Removes a spam key.
killsslvhost - Removes a SSL entry for a virtual host.
killvhost - Delete a vhost.
listcheck - Checks mailing lists for issues.
listproblems - Lists common problems.
listsubdomains - List subdomains.
mailperm - Fix almost any mail permission problem.
mailscannerupdate - Updates MailScanner
mailtroubleshoot - Guided mail fix.
makecpphp - Installs php.
makesecondary - Part of DNS transfer.
manualupcp - Updates cPanel manually.
md5crypt - Encrypts a password into MD5.
mseclocal - Sets up Mandrake’s msec to allow exim to run as mailnull.
mysqladduserdb - Create a MySQL databse and user.
mysqlconnectioncheck - Attempts to connect to MySQL, restarts SQL if necessary.
mysqldeluserdb - Delete a MySQL database and user.
mysqlpasswd - Change MySQL password.
mysqlrpmpingtest - Checks your connection speed for downloading mySQL rpms.
mysqlup - Updates mySQL.
ndbmcheck - Checks to see if the nbdm module is loaded (kills in RedHat 7.2)
netftpsslpatch - Patches FTPSSL.pm.
newexim - Installs the latest version of exim.
nofsck - Make fsck always use -y
nomodattach - Removes mod_attach from httpd.conf.
nomodauthmysql -Removes mod_auth_mysql from httpd.conf.
nomodbwprotect - Removes mod_bwportect from httpd.conf.
nomodgzipconfmods - Removes mod_gzip from httpd.conf.
nomodperl - Removes mod_perl from httpd.conf.
oldaddoncgi2xaddon - Updates old addons to X addons.
park - Parks a domain.
patcheximconf - Fixes exim.conf.
perlinstaller - Installs perl.
phpini - Create a php.ini file.
pingtest - Checks your download time from cPanel mirrors.
pkgaccount-ala - backs up an Alab*nza account for transfer.
pkgacct-ciXost - backs up a ci*ost account for transfer.
pkgacct-dXm - backs up a d*m account for transfer.
pkgacct-enXim - backs up an en*im account for transfer.
pkgacct-pXa - backs up a p*a account for transfer.
proftpd128 - Installs proftpd-1.2.8.
ptycheck - Fixes permissoins on /dev/ptmx.
pwck -Verifies the integrity of system authentication information.
quickkernel - Updates your kernel.
quicksecure - Quickly kill useless services.
rebuildcpanelsslcrt - Rebuilds the cPanel SSL Certificate.
rebuildcpusers - Rebuilds /var/cpanel/users.
rebuildetcpasswd - Rebuilds /etc/passwd.
rebuildeximbsd - Rebuilds exim on FreeBSD.
rebuildhttpdconffromproftpd - Rebuild httpd.conf from the proftpd.conf file.
rebuildinterchangecfg - Used after moving a domain with Interchange to the server.
rebuildnamedconf - Restore named.conf from files in /var/named.
rebuildproftpd - Restore proftpd.conf from httpd.conf.
reinstallmailman - Reinstalls mailman.
relocatevartousr - Relocates files from /var to /usr in case of disk space issues.
remdefssl - Remove default SSL vhost.
reseteximtodefaults - Resets exim’s default settings.
resetimappasswds - Resets all imap passwords.
resetquotas - Change quotas to what they should be .
restartsrv - Restart a service.
restartsrv_apache - Restart apache.
restartsrv_bind - Restart bind.
restartsrv_clamd - Restart clamd.
restartsrv_courier - Restart courier imap.
restartsrv_cppop - Restart cppop.
restartsrv_entropychat - Restart entropy chat.
restartsrv_exim - Restart exim.
restartsrv_eximstats - Restart exim statistics.
restartsrv_ftpserver - Restart your ftp server.
restartsrv_httpd - Restart httpd.
restartsrv_imap - Restart impad.
restartsrv_inetd - Restart inetd.
restartsrv_interchange - Restart Interchange Shopping Cart.
restartsrv_melange - Restart melange chat.
restartsrv_mysql - Restart mysqld.
restartsrv_named - Restart named.
restartsrv_postgres - Restart postgresql.
restartsrv_postgresql - Restart postgresql.
restartsrv_proftpd - Restart proftpd.
restartsrv_pureftpd - Restart pure-ftpd.
restartsrv_spamd - Restart spamd.
restartsrv_sshd - Restart sshd.
restartsrv_syslogd - Restart syslogd.
restartsrv_tomcat - Restart tomcat.
restartsrv_xinetd - Restart xinetd.
restoremail - Restores a user’s mail.
reswhostmgr - Restart whostmgr.
rpmup - Upgrade redhat/mandrake errata/security.
rrdtoolinstall - Installs RRD Tool.
runstatsonce - Runs statistics (should be used from the crontab).
runweblogs - Run analog/webalizer/etc. for a user.
safeperlinstaller - Installs perl safely.
safeup2date - Runs up2date safely.
safeyum - Runs yum safely.
secureit - Remove unnecessary suid binaries.
securemysql - Attempts to secure the MySQL configuration.
securetmp - Adds securetmp to system startup.
setupfp - Install FrontPage 3 on an account.
setupfp4 - Install FrontPage 4 (2000) installer on an account.
setupfp5 - Install FrontPage 5 (2002) installer on an account.
setupfp5.nosueuxec - Install FrontPage 5 (2002) installer on an account when not using suexec.
showexelist - Shows exe processes.
simpleps - Display the process list.
smartcheck - Checks hard drive integrity.
smtpmailgdionly - Enables SMTP Mail Protection.
spamboxdisable - Disables SpamAssassin’s spambox delivery for all accounts.
suspendacct - Suspends an account.
sysup - update cPanel RPMs.
unlimitnamed - Installs the latest version of bind patched to support greater than 512 ips on the server.
unblockip - Unblocks an IP blocked by portsentry.
unsetupfp4 - Removes FrontPage 4 or 5 from an account.
unslavenamedconf - If the user accidentally sets a DNS master as local server, this will repair named.conf after the loop.
unsuspendacct - Unsuspends an account.
upcp - Updates cPanel.
updated - Updates /scripts.
updatefrontpage - Updates FrontPage
updatenow - Updates /scripts NOW.
updatephpconf - Updates PHP configuration files.
whoowns - Finds out who owns a domain.
wwwacct - Creates an account.
xaddonreport - Reports the current addon scripts installed.
crontab -e
“Vi” is the editor that opens up.
I personally don’t like it and I wanted to change it to the good old nano.
If you are in the same situation here is the simple command that will change your default OS editor.
export VISUAL=’pico -w’
Now when you run:
crontab -e
Nano will open up.
Hope it helps !
]]>]]>New cPanel builds have been published tonight to improve installation, speed, memory usage and upgrade experiences. Recently, installs and updates have been taking excessively long due to CPAN module tests during the Perl module updates. New EDGE, CURRENT and RELEASE builds 11.23.3 build 25946 (or later) have been released tonight to address this issue and to improve installer speed and add checks unrelated to Perl. If you have been experiencing update or install issues, we recommend re-downloading http://layer1.cpanel.net/latest for installs or re-running /scripts/upcp for updates.
]]>Currently, RedHat is shipping an older version of coreutils which contains a known bug in /bin/pwd. If a parent directory to the directory /bin/pwd is executed in does not have read permissions, /bin/pwd will fail with the following error:
/bin/pwd: cannot open directory `..’: Permission denied
cPanel has built a script to modify the permissions on your /home directories to 0755 in order to maintain full functionality of the system until this issue is corrected by RedHat. If you experience the above error, you can run the following command to resolve the issue:
/scripts/enablefileprotectThe issue has been reported to RedHat and they have promised a fix in the next coreutils update. More information on the report can be found here:
https://bugzilla.redhat.com/show_bug.cgi?id=448446
References:
http://lists.gnu.org/archive/html/bug-coreutils/2007-02/msg00053.html