Linux

From 太極
Jump to navigation Jump to search

Handy Linux tips

Find binary file location

  • whereis
$ whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.gz /usr/share/man/man1/ls.1.gz
  • type -a
$ type -a ls
ls is aliased to `ls --color=tty'
ls is /bin/ls

IP address fundamental

http://www.howtogeek.com/133943/geek-school-learning-windows-7-ip-addressing-fundamentals/

Bash shell programming

http://bash.cyberciti.biz/guide/Main_Page

Redirect standard error

http://bash.cyberciti.biz/guide/Standard_error. Use 2> operator.

command 2> errors.txt

ls | more without lose color

ls --color | more

Most likely your ls is aliased to ls --color=auto. If you do ls --color (which is morally equivalent to ls --color=always), that will force it to turn on colors.

colordiff-color in terminal diff

Need to install first. apt-get install colordiff. http://www.cyberciti.biz/programming/color-terminal-highlighter-for-diff-files/

Listen to pandora in Europe: install squid proxy

http://www.cyberciti.biz/faq/access-pandora-radio-using-proxy-server-outside-usa/

Interestingly, the firefox connection settings should choose HTTP Proxy instead of 'SOCKS host'.

Bypass blocked website from work computer

http://www.panix.com/~ruari/censorship.html

ssh -D 4096 user@remoteip
ssh -D 4096 -p 23 user@remoteip

This will require you to enter the password and leave you in the remote machine. If a nonstandard port is required, we can use -p option.

Now in the firefox, we need to go to Edit -> Preferences -> Advanced -> Network tab -> Settings... Check 'Manual proxy configuration' (The default is 'Use system proxy settings') and enter 'localhost' for SOCKS Host and '4096' for the Port. Don't enter 'localhost' in the HTTP Proxy.

On Windows, we can use Putty. In short, in the left-hand panel, navigate through Connection > SSH > Tunnels. Enter 4096 in the Source Port box and select the Dynamic radio button. Click Add and “D4096″ will appear in the Forwarded Ports list. The setting in the firefox end is the same.

Linux journal also put a video on youtube. We can use http://www.ipligence.com/geolocation to check the current location. The port number is 1080 in the example. The example actually also use '-N' option which means no interaction; i.e. ssh -N -D 1080 user@remoteip. So we won't see anything after we type our password. Once we want to stop SOCK proxy, we just need to hit Ctr+C on terminal.

Graphical way to display disk usage

For example, to use xdiskusage, we run apt-get install xdiskusage and launch it by xdiskusage ~/.

Display directory size with sorting and human readable

du -k ~/ --max-depth=1 --exclude ".*" | sort -nr | cut -f2 | xargs -d '\n' du -sh

The --exclude is to hide hidden directories.

Note that the 'du' commands may be cheating. See the following screenshot.

DiskUsage.png

The discrepancy is explained by 'sector'. See http://askubuntu.com/questions/122091/difference-between-filesize-and-size-on-disk.

$ sudo dumpe2fs /dev/sda1 | grep -i "block size"
dumpe2fs 1.41.14 (22-Dec-2010)
Block size:               4096

To show a file size in terms of blocks, we can use

ls -s

So for example, if a file takes 150 blocks, and if a block takes 4096 bytes, then the file takes 150*4096/1024 KB on disk.

Apache benchmark (ab) testing

ab -n 100 -c 10 http://taichi.selfip.net:81/
ab -n 100 -c 10 http://taichi.selfip.org/

rsync with non-standard port

Use -e option

rsync -avz -e "ssh -p 23" mydir user@remoteip:

rsync with progress bar

Use --progress option.

rsync -avz --progress file1 file2

The 'rsync' command works on transferring files local to local too.

rsync on Windows

Download and install command line rsync from http://www.rsync.net/resources/howto/windows_rsync.html. The website also provides a documentation. Some people are concern about the license issue. The website here provides a link to the free, old but usable version 4.0.5 which is newer than I tested v3.1.0.

Below are my note by using cwrsync v3.1.0 installer got from http://www.rsync.net.

cd C:\Program Files (x86)\cwRsync\bin
ssh-keygen -t rsa -N ''
rsync -av "/cygdrive/c/Users/brb/.ssh/id_rsa.pub" [email protected]:.ssh/authorized_keys

rsync -av "/cygdrive/c/Users/brb/Downloads/cytokineMC.txt" [email protected]:Downloads/

scp with non-standard port

Use -P argument.

ssh -P 23 myfile user@remoteip:

The device is busy

See http://ocaoimh.ie/2008/02/13/how-to-umount-when-the-device-is-busy/

# fuser -m /dev/sdc1
/dev/sdc1: 538
# ps auxw|grep 538
donncha 538 0.4 2.7 219212 56792 ? SLl Feb11 11:25 rhythmbox

Another handy one is:

umount -l /dev/sdwhatever

Kill a process

kill -9 PID

Create an ext3 file system on a USB flash drive

umount /dev/sdb1   (depending on the device of course)
sudo mkfs.ext3 /dev/sdb1
sudo e2label /dev/sdb1 usbdrive   (change the label)

We can create MS-DOS file system by

sudo mkfs.vfat /dev/sdb1

Port forwarding

For example, we like to use source port number 8080, destination port 80 (the http port), and destination server www.ubuntuforums.org.

ssh -L 8080:www.ubuntuforums.org:80 <host>

Where <host> should be replaced by the name of your laptop. The -L option specifies local port forwarding. For the duration of the SSH session, pointing your browser at http://localhost:8080/ would send you to http://www.ubuntuforums.org/.

To stop the ssh session, use ps -ef to find the process id and kill it.

Add a new user with home directory

adduser xxx

adduser is better than useradd since useradd does not create home directory and it does not even ask the password for new user. adduser will interactively ask user information.

To delete the user, use

deluser xxx

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

Show folder size for one level only

du --max-depth=1 -h

Soft link

ln -s /full/path/of/original/file /full/path/of/soft/link/file

Backup

  • Use dropbox folder.

If we don't want to install dropbox software, we can install bash dropbox uploader: http://www.andreafabrizi.it/?dropbox_uploader OR https://github.com/andreafabrizi/Dropbox-Uploader

It allows to upload/download/delete/list files and show info of user. The version I am using is v0.9.7. It works on linux, Windows/Cygwin, Raspberry Pi, etc.

I install it under ~/Downloads/andreafabrizi-Dropbox-Uploader-cdc2466 directory

Instruction with screenshots: http://www.jobnix.in/dropbox-command-line-interface-cli-client/

Sample usages:

./dropbox_uploader.sh  list /
./dropbox_uploader.sh  upload ~/Desktop/ConfigurateNote.txt

Running a cron job as a user

  • crontab cron-file-winter; crontab -l

Make sure the .sh file gives a complete path. For example,

#!/bin/sh
R --vanilla  < arraytoolsip.R

does not work in cron job although it works perfect when we manually run it from the right path. The sh file should be

#!/bin/sh
R --vanilla  < $HOME/Dropbox/scripts/arraytoolsip.R

Running crontab as root

Use sudo crontab -e to edit. After saving it, no need to initialize it. Use sudo crontab -l to list the cron job.

Mount usb drive

Run

fdisk -l

OR

dmesg | grep -i "SCSI"

to confirm the USB device is detected.

Now suppose the usb device is found in dev/sdb1.

mkdir /mnt/usb
mount -t vfat -o rw,users /dev/sdb1 /mnt/usb

The above mount command assumes the usb drive has Windows vfat partition and users give non-root users the ability to unmount the drive. If the USB drive is partitioned linux ext2/3, we can merely run mount command as

mount /dev/sdb1 /mnt/usb

At the end, run umount command like

umount /mnt/usb

To make the mounting automatically, edit the file /etc/fstab.

/dev/sdb1       /mnt/usb           vfat    defaults        0       0 
/dev/sdb1       /mnt/usb           ext3    defaults        0       0

and run

mount -a


run commands in a background and allow log off

nohup /path/to/script >output 2>&1 &

vi keys

  • editmode / insert: "i"
  • editmode / append: "a"
  • leave edit mode: "ESC"
  • save: ":w"
  • quit: ":q"
  • save and quit: ":wq"
  • quit without saving: ":q!"

Some helps

Cloud

http://slidedecks.wilmoore.com/2012-confoo/diy-private-cloud-using-virtualBox-and-chef/#66

http://www.datacentermap.com/blog/cloud-software-389.html

U-boot

http://www.denx.de/wiki/U-Boot

Pandora linux client

http://kevinmehall.net/p/pithos/

COW (copy on write) file system

The cow filesystem was found on xubuntu live CD. See http://en.wikipedia.org/wiki/Copy-on-write

Apache redirection

http://cran.r-project.org/mirror-howto.html

Important linux directories

  • /bin - executables used by the base system
  • /boot
  • /dev
  • /etc - configuration files
  • /media
  • /mnt
  • /opt - optional application packages
  • /proc - process information only
  • /sbin - critical executables for running the system, but should be used by superuser
  • /usr - non-critical files. Inside is /usr/bin, which contains most of the libraries used by apps.
  • /var - variable data such as databases, mails spools and system logs.


DHCP lease time

On Windows, it is 8 days.

Check a file's encoding

file -bi myfile

For example,

mli@PhenomIIx6:~$ file -bi Downloads/hmv_.rc 
text/x-c++; charset=utf-16le
mli@PhenomIIx6:~$ 

System monitor tools

Git and Github (arraytools)

My example of working on a new repository called 'network'.

  1. Follow https://help.github.com/articles/create-a-repo to create a new repository. For convenience, I also check the button to create README file.
  2. Click 'GitHub' icon on Windows Desktop. Look at the LHS and click on the word 'github'. Click 'clone' button (This can be accomplished by git clone https://github.com/arraytools/network.git). The new repository will appear under C:\Users\USERNAME\Documents\Github\ directory. Now Click 'Git Shell' icon on the Windows Desktop and go to C:\Users\USERNAME\Documents\Github\network directory where 'network' is my repository's name.
git init

git add client.c
git add server.c
git add server2.c
git commit -m 'first commit'

git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.

# git remote add origin https://github.com/arraytools/network.git
# git push <remote> <branch>
git push origin master

# If we modify any file, we need to go through git add, git commit and git push 3 commands.

# get commit_id
git log
# get a specific version
git checkout commit_id

# after an examination, we want to get the latest version
git pull origin master
# If you do not want to merge the upstream changes wit your local repository, run git fetch to 
# fetch the changes and then git merge to merge the changes. 
# git pull is just a combination of fetch and merge.

# To rename a file
git mv originafile newfile
git commit -m "rename orginalfile"
git push

# To remove a file
rm myfile
git add . -A
git commit -m "remove a file"
git push

# Compare difference in local and remote repository
git fetch    (the syntax is the same as git pull, but it doesn't automatically merge)
git status
git diff origin/master --name-only     (Show only names of changed files.)

# To force to overwrite local files on pull
git fetch --all
git reset --hard origin/master

Check the https://github.com/arraytools/network. The commit goes to the repository!

In summary: add and commit are local operations, push, pull and fetch are operations that interact with a remote.

If we want to checkout a specific commit on a new computer, we can use (here we use Qt repository as an example)

git clone https://xxxxxx/xxxxxx/Qt.git
cd Qt       
git log --oneline
git checkout SHA1  (7 digits obtained from git log --oneline commandis enough)

After that we can run

# move HEAD to origin
git checkout origin/master

# Visualize using text mode
git log --graph --oneline --date-order --decorate --color --all  

Bitbucket (free for 5 users)

Bitbucket 101

  • Unlimited private repos
  • Code reviews
  • JIRA integration
  • REST API
  • Custom domains

Convert an image file to a different format (eg icon)

Using imagemagic program.

convert winamp-ncrow.png -resize 32x32 winamp-ncrow.ico 

Run a command from previous history

http://www.thegeekstuff.com/2008/08/15-examples-to-master-linux-command-line-history/ For example,

!-1
!4

Listen to HiChannel internet radio

Use Radio Tray

I use it to listen m3u file (VLC also supports it too).

Debian/Ubuntu/Bio-Linux

Debian

Download Debian

Go to http://www.debian.org/distrib/ and download "small installation image", for example debian-7.1.0-amd64-netinst.iso. It is about 222 MB.

Screenshots of step-by-step installation can be found in here.

After installation, you got a desktop environment of Debian based on GNOME 3 (Virtual machine will use recovery mode, but still works. Some people suggest to install the guest additions (in the guest) and make sure that you enable the 3D acceleration in the guest settings.). Also 'free -m' command shows it uses 202 MB memory and the whole system takes up 3.3 GB. I am testing on a Chinese desktop environment.

When Debian is in recovery mode, the desktop interface is like old fashion. Application and Place on top of the screen. When GNOME 3 is working (in my test of Debian 7.1.0, I cannot run VBoxLinux.run, but it still works after I did other steps), the interface is sort of Ubuntu with application launched from the left hand side. It differs from Ubuntu because the side bar appears by clicking a 'preview' button on top left corner.

The default browser in Debian is Iceweasel with AdBlock Plus preinstalled.

I don't know why the default user does not have root privilege.

When I installed the Chinese version, the keyboard switch icon (SCIM) is automatically available. However once the desktop is in regular GNOME 3, the switch icon disappeared. Fortunately, we can use Ctrl + Space to switch languages. Thanks to the hint there.

Server version

There is no a server version of iso to download. At the end of installation, it will ask what software to install: Debian desktop environment, Web server, SSH server, Laptop, SQL database, ... We can uncheck 'Debian desktop environment' item.

Compared to Desktop version, the server version takes 1.3GB space and 33MB memory.

The server version does not have 'sudo' command. Use 'su' to switch to 'root' user.

Note that even we installed 'sudo', we can not use 'sudo' from the default user. It will complain xxx is not in the sudoers file. This incident will be reported..

Browse iso files

http://ftp-nyc.osuosl.org/debian-cdimage/7.1.0/amd64/iso-cd/

Ubuntu/Kubuntu/Lubuntu/Xubuntu

For some reason, when I try the Ubuntu (13.04) live CD, the screen resolution looks perfect. But when I installed the OS, the screen resolution is always too low. The propriety graphics driver cannot be installed successfully. Fortunately, when I try the Kubuntu (13.04), the display resolution problem automatically works!

Update: Kubuntu failed to respond after I install SCIM related programs. A freshly installed linuxmint OS also has a similar problem that the desktop does not respond to mouse or keyboard. Luckily, the Xubuntu works fine and the Chinese input works out of box if I choose Chinese as desktop evvironment (339MB was used).

Samba

sudo apt-get install samba samba-common
sudo apt-get install python-glade2
sudo apt-get install system-config-samba

Use Dash and search for 'samba'. It will ask for the user's password first.

The 'Access' tab in my samba configuration window, I cannot select users. So I choose 'Allow access to everyone'.

A non-gui way to configuration samba is adding the following to the end of /etc/samba/smb.conf file, sudo nano -w /etc/samba/smb.conf

[brb]
        path = /home/brb
;       writeable = no
;       browseable = yes
        guest ok = yes
smb://192.168.1.3/

On Windows PC, go to start and open 'Run' then enter ip with double backslash. Like this (\\192.168.1.3).

Install to USB drive

Change time zone

http://wiki.debian.org/TimeZoneChanges

$sudo dpkg-reconfigure tzdata

The command launches an ncurses based interface which allows arrow keys to be used to select the region specific time zone.

Make script run at boot time with init.d directory

http://www.debian-administration.org/articles/28

For example, see here from running a python script for raspberry pi.

  1. Create a script /etc/init.d/lcd
  2. Make the script executable
  3. Make the script known to the system by using the update-rc.d' command
sudo update-rc.d lcd defaults

wireless connection randomly drop off

My wireless adapter is TP-LINK, TL-WN722N.

http://askubuntu.com/questions/73607/wireless-connection-keeps-dropping-with-an-intel-3945abg-card

sudo iwconfig wlan0 power off

5 Best Linux/Ubuntu compatible USB Wifi cards:

  • AirLink101 AWLL6075 Wireless N Mini USB Adapter
  • Medialink – Wireless N USB Adapter – 802.11n
  • ASUS (USB-N13) Wireless-N USB Adapter
  • Panda Mini Wifi (b/g/n) 150Mbps Card
  • TP-Link TL-WN722N 150Mbps High Gain Wireless USB Adapter

To show (USB) wireless adapter information

sudo lshw -C network
sudo lsusb -v
iwconfig

To check wifi connection information (SSID, channel, address, frequency, qualiyt, signal level, ...)

sudo iwlist wlan0 scan

My experience is quality should be at least 50/70 and signal level should be larger than -60dBm.

Write an image to a flash drive

sudo fdisk -l
sudo dd bs=4M if=xxx.img of=/dev/sdb

where /dev/sdb is a device name, not a partition name. We can also adjust bs to a smaller value like 1M, 4m.

Create an iso file from a CD or HD

Method 1. Make sure the cdrom is NOT mounted. Type mount to confirm it. If cd was mouted automatically unmout it with umount command: like umount /dev/cdrom or umount /mnt/cdrom. Note that no extra forward slash after /dev/cdrom for the command below.

dd if=/dev/cdrom of=~/cdrom_image.iso

Method 2. No need to umount the cdrom.

mkisofs -o /tmp/cd.iso /tmp/directory/

to make an ISO from files on your hard drive.

Have fun with /etc/hosts file

su -c "nano /etc/hosts"

74.125.67.100   DNS_NAME1 DNS_NAME2

Find a file based on file name

$ find . -iname '*.txt'

Find files modified in one day.

$ find . -mtime -1 

Find files modified in one day and contain string 'est'

$ find . -mtime -1 -exec grep --with-filename est {} \;

Find a file by searching contents

grep -r -i "Entering" ~/Downloads/R-3.0.0/

where -r means recursively searching the directory and -i means case insensitive.

Mount iso file

$ sudo mkdir /mnt/iso
$ sudo mount -o loop /tmp/file.iso /mnt/iso
$ sudo umount /mnt/iso

Check ubuntu version from command line

lsb_release -a

keyboard shortcuts

Go to keyboard app to change the settings. Note: Super key is also Windows key.

  • Ctrl + Super + D: To minimize all windows

BioLinux

Bio-Linux 7.0 (2012/11/21) screenshot.

BioLinux.png

Apache configuration

https://help.ubuntu.com/11.10/serverguide/httpd.html

Device manager

By default, ubuntu does not provide any graphical tool like device manager on Windows. A very close one is lshw (hardware lister). A GUI tool based on it is called lshw-gtk and can be installed by sudo apt-get install lshw-gtk in Ubuntu/Debian or yum install lshw in Red Hat/Fedora/CentOS.

$ sudo lshw -short
H/W path        Device      Class       Description
===================================================
                            system      To Be Filled By O.E.M. (To Be Filled By O.E.M.)
/0                          bus         970 Extreme4
/0/4                        processor   AMD Sempron(tm) 145 Processor
/0/4/5                      memory      128KiB L1 cache
/0/4/6                      memory      1MiB L2 cache
/0/10                       memory      8GiB System Memory
/0/10/0                     memory      2GiB DIMM DDR3 Synchronous 667 MHz (1.5 ns)
/0/10/1                     memory      2GiB DIMM DDR3 Synchronous 667 MHz (1.5 ns)
/0/10/2                     memory      2GiB DIMM DDR3 Synchronous 667 MHz (1.5 ns)
/0/10/3                     memory      2GiB DIMM DDR3 Synchronous 667 MHz (1.5 ns)
/0/0                        memory      64KiB BIOS
/0/100                      bridge      RD890 PCI to PCI bridge (external gfx0 port B)
/0/100/2                    bridge      RD890 PCI to PCI bridge (PCI express gpp port B)
/0/100/2/0                  display     RV770 [Radeon HD 4850]
/0/100/2/0.1                multimedia  RV770 HDMI Audio [Radeon HD 4850/4870]
/0/100/9                    bridge      RD890 PCI to PCI bridge (PCI express gpp port H)
/0/100/9/0                  bus         ASM1042 SuperSpeed USB Host Controller
/0/100/a                    bridge      RD890 PCI to PCI bridge (external gfx1 port A)
/0/100/a/0                  bus         ASM1042 SuperSpeed USB Host Controller
/0/100/11                   storage     SB7x0/SB8x0/SB9x0 SATA Controller [IDE mode]
/0/100/12                   bus         SB7x0/SB8x0/SB9x0 USB OHCI0 Controller
/0/100/12.2                 bus         SB7x0/SB8x0/SB9x0 USB EHCI Controller
/0/100/13                   bus         SB7x0/SB8x0/SB9x0 USB OHCI0 Controller
/0/100/13.2                 bus         SB7x0/SB8x0/SB9x0 USB EHCI Controller
/0/100/14                   bus         SBx00 SMBus Controller
/0/100/14.1                 storage     SB7x0/SB8x0/SB9x0 IDE Controller
/0/100/14.2                 multimedia  SBx00 Azalia (Intel HDA)
/0/100/14.3                 bridge      SB7x0/SB8x0/SB9x0 LPC host controller
/0/100/14.4                 bridge      SBx00 PCI to PCI Bridge
/0/100/14.5                 bus         SB7x0/SB8x0/SB9x0 USB OHCI2 Controller
/0/100/15                   bridge      SB700/SB800/SB900 PCI to PCI bridge (PCIE port 0)
/0/100/15.2                 bridge      SB900 PCI to PCI bridge (PCIE port 2)
/0/100/15.2/0               bus         VT6315 Series Firewire Controller
/0/100/15.3                 bridge      SB900 PCI to PCI bridge (PCIE port 3)
/0/100/15.3/0   eth0        network     RTL8111/8168B PCI Express Gigabit Ethernet controller
/0/100/16                   bus         SB7x0/SB8x0/SB9x0 USB OHCI0 Controller
/0/100/16.2                 bus         SB7x0/SB8x0/SB9x0 USB EHCI Controller
/0/101                      bridge      Family 10h Processor HyperTransport Configuration
/0/102                      bridge      Family 10h Processor Address Map
/0/103                      bridge      Family 10h Processor DRAM Controller
/0/104                      bridge      Family 10h Processor Miscellaneous Control
/0/105                      bridge      Family 10h Processor Link Control
/0/1            scsi2       storage     
/0/1/0.0.0      /dev/cdrom  disk        CDDVDW SH-S223Q
/0/2            scsi4       storage     
/0/2/0.0.0      /dev/sda    disk        80GB MAXTOR 4K080H4
/0/2/0.0.0/1    /dev/sda1   volume      66GiB EXT4 volume
/0/2/0.0.0/2    /dev/sda2   volume      8186MiB Extended partition
/0/2/0.0.0/2/5  /dev/sda5   volume      8186MiB Linux swap / Solaris partition
/0/3            scsi6       storage     
/0/3/0.0.0      /dev/sdb    disk        SCSI Disk
/0/3/0.0.1      /dev/sdc    disk        SCSI Disk
/0/3/0.0.2      /dev/sdd    disk        SCSI Disk
/0/3/0.0.3      /dev/sde    disk        SCSI Disk
/1              wlan0       network     Wireless interface

For storage part, ubuntu provides a graphical tool. See "disk utility" on gnome based ubuntu or search for "disk" in launcher.

Set static IP

root@debian:~# cat /etc/network/interfaces
auto lo eth0
iface lo inet loopback
iface eth0 inet dhcp

Now edit the file /etc/network/interfaces

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.3
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
dns-nameservers 192.168.1.1 8.8.8.8

After it, restart network

/etc/init.d/networking restart

OR sudo reboot

Note: It does not work by editing /etc/resolv.conf since this file will be overwritten.

Change IP address from the command line

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

Dyndns

See https://help.ubuntu.com/community/DynamicDNS

nano /etc/ddclient.conf

daemon=600
protocol=dyndns2
use=web, web=checkip.dyndns.com, web-skip='IP Address'
server=members.dyndns.org
login=YOURNAME
password='YOURPASSWORD'
taichi.selfip.net

And run ddclient -daemon=0 -debug -verbose -noquiet to confirm it is working.

Mail

  • check the option of Mail Routing: I have mail server with another name and would like to add MX hostname...
  • In 'MX hostname' entering aspmx.l.google.com
  • In 'Primary' choose 'Yes, use it as my primary mail relay.'

After that, see http://yaui.me/postfix-gmail-smtp-server-relay-ubuntu/ for setup on Ubuntu machine.

no-ip

Similar to Dyndns. It has its own client program. Needs to build it yourself.

Also see the troubleshooting guide.

See http://ducky-pond.com/posts/12 for instruction of setting autostart on Debian system.

See http://www.coulterfamily.org.uk/pages/PCs/Linux/FAQ-LINUX-NO-IP-CLIENT.php for another approach.

Note: If noip2 cannot start automatically or noip2 does not update even it can be seen from ps -ef command, use sudo crontab -e command. For some reason, after I use sudo crontab, noip2 can update IP. So the only problem right now is it cannot update every 30 minutes even sudo noip2 -S says so. The problems may be 1. ps -ef shows the command runs from nobody user 2. sudo noip2 -S says it updates every 30 minutes via /dev/eth0 with NAT enabled.

Update: An alternative is to use ddclient. However, ddclient never updates the IP.

Mail

  • Allow only one MX record for each host for free no-ip account.
  • Click Host/Redirects > Manage Hosts > Modify.

webmin

See http://www.webmin.com/deb.html

wget http://prdownloads.sourceforge.net/webadmin/webmin_1.600_all.deb
dpkg --install webmin_1.600_all.deb

The install will be done automatically to /usr/share/webmin, the administration username set to root and the password to your current root password. You should now be able to login to Webmin at the URL http://localhost:10000/. Or if accessing it remotely, replace localhost with your system's IP address.

Install Virtualbox on ubuntu

http://www.ubuntugeek.com/virtualbox-4-2-14-released-and-ubuntu-installation-instructions-included.html

Virtual box guest addition

Install guest addition for virtualbox on Debian See the link [1]

virtual machine software benchmark

virtualbox failed to create the host-only network

Virtualbox (*.deb) was downloaded from virtualbox website. However, when I want to create a host-only network, I have to execute

sudo /etc/init.d/vboxdrv setup
sudo apt-get install dkms build-essential linux-headers-$(uname -r)

This also solves the error "Kernel driver not installed (rc=-1908)".

Clone vs Import/Export appliance

Clone will create a new VM directory (including *.vdi) on the same machine.

Import/Export appliance (*.ova) allows to transport the appliance to a new machine. The appliance will not be touched on the new machine.

vmware

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

Emulation vs virtualization

Virtualization allows users to configure virtual machines outfitted with similar hardware and processors as the host system, whereas emulation simulates different hardware and processor configurations in software.

Emulators are what allow you to run old Commodore 64 or NES games on a PC, for example.

Remote desktop

Remote desktop connection to Windows 7 from xubuntu

sudo apt-get update
sudo apt-get install rdesktop
rdesktop xxx.xxx.x.x -f -u USERNAME -p PASSWORD
rdesktop 192.168.1.4 -g 1280x720 -u USERNAME -p PASSWORD

where -f means full screen.

Remote desktop connection to NCI

ts.nci.nih.gov:1494

DOMAIN: NIH

resolution: 1024 x 768

Use remmina or rdesktop or freerdp (sudo apt-get install freerdp-x11)

rdesktop ts.nci.nih.gov:1494 -d NIH -u XXXXX -g 1024x768

Allow for 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.

Allow for remote desktop connection when vino failed

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.

Remote desktop connection through vmware workstation

We shall be able to remote desktop connect to a Windows guest machine if the guest machine has configured to use bridge connection and a static IP. If there is a problem, it is likely caused by Window's firewall. See the two screenshots. We can just turn off the firewall of home network but keep the firewall on for the public network.

We don't need to use port forward for the remote desktop connection.

ViewActiveNetwork.png Firewall.png

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

Another instruction including how to set up user directories for Apache web server http://wiki.debian.org/LaMp

apt-get install mysql-server mysql-client
mysql_secure_installation
apt-get install apache2 apache2-doc
apt-get install php5 php5-mysql libapache2-mod-php5
apt-get install python libapache2-mod-python

The apache configuration file is in /etc/apache2/apache2.conf.

For PHP, it is also useful to install php for command line.

sudo aptitude install php5-cli

Restarting apache before testing on web browser

/etc/init.d/apache2 restart

Install mediawiki using tar ball

http://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Ubuntu

Install mediawiki using aptitude

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,

For security reason, I remove new account creation and anonymous editing. I also remove edit counters.

Backup and Restore mediawiki

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

Install moinmoin

MYSQL security

Just execute mysql_secure_installation from the command line.

  • You can set a password for root accounts.
  • You can remove root accounts that are accessible from outside the local host.
  • You can remove anonymous-user accounts.
  • You can remove the test database, which by default can be accessed by anonymous users.

See http://www.mysql-optimization.com/mysql-secure-installation-program.html

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

Package maintenance

https://help.ubuntu.com/community/AptGet/Howto#Maintenance_commands

Show package information

apt-cache show <package_name>

List files in a package

dpkg -L <package_name>

List racing games package (kind of search packages by key words)

apt-cache search racing game

List all packages installed in the system

apt-cache pkgnames

List of installed packages

dpkg --get-selections 

List of available (uninstalled) packages

aptitude -F "%p" search "?not(?installed)"

See http://superuser.com/questions/408082/how-do-i-get-a-list-of-available-i-e-uninstalled-packages-in-debian

View logs

  • Apache /var/log/apache2/access.log

Torrent

Popular search sites

  • torrentz
  • thepiratebay
  • isohunt
  • kickass torrents

Torrent client: transmission-cli

Torrent client: rtorrent

Install webmin

apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.600_all.deb
dpkg --install webmin_1.600_all.deb

Webmin.png

File does not exist: /var/www/favicon.ico from /var/log/apache2/error.log

The reason? You have not created a favicon, also known as a website icon, for your website. It’s the icon that displays in the address bar of your web browser when you connect to a website. A web browser will request this icon file from every website.

If you choose to create one. Use a program such as Gimp and create a 16×16 pixel image and save it as a .ico filetype. Then upload that file to the DocumentRoot of your website. You will need one for each VirtualHost. If you don’t have Gimp, there are online resources such as favicon.cc where you can create a .ico file and download it for your own use.

As you know by now, not having a favicon.ico file, won’t stop web browsers from requesting it each time. But you can tell Apache not to log the event as an error message. You will still see the request in the access.log, but at least you will have a cleaner error.log file.

Add the following block of code to each VirtualHost, or at least the ones which don’t have a favicon file.

Redirect 404 /favicon.ico
<Location /favicon.ico>
 ErrorDocument 404 "No favicon"
</Location>

Don’t forget to restart apache after making the change. If you want make a “global” change, which would apply to any and all VirtualHosts, you can create a file in Apache’s conf.d folder with a name such as nofavicon.conf and then add that block of code to the file. That would disable favicon across the board and save you from having to edit each VirtualHost.

Or, you create an empty file with the name “favicon.ico” in the directory root of Apache (for exemple /var/www/).

Show weather on the taskbar

http://www.noobslab.com/2012/10/important-thingstweaks-to-do-after.html

Screencaster

Watch TV

Freetuxtv

Running concrete5 On Nginx (LEMP)

http://www.howtoforge.com/running-concrete5-on-nginx-lemp-on-debian-squeeze-ubuntu-12.10

Download mms stream (suitable if mms is an extension; for example, studioclassroom)

  • Use mimms (will NOT output to speaker at the same time; so is best in terms of performance)
sudo apt-get install mimms
mimms -t 60 mms://example.com/video

where -t option specifies number of minutes. See http://linuxers.org/howto/how-download-mms-streaming-videos-ubuntu The output will have the same extension as the input. But it is not always clear. For example

$ mimms -t 3 mms://bcr.media.hinet.net/RA000073                                                                                                    
mms://bcr.media.hinet.net/RA000073 => RA000073.wmv
1.48 MB / ∞ B (8.79 kB/s, ∞ s remaining)           
Download stopped after user-specified timeout.


  • Use mplayer (will output to speaker at the same time, so suffer from performance, anyway do not get output)
mplayer mms:/link/something.xxx -dumpstream -dumpfile file.xxx

mms:/link/something.xxx - link to the stream you wish to download file.xxx - file to which you wish to download the stream, be careful to write the same extension xxx

Wait for the file to download and that's it. See http://ubuntuhowtos.com/howtos/download_mms_stream

Use VLC to record internet radio (suitable if the stream is continuous)

sudo apt-get install ubuntu-restricted-extras
sudo apt-get install lame  libmp3lame0
sudo apt-get install ffmpeg
sudo apt-get install libavcodec-extra-53 libavdevice-extra-53 libavfilter-extra-2 libavformat-extra-53 libavutil-extra-51 libpostproc-extra-52 libswscale-extra-2

A successful run will have an output like

VLC media player 2.0.3 Twoflower (revision 2.0.2-93-g77aa89e)
[0x2329ca8] dummy interface: using the dummy interface module...
[0x7fac2c007428] mux_dummy mux: Open
[0x7fac2c003598] access_mms access: selecting stream[0x1] audio (39 Kib/s)
[0x7fac2c003598] access_mms access: connection successful
[0x7fac2c003598] access_mms access error: failed to send command
[0x7fac2c005fe8] idummy demux: command `quit'


