Posts Tagged ‘ server

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 :)

How to do a port forward with IPTables on Linux

Hi there!

Long time no post so I am posting this simple howto to show you how to forward a port with IPTables on Linux. This come up because I installed Zenoss on a server and the default port is 8080 and I don’t want to use it so I forwarded the port 80 to the port 8080 on the same machine.

The command to do this is:

iptables -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT \
--to-ports 8080

Cheers!

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!