Thursday 9 December 2010

Install Postgresql 8.4 on Ubuntu 10.10

Install postgres and the python libraries:
sudo apt-get install postgresql-8.4 postgresql-client-8.4 python-psycopg2
Modify the config file to allow local connections:
sudo nano /etc/postgresql/8.4/main/pg_hba.conf
Add the line:
local     all         all     md5
Save the changes to the file and restart the server.
sudo /etc/init.d/postgresql restart
Set the password for the postgres user:
sudo passwd postgres
Change to the postgres user:
su - postgres
Create a new Database:
createdb mydb
Login to the postgres shell and point to our new database:
psql mydb
Now from the postgress shell create a user and give him access to the database:
mydb=> CREATE USER myuser WITH PASSWORD 'myPassword';
mydb=> GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;
mydb=\q
Done!

Source:  Videntity's Blog


Sunday 5 December 2010

batch rename in Linux command line

The most intuitive way is  'sed' a loop. like this


for file in *.*; do mv $file `echo $file | sed 's/foo/bar/g'` ; done;
-----