Friday, June 15, 2012

$PATH

To export

export PATH=$PATH:/home/velayuts/Desktop
To delete

del=':/home/velayuts/Desktop';export PATH="${PATH//$del}"

Tuesday, November 22, 2011

SSH Trust:SSHv2 to SSHv2

Steps To configure as follows:
FSecure SSH v2 --> FSecure SSH v2Case Study: ssh trust for user kumar from Sun to Moon

1) sun:-->ssh-keygen2 -t dsa
(Key will be generated at user's home - /home/kumar/.ssh2)
2) sun:/home/kumar/.ssh2-->cp id_dsa_1024_sun_a kumar@sun. (This step is done to give some useful name and to avoid confusion.)
3) sun:/home/kumar/.ssh2-->cp id_dsa_1024_sun_a.pub kumar@sun.pub (This step is done to give some useful name and to avoid confusion.)
4) sun:/home/kumar/.ssh2-->echo 'IdKey
kumar@sun' > identification ('Identification' file will be created)
5) Copy kumar@sun.pub to remote host's(moon) /export/home/kumar/.ssh

6) moon#:/home/kumar/.ssh2-->echo 'Key mathamsv@oktstcl1.okla.seagate.com.pub' > authorization
7)Done.Now user 'kumar' can ssh without password from Sun to Moon.

Wednesday, October 12, 2011

To Capture/Record Unix command

There is way to record/capture what ever commands executed in Unix. You can use 'script' command where all the command dumped to a file that we specify and this process executed at the background. This is very useful when we do some software installation and we are able to capture all the steps and commands that we used.

#script ApacheInstallationSteps.txt
Script started, file is ApacheInstallationSteps.txt
#
#exit
Script done, file is ApacheInstallationSteps.txt
#

Friday, October 7, 2011

Linux:Steps to change root password

Steps to change root password:

1)When GRUB is started press any key followed by 'a' to modify the kernel arguments before booting.

2) Add 1 or single at the end of line and press 'b' to boot to the single user mode.

3) Once single user mode started you can run 'passwd' command to set new password for 'root'.

4) Exit or reboot the server once password has been reset.

LSOF command

Usage example:

#lsof -i TCP (Show all open TCP files)

#lsof -i TCP:80 (Show open TCP files on port 80)

#lsof -c passwd (to find out what files opened when execute this command)

#lsof /dev/sda3 ( which files opened for a device)

Friday, January 28, 2011

Add Virtual IP in Linux

Steps to add virtual IP.

1)Copy existing device etho to new virtual device.
#cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:1

2)Edit device and IP address in ifcfg-eth0:1
#vi ifcfg-eth0:1

3)Restart the network service
#service network restart

4)Verify the virtual device is up. You'll see 2 different IP address.I've purposely hide the IP address,Bcast and Netmask. You should get the reply once ping.

# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:50:56:BE:00:3B
inet addr:xx.x.xxx.184 Bcast:xx.x.xxx.xxx Mask:xxx.xxx.xxx.x
inet6 addr: fe80::250:56ff:febe:3b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:36 errors:0 dropped:0 overruns:0 frame:0
TX packets:28 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3751 (3.6 KiB) TX bytes:4480 (4.3 KiB)

eth0:1 Link encap:Ethernet HWaddr 00:50:56:BE:00:3B
inet addr:xx.x.xxx.185 Bcast:10.9.135.255 Mask:255.255.248.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
#ping xx.x.xxx.185
PING xx.x.xxx.185 (xx.x.xxx.185) 56(84) bytes of data.
64 bytes from xx.x.xxx.185: icmp_seq=1 ttl=64 time=0.018 ms
64 bytes from xx.x.xxx.185: icmp_seq=2 ttl=64 time=0.018 ms

Wednesday, January 26, 2011

NOHUP:Running a process and log out

Nohup is a POSIX command to ignore the HUP (hangup) signal, enabling the command to keep running after the user who issues the command has logged out. The HUP (hangup) signal is by convention the way a terminal warns depending processes of logout.

nohup is most often used to run commands in the background as daemons. Output that would normally go to the terminal goes to a file called nohup.out if it has not already been redirected. This command is very helpful when there is a need to run numerous batch jobs which are inter-dependent.

If you redirect the streams you can avoid filling up your filesystem with nohup.out files as follow:


$ nohup tar czf /backup/home.tgz . > /dev/null 2>&1