Tuesday, 2 June 2015

difference between soft and hard link in linux...........???

Hardlink


  • Hardlink is possible within the same filesystem

  • Hardlink pointing to the same inode

  • Hardlink cannot create a link for a directory

  • Hardlink does not break even if you change the name of the original file


Softlink (symlink)


  • Softlink is possible in a different filesystem

  • Softlink have different inode 

  • Softlink can be used to create a link for both directory & file

  • Softlink will break if you change the name of the original file because it resolves the name of the file each time you access it through the softlink.

Inode(Index Node):-

Inode is a data structure (or) it is a file structure on a file system, Each inode stores the attributes of the file system objects.Inode contains the following information about the file:-

  • Inode Number
  • File Change (or) Modify Time
  • Owner (user-id of the file) & (group-id of the file)
  • Size of the File 
  • Device ID (this identifies the device containing the file).
  • Disk Block Location
  • Number of links
  • Status flags

To create Softlink in linux:-

Use the following syntax:-
# ln -s <source-file> <link-file>

[root@lenovo ~]# ln -s /var/ftp/pub/file1.txt /softlink/file1.txt

[root@lenovo ~]# ll -ltrh /softlink/
lrwxrwxrwx. 1 root root 22 Jun  8 10:26 file1.txt -> /var/ftp/pub/file1.txt

To unlink the file in linux:-

Use the following syntax:-
# unlink <linkname>
[root@lenovo ~]# unlink /softlink/file1.txt


To create Hardlink in linux:-

Use the following syntax:-
#ln <source-file> <link-file>

[root@lenovo ~]# ln /var/ftp/pub/file2.txt /linkdir/file2.txt
[root@lenovo ~]# ls -li /var/ftp/pub/file2.txt
1181563 -rw-r--r--. 2 root root 0 Jun  8 10:50 /var/ftp/pub/file2.txt
[root@lenovo ~]# ls -li /linkdir/file2.txt
1181563 -rw-r--r--. 2 root root 0 Jun  8 10:50 /linkdir/file2.txt
[Note:-  see after creating hardlink both the files showing same inode number]

Tuesday, 28 April 2015

rsh configuration in linux

How to configure rsh in linux centos or redhat ..............????


This post shows you how to configure rsh in cluster environment

[root@lenovo ~]# yum install rsh rsh-server -y 

 Edit the configuration file for enabling rsh and rlogin

[root@lenovo ~]#vim /etc/xinetd.d/rsh

 service shell
 {
  socket_type             = stream
  wait                    = no
  user                    = root
  log_on_success          += USERID
  log_on_failure          += USERID
  server                  = /usr/sbin/in.rshd
  disable                 = no
 }
  you have to change only option "disable = no" .

 

[root@lenovo ~]# service xinetd restart 

 .rhosts file must be present in users home directory. This file allows a users to login without a password, Now i am going to create this file under root users home directory.

[root@lenovo ~]# vim ~/.rhosts
 

[root@lenovo ~]# cat ~/.rhosts
localhost
lenovo.example.com
client1.example.com
client2.example.com

 

[root@lenovo ~]# chmod 0600 ~/.rhosts

[root@lenovo ~]# vim /etc/securetty

Edit file /etc/securetty & append these entry

rsh 

rexec 

rlogin 

 

 


 

 


Friday, 17 April 2015

How to create GPT disk label in RHEL or CentOS....???error "sda Must have a GPT disk label"


GPT(GUID Partition Table)
MBR and GPT are two different ways of storing the partitioning information. In RHEL6 the default way of partitioning a harddisk is to use a MS-DOS disk label.This type of partitioning a hard disk is an old method.Unfortunately this way of partitioning does have some problems that is MBR works with disks up to 2TB, But it can't handle disks more than 2TB.

NOTE:- RHEL 6.3 or later the installer will automatically use GPT partitioning for disks larger than 2TB in size.

Have you ever seen this error "sda Must have a GPT disk label" while installing RHEL (or) CentOS

 
Disable UEFI Mode in your machine BIOS setup 

[OR] 

Another way you can use PARTED Utility to resolve this issue:-

parted is a command which is used for disk partitioning and partition resizing program.

First PRESS CTRL+ALT+F2 to go to terminal for running parted utility from GUI

# parted
(parted) print /dev/sda

(parted) select /dev/sda

(parted) mklabel gpt

(parted) yes

(parted) print /dev/sda

(parted) quit

 Finally PRESS CTRL+ALT+F1 for return back to GUI mode.

Monday, 13 April 2015

How to identify 64 bit processor in linux

[root@server Desktop]# grep flags /proc/cpuinfo | grep 'lm'

flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm arat epb xsaveopt pln pts dtherm fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid

[Note:- Check Flag Entry in above output "lm" If you see lm flag then you can able to run 64bit Operating System in your machine]

[root@server Desktop]# uname -m
x86_64

uname is a command used to print system information x86_64 means 64bit operating system, i686,i386 means 32 bit.
[ If your CPU is 64 bit machine then it will support both 32bit & 64bit operating system, But If your machine[CPU] is 32bit it will support only 32bit operating system not 64bit  ]

