Access files from password proctected site

----------------------------------------------------------------------------------------------------------------------------------------
#wget --user=username --password=password http://example.com/files.tar.gz
----------------------------------------------------------------------------------------------------------------------------------------

Change username and password as your requirement from the above command .

How do I enable server-side includes on my site ?

How do I enable server-side includes on my site ?

    1. #cd /to/your/site/folder

    2. #vi .htaccess

    3. and paste the below content in that 

      ------------------------------------------------------------------------------------------ 
       
      AddType text/html .shtml
      AddHandler server-parsed .shtml
      DirectoryIndex index.shtml index.html index.htm index.php
      Options +IncludesNoExec -ExecCGI 
       
      ------------------------------------------------------------------------------------------ 
    4.  thats it done .

Back up files in linux

The below is the script to backup files in linux :
  • copy the below script and name example.sh
-----------------------------------------------------------------------------------------------------------------------------------------
#!/bin/bash
#START

TIME=`date +"%b-%d-%y_%H-%M-%S"`            
FILENAME="backup-$TIME.tar.gz"     
SRCDIR="/path/to/source/folder"         #please change to your source folder         
DESDIR="/path/to/destination/folder"   # please change to your destination folder        
tar -cpzf $DESDIR/$FILENAME $SRCDIR

find
/path/to/destination/folder/ -iname '*.tar.gz' -ctime +45 -exec rm -f {} \;  #please change to your destination folder
#END

-----------------------------------------------------------------------------------------------------------------------------------------
  •  And change the mode of file example.sh
-----------------------------------------------------------------------------------------------------------------------------------------
 #chmod +x example.sh
-----------------------------------------------------------------------------------------------------------------------------------------
  • And move the examle.sh file  
-----------------------------------------------------------------------------------------------------------------------------------------
#mv example.sh /bin/
-----------------------------------------------------------------------------------------------------------------------------------------
  • Now edit crontab
-----------------------------------------------------------------------------------------------------------------------------------------
 #sudo crontab -e

 45 22 * * * example.sh    #Edit as your requirement
-----------------------------------------------------------------------------------------------------------------------------------------

Creating user in Phpmyadmin using SQL

1) Login to phpmyadmin

2) open the perticular DB

3) click on SQL tab

4) Paste the below line there and change the username and dbname as yours and password as you require .

-------------------------------------------------------------------------------------------------------------------------------------
grant all privileges on dbname.* to username@localhost identified by 'passwd';
-------------------------------------------------------------------------------------------------------------------------------------

INSTALL MONGODB ON UBUNTU


Create a the /etc/apt/sources.list.d/10gen.list file and include the most appropriate version of the following lines for the 10gen repository

----------------------------------------------------------------------------------------------------------------------------------------
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
-----------------------------------------------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------------------------------------------
sudo apt-key adv –keyserver keyserver.ubuntu.com –recv 7F0CEB10
----------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------
sudo apt-get update
-----------------------------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------------------------
sudo apt-get install mongodb-10gen
-----------------------------------------------------------------------------------------------------------------------------------------

You are ready with mongodb , to check status service mongodb status.



 INSTALL GRAPHICAL TOOL

Download mViewer from

--------------------------------------------------------------------------------------------------------------------------------------   
https://github.com/Imaginea/mViewer
--------------------------------------------------------------------------------------------------------------------------------------

Now go to scripts folder and run start_mviewer.sh

Visit your localhost on 8080 port with no username and password if you have not set any(

---------------------------------------------------------------------------------------------------------------------------------------
http://127.0.0.1:8080
---------------------------------------------------------------------------------------------------------------------------------------

Now you are done with mongodb GUI interface.

ENABLE IP FORWORDING (RHEL ,CENT OS)

Open /etc/sysctl.conf file using a text editor, enter:

------------------------------------------------------------------------------------------------------------------------------------------
 # vi /etc/sysctl.conf
--------------------------------------------------------------------------------------------------

Set net.ipv4.ip_forward to 1, enter:
 
-------------------------------------------------------------------------------------------------- 
net.ipv4.ip_forward = 1
-------------------------------------------------------------------------------------------------- 
 
Save and close the file. Reload the changes by typing the following command: 
 
--------------------------------------------------------------------------------------------------
# sysctl -p
--------------------------------------------------------------------------------------------------                  

ACL (access control list)

1 ) To check if your ext4 filesystem has the proper default options, use tune2fs as below :
  ------------------------------------------------------------------------------------------------------------------------
   # tune2fs -l /dev/sdb1
 --------------------------------------------------------------------------------------