CVS server

# Original data dir: /home/mli/Downloads/hmv_arc
# CVS dir on server (CVSROOT): /home/mli/cvsrep
# CVS dir on local:  /home/mli/Downloads/localcvs
# Project name: mycvs
# cvs user name: mli

sudo apt-get install cvs

mkdir ~/cvsrep
export CVSROOT=/home/mli/cvsrep
cvs init
sudo groupadd mycvsgrp
sudo useradd -G mycvsgrp mli # Assume mli is a new user
sudo usermod -a -G mycvsgrp mli  # assume mli is an existing user  
groups mli  # view groups a user is in use
sudo chown -R :mycvsgrp /home/mli/cvsrep # change the group ownership of cvsrep directory to mycvsgrp.
cd ~/Downloads/hmv_arc
cvs import -m "initial" mycvs mli START # import files to CVS repository
                                        # the new subfolder mycvs has owner mli.mli

Note 1. It is OK to use the same CVSROOT for multiple modules/projects since each module/project will be saved under a separate subfolder.

Note 2. The cvs version that I have installed in my ubuntu server is 1.12.13.

$ cvs -v

Concurrent Versions System (CVS) 1.12.13-MirDebian-6 (client/server)


Quick test to checkout project to the same machine

cd ~/Downloads
mkdir localcvs
cd localcvs
cvs checkout mycvs

