Changing multiple account ownerships via SSH

Issue:

How to change the ownership of multiple accounts under /home via SSH? The option in WHM is a bit tedious.

Solution :

To change the ownership of all accounts to the respective user.user :

cd /home
ls -al | grep root

for i in `ls /var/cpanel/users/`; do chown $i:$i /home/$i ; done
for i in `ls /var/cpanel/users/`; do chown -R $i:$i /home/$i/* ; done

Then change the ownership of the individual public_htmls to their respective user.nobody:

for i in `ls /var/cpanel/users/`; do chown $i:nobody /home/$i/public_html ; done

Change the permissions for public_htmls to 750:

for i in `ls /var/cpanel/users/`; do chmod 750 /home/$i/public_html ; done

Fix the permissions for mail to work fine:

/scripts/mailperm

Fix the ownership of /home:

chown root.root /home

semget: No space left on device

Whenever you start Apache, it keeps crashing with error "semget: No space left on device".

# tail /etc/httpd/logs/error_log
semget: No space left on device
semget: No space left on device
[Wed Sep 12 10:54:27 2007] [warn] pid file /usr/local/apache/logs/httpd.pid overwritten
-- Unclean shutdown of previous Apache run? semget: No space left on device
[Wed Sep 12 10:56:27 2007] [warn] pid file /usr/local/apache/logs/httpd.pid overwritten
-- Unclean shutdown of previous Apache run? semget: No space left on device
[Wed Sep 12 10:58:27 2007] [warn] pid file /usr/local/apache/logs/httpd.pid overwritten
-- Unclean shutdown of previous Apache run? semget: No space left on device
[Wed Sep 12 11:00:27 2007] [warn] pid file /usr/local/apache/logs/httpd.pid overwritten
-- Unclean shutdown of previous Apache run? semget: No space left on device

If you have similar problem as mine above + if your disk space is nowhere near/above 100% + /var/messages and /usr/local/apache/logs/error_log shows no clue about this problem + any files in /etc/httpd/logs/ and /etc/httpd/domlogs nowhere near/above 2GB in size, its most probably semaphore problem. Use the following script to cure your Apache.

#!/bin/bash

ipcs -s | grep nobody | perl -e 'while () {
@a=split(/\s+/); print `ipcrm sem $a[1]`}'

/scripts/restartsrv httpd

Script how to:
- SSH as root to your CPanel server
- Go to root dir

# cd /root


- Create a httpdsemclean.sh blank file

# pico httpdsemclean.sh


- Write above script
- Save

Ctrl + O


- Exit pico

Ctrl + X


- Chmod httpdsemclean.sh to 777

# chmod 777 httpdsemclean.sh


- Execute the script

./httpdsemclean.sh

If all goes fine, you'll see something like this:

...
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
Waiting for httpd to restart..............finished.

httpd started ok

PS: Do this at your own risk, we do not guarantee this will work on all CPanel servers!