Thursday, May 16, 2013

My System

Unless otherwise noted, all the posts in this blog are related to working in the following environment.

Hardware

  • Lenovo T510 Laptop
    • 8GB memory
    • internal 500GB HD for Windows 7
    • internal 750GB HD for Linux
    • eSATA port for connecting external SATA drives (great feature when one want to have 3 HDs available or swap in other HDs for special purposes)
  • Thermaltak BlackX HDD docking station (ST0005U)
    • takes a single 2.5" HD or a single 3.5" HD
    • USB 2.0 or eSATA connection to host
    • press F12 at system startup to get a boot menu that sees this device
    • both Windows 7 and Linux Mint see this device
Software
  • Windows 7 Professional edition, 64 bit
  • Linux Mint 14 Nadia, 64 Bit, Cinnamon
    • Based on Ubuntu Quantal (12.10)

Tuesday, May 14, 2013

Install latest PostgreSQL on Linux Mint


PostgreSQL

Installation


create /etc/apt/sources.list.d/pgdg.list containing:

deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main

Import the repository signing key, and update the package lists

$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
sudo apt-key add -

Update repository indexes

$ sudo apt-get update

Install postgreSQL (run all these cmds as root)

# apt-get install postgresql-9.2
# apt-get install postgresql-contrib-9.2
# apt-get install pgadmin3

Set OS password for user 'postgres'

$ sudo passwd postgres

Set DB password for user 'postgres'

$ psql
psql> ALTER USER postgres WITH PASSWORD 'jessie123';
psql>\q

(note: the new password above is enclosed in double quotes)

Create a .bashrc in home dir of user 'postgres' containing:

PATH=$PATH:/usr/lib/postgresql/9.2/bin
export PGDATA='/var/lib/postgresql/9.2/main/'
export PGCONF='/etc/postgresql/9.2/main'



psql commands

\q
Quit out of psql
select name, setting from pg_settings where category = 'File Locations';
Show settings & file locations


























Key directories

/etc/postgresql/9.2/main
Configuration files
/var/lib/postgresql/9.2/main
Data dir (env var $PGDATA)
/var/lib/postgresql
Home dir for user postgres






Key files

/etc/postgresql/9.2/main/pg_ident.conf
Mappings of OS logins to postgreSQL user
/etc/postgresql/9.2/main/postgresql.conf
General settings, where data is stored, where logs are etc
/etc/postgresql/9.2/main/pg_hba.conf
Host based authentication, security and authentication settings
/var/log/postgresql/postgresql-9.2-mail.log
Log file for postgreSQL server







Environment Variables

PGDATA
Location of postgres data
PGCONG
Location of postgres config files (gcb use only)


Server Control

Start the service
/etc/init.d/postgresql start
pg_ctl start
Stop the service
/etc/init.d/postgresql stop
pg_ctl stop
Know the status
/etc/init.d/postgresql status
pg_ctl status
Restart the service
/etc/init.d/postgresql restart
pg_ctl restart
Reload config without restarting server
pg_ctl_reload








apt-get notes (package management)

List all installed packages (pipe to grep to search for a specific pattern):
$ dpkg --get-selections | grep <pattern>


remove all libreoffice packages:

$ sudo apt-get purge libreoffice-*

remove orphaned packages, i.e. installed packages that used to be installed as an dependency, but aren't any longer. Use this after removing a package which had installed dependencies you're no longer interested in:
$ sudo apt-get autoremove

see what packages are available to install matching a  pattern
$ apt-cache search <pattern>

To see all the files installed by a package like 
python-kivy-examples:
$ dpkg-query -L  <package name>


apt-get commands:

update is used to resynchronize the package index files from their sources. The indexes of available packages are fetched from the location(s) specified in /etc/apt/sources.list. An update should always be performed before an upgrade or dist-upgrade.


upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded; under no
circumstances are currently installed packages removed, or
packages not already installed retrieved and installed. New
versions of currently installed packages that cannot be upgraded
without changing the install status of another package will be
left at their current version. An update must be performed first
so that apt-get knows that new versions of packages are available.

dist-upgrade in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages; apt-get has a "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary. The dist-upgrade command may therefore remove some packages. The /etc/apt/sources.list file contains a list of locations from which to retrieve desired package files. See also apt_preferences(5) for a mechanism for overriding the general settings for individual packages.



Install LibreOffice 4.0.3 on Linux Mint

Remove existing libreoffice (likely older than 4.x)


$ sudo dpkg --get-selections | grep libreoffice
$ sudo apt-get purge libreoffice-*
$ sudo apt-get autoremove

Download new tarballs from:

http://www.libreoffice.org/download/?type=deb-x86_64&lang=en-US&version=4.0.3

