Tag Archives: nano

Resetting the root/postgres password for PostgreSQL

The following is required to reset the root/postgres user password for PostgreSQL. The distribution used in my example is CentOS 5.5 and PostgreSQL 8.4.

Note: By default there’s no password for the postgres user.

In step 2 and 5 you will most likely not be using “ident” but rather “password” or “md5”.

1. Shut down PostgreSQL

# service postgresql stop

2. Reset the authentication mechanism (assuming defaults are already being used)

Edit the /usr/lib/pgsql/data/pg_hba.conf file

# nano /usr/lib/pgsql/data/pg_hba.conf

Navigate down to the line that says

local all all ident

Edit it to

local all postgres trust

And now save the file.

3. Start PostgreSQL

# service postgresql start

4. Log in and change the password

# su - postgres
$ psql -d template1 -U postgres
alter user postgres with password 'new_password';

Or alternatively do it all in one go with the following command

> psql -U postgres template1 -c "alter user postgres with password 'new_password';"

5. Reverse the actions you did in step 2

Edit the /usr/lib/pgsql/data/pg_hba.conf file

# nano /usr/lib/pgsql/data/pg_hba.conf

Navigate down to the line that says

local all all trust

Edit it to

local all postgres ident

And now save the file.

6. Start PostgreSQL

# service postgresql start

Success!

// CrashMAG

How to configure the networking in Fedora 14 when you used a minimal install

Using the minimal Fedora 14 install presented two small challenges.

  1. No networking except for loopback / 127.0.0.1
  2. No nano to edit the relevant configuration files.

In a nutshell, it’s a paradox. I’d like to get nano to edit configuration files. But to do that I need network access. Turned out that I had to use “vi” which I never do to edit the networking files. What a pain. I personally can’t stress how retarded it is with an editor, that requires you to enter text, to be able to enter text.

So the following was done to remedy the matter.

Edit the networking configuration using vi

# vi /etc/sysconfig/networking-scripts/ifcfg-eth0

Used the arrows to navigate to the end of the “ONBOOT=no” line.

  1. Pressed i to enter insert mode.
  2. Modified “ONBOOT=no” to “ONBOOT=yes”.
  3. Pressed ESC to exit insert mode.
  4. Pressed o to add a new line.
  5. Press i to enter insert mode.
  6. Added “BOOTPROTO=dhcp”
  7. Pressed ESC to exit insert mode.
  8. Typed in :wq to exit and save the file.

Or for a static IP

  1. Press i to enter insert mode.
  2. Modify “ONBOOT=no” to “ONBOOT=yes”.
  3. Press ESC to exit insert mode.
  4. Press o to add a new line.
  5. Press i to enter insert mode.
  6. Added “BOOTPROTO=static”
  7. Press o to add a new line.
  8. Add IPADDR=X.X.X.X
  9. Press o to add a new line.
  10. Add NETMASK=X.X.X.X
  11. Press ESC to exit insert mode.
  12. Type in :wq to exit and save the file.

Restart the networking service

# service network restart

Done!

Install nano

# yum install nano

Voila! This way one can edit text files easily, without having to enter text to enter text like in vi. (Made my dizzy just typing it)

// CrashMAG

Nano syntax highlighting

I wanted to share an easy way of adding syntax highlighting to your favorite editor. I’ll give you examples to use for Arch Linux, RHEL, CentOS, Fedora and Debian. This all requires you to add code to your ~/.nanorc file. Luckily, the nano packages contain what you want. You just have to add it.

The typical format of these nanorc files that comes with the nano package is programming_language.nanorc.

To list the available packages for each distributions please do the following

RHEL/CentOS/Scientific Linux/Fedora

# rpm -ql nano | grep nanorc

Debian

# dpkg -S nano | grep nanorc

Arch Linux

# pacman -Ql nano

They all reside in the /usr/share/nano/ folder on each system.

You add languages to your ~/.nanorc the following way.

$ cat /usr/share/nano/programming_language.nanorc >> ~/.nanorc

The >> option will append information so you can keep using this command for each language you want to add syntax highlighting for.

// CrashMAG