2 ) To enable ACLs on a filesystem, we must set the fs default and remount: 
 -------------------------------------------------------------------------------------------
 # tune2fs -o acl /dev/sdb1
 # mount -o remount,acl /data1
 -------------------------------------------------------------------------------------------
3) Use getfacl to view ACLs: 
------------------------------------------------------------- 
# touch /data1/foo.txt
# getfacl /data1/foo.txt
-------------------------------------------------------------
4) Use setfacl to set ACLs, with -m to modify and -x to remove a given ACL. 
          a) give user bob read+write+execute on a file:
----------------------------------------------------------------------------------------------------------------------------------------
#setfacl -m u:bob:rwx /data1/foo.txt
 
      b)give group peeps read+write on a file: 


#setfacl -m g:peeps:rw /data1/foo.txt
--------------------------------------------------------------------------------------------------------------------------------------

5)remove bob's ACL permissions:
-------------------------------------------------------------------------------------------------------------------------------------
#setfacl -x u:bob /data1/foo.txt
-----------------------------------------------------------------------------------------------
6)setfacl permission to directory
------------------------------------------------------------------------------------------------ 
#setfacl -m d:g:peeps:rw /data1/stuff/
---------------------------------------------------------------------------------------------- 
7) revoke write permission for everyone:
--------------------------------------------------------------------------------------------------- 
#setfacl -m m::rx /data1/foo.txt 
------------------------------------------------------------------------------------------------- 
 
8) When ACLs are present, an ls -l will show a plus sign to notify you:
-------------------------------------------------------------------------------------------------- 
 # ls -l /data1/foo.txt 
-rw-rwxr--+ 1 root root 0 Dec  3 14:54 /data1/foo.txt
 --------------------------------------------------------------------------------------------------------------------------------------

To remove only the tables in DB :


Go to terminal and excute the bellow command with your database username ,databasename , and password :

mysqldump -u username -p --no-data dbname | grep ^DROP > drop.sql 

mysql -u username -p dbname < drop.sql   

rm drop.txt

To find which version of linux OS installed

This is only for the Linux distribution
open the terminal and enter the bellow command

#cat /etc/*release

.htaccess Proctection

IP address restrictions to protect directories using .htaccess

    copy the below 6 lines to .htaccess file 
    <limit GET>
    order deny,allow
    deny from all
    allow from 128.175
    allow from 128.4
    </limit>
       

Folder proctection using .htaccess this is only for linux users

     Create .htaccess if not present and add below 5 lines
    AuthName "Restricted Area"
    AuthType Basic
    AuthUserFile /var/www/vhosts/sitename/httpdocs/.htpasswd
    AuthGroupFile /dev/null
    require valid-user

# htpasswd -c /var/www/vhosts/sitename/httpdocs/.htpasswd kirthan

Creating Vhosts in Ubuntu

Steps for Creating Vhosts in Ubuntu :


1)
Create the folders that will host your new sites. By default, Apache in Ubuntu serves from /var/www

2) 
mkdir /var/www/site
 
 
3) 
cp /etc/apache2/sites-available/default /etc/apache2/sites-available/site
 
4)  
Edit the new config files for each site using your preferred text 
editor. Add the line ServerName server1 right below the ServerAdmin line
 and change both DocumentRoot and Directory to point to your new sites.

repeat this step for as many new sites as you’ll be 
creating
/etc/apache2/sites-available/site



<VirtualHost *:80>
 ServerAdmin webmaster@localhost
 ServerName site1

 DocumentRoot /var/www/site
 <Directory />
  Options FollowSymLinks
  AllowOverride All
 </Directory>
 <Directory /var/www/site1/>
  Options -Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  allow from all
 </Directory>

 ErrorLog ${APACHE_LOG_DIR}/error.log

 # Possible values include: debug, info, notice, warn, error, crit,
 # alert, emerg.
 LogLevel warn

 CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
 
5)  
  After you have edited the config files just tell Apache to start serving the 
new domains and stop serving the default:
 
 sudo a2ensite site
 

 6)
Now reload apache and you should be able to get to each of your new domains
 
sudo /etc/init.d/apache2 reload

7)
for disabling the site use command 
 
sudo a2dissite site 

Start and Stop ssh-agent

Below is the bash script used to start and stop ss-agent #!/bin/bash ## in .bash_profile SSHAGENT=`which ssh-agent` SSHAGENTARGS="...