This will create a new subfolder 'mycvs' under ~/Downloads/localcvs.

CVS repository on server has a structure

cvsrep/CVSROOT
cvsrep/mycvs

CVS sandbox on local machine has a structure

mycvs/CVS
mycvs/[files1]
mycvs/[files2]

CVS client (ubuntu)

cvs -d :ext:[email protected]:/home/mli/cvsrep checkout mycvs

OR

export CVSROOT=:ext:[email protected]:/home/mli/cvsrep
cvs checkout mycvs

To add/commit a new file

cvs add mynewfile
cvs commit -m "my log message" mynewfile

cvs update filename

The file's encoding is correct for 'hmv_.rc' file.

brb@ubuntu:~/Downloads$ cvs -d :ext:[email protected]:/home/mli/cvsrep checkout mycvs
brb@ubuntu:~/Downloads$ file -bi mycvs/src/hmvUnicode.rc
text/x-c; charset=utf-16le

CVS client (windows)

I use WinCVS for a demonstration

  • Remote -> checkout module
  • Module name: mycvs
  • CVSROOT:
    • protocol: ssh
    • repository path: /home/mli/cvsrep
    • user name:
    • host name: taichi.selfip.net

If I use TortoiseCVS (1.12.5 from 1/24/2011), I need to choose ext as protocol instead ssh. Still the checked out file 'hmv_.rc' still contains unreadable Chinese characters. The cvsnt is the latest free version (2.5.05). If I want to use WinCVS + cvsnt from TortoiseCVS, the options in the CVSROOT dialog looks weird and cannot create a connection.

