Pages

Friday, April 19, 2013

How to create service in Linux


Sometimes we need to make our program automatically run when computer started.
To do this, we need to make our program as service and make it started when computer booted.
This time, we will discuss about how to create service in linux using httpd compiled as sample :
  1. login as root
  2. create new file in /etc/init.d/ using this command :
    # cd /etc/init.d/
    # vi httpd
    
  3. write this code below
    #!/bin/bash
    #
    # httpd: This shell script handle starting and stopping
    #
    # chkconfig: 35 80 30
    # description: httpd a application daemon, to handle web request dan response
    
    . /etc/rc.d/init.d/functions
    
    case "$1" in
    start)
            echo $"starting httpd"
            /usr/local/httpd/bin/apachectl start        
    ;;
    stop)
            echo $"stopping httpd"
            /usr/local/httpd/bin/apachectl stop
    ;;
    *)
            echo $"usage: $0 {start|stop}"
    esac
    
  4. save this file
  5. set file to be executable using this command
    # chmod +x httpd
    
  6. install as service
    chkconfig httpd on
    

Thursday, April 18, 2013

How to mount windows sharing in linux


All files in a Linux system are arranged in one big tree file hierarchy at /. It include devices too. We use the mount command attach the file system or devices to the tree. We also able to mount windows share under Linux as follows :
  1. Make sure you have  : 
    • Windows username and password to access share
    • Sharename or IP address
    • root access on Linux
  2. Login to Linux as a root user
  3. Create mount point:
    # mkdir -p /mnt/winshare
    
  4. Use the mount command as follows :
    # mount -t cifs //ntserver/winshare -o username=admin,password=myAdminPassword /mnt/winshare
    
    while :
    • -t cifs : File system type to be mount
    • //ntserver/winshare : Sharename on windows (change it as yours)
    • -o username=admin,password=myAdminPassword : are options passed to mount command. First argument is username (admin) and second argument is password to connect windows share
    • /mnt/ntserver : Linux mount point to access Sharefiles
  5. Access Windows share using command:
    # cd /mnt/winshare; ls -l
    

Wednesday, April 17, 2013

How to easily set DNS in Linux


This post below are the steps on how to configure primary and secondary DNS :
  1. Login as root
  2. Modify file /etc/resolv.conf
    vi /etc/resolv.conf
    
  3. Add lines below
    nameserver 192.168.6.17
    nameserver 192.168.6.18
    
    You must replace DNS IP on your own
  4. Save and close the file
  5. To test DNS use one of the following command :
  6. $ host google.com
    $ dig google.com
    $ ping google.com
    $ nslookup your-domain.com
    
Don't Forget To Join Our Community
×
Widget