Autologin with getty on linux console
[info]neelesh_gurjar
1. Create autologin.c and put following code in it.

int main()
{
execlp( "login", "login", "-f", "andrew", 0);
}

2. Compile it with following command:

cc autologin.c -o autologin

3. Do following changes in /etc/inittab
Please add "-n -l /usr/sbin/autologin" immidiate after "/sbin/getty"
Your line will be like this:

c1:12345:respawn:/sbin/agetty -n -l /usr/sbin/autologin 38400 tty1 linux


4. Reboot

Creating link with mount --bind
[info]neelesh_gurjar
In linux users home folders are in /home. Many times we need it in /var/www/html but we do not want to change default setting. Then there is a simple workaround for this.

Step 1. : Just create directory home under /var/www/html
Step 2. : mount --bind /home /var/www/html/home
Step 3. : Put above command in init script. For eg. If you are using CentOS then put it in /etc/rc.local

And your link is ready. :)

(no subject)
[info]neelesh_gurjar
Bid on GetAFreelancer projects
 

Compiling Apache, mysql and PHP
[info]neelesh_gurjar
Compiling Apache for fully dynamic web server
1. Download Apache sourcecode from http://apache.org
2. Extract it and enter into the extracted directory
3. ./configure --prefix=/usr/local/apache2 --enable-mods-shared=all

make ; make install
4. Dowload PHP from php.net. Then extract it and enter the extracted directory
5. ./configure --with-apxs2=/usr/local/apache2/bin/apxs
--with-mysql --prefix=/usr/local/apache2/php
--with-config-file-path=/usr/local/apache2/php
--enable-force-cgi-redirect --with-zlib --with-gettext
--with-gdbm --enable-mbstring=all

make ; make install
6. cp -p .php.ini-recomanded /usr/local/apache2/php/php.ini
7. Go to /usr/local/apache2/bin
8. start apache with following cmd
./apachectl start

Setting up Samba PDC for Multiple domains
[info]neelesh_gurjar
We will setup 2 domains mydomain1 & mydomain2 on 1 linux machine with samba.

1. Create 2 samba config files in /etc/samba/
     a. smb.conf_mydomain1
     b. smb.conf_mydomain2

2. Your smb.conf_mydomain1 will look like below:

[global]
        workgroup = mydomain1
        netbios name =server1
        time server = Yes
        domain logons = Yes
        os level = 65
        preferred master = Yes
        domain master = Yes
        encrypt passwords = yes
        smb passwd file = /etc/samba/smbpasswd
        security = user
        mangling method = hash
        add machine script = /usr/sbin/useradd -d /dev/null -g trust -s /bin/false -M %u
        log file = /var/log/samba/log.%m
        log level = 3 passdb:5 auth:10 winbind:2
        logon path = \\%L\profiles\%U
        logon drive = H:
        logon home = \\%L\%U\.profile
        logon script = logon.cmd
        interfaces = 192.168.2.249/24
        bind interfaces only = yes
        lock directory = /var/lib/samba/locks/server1
 
[homes]
        read only = No
        browseable = Yes
        create mask = 0644
        directory mask = 0755
 
 
[netlogon]
        path=/var/lib/samba/netlogon
        guest ok = yes
 
[profiles]
        path=/var/lib/samba/profiles
        browseable = yes
        read only = No
        create mask = 0600
        directory mask = 0700
        root preexec = PROFILE=/var/lib/samba/profiles/%u; if [ ! -e $PROFILE ]; \
then mkdir -pm700 $PROFILE; chown %u:%g $PROFILE;fi

3. Following lines will get change in smb.conf_mydomain2 remaining will be same like above:

workgroup = mydomain2
netbios name =server2
lock directory = /var/lib/samba/locks/server2

4. Then create below directories:
     /var/lib/samba/locks/server1
     /var/lib/samba/locks/server2

5.  Start samba using below commands:
      
      smbd -s /etc/samba/smb.con_mydomain1
      nmbd -s /etc/samba/smb.con_mydomain1
      smbd -s /etc/samba/smb.con_mydomain2
      nmbd -s /etc/samba/smb.con_mydomain2

