Showing posts with label LINUX COMMAND. Show all posts
Showing posts with label LINUX COMMAND. Show all posts

Monday, March 19, 2012

Gateway Server Setup


Example: IP range from 192.168.1.0 to 192.168.1.31

Ethernet0 setup:

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

BOOTPROTO=static

BROADCAST=192.168.1.31

IPADDR=192.168.1.1

NETMASK=255.255.255.0

NETWORK=192.168.1.0

ONBOOT=yes

USERCTL=no

PREDNS=192.168.1.25

TYPE=ETHERNET

:wq

Ethernet1 setup:

# vi /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1

BOOTPROTO=static

BROADCAST=172.16.1.15

IPADDR=172.16.1.1

NETMASK=255.255.0.0

NETWORK=172.16.1.0

ONBOOT=yes

USERCTL=no

PREDNS=NONE

GATEWAY= IP [given by ISP]

TYPE=ETHERNET

:wq

# vi /etc/sysctl.conf

net.ipv4.ip_forward=1

:wq

# service network restart

# netstat -rn [v.c]

Proxy Server Setup


# rpm -qa|grep squid

# vi /etc/squid/squid.conf

Search:

/http_port [http_port 3128]

/Cache_mem [Cache_mem 7 MB]

/Cache_dir [Cache nfs /var/spool/squid 100 16 256]

/Cache_access_log [Cache_access_log /var/log/squid/cache.log]

/Client_network [Client_network 255.255.255.0]

/Cache_effictive [Cache_effictive_user squid]

/INSERT

[acl example.com ip_address/ http_access allow example.com/ acl example.com src 192.168.1.0/24/ acl deny example.com]

Foreward lookup zone:

proxy IN CNAME linux204 (hostname of proxy_server) or linux204 IN A 192.168.1.204

Reverse lookup zone:

204 IN PTR linux204.example.com.

# squid -z [v.c]

# service squid restart [v.c]

[*In web server RLF ip is ip of DNS]

DHCP Server Setup


# rpm -qa|grep dhcp

# vi /var/named/example.com

Line 12 . dhcp IN CNAME linux205

:wq

# service named restart

# rndc reload

# cp /usr/share/doc/dhcp3.0p11/dhcpd.conf.sample /etc/dhcp.conf

# vi /etc/dhcp.conf [configuration file]

# service dhcpd restart

Mail Server Setup


# rpm -qa|grep sendmail

# rpm -qa|grep xinetd

# vi /var/named/example.com

Line 12. ID IN MX 10 mail.example.com.

14 . Mail In CNAME linux205

:wq

# service named restart

# rndc reload

# vi /etc/mail/sendmail.mc

Search:

/DAEMON_OPTION- [block thi line]

/LOCAL_DOMAIN- [ LOCAL_DOMAIN(‘example.com’)dnl ] :wq

# vi /etc/xinetd.d/ipop3

Disable=no

:wq

# make -C /etc/mail

# service sendmail restart

# service xinetd restart

# echo “msg body”|mail -v -s “subject” a1@example.com [to send msg to a1(user name)]

[quit-> to save mail & exit-> to exit without save]

Web/http Server Setup


Forword lookup zone file of DNS :

linux205 IN A IP_address

www IN CNAME linux205

# rpm -qa|grep http [to check package]

# vi /etc/httpd/conf/httpd.conf [configuration file]

Search

/User apache – User apache

Group apache

/ServerName – www.example.com: 80

/ServerAdmin – root@example.com

/DirectoryIndex - index.html index.html.var [hello.html hello.html.var]

/Listen- Listen 80

/DocumentRoot – “/var/www/html”, /MaxClients-150

# service httpd restart

# vi /var/www/html/hello.html

Test Server

Body bgcolor= “FFF245”>

How r u

Wellcome to test

:wq

# chmod 777 /var/www/html

# chown apache.apache /var/www/html/hello.html

# service httpd restart

Secondary DNS Setup



# vi /etc/resolv.conf

