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