Posts

Showing posts with the label Ubuntu

[Level 1] Install R in Ubuntu

Here are the steps to install R on Ubuntu 16.04 $ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 $ sudo add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/' $ sudo apt-get update $ sudo apt-get -y install r-base r-base-core $ sudo -i R ## test R Here are the steps to instal R packages from CRAN $ sudo -i R > install.packages('__package_name__') Wish this helps. regards, Stanley Huang

[ Level 2 ] Create an egg for Python in Ubuntu.

How to create an egg file for Python. First of all, you must have setuptools module. $ sudo apt-get -y install python-setuptools Now, you could try to create an empty egg now. $ mkdir /tmp/demo $ cd /tmp/demo $ cat &ht; ./setup.py <<EOF #!/bin/env python #-*- coding:utf-8 -*- from setuptools import setup setup() EOF $ python setup.py bdist_egg ## bdist_egg is the option for creating egg. $ ls -ALb build dist setup.py UNKNOWN.egg-info You could find, we have three more directories after you execute setup.py build -> dist -> final egg file UNKNOW.egg-info -> egg info Now, we could give setuptools more information about egg. cat > ./setup.py <<EOF #!/bin/env python #-*- coding:utf-8 -*- from setuptools import setup, find_packages setup( name = "my_first_egg", version="0.0.1", packages = find_packages(), zip_safe = False, description = "my first egg.", long_descriptio...

[ Level 3 ] How to build MySQL client tool - mysql

First, you have to download MySQL source and use the following command to build it. $ ./configure --without-server --enable-thread-safe-client --with-client-ldflags=-all-static --prefix=/usr/local/mysql --with-machine-type=powerpc --with-zlib-dir=/usr/local/zlib --without-debug --without-docs --with-big-tables If you don't want to build it, there is a way to get it. (The sample is for Ubuntu only.) $ apt-get install libmysqlclient15-dev Wish this helps. regards, Stanley Huang

[ Level 1 ] A good editor, Sublime.

Here is a power editor called "Sublime", please follow the link to get more information. http://www.sublimetext.com/ Some useful settings: 1. enable vim. In Perferences -> Settings-Default, empty the value of ignored_packages, e.g. "ignored_packages": [], Default ignore the package Vintage, the vim pakcage. 2. default with command mode. Add one line in Perferences -> Settings-User: "vintage_start_in_command_mode": true, The default mode of vintage would be "command mode" 3. tab for 4 spaces. In Perferences -> Settings-Default, modify the value of tab_size with 4, e.g. "tab_size": 4, And also modify the value of translate_tabs_to_spaces with true, e.g. "translate_tabs_to_spaces": true, 4. auto-trim tailing spaces. Add one line in Perferences -> Settings-User: "trim_trailing_white_space_on_save": true, Wish this helps. regards, Stanley Huang

[ Level 3 ] The script for creating virtualbox envrionment (Ubuntu 12.04) with lauch new OS image.

In my company, I need to test it when I build a new image. Therefore I have to setup my testing environment for integration test. I wrote a script to automatically setup the environment from new install Ubuntu. The steps are: 1. Download and setup tftp server. 2. Download and setup dhcp server with netboot option. 3. Install virtualbox. After that you could create a VM then choose netboot. (the first interface must connect to tap0 to get boot server information) #!/bin/bash ######## utilities ######## _getTasks() { indent="$1" cat $0 | grep '()' | grep -v "^_" | grep "^[^ ]" | cut -d'(' -f1 | sed -e "s/^/$indent/" } _showUsage() { indent=" " cat <<EOF Usage: $0 task Ex. $0 `_getTasks | head -1` tasks: ${indent}[ all ] `_getTasks "$indent"` EOF } _die() { echo "$1" exit ${2:-1} } _checkID() { uid=`id | cut -d'(' -f1 | cut -d'=' -f2` [ $uid -ne ...

[ Level 3 ] The script for setup the Ubuntu for Juniper VPN.

There is an paper told us how to setup Ubuntu 12.04 for Juniper VPN. Then I follow the guide and also write a script for installation/setup. The steps as the following: 1. Download ans install ia32-libs to support 32 bit libraries. 2. Download and install x64 JRE, jre-7u21-linux-x64.tar.gz. 3. Create plugin link for firefox/google chromium. 4. Update alternative Java. 5. Download and install i586 JRE, jre-7u21-linux-i586.tar.gz. After that, you could login to your VPN. #!/bin/bash ## url link for 64 bit JRE. jre_x64_source_url=http://javadl.sun.com/webapps/download/AutoDL?BundleId=76853 ## url link for 32 bit JRE jre_i586_source_url=http://javadl.sun.com/webapps/download/AutoDL?BundleId=76851 die() { echo "$1" exit ${2:-1} } checkRootID() { uid=`id | cut -d'(' -f1 | cut -d'=' -f2` [ $uid -ne 0 ] && die "Need root to execute this command, exit!" } checkRootID pek2c() { bDebug && read -p "Press enter key t...