6. Check smb started or not.
     ps -ef|grep smb

7. Add trust account (for NT machines only)
    groupadd trust
    useradd -g trust -d /dev/null -s /bin/false <machine name>$
    passwd -l <machine name>$
          ====> NOTE: PLEASE DONT FORGET TO GIVE '$' IN ABOVE 2 COMMANDS
    smbpasswd -l <machine name>
If you want to add group of machines. Please download my script from sites.google.com/site/techbirdin/knowledge-base/addmachine.sh

8. Adding administrator account
    smbpasswd -a root
    (GIVE Samba Passwd for root)

9. FOR WIN XP PROF users NOT for WIN98 ot XP HOME

login to that windows machine (machine name) with administrator.
Right click to "My Computer" and click on "Properties"
Click on "Computer Name" Tab
Click on "Change"
Put Domain - "mydomain1" OR "mydomain2"
Click OK
It will ask for Domain admin username & passwd. Give username: root and smbpasswd of root
If everything is good then it will show you "Welcome to mydomain1 or 2"


   
 


Plain Authentication for sendmail with SASL
[info]neelesh_gurjar
1. Test your sendmail is compiled with SASL or not
sendmail -d0.1 -bv root | grep SASL  make sure SASL should come in Output.  If not then you need to compile sendmail with SASL

2. Changes in /etc/mail/sendmail.mc -->

