Tuesday 27 September 2016

How to find size of a directory in Linux


du is a linux command, is to display the file space allocated to each file and directory contained in the current directory. It Summarize disk usage of each FILE, recursively for directories.



                        # du    - List of directories that exist in the current directory along with their sizes.


                       # du -c   -Gives grand toal as last line of output.

                   
                       # du -s    -Displays summary of directory size.


                         # du -h   -Displays size in human readable format.









Sort Directory size in ascending order.




                         # sudo du -sh * | sort -hr








Thursday 22 September 2016

How to scheduling Crontab for backup files and directories in linux


1. Install crontab

In centos,redhat:

            # yum install cron*

2. Open crontab.

                  # crontab -e


                                field                    allowed values
                                ------------            -------------------
                                   minute                   0-59
                                   hour                       0-23
                                   day of month         1-31
                                   month                    1-12 (or names, see below)
                                   day of week           0-7 (0 or 7 is Sun, or use names)




 15      16      *       *       1       /bin/tar -czvf /Backup-Folder/Project-Folder-MON.tar.gz       /Project-Folder




The 'Project-Folder' will backup every Monday - every month - every day at 04:15 PM to 'Backup-Folder' under '/' with the name 'Project-Folder-MON.tar.gz'.


-c : Create
-z : Gzip
-v : Verbose
-f : File

3. Save the file


4. List crontab


            # crontab -l


5. Remove crontab


            # crontab -r


6. Restart crontab


            # service crond restart


7. Add crontab on startup


            # chkconfig crond on


How to schedule crontab for other users



Open crontab with username and add the scheduler and restart the service.


            # crontab -e -u username


How to deny a user from crontab



Open crontab.deny file and add the user you want to deny. save the file and restart the service.


            # vim /etc/crond.deny



Wednesday 21 September 2016

CIFS Mounting in Linux


1. Open fstab file





                #vim /etc/fstab/






2. Add the following line.


               /192.168.10.101/Projects /Project-Folder cifs username=name,password=pwd 0 0


3. Save the file.

     

How to Change JVM Heap settings of apache tomcat in Linux


1. Go to apache installation folder

                    # cd /home/apache-tomcat-8.5.4/bin/

2. Edit setenv.sh as follows

                    # vim setenv.sh

export CATALINA_OPTS="$CATALINA_OPTS -Xms1024m"
export CATALINA_OPTS="$CATALINA_OPTS -Xmx1024m"
export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxPermSize=512m"

3. Save the file

4. Execute the command

                       # ./catalina.sh

How to Change JVM Heap settings of apache tomcat in Wndows

1. Open Monitor Tomcat.

2. Go to java (4th tab).

3. Change initial memory pool (-Xms) and maximum memory pool (-Xmx).

4. Click Apply and Ok.




Tuesday 20 September 2016

How to Start apache tomcat server on startup in Ubuntu,LinuxMint

1. First install the apache server.


                           http://rapidsolutions4u.blogspot.in/2016/09/install-apache-tomcat-on-linux-1.html

2. Go to init.d directory.


                                # cd /etc/init.d


3. Create and edit "tomcat.sh" file.


                                # vim tomcat.sh


    # Tomcat auto-start
    # description: Auto-starts tomcat
    # processname: tomcat
    # pidfile: /var/run/tomcat.pid

    export JAVA_HOME=jdk path


    case $1 in

    start)
            sh /home/apache-tomcat-8.5.4/bin/startup.sh
            ;;
    stop)
            sh /home/apache-tomcat-8.5.4/bin/shutdown.sh
            ;;
    restart)
            sh /home/apache-tomcat-8.5.4/bin/shutdown.sh
            sh /home/apache-tomcat-8.5.4/bin/startup.sh
            ;;
    esac
    exit 0


4. Save the file.

5. Set permission to created file.

                               # sudo chmod 755 /etc/init.d/tomcat

6. Create links


                               # sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat
                              # sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat


7. Restart tomcat service.



                             # /etc/init.d/tomcat restart



8. Similarly stop and restart tomcat service.




Monday 19 September 2016

How to Start apache tomcat server on startup in Centos,Redhat


1. First install the apache server.


                           http://rapidsolutions4u.blogspot.in/2016/09/install-apache-tomcat-on-linux-1.html

2. Go to init.d directory.


                                # cd /etc/init.d


3. Create and edit "tomcat.sh" file.


                                # vim tomcat.sh


#!/bin/bash  
# description: Tomcat Start Stop Restart  
# processname: tomcat  
# chkconfig: 234 20 80  
JAVA_HOME=jdk path 
export JAVA_HOME  
PATH=$JAVA_HOME/bin:$PATH  
export PATH  
CATALINA_HOME=apache path  
 
case $1 in  
start)  
sh $CATALINA_HOME/bin/startup.sh  
;;   
stop)     
sh $CATALINA_HOME/bin/shutdown.sh  
;;   
restart)  
sh $CATALINA_HOME/bin/shutdown.sh  
sh $CATALINA_HOME/bin/startup.sh  
;;   
esac      
exit 0


4. Save the file.

5. Set permission to created file.

                               #  chmod 755 tomcat

6. Add on startup


                               # chkconfig --add tomcat
                               # chkconfig --level 35 tomcat on


7. Start tomcat service.



                             /etc/init.d/tomcat on


8. Similarly stop and restart tomcat service.



How to install apache tomcat on Linux


Apache Tomcat is an opensource web server that is developed by Apache software foundation.
It is bascically used for deploying java web application. It is run on port 8080.


1. Download jdk-version.tar.gz from


                 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html


2. Extract the downloaded jdk.


                   # tar -xzf jdk-version.tar.gz


3. Set environmental variable.


                    Edit vim .bash_profile  --->  export PATH=(path of jdk bin):$PATH  (in centos,redhat....) 
           Edit vim .profile           --->  export PATH=(path of jdk bin):$PATH  (in ubuntu,mint....)


4. Download and Extract Tomcat Archive  http://tomcat.apache.org/


                     # tar -xzf apache-tomcat-(version).tar.gz



Tar is a linux command used to create or extract .tar.gz file formats. Tar stands for tape archive. It is an archiving file format.

Tar synopsis


                       tar <operation> [options]

Operations:


[-]A --catenate --concatenate
[-]c --create
[-]d --diff --compare
[-]r --append
[-]t --list
[-]u --update
[-]x --extract --get
--delete

Common Options:


-C, --directory DIR
-f, --file F
-j, --bzip2
-p, --preserve-permissions
-v, --verbose

-z, --gzip




5. Start Tomcat


            # cd /apache-tomcat-(version)/bin/
            # ./startup.sh


6. Access Tomcat in Browser


             http://localhost:8080/


7. Stop Tomcat


            # cd /apache-tomcat-(version)/bin/
            # ./shutdown.sh


8. Setup User Accounts


             Edit "conf/tomcat-users.xml" file and paste inside <tomcat-users> </tomcat-users> tags.


<role rolename="manager-gui" />
<user username="manager" password="YOUR_PASSWORD_" roles="manager-gui" />



11. Restart the tomcat server




How to Install apache tomcat on Windows


Apache Tomcat is a opensource web server that is developed by Apache software foundation.
It is bascically used for deploying java web application. It is run on port 8080.


1. Download apache tomcat from


                                    http://tomcat.apache.org/


2. Install apache-tomcat-(version).exe