Terminal Commands Cheat Sheet

Fixing Permissions

sh fixperms.sh -a cpaneluser

^ Make sure to replace cpaneluser with the cPanel username of the account you’d like to fix.

If you’re only really needing to fix permissions on a single directory, not the full cPanel account, navigate to that folder in terminal and run the following commands:

find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

^ Please note that these commands should never be used at the root of an account, but always in public_html subfolders or subdomain folders.

Importing Applications into Installatron

/usr/local/installatron/installatron --send-update-report --user xxx

^ Replace xxx with the user’s cPanel username.

Removing AddHandler (Bluehost Migration Specific)

grep -R “AddHandler”

^ Go into all .htaccess files on the account and remove any lines that begin with AddHandler. You can quickly search every file/folder in the user’s account by using the above command.

Sync a folder with a remote server folder (fast and great for migrating files versus FTP)

rsync -avz . xxx@serverhostname.reclaimhosting.com:public_html/

^ Run this command within the folder you are migrating. In this example . mean “this folder” and it’s being uploaded to public_html. See also Rsync (Remote Sync): 10 Practical Examples of Rsync Command in Linux

List IP Addresses hitting a server

`netstat -plan|grep :80|awk {‘print $5’}|cut -d: -f 1|sort|uniq -c|sort -nk 1

Grep instances of a domain in a mail log

exigrep domain.com /var/log/exim_mainlog

Show last 10 lines of error log

tail -f error_log

Import SQL file to a database

mysql -u root databasename < dbaname.sql

Export SQL database to a file

mysqldump -u database user -p password > dbname.sql

Restart Shibboleth

service shibd restart

Restart Apache

/scripts/restartsrv_httpd

Restart MySQL

/scripts/restartsrv_mysql

Restart nginx

service nginx restart

Change ownership of a folder recursively

chown -R someuser:somegroup /your/folder/here

Scp (scoop) a file from one location to another

scp backupfile.tar.gz root@yourserver.com:/home/

Find who owns a domain on a particular server

/scripts/whoowns domainexample.com

Log of logins on a particular server

grep “cpaneluser” /var/log/secure – for SFTP
grep “cpaneluser” /var/log/messages –FTP

More to explore

cPanel Basics

cPanel Read below to understand the basics of a cPanel dashboard. By deafult, cPanel will put the Files section first on your dashboard. Note

Changing PHP Version

To change the version of PHP you’ll first navigate to cPanel 3. From there you’ll scroll down to the ‘Software’ section. Click the ‘MultiPHP

Changing Primary Domain

A very common support request we often get is asking for assistance with changing a domain name. More specifically, switching the primary

SEARCH

css.php