[ Level 1 ] How to remove rc listed in dpkg -l @Ubuntu.

You could use dpkg -P to remove it. e.g. $ dpkg -l virtualbox Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-==================================-======================-======================-========================================================================= ii virtualbox 4.1.18-dfsg-1ubuntu1.1 amd64 x86 virtualization solution - base binaries $ apt-get remove virtualbox ... $ dpkg -l | grep virtual ... rc virtualbox 4.1.18-dfsg-1ubuntu1.1 amd64 x86 virtualization solution - base binaries rc virtualbox-qt 4.1.18-dfsg-1ubuntu1.1 amd64 x86 virtualization solution - Qt based user interface $ pac...

[ Level 2 ] Ubuntu package install script.

I wrote an easy script for install Ubuntu packages. #!/bin/bash # # This script is for install popular packages # #$: check package, if exists, skip the following prefix #^ #@: apt-get install packages #!: unix command #^@: apt-get install packages, depends on previous #$ #^!: unix command, depends on previous #$ # showUsage() { cat <<EOF Usage: $0 $0 [package name] Ex. $0 $0 rdesktop EOF } isPackageNotInstall() { dpkg -l $1 >/dev/null 2>&1 if [ $? -eq 0 ] then echo "Package '$1' exists, skip it!" return 1 else return 0 fi } getContent() { declare -i begin declare -i end declare -i size begin=$1 end=$2 size=$end-$begin+1 tail -n +$begin $0 | head -$size } getPackageName() { echo $1 | cut -d' ' -f2- | cut -d'#' -f1 } getCommand() { echo "$line" | cut -d' ' -f2- | cut -d'#' -f1 } die() { echo $1 exit 1 } aptGetInstall() { echo -n "Start instal...

[ Level 2 ] Recovery disk partition utility in for Ubuntu.

There is a tool for Ubuntu could help you to recover disk partition, called "testdisk'. $ sudo apt-get -y install testdisk $ sudo testdisk and choose: Create -> [select disk] -> Intel -> Analyse -> Quick Search -> Write And done~ Wish this helps. regards, Stanley Huang

[ Level 2 ] Enable USB 3.0 in Ubuntu 12.04

After I upgrade 12.04, the USB 3.0 port seems not work. Then I google the solution: add "blacklist uas" in the file /etc/modprobe.d/blacklist.conf Wish this helps. regards, Stanley Huang

[ Level 1 ] Install Indicator-VirtualBox in Ubuntu

You could install indicator-virtualbox to launch virtualbox guest OS. https://launchpad.net/indicator-virtualbox/ http://indicator-virtualbox.en.uptodown.com/ubuntu Wish this helps. regards, Stanley Huang

[Level 2] Allow remote display in Ubuntu 12.04/10.04

If you want to allow remote display in Ubuntu 12.04, you have do the following steps: 1. remove "-nolisten tcp" from /etc/X11/xinit/xserverrc #[before] $ cat /etc/X11/xinit/xserverrc exec /usr/bin/X -nolisten tcp "$@" #[after] $ cat /etc/X11/xinit/xserverrc exec /usr/bin/X "$@" 2. add "xserver-allow-tcp=true" into /etc/lightdm/lightdm.conf #[before] [SeatDefaults] user-session=ubuntu greeter-session=unity-greeter #[after] [SeatDefaults] user-session=ubuntu greeter-session=unity-greeter xserver-allow-tcp=true 3. restart X 4. allow remote x connection local> xhost + 5. ssh remote server and set DISPLAY local> ssh remote_server remote> export DISPLAY=local_ip:0.0 remote> xclock in 10.04, you have to change above step 2 as the following: 2-10.04: add "DisallowTCP=false" in "security" section. #[before] $ cat /etc/gdm/custom.conf [daemon] TimedLoginEnable=false AutomaticLoginEnable=true TimedLogin=stanley Aut...

[ Level 1 ] Ubuntu tools for Mac OS.

Here are some useful tools for Mac OS. $ apt-cache search hfs hfsplus - Tools to access HFS+ formatted volumes hfsutils - Tools for reading and writing Macintosh volumes libhfsp-dev - Library to access HFS+ formatted volumes libhfsp0 - Shared library to access HFS+ formatted volumes squashfs-tools - Tool to create and append to squashfs filesystems squashfs-tools-dbg - Tool to create and append to squashfs filesystems (debug) dmg2img - Tool for converting compress dmg files to hfsplus images hfsprogs - mkfs and fsck for HFS and HFS+ file systems hfsutils-tcltk - Tcl/Tk interfaces for reading and writing Macintosh volumes libhfstdc++6-4.6-dbg-armel-cross - GNU Standard C++ Library v3 (debugging files) libhfstdc++6-armel-cross - GNU Standard C++ Library v3 (hard float ABI) rdiff-backup-fs - Fuse filesystem for accessing rdiff-backup archives $ sudo apt-get -y install hfsplus hfsutils hfsprogs $ sudo apt-get -y install dmg2img Other packages for hfs: $ apt-cache search s...

