Monday, January 26, 2015

How to Set Environment Variable on Solaris 10

How do I set environment variables on UNIX systems?

UNIX and all UNIX-like operating systems such as OpenBSD, Linux, Redhat, CentOS, Debian allows you to set environment variables. When you log in on UNIX, your current shell (login shell) sets a unique working environment for you which is maintained until you log out. Following are most command examples of environment variables used under UNIX operating systems:
  • PATH - Display lists directories the shell searches, for the commands.
  • HOME - User's home directory to store files.
  • TERM - Set terminal emulator being used by UNIX.
  • PS1 - Display shell prompt in the Bourne shell and variants.
  • MAIL - Path to user's mailbox.
  • TEMP - Path to where processes can store temporary files.
  • JAVA_HOME - Sun (now Oracle) JDK path.
  • ORACLE_HOME - Oracle database installation path.
  • TZ - Timezone settings
  • PWD - Path to the current directory.
  • HISTFILE - The name of the file in which command history is saved
  • HISTFILESIZE -The maximum number of lines contained in the history file
  • HOSTNAME -The system's host name
  • LD_LIBRARY_PATH -It is a colon-separated set of directories where libraries should be searched for.
  • USER -Current logged in user's name.
  • DISPLAY -Network name of the X11 display to connect to, if available.
  • SHELL -The current shell.
  • TERMCAP - Database entry of the terminal escape codes to perform various terminal functions.
  • OSTYPE - Type of operating system.
  • MACHTYPE - The CPU architecture that the system is running on.
  • EDITOR - The user's preferred text editor.
  • PAGER - The user's preferred text pager.
  • MANPATH - Colon separated list of directories to search for manual pages.

Display Environment Variable

Open the terminal and type the following commands to display all environment variables and their values under UNIX-like operating systems:
$ set
OR
$ printenv
OR
$ env
To display search path, enter:
 
echo $PATH
 
To display prompt settings, enter:
 
echo $PS1
 
A few more examples:
 
echo $USER
echo $PWD
echo $MAIL
echo $JAVA_PATH
echo $DB2INSTANCE
 

Change or Set Environment Variable

You can use the following command to change the environment variable for the current session as per your shell.

For Korn shell (KSH)

The syntax is as follows:
 
var=value
export var
 
To set JAVA_PATH, enter:
 
JAVA_PATH=/opt/jdk/bin
export JAVA_PATH
 

For Bourne shell (sh and bash)

The syntax is as follows:
 
export var=value
 
To set PATH, enter:
 
export PATH=$PATH:/opt/bin:/usr/local/bin:$HOME/bin
 

For C shell (csh or tcsh)

The syntax is as follows:
 
setenv var value
 
Set EDITOR to vim, enter:
 
setenv EDITOR vim
 

Example: UNIX C Shell Startup Configuration Files For Environment Variable

C shell use the following files:
  1. /etc/csh.login - It is executed if C shell is your login shell.
  2. $HOME/.cshrc and $HOME/.login - These files are executed every time C Shell starts. The ~/.login is csh login script, read by login shell, after ~/.cshrc at login.
The above set or setenv commands can be placed in the ~/.cshrc or ~/.login files. A sample $HOME/.cshrc file is as follows:
 
alias h  history 25
alias j  jobs -l
alias la ls -a
alias lf ls -FA
alias ll ls -lA
 
umask 22
 
set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin)
 
setenv EDITOR vi
setenv PAGER more
setenv BLOCKSIZE K
 
if ($?prompt) then
 # An interactive shell -- set some stuff up
 set filec
 set history = 100
 set savehist = 100
 set mail = (/var/mail/$USER)
 if ( $?tcsh ) then
  bindkey "^W" backward-delete-word
  bindkey -k up history-search-backward
  bindkey -k down history-search-forward
 endif
endif
 
# Traps CTRL-D's to avoid accidental system log off
set ignoreeof
 
# Set prompt
set prompt = "[\!] %"
 
# Sequentially keeps a buffer of your last events.
set history=100
set savehist=100
 
# Stops C Shell from overwriting and destroying the information in an existing file.
set noclobber
A sample ~/.login file is as follows:
 
# Show fortune :)
if ( -x /usr/games/fortune ) /usr/games/fortune
 
# Sets the system variable TERM to recognize the xterm
setenv TERM xterm
 
