Linux

From 太極
Revision as of 21:22, 2 November 2012 by Brb (talk | contribs)
Jump to navigation Jump to search

Not-so-obvious Linux commands

Compress a folder without full path name

Suppose we want to compress the folder ~/Documents and its subfolders. We want to include Documents folder name but not /home/brb/Documents name.

tar -czvf tmp.tar.gz -C ~/ Documents
tar -tzvf tmp.tar.gz

Debian

Change IP address

/sbin/ifconfig eth0 192.168.1.17 netmask 255.255.255.0 up
/sbin/ifconfig eth0

Install guest addition for virtualbox

See the link [1]

apt-get update
apt-get install build-essential module-assistant
m-a prepare
cd Downloads
tar xzvf /media/cdrom0/VMwareTools-9.2.0-799703.tar.gz
cd vmware-tools-distrib
./vmware-install.pl
[Accept all default]
shutdown -r now

Remote desktop connection

  1. Go to System -> Preference -> Remote desktop. Allow other uses to view your desktop & uncheck you must confirm each access & require user to enter this password.
  2. Go to System -> Preference -> Monitor. Change monitor resolution to 1280 x 720.

Instal sshd

apt-get update
apt-get install openssh-server

Install LAMP

See the page [2]

apt-get install apache2
a2enmod rewrite
apt-get install mysql-server   [I choose branch name as MYSQL root password]
apt-get install php5 php-pear php5-suhosin
apt-get install php5-mysql
/etc/init.d/apache2 restart

Install mediawiki

And also the link http://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Debian_GNU/Linux

aptitude install mediawiki php5 apache2 mediawiki-extensions libapache2-mod-php5

This will install latex. After the end, we can use Synaptic package manager to see what were installed. Now following the instruction in https://help.ubuntu.com/community/MediaWiki, we remove the '#' from the third line so that it reads 'Alias /mediawiki /var/lib/mediawiki':

sudo nano /etc/mediawiki/apache.conf
sudo /etc/init.d/apache2 restart

Now we can start mediawiki by opening a browser and pointing it to http://localhost/mediawiki.

We need to enter

Site config
  admin username: WikiSysop
  password:

Database config
  Database name: wikidb
  DB username: 
  DB password: 
  Superuser name: root
  Superuser password: [depend on how it was chosen when installing MYSQL]

Press the button of "Installing mediawiki". We will be welcomed to the wiki page. Following the instruction,

Backup and Restore mediawiki

See docs.google.com note. The process involves 3 parts: mediawiki system, mysql and images.

Install moinmoin

Ubuntu

Compiling R

Use the following command to download required components before building any R packages. See also ubuntu package for R

sudo apt-get build-dep r-base

Remote desktop connection

If vino failed, then try teamviewer. It works fine. After launching it, the software automatically creates an ID and password. We can change the password so it is fixed. Then launch the software on the client. Use the partner's ID and password to connect to it.

RHEL

Pogoplug

Install ArchLinux on pogoplug

See the instruction in http://archlinuxarm.org/platforms/armv5/pogoplug-v2-pinkgray for how to install Archlinux on pogoplug (E02). I make a copy below.

killall hbwd
cd /tmp
wget http://jeff.doozan.com/debian/uboot/install_uboot_mtd0.sh
chmod +x install_uboot_mtd0.sh
./install_uboot_mtd0.sh
/sbin/fdisk /dev/sda

At the fdisk prompt, delete old partitions and create a new one:

  • Type o. This will clear out any partitions on the drive.
  • Type p to list partitions. There should be no partitions left.
  • Now type n, then p for primary, 1 for the first partition on the drive, and then press ENTER, accepting default values.
  • Exit by typing w.
wget http://archlinuxarm.org/os/pogoplug/mke2fs
chmod 755 mke2fs
./mke2fs /dev/sda1
mkdir usb
mount /dev/sda1 usb
cd usb
wget http://archlinuxarm.org/os/ArchLinuxARM-armv5te-latest.tar.gz
tar -xzvf ArchLinuxARM-armv5te-*.tar.gz  # This will take a long time
rm ArchLinuxARM-armv5te-*.tar.gz
sync  # Takes a while when using a flash drive. Not in my case however.
cd ..
umount usb
/sbin/reboot

Log back in after your Pogoplug reboots using username root and password root.

Install Debian on pogoplug

See the instruction on http://projects.doozan.com/debian.

  • Find your devices's IP address and connect via SSH:
  • Partition your flash drive with fdisk:
fdisk /dev/sda
# Configure partion 1 as Linux (I'd recommend making this at least 512Mb. The default bare-bones installation uses 280Mb.)
# Configure partion 2 as Linux Swap (I used 256MB.  Adjust according to your anticipated memory usage.)
# Set partition 1 active
  • Download and run the Debian Wheezy installer:
cd /tmp
wget http://projects.doozan.com/debian/kirkwood.debian-wheezy.sh
chmod +x kirkwood.debian-wheezy.sh
export PATH=$PATH:/usr/sbin:/sbin
./kirkwood.debian-wheezy.sh
  • Alternatively, you can choose to install Debian Squeeze with the following commands:
cd /tmp
wget http://projects.doozan.com/debian/dockstar.debian-squeeze.sh
chmod +x dockstar.debian-squeeze.sh
export PATH=$PATH:/usr/sbin:/sbin
./dockstar.debian-squeeze.sh

The script will take some time to download the debian images and extract them to your flash drive. The total install time will vary with the speed of your flash drive and your Internet connection. On my system, it takes about 20 minutes. Once it's finished, you can reboot into your new Debian install.

After your device reboots, it may have a different IP address (it's identifying as 'Debian' to the DHCP server now instead of 'Pogoplug').

The default root password in Debian is 'root'. After you've logged in, you should change the root password and configure /etc/apt/sources.list to point to a Debian mirror near you.

passwd
nano /etc/apt/sources.list