Create directory and change into it automatically

More quick command line geekery.... Create a command in .bashrc that lets you create directories and change into them immediately:

mkcd () {
  mkdir -p "$*"
  cd "$*"
}


so to use it:

mkcd directory/another/yet_another

Filed under  //   command line   linux   ubuntu  

Change permissions on all directories except SVN with the command line?

OK, a quick one. Want to set permissions on all directories except .svn ones?

So, working from your current directory down, let's say you want to make all directories writeable, and leave the svn ones alone:

find . -type d -not -name ".svn" | xargs chmod 0777

Or, if you need to exclude several directory types, you could arrange it a little bit differently:

find . -type d -print | grep -v '\(\.svn\|modules\)' | xargs chmod 0777

Filed under  //   command line   linux   ubuntu  

Downgrading to PHP 5.2 from PHP 5.3 on Ubuntu 10.04

On the Ubuntu 10.04 Lucid Lynx release, by default PHP 5.3 is installed. Great if you are using it, but it's not for everyone. Definitely not for me being a Drupal developer, as for the moment, it causes problems.

This method worked for me (however I am not responsible if it doesn't for you). All you need to do it put this lot in a shell file and run it. Remember to chmod +x file for it to run.

 

php_packages=`dpkg -l | grep php | awk '{print $2}'`
sudo apt-get remove $php_packages
sed s/lucid/karmic/g /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/karmic.list
sudo mkdir -p /etc/apt/preferences.d/
for package in $php_packages;
do echo "Package: $package
Pin: release a=karmic
Pin-Priority: 991
" | sudo tee -a /etc/apt/preferences.d/php
done
sudo apt-get update
sudo apt-get install $php_packages
sudo /etc/init.d/apache2 restart

Filed under  //   command line   downgrade   linux   php   ubuntu