# This command sets the time zone variable
setenv TZ IST
 
# set PATH 
setenv PATH /opt/gnu/bin:/bin/posix:/bin:/usr/bin:/usr/local/bin:/etc:/users/vivek:.
 
# set mail box
set mail=/usr/mail/vivek
 
# alias bye is easier to remember 
alias bye logout
alias c clear
 
# read mail as soon as I get into the systems
mutt
 

Example: UNIX KSH Shell Startup Configuration Files For Environment Variable

KSH shell use the following files:
  1. /etc/profile - This default system file is executed by the KSH and sets up default environment variables.
  2. $HOME/.profile - Put your customization in this file.
A sample $HOME/.profile for the ksh shell:
 
PATH=/opt/gnu/bin:/bin/posix:/usr/bin:/usr/lib:/bin:/users/v/vivek/bin
MAIL=/usr/mail/vivek
HOME=/users/vivek
EDITOR=/opt/gnu/bin/vim
START=~/.kshrc
TERM=xterm
 
# export it
export ENV START EDITOR TERM PATH MAIL HOME
stty sane susp ^Z
 
# email notification 
if mail -e
then
   echo "You have mail."
fi
 
# prompt
PS1="$ "
 
# Check system messages
msgs -q
 
# Allow terminal messages
mesg y
 
Credits to www.cyberciti.biz

Friday, January 23, 2015

How to add or change the default gateway/default route on Solaris 10

The Default Gateway or the Default Router is the IP address (IPv4) to which all the traffic to any target destination(s) which does not have a route in the Routing Table of the server will be forwarded.
This Default Gateway is maintained in the file
/etc/defaultrouter [IPv4 only]
This IP Address should be in the same network or the subnet as that of the server itself.
If you wish to add or edit the Default Gateway or the Default Router in Sun Solaris, edit /etc/defaultrouter file and update the IP Address. One entry per line for one or more default gateways (very unlikely to have muktiple default gateways).
This file is read at the boot time and hence the server needs to be rebooted for the changes to take effect.
Instead of rebooting the server, update the Kernel IP Routing table first by deleting the existing Default Gateway or Default Router (if any) and then adding the new IP address.
To view the existing Kernel IP Routing table,
# netstat -rn
Routing Table: IPv4
Destination           Gateway           Flags  Ref     Use     Interface
——————– ——————– —– —– ———- ———
192.168.1.0          192.168.1.10         U         1        195 hme0
224.0.0.0            192.168.1.10          U          1          0 hme0
default              192.168.1.1             UG        1        325
127.0.0.1            127.0.0.1               UH        5         92 lo0
Now, remove the dexisting default gateway;
# route delete default 172.1.1.1
Add the new Default Gateway using:
# route add default 192.168.1.1
This should help. For a detailed Man Page for /etc/defaultrouter

How to reboot Solaris 10

Shut Down or Reboot a Solaris System

Solaris is usually used as a server operating system. Because of this, you want to make sure that you shut the system down as gracefully as possible to ensure there isn’t any data loss.
For every application that is installed on your server, you should make sure that you have the correct scripts in /etc/rc(x).d to gracefully shut down the service.
ShutdownYou have more than one command option that you can use. The best command is this, executed as root:
shutdown -y -i5 -g0
This will immediately shut the system down. You can also use the older command that still works:
sync;sync;init 5
You can even use:
poweroff
Reboot
If you are trying to reboot the system as opposed to turning it off, you could use:
shutdown -y -i6 -g0
Or:
sync;sync;init 6
Or even:
reboot

Thursday, January 22, 2015

How to check your symbolic link in Solaris 10

#echo $PATH

$PATH - Contains $SOFTWARE_REP/config/bin

where $SOFTWARE_REP is another symbolic link with subpath.


How to create a symbolic link on Solaris 10

Hard link vs. Soft link in Linux or UNIX

[a] Hard links cannot links directories ( cannot link /tmp with /home/you/tmp)
[b] Hard links cannot cross file system boundaries ( cannot link /tmp mounted on/tmp to 2nd hard disk mounted on /harddisk2)
[c] Symbolic links refer to a symbolic path indicating the abstract location of another file
[d] Hard links, refer to the specific location of physical data.

UNIX create a symbolic link command

To create a symbolic link, enter:
$ ln -s {/path/to/file-name} {link-name}
$ ln -s /shared/sales/data/file.txt sales.data.txt
$ vi sales.data.txt
$ ls -l sales.data.txt

