Archive for the Linux VPS Category

how to delete files is older then n no of days on centos linux

You may be having lakhs of files on a folder which is taking chunk out of you from your server.

Its hard to list all the files even on a GUI file manger on KDE or on GNOME.

Without worries, this can done with a simple command.

find /home/username/foldername -mtime +10 -exec rm {} \;

with the above command, we can delete the files older then 10 days on the location /home/username/foldername change the path that points your local OS files or folder location

unable to remove files using rm command /bin/rm: Argument list too long

I had faced issues in deleting files using rm command which caused our linux BOX struggle to work with Mysql Databases.
I came to see an nice article from simplehelp.net and thought of sharing the same.

which will help to take your headache.

# /var/spool/clientmqueue # rm -Rf SAS*
#/bin/rm: Argument list too long.

Ever seen this error in Linux when you have too many files in a directory and you are unable to delete them with a simple rm -rf *? I have run into this problem a number of times. After doing a bit of research online I came across a neat solution to work around this issue.

find . -name ‘SAS*’ | xargs rm

In the above instance the command will forcefully delete all files in the current directory that begin with SAS. You can replace the SAS-* with anything you like. You can also replace it with just a * if you want to remove all files in the folder.

find . -name ‘*’ | xargs rm

Thanks who ever wrote this.

/var/cpanel/bandwidth causing issue on /var full in cpanel

Issue : /var/cpanel/bandwidth causing issue on /var full in cpanel

When you get the issue of /var is full,

normally it happens because the following using the more space
1. Bandwidth files of the domains hosted.
2. Logs files of the server, which includes cpanel, mail, mysql & all other services running the Server
3. Due to Mysql Usage.

Here we are going to resolve the issue which caused due tot he bandwidth files.

Generally the Location will be /var/cpanel/bandwidth
This files are not not log files, which cannot rotated and even if you rotate it will not help you in reducing the files size.

Instead of deleting the directory, move the files to a location where you have more storage, then sym link to the old location

Use the Below Commands :
# mv /var/cpanel/bandwidth /home/bandwidth
# ln -s /home/bandwidth /var/cpanel/bandwidth

viewing & finding contents from the mail logs on Linux centos cpanel

To viewing & finding contents from the logs on Linux centos cpanel

Use the below commands view or find the email or domains transaction logs.

/var/log/exim_mainlog
/var/log/maillog

# grep domainname /var/log/exim_mainlog  for finding logs of a particular domain

and

# grep emailaddress /var/log/exim_mainlog for finding logs of a particular email address.

how to restart linux cpanel apache tomcat

To restart the Linux servers, Apache TOMCAT installed with cpanel

/scripts/restartsrv tomcat

checking the folder size – The /usr partition on this server is running out of disk space

If you have 1000s of accounts on cpanel, you would probably get the error message

The /usr partition on this server is running out of disk space. WHM operation has been temporarily suspended to prevent something bad from happening. Please ask your system admin to remove any files not in use on that partition.

Here, you will left alone to find what files are taking too much space on the /usr partition

Normally,

/usr/local/cpanel
/usr/local/apache
If you have ASSP or some kind of Antispam Engine installed it would take logs of space for storing the messages & logs
for ASSP
/usr/local/assp

First, Login to ssh
use the below command
du -h --max-depth=1 /usr/

If you find any specific folder taking more space, you do denote the specific folder by

du -h --max-depth=1 /usr/local

here you can increase depth to 2, 3 & etc.. to see the space used in depth.

To sort the foldersize in ascending order user
du -h --max-depth=1 /usr/ | sort -n -r

Once you have found, You can remove the logs of cpanel, apache, assp & etc…

Editing Network Ipaddress on Linux OS cent-os

Make sure that you have Network Card is physically installed on the PC/Server.

And enable the Network card. by command >> service network start

Now, use any editor, here i use nano for editing the configuration of the networking IP Addres
nano /etc/sysconfig/network-scripts/ifcfg-<interface-name>

From here you can edit/remove/add any Ipaddres.

making the cpanel user to create the database name with the username as prefix

If your users are create databases in different like what ever the name they want, we cannot able to identify the user who is abusing the server.

Only by the username of the account, we can easily identify the abuser.

If this featured is disabled, We can enable the same.
Just follow the steps.

You can disabled this by changing in
/var/cpanel/cpanel.config
database_prefix=0
to
database_prefix=1
and restarting cpsrvd.
/usr/local/cpanel/etc/init/stopcpsrvd
/usr/local/cpanel/etc/init/startcpsrvd

command to find no of files on a folder in linux OS

How to find the no of files on a particular folder

ls -l | wc -l

Say If you want to find a specific files nos, You can use the below command.

for eg. you want to find .gz files

ls *.gz -l | wc -l

installing fantastico on linux with CPANEL

Login to the SSH with the root password.
Change to directory >> CGI

cd /usr/local/cpanel/whostmgr/docroot/cgi

wget -N http://www.netenberg.com/files/free/fantastico_whm_admin.tgz

tar -xzpf fantastico_whm_admin.tgz

rm -rf fantastico_whm_admin.tgz

Login to WHM, and follow the link WHM -> Add-Ons -> Fantastico De Luxe WHM Admin.