nohup Execute Commands After You Exit From a Shell Prompt

nohup command :

Answer is simple, use nohup utility which allows to run command./process or shell script that can continue running in the background after you log out from a shell:

nohup Syntax:

--------------------------------------------------------------------------------------------------
#nohup command-name &
-----------------------------------------------------------------------------------------------------------------------------------------
Where,
  • command-name : is name of shell script or command name. You can pass argument to command or a shell script.
  • & : nohup does not automatically put the command it runs in the background; you must do that explicitly, by ending the command line with an & symbol.
By the above command you can run the process in background .

Reverse proxy on virtualhost

Run node.js on apache


                                     The problem with Subsonic is that it runs on Node.js on a non-standard port. The rest of my web applications run in Apache on port 80. Therefore, it would be nice if instead of having to go to http://example.com:8180/subsonic/, I could simply go to http://example.com. The solution is called a reverse proxy. Reverse proxies can do things like load balance between multiple web servers or simply make resources on an internal web server available externally. In this case, I am using a reverse proxy to make a web application available on a different port available on the standard port 80.
The set up is fairly simple. On Ubuntu, it should be as simple as issuing this command (as root) to enable the proxy modules:


<VirtualHost *:80>
DocumentRoot /var/www/vhosts/path/to/folder
ServerName example.com

ErrorLog /var/www/vhosts/loh/logs/error_log
CustomLog /var/www/vhosts/loh/logs/access_log combined

<Directory /var/www/vhosts/path/to/folder>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://example.com:8180/
ProxyPassReverse http://example.com/
</Location>
</VirtualHost>

Backup and Restore MySQL Database Using mysqldump Command

Using mysqldump, you can backup a local database and restore it on a remote database at the same time, using a single command. In this article, let us review several practical examples on how to use mysqldump to backup and restore.

----------------------------------------------------------------------------------------------------------------------------------------

backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql 
 
restore:# mysql -u root -p[root_password] [database_name] < dumpfilename.sql  

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

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="...