How do I delete a symbolic link?

To delete a link, enter:
$ rm {link-name}
$ rm sales.data.txt
$ ls -l
$ ls -l /shared/sales/data/file.txt

If you delete the soft link itself (sales.data.txt) , the data file would still be there ( /shared/sales/data/file.txt ). However, if you delete /shared/sales/data/file.txt, sales.data.txt becomes a broken link and data is lost.

UNIX create a hardlink command

To create hard link, enter (without the -s option):
$ ln {file.txt} {hard-link}
$ ln /tmp/file link-here

How do I delete a hard link?

You can delete hard link with the rm command itself:
$ rm {hard-link}
$ rm link-here

If you delete a hard link, your data would be there. If you delete /tmp/file your data still be accessible via link-here hard link file.

How to add an Alias on Solaris 10

An alias is nothing but shortcut to commands. The alias command allows user to launch any command or group of commands (including options and filenames) by entering a single word. Use alias command to display list of all defined aliases. You can add user defined aliases to ~/.bashrc file. You can cut down typing time with these aliases, work smartly, and increase productivity at the command prompt.


More about aliases

The general syntax for the alias command for the bash shell is as follows.

Task: List aliases

Type the following command:
 
alias
 
Sample outputs:
alias ..='cd ..'
alias amazonbackup='s3backup'
alias apt-get='sudo apt-get'
...
By default alias command shows a list of aliases that are defined for the current user.

Task: Define / create an alias (bash syntax)

To create the alias use the following syntax:
 
alias name=value
alias name='command'
alias name='command arg1 arg2'
alias name='/path/to/script'
alias name='/path/to/script.pl arg1'
 
In this example, create the alias c for the commonly used clear command, which clears the screen, by typing the following command and then pressing the ENTER key:
 
alias c='clear'
 
Then, to clear the screen, instead of typing clear, you would only have to type the letter 'c' and press the [ENTER] key:
 
c
 

Task: Disable an alias temporarily (bash syntax)

An alias can be disabled temporarily using the following syntax:
 
## path/to/full/command
/usr/bin/clear
## call alias with a backslash ##
\c
 

Task: Remove an alias (bash syntax)

You need to use the command called unalias to remove aliases. Its syntax is as follows:
 
unalias aliasname
 
In this example, remove the alias c which was created in an earlier example:
 
unalias c
 
You also need to delete the alias from the ~/.bashrc file using a text editor (see next section).

Task: Make aliases permanent (bash syntax)

The alias c remains in effect only during the current login session. Once you logs out or reboot the system the alias c will be gone. To avoid this problem, add alias to your ~/.bashrc file, enter:
 
vi ~/.bashrc
 
The alias c for the current user can be made permanent by entering the following line:
 
alias c='clear'
 
Save and close the file. System-wide aliases (i.e. aliases for all users) can be put in the /etc/bashrc file. Please note that the alias command is built into a various shells including ksh, tcsh/csh, ash, bash and others.

A note about privileged access

You can add code as follows in ~/.bashrc:
 
# if user is not root, pass all commands via sudo #
if [ $UID -ne 0 ]; then
    alias reboot='sudo reboot'
    alias update='sudo apt-get upgrade'
fi
 

A note about os specific aliases

You can add code as follows in ~/.bashrc using the case statement:
 
### Get os name via uname ###
_myos="$(uname)"
 
### add alias as per os using $_myos ###
case $_myos in
   Linux) alias foo='/path/to/linux/bin/foo';;
   FreeBSD|OpenBSD) alias foo='/path/to/bsd/bin/foo' ;;
   SunOS) alias foo='/path/to/sunos/bin/foo' ;;
   *) ;;
esac
 

30 uses for aliases

You can define various types aliases as follows to save time and increase productivity.

#1: Control ls command output

The ls command lists directory contents and you can colorize the output:
 
## Colorize the ls output ##
alias ls='ls --color=auto'
 
## Use a long listing format ##
alias ll='ls -la'
 
## Show hidden files ##
alias l.='ls -d .* --color=auto'
 

#2: Control cd command behavior

 
## get rid of command not found ##
alias cd..='cd ..'
 
## a quick way to get out of current directory ##
alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'
alias .....='cd ../../../../'
alias .4='cd ../../../../'
alias .5='cd ../../../../..'
 