For the unicode encoding. If I commit the file at first from ubuntu os, but check out in Windows. The checked out file has right encoding (using Notepad ++, or from VS2010). However, the file does not have right line ending and it shows Chineses character when I open it in either Notepad++ or VS2010.

To see hidden characters in Linux, try either one of the following 2 methods:

  • Open the file in EMACS and do a M-X hexl-mode
  • geany editor.

The solution I have found to overcome accessing unicode (utf-16) file on Windows OS is using Cygwin.

  • Download setup.exe from http://cygwin.com/install.html
  • Root directory = c:\cygwin
  • Local package directory = C:\Users\brb\Downloads
  • Direct connection
  • Download site: ftp://cygwin.mirrors.pair.com (Some mirrors are not updated & contain old version of packages! For example, make sure the cvs version is 1.12.13.)
  • Search: cvs. Click plus sign next to "Devel". Click 'Skip' corresponding to cvs package.
  • Search: ssh. Click plus sign next to "Net". Click 'skip' correspond to openssh package.
  • Click 'Next' button.
  • Click 'Finish' button.
  • Now open 'Cygwin Terminal' icon on Windows Desktop.
export CVSROOT=:ext:[email protected]:/home/mli/cvsrep
cvs checkout mycvs

The 'mycvs' directory should be under C:\cygwin\home\brb (a.k.a. /home/brb in cygwin) directory. We can open 'hmv_.rc' file in Notepad++ to double check if the file looks normal OR use md5sum to check.

