Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Thursday, July 21, 2011

Cannot shutdown Ubuntu, always restarts

Solution:
sudo shutdown -h now

Ubuntu pip install record

MozSecWorld$ sudo pip install -r requirements/compiled.txt 
Downloading/unpacking py-bcrypt==0.2 (from -r requirements/compiled.txt (line 7))
  Running setup.py egg_info for package py-bcrypt
Downloading/unpacking hashlib==20081119 (from -r requirements/compiled.txt (line 6))
  Running setup.py egg_info for package hashlib
    Using OpenSSL version 0x009080ff from
     Headers: /usr/include
     Library: /usr/lib/libssl.so
    no previously-included directories found matching 'build'
    no previously-included directories found matching 'dist'
    no previously-included directories found matching 'RCS'
    no previously-included directories found matching 'CVS'
    no previously-included directories found matching '.svn'
Downloading/unpacking Jinja2==2.5.5 (from -r requirements/compiled.txt (line 2))
  Running setup.py egg_info for package Jinja2
    warning: no previously-included files matching '*' found under directory 'docs/_build'
    warning: no previously-included files matching '*.pyc' found under directory 'jinja2'
    warning: no previously-included files matching '*.pyc' found under directory 'docs'
    warning: no previously-included files matching '*.pyo' found under directory 'jinja2'
    warning: no previously-included files matching '*.pyo' found under directory 'docs'
Downloading/unpacking MySQL-python==1.2.3c1 (from -r requirements/compiled.txt (line 1))
  Running setup.py egg_info for package MySQL-python
    sh: mysql_config: not found
    Traceback (most recent call last):
      File "", line 14, in 
      File "/home/haoqili/Desktop/MozSecWorld/build/MySQL-python/setup.py", line 15, in 
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 24, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    Complete output from command python setup.py egg_info:
    sh: mysql_config: not found

Traceback (most recent call last):

  File "", line 14, in 

  File "/home/haoqili/Desktop/MozSecWorld/build/MySQL-python/setup.py", line 15, in 

    metadata, options = get_config()

  File "setup_posix.py", line 43, in get_config

    libs = mysql_config("libs_r")

  File "setup_posix.py", line 24, in mysql_config

    raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found

----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /home/haoqili/.pip/pip.log

and then python manage.py runserver still gives "ImportError: No module named bcrypt" error.

so sudo pip install py-bcrypt worked

Sunday, February 13, 2011

Git tutorial -- Getting started with git (hosting and cloning)

I have used git a bit in classes and for github projects created by others. But today I'm taking the initiative to learn it from scratch. My friend Phil set up a Ubuntu virtual machine for me on his server, where I plan to do a very small web project with dcluo. Git was not installed.

Creating a git repository on a directory for a project:

0. My directory where I want to make into a git repository is /var/www/game1. There is currently only 1 file inside it: index.html

1.* Install git from Ubuntu terminal: sudo apt-get install git-core git-doc
* See note below *

2. Create git repository: git init
Initialized empty Git repository in /var/www/game1/.git/

3. Check it's working: git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# index.html
nothing added to commit but untracked files present (use "git add" to track)

4. git config --global user.name "Your Name"
5. git config --global user.email youremail@email.com

6. git add index.html and add other files similarly

7. git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: index.html
#

8. git commit -a -m "brand new start" the "-a" adds all the changed files (yes, it's redundant here because I have added my only file in step 6, but it's good to know)
[master (root-commit) d38fbfd] brand new start
1 files changed, 22 insertions(+), 0 deletions(-)
create mode 100644 index.html

9. git status
# On branch master
nothing to commit (working directory clean)

10. git log note it doesn't say "commit #1", it's good because ordering by numbers would be confusing if you merge or revert commits in the future
commit d38fbfd10003a28859d5b943b729084bfcf6b78d
Author: HaoQi Li <youremail@email.com>
Date: Sun Feb 13 06:14:54 2011 -0500

brand new start

Getting that git repository directory on another machine:

11. On another machine, make a directory where you want to clone the repository. mkdir anotherDir

12. cd anotherDir

13. git clone haoqi@haoqi_s.host.com:/var/www/game1 . don't forget the dot at the end! It means copying to the the current directory.
Initialized empty Git repository in /path/to/anotherDir/.git/
The authenticity of host 'haoqi_s.host.com (209.143.128.58)' can't be established.
RSA key fingerprint is 58:9c:96:f9:7c:39:3c:78:07:8c:40:59:a5:4b:34:9b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'haoqi_s.host.com,209.143.128.58' (RSA) to the list of known hosts.
haoqi@haoqi_s.host.com's password:
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.