#3: Control grep command output

grep command is a command-line utility for searching plain-text files for lines matching a regular expression:
 
## Colorize the grep command output for ease of use (good for log files)##
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
 

#4: Start calculator with math support

 
alias bc='bc -l'
 

#4: Generate sha1 digest

 
alias sha1='openssl sha1'
 

#5: Create parent directories on demand

mkdir command is used to create a directory:
 
alias mkdir='mkdir -pv'
 

#6: Colorize diff output

You can compare files line by line using diff and use a tool called colordiff to colorize diff output:
 
# install  colordiff package :)
alias diff='colordiff'
 

#7: Make mount command output pretty and human readable format

 
alias mount='mount |column -t'
 

#8: Command short cuts to save time

 
# handy short cuts #
alias h='history'
alias j='jobs -l'
 

#9: Create a new set of commands

 
alias path='echo -e ${PATH//:/\\n}'
alias now='date +"%T"'
alias nowtime=now
alias nowdate='date +"%d-%m-%Y"'
 

#10: Set vim as default

 
alias vi=vim
alias svi='sudo vi'
alias vis='vim "+set si"'
alias edit='vim'
 

#11: Control output of networking tool called ping

 
# Stop after sending count ECHO_REQUEST packets #
alias ping='ping -c 5'
# Do not wait interval 1 second, go fast #
alias fastping='ping -c 100 -s.2'
 

#12: Show open ports

Use netstat command to quickly list all TCP/UDP port on the server:
 
alias ports='netstat -tulanp'
 

#13: Wakeup sleeping servers

Wake-on-LAN (WOL) is an Ethernet networking standard that allows a server to be turned on by a network message. You can quickly wakeup nas devices and server using the following aliases:
 
## replace mac with your actual server mac address #
alias wakeupnas01='/usr/bin/wakeonlan 00:11:32:11:15:FC'
alias wakeupnas02='/usr/bin/wakeonlan 00:11:32:11:15:FD'
alias wakeupnas03='/usr/bin/wakeonlan 00:11:32:11:15:FE'
 

#14: Control firewall (iptables) output

Netfilter is a host-based firewall for Linux operating systems. It is included as part of the Linux distribution and it is activated by default. This post list most common iptables solutions required by a new Linux user to secure his or her Linux operating system from intruders.
 
## shortcut  for iptables and pass it via sudo#
alias ipt='sudo /sbin/iptables'
 
# display all rules #
alias iptlist='sudo /sbin/iptables -L -n -v --line-numbers'
alias iptlistin='sudo /sbin/iptables -L INPUT -n -v --line-numbers'
alias iptlistout='sudo /sbin/iptables -L OUTPUT -n -v --line-numbers'
alias iptlistfw='sudo /sbin/iptables -L FORWARD -n -v --line-numbers'
alias firewall=iptlist
 

#15: Debug web server / cdn problems with curl

 
# get web server headers #
alias header='curl -I'
 
# find out if remote server supports gzip / mod_deflate or not #
alias headerc='curl -I --compress'
 

#16: Add safety nets

 
# do not delete / or prompt if deleting more than 3 files at a time #
alias rm='rm -I --preserve-root'
 
# confirmation #
alias mv='mv -i'
alias cp='cp -i'
alias ln='ln -i'
 
# Parenting changing perms on / #
alias chown='chown --preserve-root'
alias chmod='chmod --preserve-root'
alias chgrp='chgrp --preserve-root'
 

#17: Update Debian Linux server

apt-get command is used for installing packages over the internet (ftp or http). You can also upgrade all packages in a single operations:
 
# distro specific  - Debian / Ubuntu and friends #
# install with apt-get
alias apt-get="sudo apt-get"
alias updatey="sudo apt-get --yes"
 
# update on one command 
alias update='sudo apt-get update && sudo apt-get upgrade'
 

#18: Update RHEL / CentOS / Fedora Linux server

yum command is a package management tool for RHEL / CentOS / Fedora Linux and friends:
 
## distrp specifc RHEL/CentOS ##
alias update='yum update'
alias updatey='yum -y update'
 

#19: Tune sudo and su

 
# become root #
alias root='sudo -i'
alias su='sudo -i'
 

#20: Pass halt/reboot via sudo

shutdown command bring the Linux / Unix system down:
 