Difference between CRLF (Windows), LF (Linux, Mac) and CR

This is a good summary I found: http://stackoverflow.com/questions/1552749/difference-between-cr-lf-lf-and-cr-line-break-types

  • The Carriage Return (CR) character (0x0D, \r) moves the cursor to the beginning of the line without advancing to the next line. This character is used as a new line character in Commodore and Early Macintosh operating systems (OS-9 and earlier).
  • The Line Feed (LF) character (0x0A, \n) moves the cursor down to the next line without returning to the beginning of the line. This character is used as a new line character in UNIX based systems (Linux, Mac OSX, etc)
  • The End of Line (EOL) character (0x0D0A, \r\n) is actually two ASCII characters and is a combination of the CR and LF characters. It moves the cursor both down to the next line and to the beginning of that line. This character is used as a new line character in most other non-Unix operating systems including Microsoft Windows, Symbian OS and others.

Common CVS commands

cvs checkout MODULE
cvs checkout DIR
cvs checkout DIR/SUBDIR
cvs co DIR/SUBDIR/FILENAME
# check out a specific tag and put it in a specified directory. 
# the specified directory name will replace the module name in output.
mkdir localcvs
cvs checkout -r v4_3 -d localcvs MODULE

cvs add myfile.c
cvs add -kb myfile.bin
# If you accidentally add a file, simply skip the commit for that file.

cvs update –dA DIR/SUBDIR 
# -d: Create  any  directories  that  exist in the repository if they're missing from the working directory.
# -A: Reset any sticky tags, dates, or -k options. Needed after you use "cvs update -D" or "cvs update -r".
cvs update –A DIR/SUBDIR/FILENAME    

cvs commit
cvs commit –m "add test suite" DIR/SUBDIR/FILENAME

mkdir ~/original
touch ~/original/newfile
cvs import ~/original VENDORTAG RELEASETAG

mkdir ~/localcvs
cd ~/localcvs
cvs checkout common/too

cvs diff -r1.23 -r1.24 SUBDIR/FILENAME     # Difference between specified versions 1.23 & 1.24.
cvs diff -D "1 hour ago" MODULE
cd LOCALCVS; cvs diff 
cvs checkout -D "1 hour ago" MODULE
cvs checkout -D "2013-02-27 01:30" MODULE

rm file(s); cvs remove file(s); cvs commit -m "Comment text" file(s)
# You must rm the file before issuing the cvs remove command. The remove is not final until the commit has been issued.

# cvs does not let you remove directories. However it does let you ignore any directories that are empty.
cvs co -P Offline
cvs update -PdA
# P: Prune empty directories. d: create new directories. A: Reset sticky tags

cvs history -c -a -D "1 day ago"  -z "-0500"
# find all changes submitted to the repository by anyone in the past day. 
# -z is used to adjust the time zone.

cvs history -c -a -D "1 day ago" -f Mu2eG4/src
# find all changes submitted to Mu2eG4/src (or any other subdirectory) by anyone in the past day

cvs history -c -u USER "1 day ago" -f Mu2eG4/src 
# find all changes submitted by USER to Mu2eG4/src in the past day

cvs log FILENAME

Bypass SSH password login (convenient for CVS, git etc)

http://www.howtogeek.com/tips/bypass-ssh-logins-by-adding-your-key-to-a-remote-server-in-a-single-command/

  1. ssh-keygen -t rsa
  2. (make sure the remote server has .ssh directory)
  3. cat ~/.ssh/id_rsa.pub | ssh user@hostname 'cat >> .ssh/authorized_keys'
  4. ssh user@hostname

It helps with CVS log in too when the CVS works by using ssh protocol. Note that step 3 allows to run a shell command at a remote machine.

See https://help.github.com/articles/generating-ssh-keys also for similar instruction when work on github.

The ssh key can be copied to another a machine (pay attention to mode). Or let the new machine to create its own key pair and use ssh-copy-id to append the identity file to remote machine's ~/.ssh/authorized_keys file. See http://superuser.com/questions/332510/how-to-transfer-my-linux-ssh-keys-to-another-machine.

We can even have multiple ssh key on local machine by using. ssh/config file. See http://www.karan.org/blog/index.php/2009/08/25/multiple-ssh-private-keys.

Install Ubuntu to a USB flash drive

The following approach assumes the boot loader will not be put on internal hard disk if you are careful enough. See also http://fernhilllinuxproject.com/guidesandhowtos/installubuntutousbdrive.html

  1. Boot from live CD in ubuntu.
  2. Insert the USB flash drive in USB Port.
  3. On desktop double click on icon 'install ubuntu 12.04'
  4. Click on continue and it will ask if you want to unmount the flash drive click on yes
  5. Choose some thing else when ask to where to install ubuntu.
  6. Next you will see your hard disk partitions and flash drive. Click on flash drive partition and then click on change. Change the partition type to ext4 and mount as to '/'. Click on ok to close the dialogue box.
  7. In last you will see a drop down menu on where to install the the boot loader. Initially it will be showing sdc,sdd but on drop down you must select sdc1 or sdd1. Failing this step you may render your computer unbootable.
  8. Then click on install and linux will be installed on your USB Flash drive.

Building a simple Beowulf Like Cluster with Ubuntu

MPICH2

