Eddie On Everything

Don't get me started

Entries for the ‘linux’ Category

How To Keep An SSH Connection Alive in Linux

By default, many Linux configurations automatically close SSH sessions after a certain amount of inactivity.
You can easily change this setting on your system by editing the sshd configuration file.
Of course, before doing so, you should consider the security implications of keeping SSH sessions active. Setting your server to keep connections alive may present a security [...]

Rotating Backup Directories using cp -al (hardlinks) to Save Disk Space

The copy command “cp -al” found on all versions of Unix/Linux creates what’s called a “hard link” to a file. The nice thing about this command is that it doesn’t create an actual copy of the file on disk – instead, it creates a “link” or pointer to the file data on the disk. [...]

Using rsync & ssh to Backup Files Between Linux Machines (Perl)

This script performs a network backup using unix’s rsync command over ssh. It performs an incremental backup, which means that it only updates new files and files that have changed since the last backup, thus minimizing network traffic.
This script runs on the source machine (SOURCE) and connects to the backup machine (BACKUP). [...]

“Argument list too long” from rm command. A Perl Script to Get Around the Problem

You’ve seen the problem – many Unix commands don’t like very long argument lists.  For instance, my Linux machine complains when I try to “rm” 10,000 files at once:
[eddie@yoakam test]$ rm *
-bash: /bin/rm: Argument list too long
Here’s a simple script that will delete all of the files in a given directory, even if the argument [...]

Linux Question: When does updatedb.mlocat / cron.daily run?

Uggh. My Ubuntu server’s updatedb.mlocate process is loud as heck and runs *forever*.
I haven’t noticed a performance decrease, as the job is set to run at a fairly low priority. But since I sit near the server, it’s annoying to listen to the hard drive churn for hours and hours. [...]

How to stop VI / VIM from auto-indenting and auto-formatting

Vim is the best editor in the world. Maybe even the best piece of software ever written. Unfortunately, Ubuntu Linux ships with a really annoying default installation – it auto-indents, it annoyingly highlights matching punctuation, doesn’t support syntax highlighting, etc. If you’ve ever tried to paste something into VIM, you know what [...]

How to do a search and replace in multiple files using Perl

Over the years, I’ve written a number of “search and replace in multiple files” scripts. Working on a computer that didn’t have my standard, custom toolset available, I found myself searching for an alternative.
Found this tip over at Dzone Snippets – do it all with a single line of perl.
perl -pi -w -e [...]

Linux fatal error: updatedb: create_db(): chdir: No such file or directory

Got this error when running updatedb from a Red Had Linux command prompt:
fatal error: updatedb: create_db(): chdir: No such file or directory
The problem:
[root@iberia george]# fatal error: updatedb: create_db(): chdir: No such file or directory
As you can see, I’m running as root, so this shouldn’t be a permissions problem. Probably a file lock or corrupt [...]

Linux / WHM / Cpanel : Resource temporarily unavailable

Getting this Linux error message?
Resource temporarily unavailable
It’s because your system is limiting the number of files / processes / CPU that your particular user ID can use.
If you use WHM/Cpanel, enabling the “Shell fork bomb protection” can make the “Resource temporarily unavailable” message appear more often.
Don’t disable the shell fork bomb protection – it’s a [...]

VanDyke Secure CRT – bind: Permission Denied Error when connecting to Ubuntu SSH Server

When using Windows, I use VanDyke SecureCRT to connect to my Linux machines, which include servers running Red Had Enterprise Linux (RHEL), CentOS, and the Debian-derived Ubuntu. Everything was working fine until today.
Though I was playing around with the SSH configuration files to get SFTP transferred files to set a specific file [...]

How To Block an IP Address On Linux / Apache Server

I operate a number of websites, some quite large as far as total “number of pages.” Over the years, I’ve noticed an increasing number of poorly behaved web crawler applications – some completely ignore the robots.txt file, and more and more submit dozens of requests per minute. (eek!) For a site with [...]

How to do a search and replace in multiple files using perl and linux

So you’ve got 100 files in a directory and you want to replace the string “foo” with “bar”. Stop before you waste your time opening up every single file and making the change, you can make all of the changes with a single line of perl.
perl -pi -w -e ’s/foo/bar/g’ *\.php
On his blog, [...]

How to get Apache to parse HTML files as PHP

PHP is a language that is parsed and interpreted by the Apache web server. That is, all code execution takes place on the server side, not on the client side.
By default, Apache only parses files ending in extension .php as PHP files. If you need to tell Apache to also process files with [...]

Uploading Large Files to a LAMP setup – upload_max_filesize, post_max_size, and max_allowed_packet

So you’re trying to upload a large file via PHP and you’re getting an error, eh? It’s probably because of PHP’s default configuration, which limits uploads to 2 Megs, or because of MySQL’s default 1.5 Meg limitation. Here’s how you change these defaults.
First, find your php.ini file. If you don’t know where [...]

How to Securely and Completely Erase Your Computer’s Hard Drive

Getting rid of that old computer? You might want to consider either hanging on to the hard drive or making sure that it’s been completely erased before you do so – your personal data may be at stake.
If you’re like most computer users, you probably have a few files on your computer that you [...]

Uninstalling the Ubuntu Linux boot manager

I’m a RedHat Linux guy, but I wanted to try out the Ubuntu Linux distribution to see if it’s an acceptable solution for Linux newbies (who would likely install a dual-boot XP system) or for cash-strapped non-profit groups (who would likely use it as their primary system).
I had no problems setting up [...]