How to install and configure OpenMPI in linux

Message Passing Interface (MPI)

MPI is mostly used in High Performance Computing.The Message Passing Interface (MPI) is a library specification that allows HPC to pass information between its various nodes and clusters. Also call MPI "is a message-passing application programmer interface, It is a language-independent used to program parallel computers.

Downloading OpenMPI From here


http://www.open-mpi.org/software/ompi/v1.8/

# wget http://www.open-mpi.org/software/ompi/v1.8/downloads/openmpi-1.8.4.tar.gz

# tar -xvzf openmpi-1.8.4.tar.gz

# ./configure --prefix=/opt/openmpi

# make

# make install

Setting Up Environment Variables


# vim .bashrc

export PATH=/opt/openmpi/bin:$PATH

export LD_LIBRARY_PATH=/opt/openmpi/lib:$LD_LIBRARY_PATH 

To view your path type the following command

# echo $PATH

How to run mpi program in parallel computing is mentioned below

[user@lenovo ~]$ mpirun -np 4 -hostfile hostfile ./helloworld.sh



Wednesday, 8 April 2015

How to find processor speed on Linux OS

The File called cpuinfo_max_freq contains the maximum frequency in KHz

[root@lenovo ~]# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
3000000

(OR)

[root@lenovo ~]# cat /proc/cpuinfo
processor    : 0
vendor_id    : GenuineIntel
cpu family    : 6
model        : 23
model name    : Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
stepping    : 6
cpu MHz        : 2000.000
cache size    : 6144 KB
physical id    : 0
siblings    : 2
core id        : 0
cpu cores    : 2
apicid        : 0
initial apicid    : 0
fpu        : yes
fpu_exception    : yes
cpuid level    : 10
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 lahf_lm dts tpr_shadow vnmi flexpriority
bogomips    : 5984.89
clflush size    : 64
cache_alignment    : 64
address sizes    : 36 bits physical, 48 bits virtual
power management:

processor    : 1
vendor_id    : GenuineIntel
cpu family    : 6
model        : 23
model name    : Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
stepping    : 6
cpu MHz        : 3000.000
cache size    : 6144 KB
physical id    : 0
siblings    : 2
core id        : 1
cpu cores    : 2
apicid        : 1
initial apicid    : 1
fpu        : yes
fpu_exception    : yes
cpuid level    : 10
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 lahf_lm dts tpr_shadow vnmi flexpriority
bogomips    : 5984.89
clflush size    : 64
cache_alignment    : 64
address sizes    : 36 bits physical, 48 bits virtual
power management:

(OR)

[root@lenovo ~]# dmesg | grep CPU
SMP: Allowing 2 CPUs, 0 hotplug CPUs
NR_CPUS:4096 nr_cpumask_bits:2 nr_cpu_ids:2 nr_node_ids:1
PERCPU: Embedded 31 pages/cpu @ffff880002200000 s94872 r8192 d23912 u1048576
CPU: Physical Processor ID: 0
CPU: Processor Core ID: 0
mce: CPU supports 6 MCE banks
CPU0: Thermal monitoring handled by SMI
CPU0: Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz stepping 06
CPU1: Thermal monitoring handled by SMI
Brought up 2 CPUs
microcode: CPU0 sig=0x10676, pf=0x1, revision=0x60c
microcode: CPU1 sig=0x10676, pf=0x1, revision=0x60c
microcode: CPU0 updated to revision 0x60f, date = 2010-09-29
microcode: CPU1 updated to revision 0x60f, date = 2010-09-29

Tuesday, 24 March 2015

how to manage iptables in linux


IPTABLES (Packet Filter) :-

Firewall is used to prevent and monitor unauthorized access of a computer network. In simple terms we can call firewall is a network security. Iptables is a rule based firewall this controls the incoming and outgoing network traffic.
[Note:-  iptables applies to IPv4 only, ipt6tables applies to IPV6 ]

3 predefined chains

  •  INPUT - All packets destined for the host computer.
  •  OUTPUT - All packets originating from the host computer.
  •  FORWARD - All packets neither destined nor originating from the host computer, but passing through (routed by) the host computer. This chain is used if you are using your computer as a router.

How to start, stop & restart iptables:-

# /etc/init.d/iptables start
# /etc/init.d/iptables stop
# /etc/init.d/iptables restart
 (OR)
# service iptables start
# service iptables stop
# service iptables restart
  

To start iptables automatically during the system startup use this command:-

#chkconfig iptables on 

To list the iptables rules:-

#iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination        

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination        

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

To list the iptables rules with line numbers:-

#iptables -L --line-numbers
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination        
1    ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh
2    ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ftp
3    ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:telnet

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination        

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination        
1    ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ftp
2    ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh

Flush or Delete all the rules :-

# iptables -F
# service iptables save
[Note:- Be careful! while running this command this will delete all the rules]

To view NAT Rules:-

# iptables -t nat -L -n -v 

 Iptables Port Forwarding :-


# iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
[all incoming traffic on port 80 redirect to port 8080]

To Block a specific ip-address 

#iptables -A INPUT -s 192.168.0.254 -j DROP