[ Level 3 ] Bash script for color ansi.

#!/bin/bash ## Get ansi color code ## Usage: ## getAnsiColorCode (f)orward_ground/(b)ack_ground color_name ## ex. ## getAnsiColorCode f/b black/red/green/yellow/blue/magenta/cyan(purple)/white/default getAnsiColorCode() { sReturnCode="" fb='f' color='default' if [ $# -eq 1 ] then color="$1" elif [ $# -gt 1 ] then fb="$1" color="$2" fi if [ "$fb" == "b" ] then sReturnCode='4' else sReturnCode='3' fi case $color in black) sReturnCode="${sReturnCode}0" ;; red) sReturnCode="${sReturnCode}1" ;; green) sReturnCode="${sReturnCode}2" ;; yellow) sReturnCode="${sReturnCode}3" ;; blue) sReturnCode="${sReturnCode}4" ;; magenta) sReturnCode="${sReturnCode}5" ;; cyan|purple) sReturnCode="${sReturnCode}6" ;; white) ...

[Level 3] How to setup Juniper VPN in Ubuntu 64 bit environment.

A good sample to demo how to setup Juniper VPN in Ubuntu 64 bit environment. http://wireless.siu.edu/install-ubuntu-64.htm Wish this helps. regards, Stanley Huang

[Level 2] Scan wifi channel in Ubuntu.

#!/bin/bash iwlist wlan0 scanning | grep Channel: | grep -v grep | cut -d: -f2 | sort Wish this helps. regards, Stanley Huang

[Level 1] How to mount exFAT filesystem in Ubuntu 10.04

You could install fuse-exfat to mount exFAT file system. e.g. $ sudo add-apt-repository ppa:relan/exfat $ sudo apt-get update $ sudo apt-get -y install fuse fuse-exfat exfat-utils Wish this helps. regards, Stanley Huang

[ Level One ] Watch mp4 video on Google Chrome on Ubuntu 12.04

When you install Google Chrome on Ubuntu 12.04, you might not watch mp4 video by Chrome, that's because you didn't install mpeg codec. (Ex. The online courses of Coursera) You could install ffmpeg-extra for chromium by apt-get command like below: $ sudo apt-get -y install chromium-codecs-ffmpeg-extra $ Wish this helps. regards, Stanley Huang

[ Level 2 ] Share terminal in Ubuntu

How to share terminal in Ubuntu terminal 1: $ id uid=1000(stanley) ... $ sudo chmod u+s /usr/bin/screen $ sudo chmod 755 /var/run/screen $ screen -S screen-share $ [ctrl + a] :multiuser on $ [ctrl + a] :acladd joseph terminal 2: $ ssh joseph@localhost $ screen -x stanley/screen-share Ref: http://blog.bodhizazen.net/linux/shared-ssh-sessions-update-for-jaunty-ubuntu-904/ http://www.pixelbeat.org/docs/screen/ #!/bin/bash -vx showUsage() { cat <<EOF Usage: $0 [session name] [multi user] Ex. $0 session guest HowTO connect from guest: \$ ssh guest@remote_host \$ guest> screen -x [session holder]/[session name] \$ guest> screen -x stanley/screen-share EOF } main () { if [ $# -lt 2 ] then showUsage exit 1 else pgName="`basename $0 | cut -d. -f1`" session="$1" user="$2" cfFile="/tmp/$pgName.cnf" cat /dev/null > $cfFile echo "multiuser on" >> $cfFile echo ...

[ Level 2 ] Install Redmine on Ubuntu.

If you want to install Redmine on Ubuntu, please follow the following steps. Ref: Redmine Wiki The steps are as the following: 1. Download Redmine by subversion. 1-a. Install subversion by apt-get: # apt-get -y install subversion 1-b. Download Redmine by subversion: # svn co http://redmine.rubyforge.org/svn/branches/2.0-stable redmine-2.0 2. Install gem by apt-get. # apt-get -y install rubygems 3. Install Redmine by bundler. 3-a. Pre-install MySQL5.5, bundler and rmagick # apt-get -y install mysql-server-5.5 # gem install bundler # gem install rmagick 3-b. Setup Redmine by bundler # cd ./redmine-2.0 # bundle install --without development test mysql postgresql sqlite rmagick 4. Create database on MySQL. # mysql mysql> create database redmine character set utf8; mysql> create user 'redmine'@'localhost' identified by 'my_password'; mysql> grant all privileges on redmine.* to 'redmine'@'localhost...