nameserver IP of primary DNS

nameserver IP of secondary DNS

:wq

# vi /etc/named.conf

[ Zone “example.com” IN { type slave; file “example.zone”; masters {IP of primary DNS; }; ]

DNS Server Setup

Primary DNS (PDNS) Setup:

# rpm –qa|grep bind [to check package]

# rpm –qa|grep caching [to check package]

# cd /var/named [contains 3 setup files (cd /var/named/chroot/var/named for fedora core) ]

1. localhost.zone [Forword lookup zone, converts domain into IP]

2. named.ca [cash memory]

3. named.local [Backword lookup zone, converts IP into domain ]

Example:

To make a PDNS, domain_name: example.com & IP-192.168.1.205, host_name: linux205

# cd /var/named

# cp localhost.zone example.com

# cp named.local 192.168.1.205

# vi example.com

Line 2: ORIGIN example.com

3: linux205.example.com. root.example.com.

10: linux205.example.com

11: 192.168.1.205

12: linux205 IN A 192.168.1.205

# vi 192.168.1.205

Line 2: @ linux205.example.com root.example.com.

8: linux205.example.com.

9: IN A 192.168.1.205

10: 205 IN PTR linux205.example.com.

# vi /etc/named.conf [at first copy the portion localhost.zone & named.local then make change to this]

# vi /etc/resolv.conf [to setup domain IP]

Line 1: nameserver 192.168.1.205

2: search example.com

# service named restart

# rndc reload

Verify Command:

# dig -x 192.168.1.205

# host example.com

FTP Server Setup


# ntsysv [ ftp config. File, select the option ‘vsftpd’]

# service vsftpd restart

# ftp server_IP [to access server , then enter name & password]

ftp> pwd

ftp> cd cse

ftp> ls -la

ftp> lcd [to enter as root]

ftp> lcd /backup [a folder of client pc contains files]

ftp> ! ls -la

ftp> mget a* [ to get file started with character a]

ftp> mput a* [ to send file to server started with character a]

ftp> mdel a* [ to delete file from server started with character a]

SAMBA Server Setup


Example:

Cse-> user name

# touch /etc/samba/smbpasswd

# smbpasswd -a cse [to encrypt the password]

# vi /etc/samba/smb.conf [SAMBA configuration file]

Important change of config file:

1. Workgooup [samba]

2. Server String [server name shown to client side, i.e samba server]

3. [myshare] [make a folder as /share ]

4. [public] [path=/, to share all folder]

5. [fredsdir] [make a folder /cse & share the folder]

# service smb restart

*In windows change workgroup from MyComputer-> Properties-> Computer Name-> Change -> Workgroup(samba).

NFS Server Setup



At first have to check 4 settings:

1. Packages

2. IP address

3. Host name

4. Host file [#vi /etc/hosts ]

# rpm -qa|grap nfs [to check the package]

Example:

Server side

# cd /

# mkdir arif

# cd arif

# vi hello

--------

:wq

# vi /etc/exports

/arif *(ro) [*ro ->read only, *rw-> read write , *- for all host, replace * by host_name for limited share i.e /arif linux102 linux103(ro) then only 2 user can share the file]

:wq

# service nfs restart

Client side

# showmount -e linux101 :/arif /mnt

# cd /mnt

# ls

Printer Setup


# printconf [printer setup file]

# lpq [printer queue]

# lpr file_name [to print a file]

# lprm job.no [to delete a print job]

# vi /etc/modules.rpm [to change LAN setup for network printer]

# cd /etc/sysconfig/networking/profiles/default

To Send Message & Mail


# ssh host_name@IP address [for remote access]

Ex: ssh linux @192.168.1.100

# write host_name [to write message to another user in the network]

# masg n [to disable message service]

# masg y [to enable message service]

# wall [to send message to all user]

[ctrl+d-> to save msg, ctrl+c-> to exit msg]

# mail hostname [to send mail]

# mail [to show the mail]

To change IP address & hostname


# ifconfig [to show ip address]

# ifconfig eth0 ip_address [to change ip temporarily]

# vi /etc/sysconfig/network-scripts/ifcfg-eth0 [ LAN ip address]

# ping ip_address [to test connectivity]

# netconfig [to change ip permanently]

# service network restart

# ifconfig eth0:1 Ip_address [to set 2 Ip on same nic]

# PS1=’\h/\u/\w/\!/\$/\#’ or ‘Red Hat >’ [to change mode]

# hostname arif [to change hostname temporarily]

# vi /etc/sysconfig/network [to change hostname permanently]

# vi /etc/hosts [contains information about server & clients]

CD /HDD Mount & Installing Package



# mkdir /mnt/test

# mount /dev/cdrom /mnt/test [to mount cdrom with the test directory]

# cd /mnt/test

# ls

[ # vi /etc/fstab then write /dev/cdrom /mnt/test iso9660 (for automount) ]

# mount /dev/sda1 [USB]

# mount /dev/fdo [floppy]

# mke2fs -j /dev/hda5 [to format D drive]

# mount /dev/hda5 [ to mount with D drive]

# rpm -ivh package_name [to install package]

# rpm -uvh package_name [to update package]

# rpm -e package_name [to uninstall package]

*RPM-> Redhat Package management.

# date [to show date]

# date monthdayhourminuteyear [to set date]

# at 9:30 [to schudule a task]

[# cp -r /root/a1 /home/a1 (this is a schedule)]

# vi f1

* * * * * command

minute hour day of month month of year day of week

00 10 * * * reboot

*To reboot the system at 10 am everyday.

CD Writting


# mkdir /home/cdr [make a folder name ‘cdr’]

# cd /home/cdr

# touch f1 f2 f3

# cd

# mkisofs -o backup.iso /home/cdr [ to convert 3 files into iso & make a file backup.iso]

# cdrecord -scanbus [ to show cdrom no such as 0,1,0 or 0,3,0]

# cdrecord -v -eject speed=4 dev= 0,1,0 backup.iso [to write into CD]

# cdrecord dev=0,1,0 blank=fast [to blank a rewritable CD]

*CDROM file standard “iso9660”.

Search

# find . –type f or d -name file_name

a. ._ to search in present directory

b. / -> to search in all directory

c. f-> file

d. d-> folder

# find . –type d -name file_name -exec rm -rf {} \ ; [to find and delete at a time, replace -exec by –ok to show message before delete]

# hdparm -tt /dev/hda [to show hdd speed]

# badblocks -s /dev/had [to find bad sector]

# bc [calculator, to exit write ‘quit’]

# bc

for (i=1; i<=5; i++)

# expr 10 + 50 [for direct calculation]

# man command_name [to show manual page, such as # man ls (to show ’ ls ‘ manual)]

# cal month year [to show calander]

Ex: # cal 5 2008

# aspell check file_name [to check spelling]

Binary System:

a)

1 -> active , 0 -> inactive

b) 4 -> r (read)

c) 2 -> w (write)

d) 1 -> x (execute)

Binary

Decimal

Permission

0

0

0

0

no permision

0

0

1

1

0 + 0 +execute

0

1

0

2

0 + write + 0

0

1

1

3

0 + write+execute

1

0

0

4

read + 0 + 0

1

0

1

5

read + 0 +execute

1

1

0

6

read + write

1

1

1

7

read + write+execute

# chmod 777 file_name [to give all permission to everyone ]

# chmod 000 file_name [to give no permission to anyone ]

# chgrp group_name file_name [ to add a file under a group]

Example:

Group name-> iiuc , User name-> cse & eee , File name-> test

user+cse-> all access and

eee and others -> only read

Process:

# groupadd iiuc

# useradd cse

# passwd cse [type and retype the password]

# useradd eee

# passwd eee [type and retype the password]

# usermod -G iiuc cse

# vi /home/test

# chgrp iiuc /home/test

# chmod 774 /home/test