LINUX - Alias - Color Bash

To get a colored prompt

Look  at my link on the left: LINUX - Cool PS1 - Cool BASH Prompt

Add the following line to:

/etc/bash.bashrc

or

~/.bashrc

source /etc/alias-by-koss

Using this command

# echo "source /etc/alias-by-koss" >> /etc/bash.bashrc

dont forget the double > or you will delete the previous entries

# touch /etc/alias-by-koss
# chmod +x /etc/alias-by-koss
# vim /etc/alias-by-koss

add the following lines (to insert text hit "i", to save and exit hit ESC then type ":wq!" and hit ENTER)

#!/bin/bash
alias c='clear'
## 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'
## get rid of command not found ##
alias cd..='cd ..'
## 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'
# install  colordiff package :)
alias diff='colordiff'
# 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"'
#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
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'
## All of our servers eth1 is connected to the Internets via vlan / router etc  ##
alias dnstop='dnstop -l 5  eth0'
# alias vnstat='vnstat -i eth0'
alias iftop='iftop -i eth0'
# alias tcpdump='tcpdump -i eth0'
alias ethtool='ethtool eth0'
alias ddu='du --max-depth 1'


Save and exit and now you should get a colored environment. Also remember to check out the PS1 link to get a colored prompt.

Some of those aliases are HASHed out and you can unhash them as needed. Also you can HASH out ones you dont like. HASH meaning it will comment the line out using the # at the front of the line. The line that is HASHed out will be ignored.

Note some of those programs need to be installed

# apt-get install vim
# apt-get install ethtool
# apt-get install atop
# apt-get install iftop
# apt-get install dnstop
# apt-get install colordiff



Comments