Thursday, May 30, 2013

Customize Places Folder in Linux "Start menu" or short-cuts in Nemo file browser


  • Open Nemo (the file browser) and drag and drop directories to the short cut list in the left pane under "My Computer". 
  • Right Click->Remove any items you want to delete from the list. 
  • Right Click-> rename to rename items. 
  • List within the Start Menu->Places will now reflect your changes.

Customize the Mouse Cursors in Linux Mint


  1. Download cursor packs (from here for example, X11 Mouse Themes section)
  2. Expand into ~/.icons (create dir if required)
  3. Menu -> System Tools -> System Settings -> Themes -> Other Settings [tab]  -> Mouse Pointer [pull down]


Upgrade to Linux Mint 15

Steps to Upgrade to Linux Mint 15

This process assumes you have an existing Linux installation on a disk that has enough free space to create a new partition for version 15. In this way you can boot 15 and copy over items from the other Linux environment.
  1. While running Windows 7, Download the ISO image for Linux Mint 15, 64 bit, Cinnamon from here.
  2. Use UNetbootin to create a bootable USB Memory Stick with the ISO image just downloaded.
  3. Reboot off the USB Memory stick (F12 at boot to get a hardware boot menu)
  4. Run Install Linux Mint
    1. select installation type "Something Else" in order to manage which HD and partition Mint is installed to.
  5. Reboot Mint from Hard disk
  6. Activate recommended NVidia video drivers
    1. Menu -> Preferences-> Driver Manager
  7. Apply any pending updates
    1. $ sudo apt-get update
    2. $ sudo apt-get upgrade 
  8. Using Firefox, Install Google-Chrome
    1. Download and run the 64 bit Ubuntu-Debian DEB file
    2. Note: the Google install updates software sources so later runs of apt-get upgrade will get updated versions of chrome.
  9. Install MongoDB
    1. Instructions here.
  10. Install Pycharm
    1. su
    2. mkdir /opt/pycharm
    3. cd /opt/pycharm
    4. mv /home/gbiglow/Downloads/pycharm-2.7.2.tar.gz .
    5. tar xfz pycharm-*.tar.gz
    6. rm pycharm-2.7.2.tar.gz
    7. Run pycharm.sh from the bin subdirectory
      1. do this in a shell once to see if pycharm complains about the wrong JDK
      2. note: look in following log to see if pycharm is logging any start-up errors
        1. /home/gbiglow/.PyCharm20/system/log/idea.log
  11. 'Install' Oracle JDK (pycharm wants the official Oracle one - too bad)
    1. Background
      1. Some notes on installing Oracle JDK - here.
      2. Some other notes on JDK - here (note remove OpenJDK step!)
    2. I took the KISS approach which requires manual repeats to update Oracle Java but does not screw with the official Linux Mint installed OpenJDK
      1. download jdk-7u21-linux-x64.tar.gz from Oracle
      2. expand it into /opt/java
      3. add following to ~./bashrc
        1. export PATH=/opt/java/jdk1.7.0_21/bin:$PATH
  12. Install tools using $ sudo apt-get install <tool-name>
    1. Development tools:
      1. python-pip
      2. python-virtualenv
      3. git
      4. terminator
      5. meld
      6. ipython
    2. Sys Admin tools:
      1. gparted
      2. htop
      3. hardinfo (shows in start menu as "System Information")
  13. Install Heroku Toolbelt
    1. $ sudo wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
    2. $ heroku login

Still Todo:
  1. Fully Copy home dir from old linux installation...
  2. Fix up GRUB and Windows boot menu

Tuesday, May 28, 2013

stockticker (flask/mongodb) on Heroku

Creating an App

1. Create ~/.gitconfig (if not already there)

$ git config --global user.name "My Name"
$ git config --global user.email emailname@mailhost.com

2. Set-up Project Specific Development environment:

$ mkdir ~/dev/stock-fh
$ virtualenv venv
$ work stock-fh
$ git init
$ gedit .gitignore
$ gedit README.md
$ git add .
$ git commit -m "initial commit"
$ mkdir static static/css static/js static/img static/ico templates

create favicon.ico file at favicon.cc and add to static/ico

add any necessary css, js, and img files, html goes in templates dir


3. Go to bitbucket.org and create a new repo called stock.fh and then:

$ git remote add origin ssh://git@bitbucket.org/gbiglow/stock-fh.git
$ git push -u origin --all

4. install required python components and generate requirements.txt

$ pip install flask
$ pip freeze > requirements.txt
$ git add requirements.txt
$ git commit -m "added initial requirements.txt"
git push origin master

5. create a Procfile for heroku and foreman

$ echo "web: python app.py" > Procfile
$ git add Procfile
$ git commit -m "added initial Procfile"
$ git push origin master

6. Create heroku app (this also creates a heroku remote for git)

$ heroku create stock-fh
git push heroku master

7. use mongoDB on heroku




