Wednesday, June 27, 2012

Install NIS Server on Ubuntu Desktop 10.10


on the NIS Server


apt-get install portmap


restart


update-rc.d portmap defaults 10


apt-get install nis


when asked for domain it is sourav.com for my case


nano /etc/default/nis


NISSERVER=master


NISCLIENT=false


nano /etc/ypserv.securenets


#This line give adjust to anybody.Please adjust
255.255.255.0    192.168.10.0


nano /var/yp/Makefile


ALL =   passwd group hosts




service portmap restart


service nis restart


nano /usr/lib/yp/ypinit -m
out shadow in between passwd and group




/usr/lib/yp/ypinit -m


master nis server is souravubuntu


ctrl + d


and then press y and you are done




useradd -d /home/sougata -m sougata


passwd username


and set the password


c /var/yp


make




on the NIS Client


apt-get install portmap




domain will be sourav.com


nano /etc/hosts


add


192.168.10.10    souravubuntu   souravubuntu.sourav.com


nano /etc/yp.conf


nano /etc/nsswitch.conf


and change the 




passwd: compat
group: compat
shadow: compat


section to


passwd: nis compat
group:  nis compat
shadow: nis compat


to allow users to login graphically in anis environment change the permission of the home folder


chmod 777 /home




Edit /etc/passwd to add a line at the end saying:


+: : : : : :


Edit /etc/group to add a line at the end saying:


+: : :


Edit /etc/shadow to add a line at the end saying:


+: : : : : : : : 




restart and it's done


log in and test using command 


ypcat passwd

Troubleshoot samba(smbd starts but nmbd does not start/unknown instance error)

sudo apt-get remove samba
sudo apt-get remove samba-common-bin
sudo apt-get install samba


source:http://ubuntuforums.org/archive/index.php/t-1663668.html

Saturday, June 23, 2012

Install webmin on Ubuntu 10.10

sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl

Download libmd5-perl and install it by dpkg -i

Download webmin_1.510-2_all.deb and install by dpkg -i

If you got errors while installing webmin, type this command:



sudo apt-get -f install

 Now  restart  webmin

sudo /etc/init.d/webmin  restart 

 To access webmin, open your browser and type :

https://localhost:10000  or https://your-ip:10000

source: http://www.unixmen.com/install-webmin-in-ubuntu-1010-maverick-meerkat/

Install and configure DHCP Server on Ubuntu 10.10 desktop

On the Ubuntu 10.10 machine

apt-get install dhcp3-server

nano /etc/default/dhcp3-server

INTERFACES="eth0"

Alt + F2

gksudo gedit

go to /etc/dhcp3/dhcpd.conf

option domain-name "sourav.com";
option domain-name-servers souravubuntu.sourav.com;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.10.255;
option routers 192.168.10.201;


default-lease-time 600;
max-lease-time 7200;

subnet 192.168.10.0
netmask 255.255.255.0
{
 range 192.168.10.190 192.168.10.195;

}

/etc/init.d/dhcp3-server restart


On the linux Client machine

nano /etc/network/interfaces

auto lo

iface lo inet loopback

save the file

go to terminal

 sudo dhclient

(you will see the full DORA process)



Friday, June 22, 2012

Caching only dns server using Ubuntu Desktop 10.10

Here are the steps.

apt-get remove NetworkManager

nano /etc/network/interfaces

auto eth0
iface eth0 inet static
address   192.168.10.10
netmask   255.255.255.0
network   192.168.10.0
broadcast 192.168.10.255
gateway   192.168.10.201

/etc/init.d/networking restart

apt-get install bind9 dnsutils bind9-doc

nano /etc/bind/named.conf.local

forwarders{
                8.8.8.8;
                4.2.2.2;
                8.8.4.4;
         };

        auth-nxdomain no;    # conform to RFC1035
        listen-on-v6 { any; };
};

nano /etc/bind/named.conf.local

#Forward Lookup Zone
zone "sourav.com" {
type master;
file "/etc/bind/db.sourav.com";

};
#Reverse Lookup Zone

zone "10.168.192.in-addr.arpa"

{
type master;
notify no;
file "/etc/bind/db.192";

};

nano /etc/bind/db.sourav.com

;
; BIND data file for local loopback interface
;
$TTL    604800
@    IN    SOA    souravubuntu.sourav.com. sourav.localhost. (
                  2        ; Serial
             604800        ; Refresh
              86400        ; Retry
            2419200        ; Expire
             604800 )    ; Negative Cache TTL
;
@    IN    NS    souravubuntu.sourav.com.
@    IN    A    127.0.0.1
@    IN    AAAA    ::1
;Below are A Record Addresses

itguru       IN      A        192.168.10.201
souravubuntu IN      A        192.168.10.10
client       IN      A        192.168.10.101

;  


server1      IN      CNAME     souravubuntu.sourav.com.
gw           IN      CNAME     itguru.sourav.com.

   

nano /etc/bind/db.192

;
; BIND reverse data file for local loopback interface
;
$TTL    604800
@    IN    SOA    souravubuntu.sourav.com. sourav.localhost. (
                  1        ; Serial
             604800        ; Refresh
              86400        ; Retry
            2419200        ; Expire
             604800 )    ; Negative Cache TTL
;
@    IN    NS    souravubuntu.sourav.com.
10      IN      PTR     souravubuntu.sourav.com.
201     IN      PTR     itguru.sourav.com.
101      IN      PTR     client.sourav.com.
  
nano /etc/resolv.conf

nameserver 192.168.10.10
domain sourav.com
search sourav.com

nano /etc/hosts


127.0.0.1    souravubuntu   localhost.localdomain    localhost
127.0.1.1    souravubuntu

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

/etc/init.d/bind9 restart