# reboot / halt / poweroff
alias reboot='sudo /sbin/reboot'
alias poweroff='sudo /sbin/poweroff'
alias halt='sudo /sbin/halt'
alias shutdown='sudo /sbin/shutdown'
 

#21: Control web servers

 
# also pass it via sudo so whoever is admin can reload it without calling you #
alias nginxreload='sudo /usr/local/nginx/sbin/nginx -s reload'
alias nginxtest='sudo /usr/local/nginx/sbin/nginx -t'
alias lightyload='sudo /etc/init.d/lighttpd reload'
alias lightytest='sudo /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -t'
alias httpdreload='sudo /usr/sbin/apachectl -k graceful'
alias httpdtest='sudo /usr/sbin/apachectl -t && /usr/sbin/apachectl -t -D DUMP_VHOSTS'
 

#22: Alias into our backup stuff

 
# if cron fails or if you want backup on demand just run these commands # 
# again pass it via sudo so whoever is in admin group can start the job #
# Backup scripts #
alias backup='sudo /home/scripts/admin/scripts/backup/wrapper.backup.sh --type local --taget /raid1/backups'
alias nasbackup='sudo /home/scripts/admin/scripts/backup/wrapper.backup.sh --type nas --target nas01'
alias s3backup='sudo /home/scripts/admin/scripts/backup/wrapper.backup.sh --type nas --target nas01 --auth /home/scripts/admin/.authdata/amazon.keys'
alias rsnapshothourly='sudo /home/scripts/admin/scripts/backup/wrapper.rsnapshot.sh --type remote --target nas03 --auth /home/scripts/admin/.authdata/ssh.keys --config /home/scripts/admin/scripts/backup/config/adsl.conf'
alias rsnapshotdaily='sudo  /home/scripts/admin/scripts/backup/wrapper.rsnapshot.sh --type remote --target nas03 --auth /home/scripts/admin/.authdata/ssh.keys  --config /home/scripts/admin/scripts/backup/config/adsl.conf'
alias rsnapshotweekly='sudo /home/scripts/admin/scripts/backup/wrapper.rsnapshot.sh --type remote --target nas03 --auth /home/scripts/admin/.authdata/ssh.keys  --config /home/scripts/admin/scripts/backup/config/adsl.conf'
alias rsnapshotmonthly='sudo /home/scripts/admin/scripts/backup/wrapper.rsnapshot.sh --type remote --target nas03 --auth /home/scripts/admin/.authdata/ssh.keys  --config /home/scripts/admin/scripts/backup/config/adsl.conf'
alias amazonbackup=s3backup
 

#23: Desktop specific - play avi/mp3 files on demand

 
## play video files in a current directory ##
# cd ~/Download/movie-name 
# playavi or vlc 
alias playavi='mplayer *.avi'
alias vlc='vlc *.avi'
 
# play all music files from the current directory #
alias playwave='for i in *.wav; do mplayer "$i"; done'
alias playogg='for i in *.ogg; do mplayer "$i"; done'
alias playmp3='for i in *.mp3; do mplayer "$i"; done'
 
# play files from nas devices #
alias nplaywave='for i in /nas/multimedia/wave/*.wav; do mplayer "$i"; done'
alias nplayogg='for i in /nas/multimedia/ogg/*.ogg; do mplayer "$i"; done'
alias nplaymp3='for i in /nas/multimedia/mp3/*.mp3; do mplayer "$i"; done'
 
# shuffle mp3/ogg etc by default #
alias music='mplayer --shuffle *'
 

#24: Set default interfaces for sys admin related commands

vnstat is console-based network traffic monitor. dnstop is console tool to analyze DNS traffic.tcptrack and iftop commands displays information about TCP/UDP connections it sees on a network interface and display bandwidth usage on an interface by host respectively.
 
## All of our servers eth1 is connected to the Internets via vlan / router etc  ##
alias dnstop='dnstop -l 5  eth1'
alias vnstat='vnstat -i eth1'
alias iftop='iftop -i eth1'
alias tcpdump='tcpdump -i eth1'
alias ethtool='ethtool eth1'
 
# work on wlan0 by default #
# Only useful for laptop as all servers are without wireless interface
alias iwconfig='iwconfig wlan0'
 

#25: Get system memory, cpu usage, and gpu memory info quickly

 
## pass options to free ## 
alias meminfo='free -m -l -t'
 