todo:
  • pip add pymongo etc. update requirements.txt
  • twitter bootstrap
  • investigate flask app generator. code. (possible automation of steps 2-6 above into a single command. hmm...

Notes:
  • This is all based on this great article.
  • The command 'work' (above) is a local script to activate a virtualenv
  • I use bitbucket rather than github as bitbucket has unlimited private repos as part of a free account.









Monday, May 27, 2013

Realy good linux reading

http://www.thegeekstuff.com/2010/11/50-linux-commands/
http://www.thegeekstuff.com/2010/12/50-unix-linux-sysadmin-tutorials/
http://www.thegeekstuff.com/2011/12/linux-performance-monitoring-tools/

htop - linux process viewer

htop

A terminal based real time process viewer. Better than the basic linux top command.

To install:

$  sudo apt-get install htop

To run:

$ htop

Read More:

http://www.thegeekstuff.com/2011/09/linux-htop-examples/

http://www.howtogeek.com/howto/ubuntu/using-htop-to-monitor-system-processes-on-linux/





Terminator - Terminal Emulator

Terminator is a very flexible terminal emulator for linux.

Installation of latest version: (taken from here)

$ sudo add-apt-repository ppa:gnome-terminator
$ sudo apt-get update
$ sudo apt-get install terminator

Note: by adding in the gnome-terminator repository (above) you will ensure you get the latest version.

Read more:


Thanks to Kuldeep for the pointer to this tool!


Sunday, May 26, 2013

Meld - a graphical DIFF tool

How to install Meld

$ sudo apt-get update
$ sudo apt-get install meld

Stay tuned for how to configure Meld in Pycharm

Using Bitbucket with Pycharm

Pycharm (the python IDE) has built in support for Github. That's nice as I want to use git for source code management. Codeschool by the way has a nice free git intro course in their electives area. Enough to get one going with git.

The free Github plan however is restrictive compared to Bitbucket's free plan.

Github: no private repos, limited to just yourself.
Bitbucket: unlimited private repos, up to 5 team members

So how does one configure Pycharm to use Bitbucket?

  1. Create a free bitbucket account
  2. Launch Pycharm and go to Settings->Plugins
  3. Click on Browse Repositories
  4. Enter Bitbucket into the search field
  5. Highlight the Bitbucket pluging and click on the "dowload & install" icon
  6. Close all windows and re-start Pycharm (required after a plug-in installation)
  7. Relauch Pycharm
  8. Return to settings and select the new Bitbucket option in the IDE section
  9. Enter Bitbucket userID and password.
  10. Click on Add SSH Key button and navigate to the SSH key you used for Bitbucket




Friday, May 17, 2013

How to install Software on Linux Mint

Read this:
http://forums.linuxmint.com/viewtopic.php?f=90&t=97158

Carefully follow the advice for : checkinstall

$ sudo apt-get install checkinstall

and then use it when building packages from source code.

https://help.ubuntu.com/community/CheckInstall

Linux Mint Update Manager no longer runs

Update Manager asks for SU passwork but fails to run when launched from the start menu. $ sudo mintupdate results in the following: (gksudo:5105): GConf-CRITICAL **: gconf_value_free: assertion `value != NULL' failed No module named gtk No module named pygtk Traceback (most recent call last): File "/usr/lib/linuxmint/mintUpdate/mintUpdate.py", line 59, in gettext.install("mintupdate", "/usr/share/linuxmint/locale") NameError: name 'gettext' is not defined Is the resent installation of Python 2.7.4 to blame? 2.7.4 is in /usr/local/bin and is the default to current user. /usr/bin/python is the old 2.7.3 $ python Python 2.7.4 (default, May 15 2013, 21:25:05) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import gtk Traceback (most recent call last): File "", line 1, in ImportError: No module named gtk >>> import pygtk Traceback (most recent call last): File "", line 1, in ImportError: No module named pygtk >>> $ /usr/bin/python Python 2.7.3 (default, Sep 26 2012, 21:51:14) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import gtk >>> import pygtk >>>


mucking with python (adding a newer version into /usr/local/bin) broke mintupdate as it requires a python with pygtk access. I will update this posting once that is resolved......

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



Install Heroku client on Linux Mint

$ sudo wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh

Python Pip & Virtualenv install on Linux Mint

this will install virtualenv and pip (but both are likely old versions):
$ sudo apt-get install python-virtualenv


use pip to upgrade itself:
$ sudo pip install pip --upgrade

use pip to upgrade virtualenv:
$ sudo pip install virtualenv --upgrade


Install MongoDB on Linux Mint 14

Install MongoDB on Linux Mint 14 or 15 Cinnamon 64 bit


Follow steps on mongoDB page to install mongo.


Configure MongoDB
These packages configure MongoDB using the /etc/mongodb.conf file in conjunction with the control script. You will find the control script is at /etc/init.d/mongodb.
This MongoDB instance will store its data files in the /var/lib/mongodb and its log files in /var/log/mongodb, and run using the mongodb user account.


Starting MongoDB
You can start the mongod process by issuing the following command:
sudo service mongodb start
You can verify that mongod has started successfully by checking the contents of the log file at /var/log/mongodb/mongodb.log.
Stopping MongoDB
As needed, you may stop the mongod process by issuing the following command:
sudo service mongodb stop
Restarting MongoDB
You may restart the mongod process by issuing the following command:
sudo service mongodb restart



Upgrading from Linux Mint 13 to 14


  1. Backup data I care about
  2. Note packages applied to Mint 13
  3. Fresh Install of Mint 14
  4. Restore data
  5. Install required packages


Best Practices

  • Do everything from a script vs. use gui tools.


Add item to Linux Mint start menu and run as Root

Right click start menu icon (lower left)
Select "edit menu"
edit properties of new or existing item
put "gksudo" in front of command that is to be run when item is selected.

This will prompt for root password before the command is run.

Linux Partition Tool

GParted is a great tool for managing partitions. Works well under Linux Mint.

Wednesday, May 1, 2013

Robomongo - gui admin tool for Mongo

Robomongo is a GUI cross platform Mongo admin tool alternative to the basic mongo shell.
Worth a look...