Linux recursive directory listings

It’s sometimes really useful to recursively generate a list of directories, excluding the files.

I use this in build scripts to create lists of directories that will need to be generated on the remote server – this is useful for things like upload directories for user generated content that wouldn’t necessarily be under version control.

 
find . -type d

To exclude a directory within this path you can use:

 
find . -type d -not -path "./directory_to_ignore/*"

phpize error on RHEL server

Trying to install the MongoDB PHP driver using Pecl (as per the documentation) on a Rackspace managed server running RHEL I ran into the following problem:

pecl install mongo
 
/usr/bin/phpize: /tmp/tmpNW0rIa/mongo-1.2.12/build/shtool: /bin/sh: bad interpreter: Permission denied
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
 
ERROR: `phpize' failed

It took me a while to remember and then search through old tickets, but the problem is that on Rackspace’s RHEL servers the /tmp partition is mounted without script execute permissions. (Is this standard for RHEL in general?)

Pecl uses the /tmp – and so therefore, the install fails.

The solution is to temporarily allow script execution in /tmp

[root@server ~]# mount | grep /tmp
/dev/sda2 on /tmp type ext3 (rw,noexec,nosuid,nodev)
 
[root@server ~]# mount -o remount,exec /tmp
 
[root@server ~]# mount | grep /tmp
/dev/sda2 on /tmp type ext3 (rw,nosuid,nodev)

Install the MongoDB driver with Pecl…

[root@server ~]# pecl install mongo

Revert the permissions on /tmp and then check the permissions are correct…

[root@server ~]# mount -o remount,noexec /tmp
 
[root@server ~]# mount | grep /tmp
/dev/sda2 on /tmp type ext3 (rw,noexec,nosuid,nodev)