Instructions from 
http://www.libreoffice.org/get-help/installation/linux/


Installation of LibreOffice on Linux

If you have a previously-existing installation of the community-supplied LibreOffice package for Linux, first to remove it.
When you are ready to start installation, go to the Downloads page and, in the left-hand dropdown list, choose the package suitable for your system, i.e. for a 32-bit or 64-bit deb-based system (for Debian, Ubuntu, ...), or for a 32-bit or 64-bit rpm-based system (for Fedora, Suse, Mandriva, ...).
At this point, you may also want to to install the "LibreOffice built-in help" package which is separate from the installation package. You can use LibreOffice without this package, however, it will then go to the "Help" page on our website instead. A separate "Help" package makes it possible to keep the installation package smaller for downloading purposes.

Installation of LibreOffice on Debian/Ubuntu-based Linux systems

The instructions here are for installing LibreOffice in US English, on a 32-bit system; there will be slight differences in some directory names if you are installing LibreOffice on a 64-bit system, but the process is basically the same and – hopefully – you will not find these instructions difficult to follow.
1) After downloading the installer archive file, use Nautilus to decompress it in a directory of your choice (your Desktop directory, for example). After decompressing it, you will see that the contents have been unpacked into a directory calledLibO_3.3.0rc1_Linux_x86_install-deb_en-US or LibO_3.4.5rc2_Linux_x86_install-deb_en-US. Open a Nautilus file manager window, and change directory to that directory.
2) The directory contains a subdirectory called DEBS. Change directory to the DEBS directory.
3) Right-click within the DEBS directory and choose “Open in Terminal”. A terminal window will open. From the command line of the terminal window, enter the following command (you will be prompted to enter your root user's password before the command will execute):
sudo dpkg -i *.deb
4) The above dpkg command does the first part of the installation process. To complete the process, you also need to install the desktop integration packages. To do this, change directory to the desktop-integration directory that is within the DEBS directory, using the following command:
cd desktop-integration
Now run the dpkg command again:
sudo dpkg -i *.deb
The installation process is now completed, and you should have icons for all the LibreOffice applications in your desktop's Applications/Office menu.

Install Pycharm on Linux Mint

Download Pycharm tarball from here

Extract it

Move it to /opt

Repair start menu if required to run bin/pycharm.sh 


Edit GRUB menu on Linux Mint 14

update-grub is a stub for running grub-mkconfig -o /boot/grub/grub.cfg to generate a grub2 config file.

$ sudo update-grub

referencegrub2 overviewgrub2 tutorials

http://www.dedoimedo.com/computers/grub-2.html



to find version of grub installed:

$ sudo grub-install -v

Linux Mint 14 has version 2.00
version 1.98 or newer is considered GRUB2



Monday, May 13, 2013

install Python 2.7.5 on Linux Mint

To begin, install all the development packages required to build python. Some of these may already be on your system and you may need others beyond these. These are the ones I had to add.

$ sudo apt-get install {the packages below...}
  • build-essential
  • libreadline6-dev 
  • libncursesw5-dev
  • libncurses5-dev
  • libssl-dev 
  • libsqlite3-dev 
  • tk-dev 
  • libgdbm-dev 
  • libc6-dev 
  • libbz2-dev
  • libltdl-dev
Download Python 2.7.5 tarball from python.org
Extract it and cd into that dir.

Review the README file for hints etc.
$ pg README

Generate a make file
$ ./configure

Run generated make file to compile Python executable
$ make
NOTE: renamed /usr/local/bin/python to python2.75 so apps like minkupdate would not be broken. need to get pygtk built into /usr/local/bin/python before things are fully happy. stay tuned for resolution......



Install the new Python
$ su root
# make altinstall


Notes: 
  • If you need to restart or repeat the running of make 
    • $ make clean 
    • will delete all files from previous runs of make
  • 2.7.5 will be installed in /usr/local/bin while 2.7.3 remains in /usr/bin
  • The installation of build-essential is require as explained here. Note the other packages listed above are required to compile a fully functioning python executable. if some are missing compile will still work but functionality may be missing (like readline which is required for python shell command recall)
  • Use of altinstall explained here
  • To use this new version of python with virtual environments:
    • change to dir you want to create a vitual environment in
    • $ virtualenv -v -p /usr/local/bin/python venv
    • above command will run in verbose mode and use specified python to create a virt env called "venv".
    • If above command fails with error like can't import zlib it means you did not have all the required packages installed to your system prior to compiling and installing your new version of python.
    • Carefully read the error messages at the end of the running of Make to see you are still missing any required packages
Outstanding:
  • ensure Pycharm works as expected with 2.7.4