define(`confAUTH_OPTIONS', `A')dnl
TRUST_AUTH_MECH(`LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `LOGIN PLAIN')dnl


2. In /usr/lib/sasl2/Sendmail.conf

pwcheck_method: saslauthd

And start saslauthd with following command:

saslauthd -a shadow

Restart sendmail

3. Test sendmail
telnet <server ip> 25
ehlo localhost

It should show 250-AUTH in the output.



Virtual Hosting in Sendmail
[info]neelesh_gurjar
Sendmail 8.13..
CentOS 5.1



1. Check following line should be there in /etc/mail/sendmail.mc

FEATURE(`virtusertable', `hash -o /etc/mail/virtusertable.db')dnl
FEATURE(always_add_domain)dnl
FEATURE(use_cw_file)dnl

2./etc/mail/virtusertable, which will look something like this:

abc@domain1.com    abc

xyz@domain2.com  xyz

abc@domain2.com    abc2

3. makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable


4. Put host alliases in /etc/mail/local-host-names.

domain1.com

domain2.com

Port forwarding in Linux with Iptables
[info]neelesh_gurjar

I have one Linux Machine. It has 2 interfaces. eth0 will have Live IP and which will be accessible across the internet. eth1 will have internal IP and can only be connected across LAN.
Here I want to forward all request which come to my internetIP should get forwarded to my internal web server. To do this need to give following commands on linux machine:


#iptables -t nat -A PREROUTING -p tcp -i eth0 -d <Live IP / IP of outside interface of firewall> --dport 80 -j DNAT --to <Internal server's IP / IP of the server where the request will forward to>:80
 
#iptables -A FORWARD -p tcp -i eth0 -d <Internal server's IP / IP of the server where the request will forward to> --dport 80 -j ACCEPT
 

Linux Addiction !!!
[info]neelesh_gurjar
Today When I ask in one department in company that "Can we switch over to Windows? As some body is donating Licensing cost for those PCs" All users said "No, We can't work on Windows now. We need only Linux"...

I got pleasent surprised by their reply. I thought that they will switch to Windows.

Three years back when I was pushing these users to work on Linux. I had to explain them advantages of Linux. They faced lots of issues in their daily work. Some of them I could resolved, In some cases they had to change their working style, some of them took a loing time also. But now when they are using it for last 2 years without any issue, they dont want to go back to Windows. They said that they forgot how to work on Windows. .... They got addicted to Linux now.....

People say that Linux is not user friendly and cannot be used for Desktops for general users.
Now I can surely say, if users, admins, management plans to use Linux, works hard on it without having windows in mind then they can switch to Linux. Offcourse proffessional companies like Adobe, Corel, Font making companies should make applications for Linux also.

Installing Atheros AR242x 802.11abg Wireless on Linux PAE kernel
[info]neelesh_gurjar
1.  echo "blacklist ath5k" >> /etc/modprobe.d/blacklist
2. Download latest madwifi-hal   from http://snapshots.madwifi.org/madwifi-hal-0.10.5.6/
3. Extract the tarball & go to extracted directory and install it with following commands:
  
     install
     modprobe ath_pci
     modprobe ath_hal

4. Create or open a file named  in the /etc/pm/config.d/config
   Add following line:   SUSPEND_MODULES="ath_pci"

5. Reboot it and then configure wireless interface in Yast2.

Sharing Printer for Windows from Linux with Samba
[info]neelesh_gurjar
Sharing Printer for Windows from Linux -->

smb.conf will be =============>

[global]
        dos charset = ASCII
        display charset = UTF-8
        workgroup = WORKGROUP
        netbios name = PRINT
        security = SHARE
        max xmit = 65535
        deadtime = 15
        socket options = IPTOS_LOWDELAY TCP_NODELAY SO_SNDBUF=16384 SO_RCVBUF=16384
        printcap name = cups
        printing = cups
        log file = /var/log/samba/%m.log

[printers]
        comment = All Printers
        path = /var/tmp
        guest ok = Yes
        printable = Yes
        browseable = yes

[print$]
        comment = Printer Drivers
        path = /var/lib/samba/drivers
        guest ok = Yes

[Test]
        comment = Test
        path = /var/lib/samba
        read only = No
        guest ok = Yes
        printable = Yes
        printer name = Test
        use client driver = Yes
        oplocks = No

===========================

/etc/cups/cupsd.conf ===================>


LogLevel debug
SystemGroup sys root
Port 631
Listen /var/run/cups/cups.sock
Browsing Off
DefaultAuthType Basic

<Location />
  Order allow,deny
   Allow from All
</Location>

<Location /admin>
  Order allow,deny
  Allow from All
</Location>

<Location /admin/conf>
  Order allow,deny
   Allow from All
</Location>

Note: If permissions are not proper then you may get "client-error-not-authorized" this error in Samba log.

================================

Please uncomment below line from /etc/cups/mime.convs

application/octet-stream        application/vnd.cups-raw        0       -

Note : If it is commented then you may get "client-error-document-format-not-supported" this error in samba log.

================================

Now restart cups and add printer in Windows.

Good Luck !!! :)

Resolution for Wine error in CentOS linux
[info]neelesh_gurjar
I am using CentOS 5.1 with Wine-0.9.57. While executin Program "Write.exe" with wine I was getting following error:

[neel_g@test drive_c]$ wine write.exe
preloader: Warning: failed to reserve range 00000000-60000000
preloader: Warning: failed to reserve range 00000000-60000000
preloader: Warning: failed to reserve range 00000000-60000000
err:dosmem:setup_dos_mem Cannot use first megabyte for DOS address space, please report
preloader: Warning: failed to reserve range 00000000-60000000
err:dosmem:setup_dos_mem Cannot use first megabyte for DOS address space, please report
err:dosmem:setup_dos_mem Cannot use first megabyte for DOS address space, please report
err:dosmem:load_winedos Could not load winedos.dll, DOS subsystem unavailable
winevdm: unable to exec '--app-name': 16-bit support missing


To resovle this issue:

1.  # cat /proc/sys/vm/mmap_min_add
        65536
2.  I added following line to /etc/sysctl.conf
        vm.mmap_min_addr = 0
3. # wineboot
4. The issue got resolved. The program is working fine.  :-)


       

How to get detail info of TCP or UDP packets
[info]neelesh_gurjar
[root@example root]# netstat -u -s
Udp:
    95043801 packets received
    2059 packets to unknown port received.
    12041 packet receive errors
    81665255 packets sent

[root@exampleroot]# netstat -t -s
Tcp:
    2119 active connections openings
    14472 passive connection openings
    0 failed connection attempts
    10 connection resets received
    1372 connections established
    101805453 segments received
    190009367 segments send out
    18675 segments retransmited
    0 bad segments received.
    31811 resets sent
TcpExt:
    ArpFilter: 0
    4892 TCP sockets finished time wait in fast timer
    774734 delayed acks sent
    3375 delayed acks further delayed because of locked socket
    Quick ack mode was activated 58 times
    2792 packets directly queued to recvmsg prequeue.
    1662 packets directly received from backlog
    681773 packets directly received from prequeue
    6711642 packets header predicted
    2594 packets header predicted and directly queued to user
    TCPPureAcks: 87512391
    TCPHPAcks: 8652457
    TCPRenoRecovery: 0
    TCPSackRecovery: 9225
    TCPSACKReneging: 0
    TCPFACKReorder: 0
    TCPSACKReorder: 0
    TCPRenoReorder: 0
    TCPTSReorder: 0
    TCPFullUndo: 0
    TCPPartialUndo: 0
    TCPDSACKUndo: 0
    TCPLossUndo: 2
    TCPLoss: 1069
    TCPLostRetransmit: 0
    TCPRenoFailures: 0
    TCPSackFailures: 817
    TCPLossFailures: 1
    TCPFastRetrans: 9691
    TCPForwardRetrans: 52
    TCPSlowStartRetrans: 122
    TCPTimeouts: 6017
    TCPRenoRecoveryFail: 0
    TCPSackRecoveryFail: 24
    TCPSchedulerFailed: 0
    TCPRcvCollapsed: 0
    TCPDSACKOldSent: 61
    TCPDSACKOfoSent: 0
    TCPDSACKRecv: 2
    TCPDSACKOfoRecv: 0
    TCPAbortOnSyn: 0
    TCPAbortOnData: 17
    TCPAbortOnClose: 1
    TCPAbortOnMemory: 0
    TCPAbortOnTimeout: 256
    TCPAbortOnLinger: 0
    TCPAbortFailed: 0

Resolved Issue of ORA:01110 File needs media recovery
[info]neelesh_gurjar
I have setup Oracle7.3 on SCO Openserver 5.0.

While starting Oracle I was getting error "ORA:01110 File 30 needs media recovery.

I resolved this by following way:

1. Logged in as oracle user.
2. Gave below commands:


# svrmgrl
SVRMGR>connect internal

SVRMGR>startup
THen it gave same error. So DB got mounted but not opened.

SVRMGR>RECOVER

Media Recovery Done.

THen I restarted Oracle and it worked. This time it didnt show the error.
This means it recovered data from "redo.log". I was lucky.

Cheers

Starting Oracle Enterprise Manager Web console in Linux
[info]neelesh_gurjar
Login as Oracle user
# emctl start dbconsole

Oracle installation errors and solutions
[info]neelesh_gurjar
While Installing Oracle I got following Error:


[oracle@neelesh ORACLE]$ ./runInstaller
Starting Oracle Universal Installer...

Checking installer requirements...

Checking operating system version: must be redhat-3, SuSE-9, redhat-4, UnitedLinux-1.0, asianux-1 or asianux-2
Passed


All installer requirements met.

Preparing to launch Oracle Universal Installer from /tmp/OraInstall2008-07-06_12-26-00PM. Please wait ...[oracle@neelesh ORACLE]$ No protocol specified
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvir onment(Unknown Source)
at java.awt.Window.init(Unknown Source)
at java.awt.Window.<init>(Unknown Source)
at java.awt.Frame.<init>(Unknown Source)
at oracle.ewt.popup.PopupFrame.<init>(Unknown Source)
at oracle.ewt.lwAWT.BufferedFrame.<init>(Unknown Source)
at oracle.sysman.oio.oioc.OiocOneClickInstaller.<init >(OiocOneClickInstaller.java:378)
at oracle.sysman.oio.oioc.OiocOneClickInstaller.main( OiocOneClickInstaller.java:2091)


SOLUTION: --

1. login as root
2. # xhost +
3. Login as oracle
4. # xhost +

Now try ./runInstaller.

Adding "tmpspace" in Linux
[info]neelesh_gurjar
Give below commands as root user:

mkdir /<different filesys>/tmp
chown root.root /<
different filesys>/tmp
chmod 1777 /<
different filesys>/tmp
export TEMP=/<
different filesys>
export TMPDIR=/<
different filesys>

For removing added "tmpspace" give below commands as root user:

rmdir /<
different filesys>/tmp
unset TEMP
unset TMPDIR


Add swap space in Linux
[info]neelesh_gurjar
Addiding Swap space:

Give below commands as root user

# dd if=/dev/zero of=
swapfile bs=1k count=500000
# chmod 600 swapfile
# mkswap
swapfile
# swapon swapfile

Removing added Swapspace:

Give below commands as root user
# swapoff tmpswap
# rm tmpswap

Basic Commands of Oracle9
[info]neelesh_gurjar
Importing .dmp file to database:

# imp username/passwd  file=<path of dmp file> full=y

To Start Oracle:

# sqlplus /nolog
SQL> connect / as sysdba
SQL> startup

To Start Listner:

# lsnctr
LSNCTR> start

To see the Database name:
SQL> SELECT NAME FROM v$database;

To find out datafiles used by Tablespace:
SQL> SELECT NAME FROM v$datafile;

To find out  Tablespace Names:
SQL> SELECT NAME FROMv$tablespace;

To see the Previlages given to Users:
SQL> SELECT * FROM db_role_privs;

To create Tablespace name USERS:
SQL> CREATE TABLESPACE USERS
            DATAFILE '<path of dbf file>'
            SIZE 100M;


To add a datafile to USERS tablespace:
SQL> Alter TABLESPACE USERS
            ADD DATAFILE  '<path of dbf file>'
            SIZE 1000M
            AUTOEXTEND ON
            NEXT 100M
            MAXSIZE 1000M;

To create user TEST:
SQL> CREATE USER TEST
            IDENTIFIED BY <password>
            DEFAULT TABLESPACE USERS;

To change password of user TEST:
SQL> Alter USER TEST IDENTIFIED BY <new password>;

Previlages to TEST:
SQL> GRANT CREATE SESSION TO TEST;

SQL> GRANT DBA TO TEST WITH ADMIN OPTION;
           

To Drop tablespace USERS:
SQL> DROP TABLESPACE USERS INCLUDING CONTENTS;

Installing CanonLBP2900 on CentOS Linux
[info]neelesh_gurjar
1. Download Drivers from http://software.canon-europe.com/software/0028622.asp?model=
2. Extract CAPTDRV160.tar.gz
3. # cd CAPTDRV160/driver/rpm
4. # rpm -ivh cndrvcups-capt-1.60-1.i386.rpm
5. # rpm -ivh cndrvcups-common-1.60-1.i386.rpm
6. # /etc/init.d/cups restart
7. # tail /var/log/messages
You should see:
May 21 13:40:10 susik64 kernel: usb 1-1: Product: Canon CAPT USB Device
May 21 13:40:10 susik64 kernel: usb 1-1: Manufacturer: Canon
May 21 13:40:10 susik64 kernel: usb 1-1: SerialNumber: 0000XXXXXXXX
May 21 13:40:10 susik64 kernel: usb 1-1: configuration #1 chosen from 1 choice
May 21 13:40:10 susik64 kernel: drivers/usb/class/usblp.c: usblp0: USB Bidirectional printer dev 17 if 0 alt 0 proto 2 vid 0x04A9 pid 0x2676

8. # /usr/sbin/lpadmin -p LBP2900 -m CNCUPSLBP2900CAPTK.ppd -v ccp:/var/ccpd/fifo0 -E
9. # /usr/sbin/ccpdadmin -p LBP2900 -o /dev/usb/lp0
10. # /etc/init.d/ccpd start
11. To see Printer status:
# captstatusui -P LBP2900

Home