Press "Enter" to skip to content

Tag: linux

Techy: Find and replace on Linux excluding SVN folders

Just another snippet aid to memory, this find and replace (using perl) uses Linux’s find’s “prune” syntax to “prune” the path before it to avoid doing and search and replace on .svn folders:

find -path '*/.svn' -prune -o -type f -exec /usr/bin/perl -pi -e "s/ORIGINAL/NEW/g" {} \;

cPanel: Error: Package system can not be repaired automatically

If, like myself, you have recently upgraded the cPanel control panel system on your Red Hat Enterprise Linux 5.2 server and received the error message “Error: Package system can not be repaired automatically” when upgrading Apache, then it’s probably caused by a problem with either the RedHat Package Manager (RPM) or YUM. To fix it, first ensure that no RPM or yum updates are running:
ps auxwww | grep yum
ps auxwww | grep rpm

If any are running, find out why and kill -9 them if they are zombie processes. Now you just need to rebuild the RPM database:
rm /var/lib/rpm/__db.* -rf
rpm --rebuilddb

This process may take some time (between 1 and 30 minutes depending on your server speed and the number of packages installed). Once it’s completed, you should be able to upgrade without problems.

Internal Server – Firewall workaround needed

At work, we’re developing something on an internal server which is behind several firewalls and routers, but we need to allow a third party website (Paypal to be exact) to be able to connect to the web server.

It is nearly impossible for me to put this machine either on the public internet or make a hole in the firewall tables (basically, it’s behind our internal NAT providing router, which is then on a NATted firewalled building router, which is then on another NATted firewalled building providers router/VPN – and then the ISPs NATted firewalled router). As you can imagine, being behind 4 routers each with their own firewall configuration and us being unable to get the rules changes makes this a bit difficult.

However, along with the Linux based web server within our LAN, I do also have a remote Linux server with spare IPs. But how can I setup a connection so that the 3rd party can go to http://testdomain.myserver.example.com which then connects to my remote Linux server which then, somehow, connects to the LANed server.

We can make as many outbound connections on whichever ports we like from our LAN (so I can connect the LAN server to the remote server), but then how do I do the connection and how do I then forward the requests inbound?

Any ideas?

Joke: Airlines and Operating Systems

Tension Not.com has some very funny analogies of how airlines would operate if they were ran the way operating systems (such as Windows, Linux and Mac) do. Here’s just two examples from their list:

Mac Airlines
All the stewards, captains, baggage handlers, and ticket agents look and act exactly the same. Every time you ask questions about details, you are gently but firmly told that you don’t need to know, don’t want to know, and everything will be done for you without your ever having to know, so just shut up.

Windows Vista Airlines:

You enter a good looking terminal with the largest planes you have ever seen. Every 10 feet a security officer appears and asks you if you are “sure” you want to continue walking to your plane and if you would like to cancel. Not sure what cancel would do, you continue walking and ask the agent at the desk why the planes are so big. After the security officer making sure you want to ask the question and you want to hear the answer, the agent replies that they are bigger because it makes customers feel better, but the planes are designed to fly twice as slow. Adding the size helped achieve the slow fly goal.

Once on the plane, every passenger has to be asked individually by the flight attendants if they are sure they want to take this flight. Then it is company policy that the captain asks the passengers collectively the same thing. After answering yes to so many questions, you are punched in the face by some stranger who when he asked “Are you sure you want me to punch you in the face? Cancel or Allow?” you instinctively say “Allow”.

After takeoff, the pilots realize that the landing gear driver wasn’t updated to work with the new plane. Therefore it is always stuck in the down position. This forces the plane to fly even slower, but the pilots are used to it and continue to fly the planes, hoping that soon the landing gear manufacturer will give out a landing gear driver update.

You arrive at your destination wishing you had used your reward miles with XP airlines rather than trying out this new carrier. A close friend, after hearing your story, mentions that Linux Air is a much better alternative and helps.

Techy: Recursive CHMOD of Folders

I’m currently in the midst of moving a large number of websites from one Red Hat Linux web server (an Ensim machine) to another Red Hat Linux web server (this one powered by Cpanel) , but the chmod (file permissions) of the “public_html” (web root, web docs, htdocs whatever) folder is incorrect on the new server. So, instead of chmodding over 200 files “by hand”, I’ve used the following little script (just run from the command line):

find . -type d -name public_html -exec chmod 0755 {} \;

Basically it searches (using find recursively (ie it checks folders and sub folders/directories and sub directories) for a directory (-type d) called (-name) public_html and when it does it runs the command (-exec) chmod 0755 (which sets the permissions so that the owner can read, write and execute/open the folder and all other users can read and execute/open the folder).

Simple eh? 😉