Skip to content

Instantly share code, notes, and snippets.

@Javvadilakshman
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save Javvadilakshman/7cf64271ea90ab7adc94 to your computer and use it in GitHub Desktop.

Select an option

Save Javvadilakshman/7cf64271ea90ab7adc94 to your computer and use it in GitHub Desktop.
List Of Usefull BASH Commands

    BASH COMMANDS COLLECTION

  1.Bash Alias's
  • Basic Alias's
  • HTTD Service
  • Mysql Service
  2.Mysql
  • Uninstalling in Ubuntu
  • Mysql Service Alias
  3.Parent Proccess Kill
  4.SCP Commands
  5.SSH
  • Connecting To Remote nix
  • Connecting To Remote nix without password
  • Connecting To Remote nix with name ,no need of ip
  6.Screen
  7.Open Terminal in Context Menu
  8.Checking which Systems are up in network
  9.Open Terminal in Context Menu
  10.Firewall & Ports
  11.Vim

alias c="clear"; # clear screen alias e="exit"; # exit session

Alias For HTTD Service Monitoring

alias hs="sudo service httpd status"; alias ha="sudo service httpd start"; alias hb="sudo service httpd restart"; alias hc="sudo service httpd stop";

Alias For MYSQLD Service Monitoring

alias ms="sudo service mysqld status"; alias ma="sudo service mysqld start"; alias mb="sudo service mysqld restart"; alias mc="sudo service mysqld stop"; alias mysql="sudo mysql";

To check which version is there

dpkg -l | grep mysql

Uninstalling mysql

from ubuntu

sudo apt-get remove --purge mysql-server mysql-client mysql-common sudo apt-get autoremove sudo apt-get autoclean

Alias For MYSQLD Service Monitoring

From Centos 6

alias ms="sudo service mysqld status"; alias ma="sudo service mysqld start"; alias mb="sudo service mysqld restart"; alias mc="sudo service mysqld stop"; alias mysql="sudo mysql";

How to Install MySQL 5.5 on Ubuntu Server 12.04 LTS

sudo apt-get update sudo apt-get install mysql-server-5.5

Once installation has completed, you just need to check that mysql is running. To do this, run

sudo netstat -tap | grep mysql

# Checking which systems are up in network
#!/bin/bash
for i in 192.168.0.{1..256};
do
if ping -c1 -w1 $i &>/dev/null
then
echo $i is up
fi
done

Firewall Opertion Manual ( Tested In Ubuntu 14.04) By Lakshman.Javvadi

For Referance : https://help.ubuntu.com/lts/serverguide/firewall.html

1.Enable Firewall

First 'ufw' needs to be enabled. From a terminal prompt enter

 sudo ufw enable

2.To open a port (ssh in this example):

sudo ufw allow 22

3.Adding Rules

Rules can also be added using a numbered format

sudo ufw insert 1 allow 80

4.Similarly, to close an opened port:

sudo ufw deny 22

5.Remov Port Rule

To remove a rule, use delete followed by the rule:

sudo ufw delete deny 22

6.Allowing Specific Port

It is also possible to allow access from specific hosts or networks to a port. The following example allows ssh access from host 192.168.0.2 to any ip address on this host:

sudo ufw allow proto tcp from 192.168.0.2 to any port 22

Replace 192.168.0.2 with 192.168.0.0/24 to allow ssh access from the entire subnet.

7. --dry-run option

Adding the --dry-run option to a ufw command will output the resulting rules, but not apply them. For example, the following is what would be applied if opening the HTTP port:

sudo ufw --dry-run allow http

8. ufw disabled

ufw can be disabled by:

sudo ufw disable

9. Firewall Status

To see the firewall status, enter

sudo ufw status

10.Verbose

And for more verbose status information use:

sudo ufw status verbose

11. Numbered Port Format

To view the numbered format:

sudo ufw status numbered
# Following commands will add "Open Terminal" menu item in Ubuntu Right Click context menu
# Tested in Ubuntu 12.04 & 14.04
sudo apt-get install nautilus-open-terminal && nautilus -q
## Parent Proccess Kill
pkill -9 -f processname
Ex: pkill -9 -f gedit
## Change the prompt
PS1='\n \u $reset_color→ \w \n \n';
\n : new line
\u : user name
\w : path
$reset_color→ :To generate right arrow
Example :
1) lakshman → ~
2) lakshman → /var/mail
Add “Open as Root/Administrator” Option in Ubuntu 14.10
sudo add-apt-repository ppa:noobslab/apps
sudo apt-get update
sudo apt-get install open-as-administrator
nautilus -q
## Copy Remote File To Local Machine
scp -r <user>@<hostname>:<file/folder> <destination>
-r : recursively copies files and folders
ex: scp -r root@tv:/var/www/html ./
## Copy the file "foobar.txt" from a remote host to the local host
`$ scp [email protected]:foobar.txt /some/local/directory`
## Copy the file "foobar.txt" from the local host to a remote host
`$ scp foobar.txt [email protected]:/some/remote/directory`
## Copy the directory "foo" from the local host to a remote host's directory "bar"
`$ scp -r foo [email protected]:/some/remote/directory/bar`
## Copy the file "foobar.txt" from remote host "rh1.edu" to remote host "rh2.edu"
`$ scp [email protected]:/some/remote/directory/foobar.txt [email protected]:/some/remote/directory/`
## Copying the files "foo.txt" and "bar.txt" from the local host to your home directory on the remote host
`$ scp foo.txt bar.txt [email protected]:~`
## Copy the file "foobar.txt" from the local host to a remote host using port 2264
`$ scp -P 2264 foobar.txt [email protected]:/some/remote/directory`
## Copy multiple files from the remote host to your current directory on the local host
`$ scp [email protected]:/some/remote/directory/\{a,b,c\} .`
`$ scp [email protected]:~/\{foo.txt,bar.txt\} .`
Screen Command
KeyBind + Combination Key Action Description
Ctrl+b % Split the current window vertically into two panes
Ctrl+b :split-window Horizontally split window or current pane
Ctrl+b o Switch to the next pane
Ctrl+b c Open new window
Ctrl+b l Move to previous window
Ctrl+b n Move to next window
Ctrl+b p Move to previous window
Ctrl+b d Detach current client
Ctrl+b x Kill the current pane
Ctrl+b & Kill the current window
Ctrl+b , Rename the current window
Ctrl+b q Display pane numbers
Ctrl+b ? List all keybindings
Ctrl+b { Move the current pane to previous
Ctrl+b } Move the current pane to next
Ctrl+b :break-pane Detach pane into its own window
Ctrl+b w List all windows
Ctrl+b 0-9 To select window
Ctrl+b :resize-pane Resize current pane down by default
Ctrl+b :resize-pane -U Upward Resize current pane
Ctrl+b :resize-pane -R Resize current pane to right
Ctrl+b :resize-pane -L Resize current pane to left
Ctrl+b :resize-pane 40 Resize current pane down by 40 cells
Ctrl+b :resize-pane -L 40 Resize current pane left by 40 cells
Ctrl+b :resize-pane -R 40 Resize current pane right by 40 cells
Ctrl+b :resize-pane -U 40 Resize current pane upward by 40 cells
Ctrl+b :resize-pane -t -L 40 Resize pane with id of 2 left by 40 cells
Ctrl+b :resize-pane -t 2 40 Resize pane with id of 2 down by 40 cells
## Connecting to remote nix system
Syntax : ssh user@remote_ip
Ex: ssh [email protected]
## Connecting to remote nix system without password
1.Genarate ssh-keygen with typeing this command 'ssh-keygen' and give info like ssh file name and password
Syntax : ssh-keygen
2.Then use 'ssh-copy-id' command to copy ssh key to remote system
Syntax : ssh-copy-id user@remote_ip
Ex: ssh-copy-id [email protected]
3.Now type ssh with remote user name and ip
Ex : ssh [email protected]
## Connect To Remote System with name ,no need of ip
##If you only want the name for ssh and ssh only, you can add a name to your ssh config in ~/.ssh/config
Syntax :
File : ~/.ssh/config
Host database
HostName <real IP address or hostname here>
User username
Ex:
Host Server
HostName 192.168.1.22
User lakshman
ssh Server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment