Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Aug 19, 2021

[Linux] provide permissions to file or directory

To provide permissions to file or directory, we can use "chmod" command.

To give all users all permissions to all txt files, 

        chmod  777  *.txt


We can create file or folder with permission setting:

    for a folder,    mkdir  -m777  folder_name  

    for a file,    chmod  -m777  file_name.txt  >>  file_name.txt  


List of numerical shorthand:

0:  (000)  no permission

1:  (001)  execute permission

2:  (010)  write permission

3:  (011)  write and execute permission

4:  (100)  read permission

5:  (101)  read and execute permission

6:  (110)  read and write permission

7:  (111)  read, write and execute permission

e.g., 777 means read, write and execute permission to user, group, and other user


- rw- rw- r--  

the first "-" means file (d for directory, e.g.,  d rw- rw- r--  )

the next three sets of three characters are for user permission, group permission, and other permission, respectively.


[Linux] create a text file using echo command

 To create a text file, we can use "echo" command in terminal.

        echo  "text to be inserted in your text file"  >  your_text_file_name.txt


If you want to add second line (next line),

        echo "text to be inserted in second line"  >>  your_text_file_name.txt


Dec 17, 2015

initial setup for Cygwin on Windows 7 or later systems

After we install Cygwin (https://cygwin.com/install.html), we encounter many problems such as "xxx command not found".
To prevent such awkward situations from happening, we may want to do some initial setups.

1. PATH
We can check the current PATH by typing "echo $PATH" in Cygwin console.
To set up PATH, open "C:\cygwin64\home\username\.bash_profile" in a text editor.
Add any PATH you want to the section "# Set PATH so it includes user's private bin if it exists".
For example,
# Set PATH so it includes user's private bin if it exists
# if [ -d "${HOME}/bin" ] ; then
   PATH="/bin/:/home/myID/src/:${HOME}/bin"
# fi

($HOME denotes "/home/userID/" under the folder where Cygwin has been installed.  e.g., C:/cygwin64/home/myID/)

If we want to add more than one PATH, we use ":" in between directories.


2. Console (terminal) visibility
On Cygwin console, mouse right-click and select "options".
Go to "text" tab and set font to "Lucia console, 11 point".
Go to "window" tab and set size to 120 columns and 40 rows.  Set scrollback lines to 50000.
It will give more powerful environment for working in the console.


Jul 28, 2014

How to change boot order using Grub (Ubuntu linux 14.04)

After installing Ubuntu 14.04, the default boot entry for Grub is set to "Ubuntu" (the first one in example as below).
e.g.,
Ubuntu
Ubuntu (Recovery mode)
Memory test 1
Memory test 2
Windows 7 (loader)

To change the default boot entry to 'Windows 7',
1. Open 'terminal' in Ubuntu
2. Type "sudo gedit /etc/default/grub"
3. Find a line saying 'GRUB_DEFAULT=0'.  All the entries in the GRUB menu are zero-indexed.
    i.e., the very first entry is indexed as '0' and the last one is indexed as 'n-1'.
4. Because 'Windows 7' is listed at 5th position, it has index '4'.
    Edit the line to 'GRUB_DEFAULT=4', and save the file.
5. To apply the changes, type "sudo update-grub" in terminal


May 12, 2011

Building your own supercomputer using Ubuntu and Kerrighed

http://www.stevekellylab.com/resources/cluster


Building your own supercomputer using Ubuntu and Kerrighed:


Introduction:

The following page describes how to build your very own supercomputer using household-type easily available parts and tying them all together using Kerrighed, a Single System Image operating system for clusters. This guide is mainly based on the install guide located at www.kerrighed.org, but includes many extra details!


Hardware Requirements:

There are few hardware requirements when it comes to choosing parts for building your own supercomputer, but there are a few options that will make the install significantly easier. The most important components of your new supercomputer are going to be the motherboards of each individual node and hence before you start you should choose these carefully.
1) Your motherboards must support PXE booting
2) Your motherboards should have VGA ports on the back. You will need to see what you’re doing in order to configure the BIOS, and additional graphics cards means extra costs as well as extra hassle!
3) Your motherboards should have onboard Gigabit Ethernet, if not you will have to buy extra network cards in order to connect them all together.
4) It’s also handy if your motherboards support multicore CPU’s so you can squeeze in more processing power into less space.
In this example, I chose to go for Asus P5B-V motherboards as these support PXE booting, they have onboard VGA and Gigabit Ethernet ports and also support Intel quad core CPU’s.
Once you have selected your motherboards you need to decide on your CPU’s and RAM. In our case we decided to go for 4GB of RAM per motherboard and to buy Intel QX6700 CPU’s. Only one of your computers (the head node) is going to need a hard drive so pick one large enough to hold all the data you’re going to generate. The head node will also need an additional Gigabit Ethernet card (I’ll explain why later) and a DVD drive to install your operating system.
So you’ve got all your parts now you need some standard PC cases to put them in. In this case we chose Gigabyte Triton cases as they are cheap and come pre-loaded with two 12cm fans to keep everything nice and cool on long runs! Last but not least you will need a gigabit Ethernet switch, with as many ports as you have computers in your cluster.
So put it all together and let’s get started!

Installing and setting up your head node:

So you need to choose a Linux distro to be the base operating system for your supercomputer. In this case I chose to use Ubuntu as it is a lightweight and very reliable Linux Distro
Install Ubuntu on your head node. Once installation is complete, set up a root account and log back in as root

Next we need to do some essential house keeping:

Remove the old sh directory and symlink bash to sh
root@server:~$ rm -f /bin/sh
root@server:~$ ln -s /bin/bash /bin/sh
Open the file “/etc/apt/sources.list” and append the following lines:
deb http://ftp.ubuntu.com/ubuntu/ gutsy main universe multiverse restricted
deb-src http://ftp.ubuntu.com/ubuntu/ gutsy main universe multiverse restricted
Open up a terminal and run
root@server:~$ apt-get update
root@server:~$ apt-get install kernel-package libncurses5-dev fakeroot wget bzip2 automake autoconf libtool rsync xmlto dhcp3-server tftpd-hpa initramfs-tools nfsbooted nfs-common nfs-kernel-server debootstrap dpkg autotools-dev syslinux ssh

Configuring the DHCP server:

Modify “/etc/dhcp3/dhcpd.conf” to contain the following lines:
#GRUB magic
option grub-menu code 150 = string;
option dhcp-max-message-size 2048;
use-host-decl-names on;
deny unknown-clients;
deny bootp;
option domain-name “mydomain”;
option domain-name-servers 192.168.0.0;
option ntp-servers ntp.network.net;
subnet 192.168.0.1 netmask 255.255.255.0 {
option routers 192.168.0.1;
option broadcast-address 192.168.0.255;
filename “/pxelinux.0″;
}
group {
option root-path “/NFSROOT”;
host node01 {fixed-address 192.168.0.101; hardware ethernet XX:XX:XX:XX:XX:XX; }
host node02 {fixed-address 192.168.0.102; hardware ethernet XX:XX:XX:XX:XX:XX; }
.
.
.
host nodeXX {fixed-address 192.168.0.1XX; hardware ethernet XX:XX:XX:XX:XX:XX; }
}
Modify “/etc/default/dhcp3-server” to contain reference to the ethernet device which is connected to the nodes of the cluster;
INTERFACES=”eth1″
Modify “/etc/network/interfaces” to contain:
auto lo
iface lo inet dhcp
auto eth1
iface eth1 inet static
address 192.168.0.1
gateway 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 198.162.0.255

Configurinng the TFTPD-HPA server:

Modify “/etc/default/tftpd-hpa” to contain:
#Defaults for tftpd-hpa
RUN_DAEMON=”yes”
OPTIONS=”-l -s /srv/tftp”

Configuring the host list file:

Modify “/etc/hosts” to contain a list of your server and all your nodes:
127.0.0.1 localhost.localdomain localhost
192.168.0.1 server.mydomain server
192.168.0.101 node01.mydomain node01
192.168.0.102 node02.mydomain node02
.
.
.
192.168.0.1XX nodeXX.mydomain nodeXX

Configure the file which specifies which directories your server will be serving:

Modify “/etc/exports” to contain:
/NFSROOT *(rw,async,no_root_squash,no_subtree_check)
/NFSROOT/tmp *(rw,sync,no_root_squash,no_subtree_check)
/NFSROOT/var *(rw,sync,no_root_squash,no_subtree_check)
/NFSROOT/dev *(rw,sync,no_root_squash,no_subtree_check)
/NFSROOT/root *(rw,sync,no_root_squash,no_subtree_check)

Create GRUB directories:

Create the network GRUB directories and copy the pxelinux.0 file to the file-server root by running the following commands:
root@server:~$ mkdir “/srv/tftp/”
root@server:~$ mkdir “/srv/tftp/pxelinux.cfg”
root@server:~$ cp /usr/lib/syslinux/pxelinux.0 /srv/tftp/

Create a boot file for your nodes:

Use your favourite text editor to create a default boot config file for your nodes called “default” and place it in the “/srv/tftp/pxelinux.cfg/” directory you made earlier. The file should contain only the following lines:
LABEL linux
KERNEL vmlinuz-“uname -r”
APPEND root=dev/nfs initrd=initrd.img nfsroot=192.168.0.1:/NFSROOT/ ip=dhcp rw

Make a kernel and ramdisk image for your nodes:

Make a kernel and ramdisk image for your nodes by running the following commands in a terminal:
root@server:~$ mkinitramfs -o /srv/tftp/initrd.img
root@server:~$ cp /boot/vmlinuz* /srv/tftp/

Next we need to do some more essential house keeping:

Symlink a mount nfs command so that nfs is mounted regardless of the network state by typing the following in a terminal:
root@server:~$ ln -s /etc/network/if-up.d/mountnfs /etc/rcS.d/S35mountnfs
Next we need to create a “restart-server” script that we can run whenever we need to reset the server without rebooting. To do this you need to create a file called “restart-server” and put it in “/bin/” the script needs to contain only the following lines:
/etc/init.d/portmap restart
/etc/init.d/dhcp3-server restart
/etc/init.d/tftpd-hpa restart
/etc/init.d/nfs-common restart
/etc/init.d/nfs-kernel-server restart
exportfs -ra

Installing the node operating system:

Create the node operating system directory by typing the following in a terminal:
root@server:~$ mkdir /NFSROOT
Build the node operating system by typing the following in a terminal:
root@server:~$ debootstrap “version” /NFSROOT http://ftp.ubuntu.com/ubuntu/
Copy some essential housekeeping files to the node operating system from the server operating system:
root@server:~$ cp /etc/apt/sources.list /NFSROOT/etc/apt/
root@server:~$ cp /etc hosts /NFSROOT/etc/
root@server:~$ cp -r /usr/lib/locale/* /NFSROOT/usr/lib/locale/
root@server:~$ cp /etc/default/locale /NFSROOT/etc/default/locale

Change root to the node operating system and do some houskeeping

When logged into your server you can change root to the node operating system root at anytime by typing the following into the terminal:
root@server:~$ chroot /NFSROOT
Once you have changed root to the node filesystem you need to set the root password. You can do this by typing “passwd” into a terminal and following the instructions:
root@server:~$ passwd
Like on the server system we need to remove the old sh directory and symlink bash to s by typing the following into a terminal:
root@server:~$ rm -f /bin/sh
root@server:~$ ln -s /bin/bash /bin/sh
Now we need to mount the proc and dev file systems on the node operating system by typing:
root@server:~$ mount -t proc none /proc
root@server:~$ mount -t devpts none /dev/pts

Update and install the necessary node packages:

Next we need to install some essential packages to allow our nodes to boot and run from the server, we do this by typing:
root@server:~$ apt-get update
root@server:~$ apt-get install libncurses5-dev fakeroot wget bzip2 automake autoconf libtool lsb-release xmlto initramfs-tools nsfbooted nfs-common autotools-dev ssh pkg-config patch make dhcpd linux-image-“uname -r”

Configure the FSTAB files for the cluster nodes:

Next we need to set up the fstab file which tells the nodes when they are booting where to find all the important directories. We do this by creating a file called fstab and placing it in “/NFSROOT/etc/” replacing the existing file. The “fstab” file should contain only the following lines:
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
192.168.0.1:/NFSROOT / nfs rw,hard,nolock 0 0
192.168.0.1:/NFSROOT/dev /dev nfs rw,hard,nolock 0 0
192.168.0.1:/NFSROOT/var /var nfs rw,hard,nolock 0 0
192.168.0.1:/NFSROOT/tmp /tmp nfs rw,hard,nolock 0 0
192.168.0.1:/NFSROOT/root /root nfs rw,hard,nolock 0 0
# TMPFS /var/run tempfs defaults 0 0

Configuring node boot parameters:

Next we need to do some boot parameter configuration. Well start by modifying the boot statement in “/NFSROOT/etc/initramfs-tools/initramfs.conf” to read:
BOOT=nfs
Again we need to symlink a mount nfs command so that nfs is mounted regardless of the network state:
root@server:~$ ln -sf /NFSROOT/etc/network/if-up.d/mountnfs          /NFSROOT/etc/rcS.d/S35mountnfs

Your done! congratulations!


Hopefully if youve reached this point then your redy to boot your nodes! First though we need to reboot the server/head node. Once its rebooted log in as root and run the “restart-server” command. Hopefully eveything will come up as OK! if not go back and double check the setting of the DHCP and TFTPD servers above.
root@server:~$ restart-server

Configure your nodes to enable PXE boot:

To do this you will need to consult the mamnual for your motherboard as all motherboards will have different procedures for enabling PXE boot.
Once PXE is enables hook up your ethernet cables and boot up your nodes. If your nodes boot into Linux then congratulate yourself on getting this far as your 99% there. Your now ready to install kerrighed so shut down your nodes again.

Get and install Kerrighed:

Kerrighed is constantly being updated so look here for the current gide for installing kerrighed on your supercomputer

And heres one I made earlier….

This is a cluster I built in 2008. Its running Ubuntu Server and kerrighed and it has only had one reboot since it was first switched on. The reboot was not because of a hardware or software failure but was so I could install a pci SSD drive to mount the client filesystem on to speed up disk access (highly reccommended!!!).
Since this cluster was built it has been used to find the origin-of-life. Understand how genome structure influences gene expression regulation in Trypanosoma brucei and other organisms. For the last year or so it has been mostly thinking about how to make better multiple sequence alignments.

Components:

Motherboards: SuperMicro X7DVL-E (X6)
Hard Disk: Western Digital Caviar (X3 1Tb in raid 1 on head node. No disks in compute nodes) mounted on “/”
RAM: 72Gb (6 x 12Gb. Each node has 6 Kingston 2Gb DDR2 modules)
CPU: intel quad core Xeon E5420 (X12, 48 Cores of low temperature CPU power!)
SSD: RevoDriveX2 (320Gb solid state PCI hard disk) mounted on “/NFSROOT”
Case: Gigabyte Triton (X 6, my favourite PC case, spacious, good airflow, no screws, what more could you ask for!)

Total cost in 2008: £5,100


Apr 30, 2011

How to switch screen among multiple monitors..

When using multiple monitors, a window pops up in an unintended monitor.
In Windows 7, monitors can be switched using "Shift + Windows Key + keyboard cursor".


In Ubuntu linux, we can use a script called "swapmonitor".
http://lab.threeword.com/attachment/cfile3.uf@112260574D997C901FE6EB.bz2
We can make a shortcut for it:
System menu --> dafault --> keyboard shortcut


References:
http://ubuntuforums.org/showthread.php?t=284511
http://lab.threeword.com/36

Dec 18, 2010

create Sudo user (administrator) in Ubuntu Linux

In Linux, we use "sudo" to run a command as administrator  (e.g., sudo  xxx_command).
If you want not to type "sudo" every time, create sudo user or get temporary sudo permission.

(1) create new sudo user 
sudo  useradd  -m  k  -G  admin

in detail,
sudo = run  "useradd" command as administrator 
useradd = command for adding a new user
-m = create home directory for the user
k = account name
-G = set up a group
admin = group name


(2) change current user to sudo user
run  "sudo  gedit  /etc/group"
find something like "admin:x:123:k" where k is current user name
add  ",sj" to change the user to sudo user,  e.g.,  admin:x:123:k,sj


(3) get temporary sudo permission
run  "sudo passwd root"  to set up password for root (skip this if root account already has password)
run  "su -"  or  "su root",  and enter the password
now command prompt changes from $ to # and current account is temporarily sudo user
this sudo permission will be gone when the command terminal/shell is closed.

Delete a folder(directory) including all sub-folders/directories in Linux

To delete a folder(directory) including all sub-folders/directories in Linux, 

rm  -rf  [directory name]


Dec 17, 2010

set PATH in Linux/Unix

To set "/home/k" as PATH,
    export PATH=$PATH:/home/k

To display current PATH,  
    echo $PATH

To set permanent PATH,
(1) vim  $HOME/.profile     or    vi  .bash_profile   (in root directory (account home))
(2) add  "export PATH=$PATH:/home/k"  in the text file
(3) save 


details of  "export PATH=$PATH:/home/k" 
$PATH -  current PATH
: -  divider between PATH


It is possible to set variable as PATH.  For example,
LAMMPSHOME=/usr/global/lammps
PATH=$PATH:$LAMMPSHOME/bin