Help:http://mixeduperic.com/ubuntu/seven-easy-steps-to-setting-up-an-interal-dns-server-on-ubuntu.html


Monday, June 11, 2012

Simple apache configuration

nano /etc/httpd/conf/httpd.conf

NameVirtualHost 192.168.240.142
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#

#
# VirtualHost example:

# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
[VirtualHost 192.168.240.142]

    ServerAdmin root@www.sourav.com
    DocumentRoot /var/www/virtual/www.sourav.com/html
    ServerName www.sourav.com
    ErrorLog logs/www.sourav.com-error_log
    CustomLog logs/www.sourav.com-access_log common

[/VirtualHost]

How to disable Auto Login in OpenSuse 12.1




By default in OpenSuse 12.1 you are automatically logged in even if you have a password on your account. To disable this follow the simple steps below.




Start > Applications > System > Administrator Settings (YaST)


Click on Security and Users down the left hand side then click User and Group Management


In the bottom right hand corner click the drop down that says "Expert Options" and then Login Settings another box will then appear where you can untick "Auto Login" then Click OK.

Sunday, June 10, 2012

Install OpenSSH on CentOS 6


OpenSSH Installations under CentOS Linux


To install the server and client type:
# yum -y install openssh-server openssh-clients


Start the service:
# chkconfig sshd on
# service sshd start


Make sure port 22 is opened:
# netstat -tulpn | grep :22

Some useful commands and compression utilities on Debian 5


seq 500 > 500.txt


gzip -c 500.txt > 500.txt.gz 


to read this binary zip format(gz files)


zcat 500.txt.gz


to read the output per page basis


zcat 500.txt.gz | less


gzip -l option give the content and stat of the file


example gzip -l 600.txt.gz


similar utility Bzip2


bzip2 -c 600.txt > 600.txt.bz2 


bunzip2 600.txt.bz2


bunzip2 -f 600.txt.bz2(this will overrite the file 600.txt(if present in the 


current directory))


bzcat filename.bz2 will show us the content


for example


bzcat filename.bz2 > content.txt




using zip utility in debian 5.


zip a.txt.zip a.txt


(first the destination and then the source file name)


zip alltxt.zip *txt will zip all the txt files in the curre


unzip a.txt.zip 


unzip -l a.txt.zip to list the contents of the zip file


zcat will also show the content of the zip file


zcat alltxt.zip


unzip -l will show you file by file and zcat will show the contents of the 


file in the zip archive,but zcat will only show the content of the first file 


in the zip archive


so basically zcat works on both zip and gzip




tar utility make a tar archive of files


tar -cvf alltxt.tar *.txt


will create an archive full of all the txt files in the current directory


tar -xvf alltxt.tar will extract those files


tar -tvf alltxt.tar will show the contentof the tar file


du -ch shows the size acclaimed by the all the files in the current directory


to extract a particular file from the tar archive


tar -xvf alltxttar.tar 20.txt


to extract 2 particular file 


tar -xvf alltxttar.tar 20.txt 100.txt




(20.txt is one of the file the alltxt.tar archive)




creating a tar.gz archive


tar -czvf text.tar.gz *.txt


will create an archive named text.tar.gz containing all the text files


the argument has to be czvf,any other combination such as cvzf or cvfz won't 


work




when extracting the z option should be added like 


tar -xvf text.tar.gz


tar -xzvf text.tar.gz




creating tar.bz2 archive named newtest.tar.bz2 containing 


60.txt,70.txt,180.txt


tar -cjvf newtext.tar.bz2 60* 70* 180*




to extract an tar.bz2 archive 


tar -xvf newtext.tar.bz2


tar -xjvf newtext.tar.bz2


to see the content of an tar.bz2 archive


tar -tvf newtext.tar.bz2



Wednesday, June 6, 2012

Some useful commands in Debian 5/6


head and tail shows the first 10 and the last 10 lines of a file respectively


head -n 1 will show the first line and tail -n 1 will show the last line


STDERR 2>error.txt


ls -l sourav 2>> error.txt


will put the error in the file error txt


we can watch the ongoing errors in a different terminal using the command 


watch tail error.txt


file filename returns the type of the file


for example file * shows every file's type that is presented in the directory


wc -l filename shows the number of lines in a file


wc is for word count


seq 50 will show the sequence from 1 to 50


creating a loop in the terminal to print hello couple of times.




for i in `seq 50`;do echo "Hello"; done


or may be like this


for i in `seq 50`;do echo "Hello - $i"; done


suppose we want to see the number of files in a directory using a loop


for i in `ls -a`;do echo "File - $i"; done | wc -l




or may be see the files one by one using a loop


for i in `ls -a`;do echo "File - $i"; done 


reset to create a new buffer(any command will now run on a new buffer after the command reset)




free to see the info about memory


free -m returns the output in a more readable format


kill a process using top


type top


type k


enter the pid of the process

Sunday, June 3, 2012

Use ! to invoke previous command

The output of the history command will be

1.cd ~

2.pwd


etc etc.


to invoke a previously typed command without typing the full command just type

!2



pwd command will be executed

Use Grep -i for case insensitive search

For example

use

ps -e | grep -i FireFOx

rather than 



ps -e | grep firefox

Friday, June 1, 2012

Stat command to know everything about a file

Simple syntax


stat filename


and it shows you all

Awesome Hindi Linux Tutorials

Check it out

http://www.youtube.com/user/KamranAtWBITT/videos

Just some useful navigating command

echo $PWD shows the current directory


echo $OLDPWD shows the most recently visited directory


cd - takes you to the last directory that you were.

in any directory (.) refers to the current directory and (..) refers to the parent direstory



thus cd . let's you remain in the current directory


cd .. takes you to the parent directory