Daily Useful Linux Commands

Finding the username from provided hosting service name - /script/whoowns domain_name

Finding the domain name from username - grep username /etc/trueuserdomains

Finding the owner of the account from username - grep username /etc/trueuserowners

Apache Error Log/ checking the live logs on server - tail -f /usr/local/apache/logs/error_log | grep IP_address (IP address of connected VPN or of your local network)

Permission fixer - (Make sure to fire it under public_html)
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

Restoring the backup file provided by client under his cPanel - 
/scripts/restorepkg  backup file name with it's path

Copying cPanel access log file in user's home - 
cat /usr/local/cpanel/logs/access_log | grep cPanel_username > /home/cPanel_username/public_html/logs.txt;
chown cPanel_username. logs.txt

File will be accessible from - /home/cPanel_username/public_html/logs.txt or websitename/logs.txt

PHP Version  - phv -v

PHP Module - php -m

Apache Version  - httpd -v
Apache Module - httpd -M 

Checking OS on server - cat /etc/redhat-release

Checking user's running process -  ps -aufx | grep php

Checking the disk usage of account - du -shc * (You'll need to fire the command under the path for which you'd like to check the disk usage)

Checking disk usage with hidden files - du -shc .??* *

Fix Quota - For fixing the account disk usage issue that is if account size is vary in cPanel and shell then you can fire this command - 
/scripts/fixquotas --force
Cagefs remount - cagefsctl --remount-all

Check if ImageMagick is installed - /scripts/checkimagemagick  If installed, the output will be “ok”

Install ImageMagick - /scripts/installimagemagick

Checking open ports on server - 
netstat -tulnp | grep port number

CSF (Firewall) related useful commands 

IP table stop/Firewall disable - 

/etc/init.d/iptables stop
service iptables stop
csf -x

IP table start/Firewall Enable-

/etc/init.d/iptables start
service iptables start
service csf restart
csf -e

  • Start the firewall rules - csf -s
  • Flush/Stop firewall rules  - csf -f
  • Restart the firewall rules - csf -r
  • Allow an IP - csf -a IP address ( It will automatically add IP in  /etc/csf/csf.allow )
  • Temporary  remove the IP from ban list - csf -tr
  • Block the IP - csf -d ( It will automatically add IP in  /etc/csf/csf.deny )
LFD Log to check if IP address is blocked in firewall or not - grep IP address /var/log/lfd.log

Exim Commands

Exim restart - 
service exim restart
/etc/init.d/exim restart

Checking the email log for particular email address - grep email address /var/log/exim_mainlog

Checking the mail queue count on server - exim -bpc

Checking the mail queue on server - exim -bp

Checking the logs of particular email address - exigrep email address /var/lo/exim_mainlog

Checking the header of the mail - exim -Mvh message_id

Checking the body of mail - exim -Mvb message_id

Removing the frozen mail on server -  exim -bp | grep "frozen"| awk '{system ("exim -Mrm "$3)}'

Removing the mails of particular email address - exim -bp | grep "email_address" | awk '{system ("exim -Mrm "$3)}'

Checking the mail count of all accounts on server in ascending order - 
exim -bpc;
grep cwd /var/log/exim_mainlog | grep -v /var/spool | awk -F"cwd=" '{print $2}' | awk '{print $1}' | sort | uniq -c | sort -n

Removing blank emails on server - 
exim -bp | grep "<>"| awk '{system ("exim -Mrm "$3)}'

Checking the message size limit - 
exim -bP | grep message_size_limit

CRON Commands

Checking CRON Status -/etc/init.d/crond status
Starting CRON service - /etc/init.d/crond start
Check CRON logs for user - tail -f /var/log/cron | grep cPanel_username
Checking the CRONs for any particular user - /var/spool/cron/cPanle_username

Was this answer helpful?

 Print this Article

Also Read

How to perform LAMP installation on CentOS?

LAMP stands for Linux, Apache, MySQL, and PHP. It is nothing but Linux operating system with...

Basic exim commands

1. REMOVE MAILS BY ID - /usr/sbin/exim -v -Mrm (MAIL ID HERE) 2. LIST QUEUED MAILS -...

Disk Usage Useful Command

Note - You can replace /home with correct '/' drive on your server. 1. Checking the disk usage -...

How to backup and restore large MySQL databases using mysqldump?

1. Backup database:#mysqldump -u username -p[username_password] databasename >...

How to change the port number of Apache Web Server?

Default port to access the Apache is 80. Secure port for communicating with world for Apache is...