## get top process eating memory
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
 
## get top process eating cpu ##
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'
 
## Get server cpu info ##
alias cpuinfo='lscpu'
 
## older system use /proc/cpuinfo ##
##alias cpuinfo='less /proc/cpuinfo' ##
 
## get GPU ram on desktop / laptop## 
alias gpumeminfo='grep -i --color memory /var/log/Xorg.0.log'
 

#26: Control Home Router

The curl command can be used to reboot Linksys routers.
 
# Reboot my home Linksys WAG160N / WAG54 / WAG320 / WAG120N Router / Gateway from *nix.
alias rebootlinksys="curl -u 'admin:my-super-password' 'http://192.168.1.2/setup.cgi?todo=reboot'"
 
# Reboot tomato based Asus NT16 wireless bridge 
alias reboottomato="ssh admin@192.168.1.1 /sbin/reboot"
 

#27 Resume wget by default

The GNU Wget is a free utility for non-interactive download of files from the Web. It supports HTTP, HTTPS, and FTP protocols, and it can resume downloads too:
 
## this one saved by butt so many times ##
alias wget='wget -c'
 

#28 Use different browser for testing website

 
## this one saved by butt so many times ##
alias ff4='/opt/firefox4/firefox'
alias ff13='/opt/firefox13/firefox'
alias chrome='/opt/google/chrome/chrome'
alias opera='/opt/opera/opera'
 
#default ff 
alias ff=ff13
 
#my default browser 
alias browser=chrome
 

#29: A note about ssh alias

Do not create ssh alias, instead use ~/.ssh/config OpenSSH SSH client configuration files. It offers more option. An example:
 
Host server10
  Hostname 1.2.3.4
  IdentityFile ~/backups/.ssh/id_dsa
  user foobar
  Port 30000
  ForwardX11Trusted yes
  TCPKeepAlive yes
 
You can now connect to peer1 using the following syntax: $ ssh server10

#30: It's your turn to share...

 
## set some other defaults ##
alias df='df -H'
alias du='du -ch'
 
# top is atop, just like vi is vim
alias top='atop'
 
## nfsrestart  - must be root  ##
## refresh nfs mount / cache etc for Apache ##
alias nfsrestart='sync && sleep 2 && /etc/init.d/httpd stop && umount netapp2:/exports/http && sleep 2 && mount -o rw,sync,rsize=32768,wsize=32768,intr,hard,proto=tcp,fsc natapp2:/exports /http/var/www/html &&  /etc/init.d/httpd start'
 
## Memcached server status  ##
alias mcdstats='/usr/bin/memcached-tool 10.10.27.11:11211 stats'
alias mcdshow='/usr/bin/memcached-tool 10.10.27.11:11211 display'
 
## quickly flush out memcached server ##
alias flushmcd='echo "flush_all" | nc 10.10.27.11 11211'
 
## Remove assets quickly from Akamai / Amazon cdn ##
alias cdndel='/home/scripts/admin/cdn/purge_cdn_cache --profile akamai'
alias amzcdndel='/home/scripts/admin/cdn/purge_cdn_cache --profile amazon'
 
## supply list of urls via file or stdin
alias cdnmdel='/home/scripts/admin/cdn/purge_cdn_cache --profile akamai --stdin'
alias amzcdnmdel='/home/scripts/admin/cdn/purge_cdn_cache --profile amazon --stdin'
 

Conclusion

This post summaries several types of uses for *nix bash aliases:
  1. Setting default options for a command (e.g. set eth0 as default option - alias ethtool='ethtool eth0' ).
  2. Correcting typos (cd.. will act as cd .. via alias cd..='cd ..').
  3. Reducing the amount of typing.
  4. Setting the default path of a command that exists in several versions on a system (e.g. GNU/grep is located at /usr/local/bin/grep and Unix grep is located at /bin/grep. To use GNU grep use alias grep='/usr/local/bin/grep' ).
  5. Adding the safety nets to Unix by making commands interactive by setting default options. (e.g. rm, mv, and other commands).
  6. Compatibility by creating commands for older operating systems such as MS-DOS or other Unix like operating systems (e.g. alias del=rm ).
I've shared my aliases that I used over the years to reduce the need for repetitive command line typing. If you know and use any other bash/ksh/csh aliases that can reduce typing, share below in the comments.
Credits to: www.cyberciti.biz