Here is my record for creating a cluster environment based on ubuntu 13.04. The master node is running on ubuntu 13.04 desktop with virtualBox 4.2. The virtualBox has added a host-only adapter (vboxnet0) with ip 192.168.56.1. This adapter will be added to the master node so I can use this ip to identify the master node in the host-only network. Creating cluster using VirtualBox is just for the education purpose, not for real practice.

  1. (virtualBox) Create two virtual machines running on ubuntu 13.04 server. The ssh server was checked during installation. The host name for each of them is ubuntuNode1 and ubuntuNode2 respectively. The network adapter is left by default (NAT) during installation. But after the installation is done, I shutdown the system and add a host-only adapter (vboxnet0) to each of them. Then after the system is up again, I change the IP so it is static. Do sudo nano /etc/network/interfaces and append the following before running sudo /etc/init.d/networking restart to take the change in effect.
auto eth1
iface eth1 inet static
address 192.168.56.101 # use 192.168.56.102 for ubuntuNode2
netmask 255.255.255.0
network 192.168.56.0
broadcast 192.168.56.255

Note that it is better not to add host-only network before installation, or during installation it will ask what is the primary network (confusing). So at the end each new nodes should have both eth0 and eth1 adapters and they should not reside in same subset. ifconfig may not show all adapters so we should use ifconfig -a instead. Although host-only network is used for communication between guest and guest OR guest and host, since each guest node has NAT adapter by default so the guest machine can still access the internet.

  1. (master node) Edit /etc/hosts so it like like
127.0.0.1 localhost
192.168.56.1 ubuntu1304
192.168.56.101 ubuntuNode1
192.168.56.102 ubuntuNode2

Note that the master node will be used to start jobs on the cluster although it is OK to let the master node as one of nodes to execute the jobs.

  1. (all nodes) Run
sudo adduser mpiuser --uid 999

It is recommeneded to use the same password for the user. This will create a new directory /home/mpiuser. This is the home directory for user mpiuser and we will use it to execute jobs on the cluster.

  1. (master node) Run
sudo apt-get install nfs-kernel-server
  1. (other nodes) Run
sudo apt-get install nfs-client
  1. (master node) Add the following to the file /etc/exports
/home/mpiuser *(rw,sync,no_subtree_check)

And then run

sudo service nfs-kernel-server restart
  1. (master node)
sudo ufw allow from 192.168.56.0/24
  1. (other nodes)
sudo mount ubuntu1304:/home/mpiuser /home/mpiuser

And if we want to mount the NFS shared directory when the compute nodes are booted, edit /etc/fstab by adding

ubuntu1304:/home/mpiuser /home/mpiuser nfs
  1. (master node)
sudo apt-get install ssh
su mpiuser
ssh-keygen
ssh-copy-id localhost

We can test if the ssh works without passwords

ssh ubuntuNode1
echo $HOSTNAME
  1. (all nodes)
sudo apt-get install mpich2
which mpirun
which mpiexec
  1. (master node, mpiuser)

Go to the home directory of mpiuser and create a new file hosts. Include host names for computing nodes (it is OK to include master node, ubuntu1304, as one of computing nodes)

ubuntuNode1
ubuntuNode2
<pre>
# (all nodes)
<pre>
sudo apt-get install build-essential
  1. (master node, mpiuser). Creating a test file <mpi_hello.c>
#include <stdio.h>
#include <mpi.h>

int main(int argc, char** argv) {
    int myrank, nprocs;

    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
    MPI_Comm_rank(MPI_COMM_WORLD, &myrank);

    printf("Hello from processor %d of %d\n", myrank, nprocs);

    MPI_Finalize();
    return 0;
}

And compile and run it by

mpicc mpi_hello.c -o mpi_hello
mpiexec -n 3 -f hosts ./mpi_hello

We should see something like

Hello from processor 0 of 2
Hello from processor 1 of 2

Successful! That's it.

OpenMPI

With R

Sharing internet via wifi

I cannot make it to work to share the internet via wifi on my Xubuntu 13.04. However the solution in http://askubuntu.com/questions/287251/creating-an-infrastructure-hotspot-using-ubuntu-12-10 works for me.

$ sudo su -
# add-apt-repository ppa:nilarimogard/webupd8
# aptitude update
# aptitude install ap-hotspot
# ap-hotspot configure
# ap-hotspot start

In the step of 'ap-hotspot configure' it will ask for Access Point name and WPA passphrase.

When I run the final line 'ap-hotspot start', it will ask me to disconnect my current wifi first.

At the end, I found my original configuration in ubuntu does not work even its setting is there. apt-hotspot create an infrastracture AP instead of adhoc.

RHEL/CentOS

Change hostname

  • Change the ^HOSTNAME line in /etc/sysconfig/network
  • Change the hostname in /etc/hosts
  • Run /bin/hostname new_hostname for the hostname change to take effect immediately.
  • Run /sbin/service syslog restart for syslog to log using the new hostname.

Note that using the command line 'hostname' to change the machine's hostname works only for the current session.

sudoer

Some distributions do not come with sudo command.

As root type:

visudo

and add a line

MyUserName ALL = ALL

What is my IP address

ifconfig eth0

What is my DNS server

/etc/resolv.conf

What services get started at boot time

chkconfig --list

Is xxx service running

xxx status 

What services are currently running

ps -e

and

lsof -i 

will show you services that are listening to TCP or UDP endpoints.

What network ports are open

lsof -i

or

netstat -aut

What firewall rules do I in place

iptables -L

What packages do I have installed

rpm -qa | less

or

rpm -qa | grep xxx

What version of package xxx do I have installed

rpm -qi xxx

List of available (uninstalled) packages

yum list available

List All Configured Repositories

yum -v repolist
yum -v repolist | less
yum repolist

To list only enabled repositores

yum repolist enabled

To list only disabled repositories

yum repolist disabled

To list available packages under a repo called ksplice-uptrack, enter:

yum --disablerepo="*" --enablerepo="ksplice-uptrack" list available

yum equivalent of apt-get update

yum check-update

Open a port

Edit the file /etc/sysconfig/optables. Create a new rule by following the examples of other rules in the file.

Power Manager for GNOME

The configuration defaults for GNOME power manager have not installed correctly. Cannot login

This error will results in a log-in problem except root account. The symptom is 50GB in root (/) is used up.

The problem was caused by a bug in yum where /var/cache/yum/x86_64/6Workstation takes about 42GB space. The 'yum' does not remove old generated .sqlite files.

See https://bugzilla.redhat.com/show_bug.cgi?id=632391

I use 'du -k' command to find out which directory took space. I use 'rm' command to delete the contents.

Even I delete the content, the directory still grows up daily.