piątek, 18 lutego 2011

Ubuntu: apt-get - how to install already installed package

Let's imagine a case where one has been removed by chance some files comes with one of deb packages installed with apt-get utility.

For sake of this example lets remove /usr/lib/php5/20060613/pdo_mysql.so file.

Now after Apache restart the following entry will appear in /var/log/apache2/error.log
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613/pdo_mysql.so' 
- /usr/lib/php5/20060613/pdo_mysql.so: cannot open shared object file: 
No such file or directory in Unknown on line 0

In this particular case is quite easy to guess which package pdo_mysql.so file comes with. But in general dpkg --search can help.

$ dpkg --search /usr/lib/php5/20060613/pdo_mysql.so
php5-mysql: /usr/lib/php5/20060613/pdo_mysql.so

Now we know for sure which packed needs to be installed again. To ask apt-get to install package which already is installed --reinstall option needs to be used.

sudo apt-get --reinstall install php5-mysql

Now pdo_mysql.so should be again on its place.

czwartek, 10 lutego 2011

Linux - "find" command by examples

  • Remove all subversion metadata (all directories with .svn name)
    find . -type d -name ".svn" | xargs rm -rf
    
  • Remove all file begining with two digits number followed by underscore character
    find . -name "[0-9][0-9]_*" | xargs rm -rf
    
  • Find all file which where modified within last 24 hours
    find . -mtime 0