If instead you get this error below, check that you're in a place where you can do git. In my case, I did "ssh scripts.mit.edu" right before running the git clone, but git doesn't work inside MIT scripts.
Cloning into ....
The authenticity of host 'haoqi_s.host.com (209.143.128.58)' can't be established.
RSA key fingerprint is 58:9c:96:f9:7c:39:3c:78:07:8c:40:59:a5:4b:34:9b.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/current/machines/home/dir/.ssh/known_hosts).
Permission denied (publickey,password).
fatal: The remote end hung up unexpectedly

14. git log
commit d38fbfd10003a28859d5b943b729084bfcf6b78d
Author: HaoQi Li
Date: Sun Feb 13 06:14:54 2011 -0500

brand new start

Yay success!

==========
Edit 3/10:
Github has new tutorials that will help you get started.
1. Set up git in Linux
2. Create a repository
3. Fork a repository
4. Follow a friend

today I learned

Ubuntu: To switch windows from one desktop to the other (accidental discovery):
- SHIFT+CTRL+ALT+Arrow Right or Left

Linux, from 6.033 hands on 1:
Jotting down notes as I go along ... feel free to point out mistakes
- stat [file_or_dir]
- The difference between symbolic link and hard link (Phil introduced this concept to me 2 years ago, but now I finally get it). I've always used symbolic link and it's the way to go!
- echo $PATH "tells the shell where to look in the file system for programs we type on the command line"
- you can do "setenv OLDPATH $PATH" in "tcsh -f", not in bash shell
- echo $0 or ps -p $$ finds what shell I'm in.

Saturday, January 29, 2011

Set up PCMCIA Sandisk compact flash card adapter import on Ubuntu 10.10

I followed these instructions.
>sudo fdisk -l
Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x41ab2316
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1           9       72261   83  Linux
/dev/sda2   *          10        5487    44002035    7  HPFS/NTFS
/dev/sda3            5488       14594    73145994    f  W95 Ext'd (LBA)
/dev/sda5            5488        5749     2104483+  82  Linux swap / Solaris
/dev/sda6            5750        8360    20972826   83  Linux
/dev/sda7            8361        9588     9857293+  83  Linux
/dev/sda8            9588       14383    38514688   83  Linux
/dev/sda9           14383       14594     1694720   82  Linux swap / Solaris
Disk /dev/sdb: 1024 MB, 1024966656 bytes
32 heads, 63 sectors/track, 993 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1         993     1000912+   6  FAT16
Be sure to note what you see after "/dev", you might have "hde1" instead of "sdb1"
> sudo mkdir /media/cfcard
> sudo mount /dev/sdb1 /media/cfcard
- right click on desktop -> create launcher
- Name: SD mount
- Command: gksu mount /dev/sdb1 /media/cfcard
- Open up Shotwell Photo Manager and you can import the photos.  Or you can go to Computer to see the files.

Friday, January 28, 2011

Setup USB camera import on Ubuntu 10.10

I have a little Kodak Easyshare camera, which I use USB to import photos to my laptop.  It's the first time I tried to import photos since I upgraded from Ubuntu 8.04 to 10.10.

I had a series of problems:


1. Problem: Nothing happened when I plugged in my camera.  In 8.04, F-stop would automatically pop out.
> lsusb
shows that the camera is recognized.
Fix: After some research, I learned that F-stop has been replaced by Shotwell Photo Manager.  Which I installed with:
> sudo add-apt-repository ppa:yorba/ppa
> sudo apt-get update
> sudo apt-get install shotwell
To open Shotwell: Applications -> Graphics -> Shotwell Photo Manager.


2. Now I plug in my camera and something pops up (twice).  But it's an error message:
Unable to mount Kodak EasyShare ... Digital Camera
Error initializing camera: -60: Could not lock the device
Fix: Apparently there is some issue with the camera not wanting to release pictures freely.  So I got gPhoto to resolve this.
> sudo apt-get install gphoto2


3. Now when I try plugging in the camera: (Somehow I still get a duplicate, whatever)
- Ignore any error messages. 
- Click on the window that opens Shotwell Photo Manager
- Click the option that unmounts the camera, wait for a while.
- Should now see a preview of all the images on your camera.
Wait until it finishes
- Click on "Import All"

Thursday, January 27, 2011

Change prompt color (and others) on Linux terminal

Simple way:

> cd ~/
> vim .bashrc
> /force_color_prompt=yes
> delete the "#" in front of this line to uncomment it
> save (":w" in vim)

Open up a new terminal to see results!

----

The more complicated way lets you customize the prompt, you can google it.

Add date to the prompt:
key is adding the :\t: to the line, where you add ":" to separate it from other parts of the prompt. But then it would not be colored.

To add nice colors, wrap it with
:\[\033[01;33m\]\t\[\033[00m\]:

The \[\033[01;33m\] means it's the beginning of the color "33" is yellow in my case, feel free to pick another color. The \[\033[00m\] means you end this coloration.

In the end, I have this:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\t\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '