Create superuser(root) in postgres database

I always forget the exact syntax for this so I am posting it here. It’s easy when you know how:

CREATE USER root WITH PASSWORD ‘My.g00d.Pa55word’;
ALTER USER root WITH SUPERUSER;

Also make sure that your ip is allowed in pg_hba.conf

Posted in postgres | Comments Off on Create superuser(root) in postgres database

How to install same packages on another ubuntu 12.04 server

There is a lot of stuff out there about this, but none of them worked for me as well as this. The difference is that the deborphan command pretty much just lists the packages you actually installed, not the stuff that got installed as a dependency.

On your old machine:

apt-get install deborphan
(Edit: parameters were backwards)
deborphan -a --no-show-section > installedpackages
deborphan --no-show-section -a > installedpackages

copy the installedpackages file to new machine

you might want to check your ppa’s and sources.list if the next commands show missing packages.

On your new machine

aptitude update
aptitude install $(cat installedpackages)

Posted in Linux, Ubuntu | Comments Off on How to install same packages on another ubuntu 12.04 server

Connect mac osx to Cisco Switch using USB to Serial adapter

This worked for me using a prolific adapter

Follow this:

http://plugable.com/2011/07/12/installing-a-usb-serial-adapter-on-mac-os-x

then

screen -S cua -s serial /dev/tty.usbserial 115200,-cstop,-cs8,-parenbreset

Posted in Mac OS X | Comments Off on Connect mac osx to Cisco Switch using USB to Serial adapter

How to restore a postgres database with a different owner

To restore a database and have the tables owned by a different user use the pg_dump command like this:

as root user run:

su postgres
pg_dump -Fc database_name > database_name.dump
exit

Now you can restore using pg_restore.


createuser -P -s -e new_user
createdb -O new_user new_database

su postgres
pg_restore -v -d new_database -O -U new_user -h localhost database_name.dump
exit

After this don’t forget to modify the new_user and drop the superuser privilege.

Posted in postgres | Comments Off on How to restore a postgres database with a different owner

mount error(13): Permission denied – Ubuntu 12.04


mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

This one can be really hard to track down.  There are many reasons you might get this error.  Basically it means you were denied access to the share you are trying to connect to with mount.cifs or mount -t cifs

I was also getting these errors in my syslog:


Aug 19 12:47:00 vger kernel: [261820.963173] Status code returned 0xc000006d NT_STATUS_LOGON_FAILURE
Aug 19 12:47:00 vger kernel: [261820.963185] CIFS VFS: Send error in SessSetup = -13
Aug 19 12:47:00 vger kernel: [261820.964461] CIFS VFS: cifs_mount failed w/return code = -13

I have seen a number of people who said that the problem was solved by including the domain in the options parameters, or putting no spaces after the ‘=’ sign.

However, for me the trick was the security setting. I recently disabled ntlm v1 on all our windows servers. Unfortunately, the samba mounter wants to use that by default. Specifying ntlmv2 did the trick for me. You may be using a newer release of linux that uses ntlmv2 by default, and you may need to specify ntlm, so it could be that too.

Adding sec=ntlmv2 to the options worked for me:


mount -t cifs //172.16.1.5/myshare/ /mnt/myshare -osec=ntlmv2,domain=MYDOMAIN,username=myusername,password=mypassword

Hope this helps someone.

Posted in Linux, Samba | Comments Off on mount error(13): Permission denied – Ubuntu 12.04