Category: Terminal/Shell

Scrap Parts

List all users whmapi1 list_users | grep ‘^ – ‘ | sed ‘s/^[ \-]*//’ | grep -v ‘^root$’ Server agnostic account-review sudo $(/bin/ls /opt/dedrads/account-review /opt/sharedrads/account-review) userna5 Move into a domain read -p “Domain: ” domain;user=$(/scripts/whoowns $domain);review=$($(ls /opt/dedrads/account-review /opt/sharedrads/account-review | sed ‘s/\*$//’) $user);docroot=$(echo “$review” | grep Docroot | grep $domain | sed -e ‘s/.*Docroot\://’ -e ‘s/Has…
Read more

MySQL Commands

Repair all databases from root user mysqlcheck –auto-repair –check –all-databases Check all databases from root user mysqlcheck –check –all-databases Check for MySQL skip_name_resolve if phpMyAdmin gives errors mysql> show variables like “skip_name_resolve”; +——————-+——-+ | Variable_name | Value | +——————-+——-+ | skip_name_resolve | ON | +——————-+——-+ Turn off MySQL strict mode echo ‘sql_mode=”ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION”‘ >> /etc/my.cnf; service…
Read more

Set Hostname and PTR

Set hostname vzctl set 31956 –hostname mail.example.com –save Check hostname from container vzlist -a | grep 31956 Check hostname from VPS vzctl enter 31956 hostname Set the ptr record in comodo Check PTR record dig -x 127.0.0.1 @ns +short

Search php.ini and .user.ini Files for Text

This is useful when your .user.ini settings are getting overwritten read -p “Search Text: ” needle;for i in $(find -name *.ini -type f); do echo “>>> $i <<<“; grep “$needle” $i; done

awk Examples

Get top 15 most instanced commands Drop the “a” flag from the initial ps command to only see commands of the same user ps -cax | cut -c 26- | awk ‘{count[$0] += 1}END{for(i in count)print count[i] ” ” i}’ | sort -nr | head -15 Mail log Find the number of failed logins per…
Read more

Filter Logs

Use this to scrape a user’s FTP logs to a file sudo cat /var/log/messages-20171001.gz | gunzip -c | grep -i user@example.com >> /home/userna5/FTPLogins.txt sudo cat /var/log/messages | grep -i user@example.com >> /home/userna5/FTPLogins.txt

Corrupt Horde SQL File

If you get a corrupt horde sql file run this: /usr/local/cpanel/bin/update_horde_config –user=dynast7 It’s specific to older server thoughs. Took a sec. Apparently this only happens on older server configurations.

Watch All Apache and cPanel Logs

tail -f /usr/local/{cpanel,apache}/logs/{error,access}_log

Using The Screen Command

To start a screen: screen -S screenname ^a then d to detatch. Once you want to resume: screen -ls screen -r screenname

Start AutoSSL for One User

Add the user’s username to the end of the command usr/local/cpanel/bin/whmapi1 start_autossl_check_for_one_user username=