Wednesday, November 26, 2008

IP Networking Control Files

Different linux distribution vendors put their networking configuration files in different places in the filesystem. Here is a brief summary of the locations of the IP networking configuration information under a few common linux distributions along with links to further documentation.

Location of networking configuration files

The format of the networking configuration files differs significantly from distribution to distribution, yet the tools used by these scripts are the same. This documentation will focus on these tools and how they instruct the kernel to alter interface and route information. Consult the distribution's documentation for questions of file format and order of operation.

Ref: http://linux-ip.net/html/basic-control-files.html

Tuesday, November 25, 2008

Command Hacks


man 4 console_codes


mount -t ntfs-3g /dev/sda6 /mnt/ -o force

Set the file system to particular partition
$mkfs.ext2 /dev/hda8
$mkfs.ext3 /dev/hda8
$tune2fs -j /dev/hda8 ---> ext2 to ext3
$blkid ----> you can use it to check the filetype of block device

How to create a partition from command line
$fdisk /dev/hda
>command(m for help): n
n for add new partition
>commandaction
>e extended
>p primary partition (1-4)
:p
>partition number(1-4):3
we are creating hda3
>First Cylender(1341-2438, default 1341):
to chose default just press Enter key
>Last cylinder or +size or +sizeM or +sizeK(1341-2438, default 2438): +56B
size is 56B
>p
> t
change a partition`s system id
>partition no(1-4):3
>Hexcode(type L to list codes): L
shows list
>hexcode(type L to list codes): 83



How to set IP address, Subnet mask , and gateway


The ip address can be assigned using ifconfig command
ifconfig "interface type" "ip address" "subnet mask" "broadcast address"
Ex:
ifconfig hme0 10.192.10.18 netmask 255.255.255.0 broadcast 10.192.10.255
ifconfig hme0 up

and the default gateway can be assigned in the /etc/defaultrouter file:

vi defaultrouter
10.192.10.1
:wq!

2) reset bootprom " " (just confirm using boot ? at OK prompt and to
come toOK prompt do init0)

Ref: http://unix.ittoolbox.com/groups/technical-functional/solaris-l/how-to-set-ip-address-subnet-mask-and-gateway-464377


Passwordless ssh login

1) Suppose you are login on 192.168.1.109
Type the following command to generate key
$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa): /root/.ssh/id_dsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
9f:7c:6c:a4:98:a7:25:03:cd:3c:4d:57:0e:c8:db:47 root@localhost.localdomain

2) Now copy this key to any computer.
$ssh-copy-id -i /root/.ssh/id_dsa root@192.168.1.31
root@192.168.1.31's password:
Now try logging into the machine, with "ssh 'root@192.168.1.31'", and check in:

.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

Ref: http://www.linuxjournal.com/video/ssh-logins-without-passwords

Displays information about ELF files.

$readelf --segments /bin/ls
$readelf --segments /lib/libc.so.6
$readelf -a /bin/ls
 --------------------------------------------------------------------------------------------------
find command
---------------------------------------------------------------------------------------------------
Sed -----------

Printing File Lines using Address and Patterns
Delete File Lines Using Address and PatternsLinkFind and Replace Text Inside a File Using RegEx
How To Write to a File Using Sed
Append, Insert, Replace, and Count File Lines
How To Execute Multiple Sed Commands
Multi-Line File Operation
Examples for Sed Hold and Pattern Buffer Operations


Ref: www.thegeekstuff.com
---------------------------------------------------------------------------------------------------

Q. How to display a list of all manual pages containing the keyword "date", what command would you type?
Ans:  man -k date or apropos date