Linux

Linux commands and usages and how to support

Create your own service in ubuntu

Create a service and set it to boot level at systems starts like how does apache2 service starts by default in ubuntu when  linux system boots

Usage you could create your own shell script that need to be used as service to start stop kill or whatever

Realtime examples are apache2,mysql, mongo, chrome,skype and every processes

 

Steps  

1. Switch to sudo user by

sudo su

2. Navigate to /etc/init.d

Virtual hosting LocalHost linux OS ubuntu 14.04

Setting virtual hosting in localhost machine, (Used Apache  linux OS ubuntu 14.04)
 

site1.com 
site2.com 

Assume that I have two sites placed in /var/www/html, site1 at  /var/www/html/site1 and site2 /var/www/html/site2

Now I have access to my site by navigating through browser http://localhost/site1 and  http://localhost/site2

Now I wish to access my two sites in my local machine by site1.com and site2.com 

 

Let see the steps 

Handy frequently used useful bash shell script aliases

alias html='cd /var/www/html/'

alias gs='git status'

alias gp='git pull'

alias ga='_ga () { git add "$@"; }; _ga'

alias clr='clear'

alias ..='cd ..'

alias 7='_7 () { sudo chmod 777 -R "$@"; }; _7'

alias 75='_75 () { sudo chmod 755 -R "$@"; }; _75'

alias gc='_gc() { git commit -m "$1" "$2"; }; _gc'

alias gps='git push'

alias slr='_slr () { 
if [ -z "$@" ]; then
/opt/solr-5.5.2/bin/solr start;
else
/opt/solr-5.5.2/bin/solr "$@";
fi  }; _slr'

alias oh='gnome-open /var/www/html/'

alias gd='_gd () { 
if [ -z "$@" ]; then
git diff;
else
git diff "$@";
fi  }; _gd'

How to create bash alias or alias functions for dynamic commands to pass line parameters in linux say ubuntu

Just edit the file ~/.bashrc by using the below command where in you will see all the bash commands 

gedit ~/.bashrc

Say now Im going to create bash alias function for dynamic command that is for git add files

We cannot simply run 

git add

We should pass the filenames to add the files to it, for this  you must create  alias as function now my alias is going to be ga for the below command

git add filename

so when We type

How to create bash alias and what is bash alias in linux OS say ubuntu

According to me

Bash alias is used to create your commands in your linux machine as it is to ease or speed up your work.


just edit the file ~/.bashrc by using the below command where in you will see all the bash commands 

 gedit ~/.bashrc

Say as per my previous article I need to clear cache of my application with short commands

How to run the command one by one or only after the previous command is complete in linux OS say ubuntu

You may have to work faster when you have tight deadlines, You may have work on linux system and you may have to add the commands one by one to achieve certain task 

Say for example 

Clear the application cache 

If you do it manually you may need to delete the folder and then create it and then 
give 777 permission for that folder, what you can do is, you can simply type in all commands by small change in it, it will save your time.