Posts Tagged ‘ Tricks

How to delete a huge amount of files at once on linux

I was trying to delete a folder which tons of files and the rm command was giving me an error,
luckly the almighty find command did the job for me :)

-bash-3.2# ls -1 | wc -l
54999

Wow that’s a lot of files!

-bash-3.2# rm *
-bash: /bin/rm: Argument list too long

Yikes! Let’s try the find alternative

-bash-3.2# find . -type f -exec rm -f {} \;
-bash-3.2# ls -1 | wc -l
0

Great :)

Change timezone from UTC to GMT using an automatic script

Hi,

If you are using alestic Ubuntu AMIs for AWS/EC2 the timezone is UTC by default, I had to change that to GMT for a customer here is a way to do it automatically in your build script or without human intervention:

echo “Etc/GMT” | tee /etc/timezone
dpkg-reconfigure –frontend noninteractive tzdata

Note: The –frontend option has two – in front

You can check more timezones at the directory /usr/share/zoneinfo/

Hope it helps you!

Cheers!

Globally Enable SpamAssassin and SpamBox in cPanel

Hi folks,

In this quick post I want to share with you a great script to easily enable SpamAssassin and SpamBox for all the accounts in your cPanel server. I was surprised that this option is not available at cPanel so I started to Google around and found this handy script:

#!/bin/bash
cd /home
for user in `ls /var/cpanel/users`
do
test ! -d $user && continue
touch  $user/.spamassassinenable $user/.spamassassinboxenable
chown $user:$user  $user/.spamassassinenable $user/.spamassassinboxenable
echo $user complete
done

All credits goes to brianoz user of cPanel forums. (I just changed the chown line to include the : instead of the .)

If you want to check the thread in that forum you can check this link: http://forums.cpanel.net/f5/spamassassin-global-enable-anyone-57111.html#post284327

I hope it helps you like it did it for me.

Take care!