Linux Shortcuts, single word, everyday aliases | Send emails with one command

Author: aashutosh

Updated: 15 Feb 2023 8:47 p.m.

Tags: #Linux

Summary : Use aliases or shortcuts to fasten tasks and ease operations for lengthy & repeated tasks using one command

Use aliases or shortcuts to fasten tasks and ease operations for lengthy & repeated tasks using one command.
Make aliases in user home ( ~/.bashrc) or global (/etc/bashrc) file.

reload . ~/.bash_profile to load aliases

 

Shortcut to send email with attachment

# Alias to send any file as email
# usage : $ mailme <file-name> [optional extra recipients  email addresses]
alias mailme='/home/aashu/scripts/mailme.sh $1'

 

Create a script, which can be called when alias mailme is called. This script will take positional arguments i.e. files to send and optional extra recipients email addresses, passed to the mailme alias.

cat /home/aashu/scripts/email.sh
echo "$1" | mailx -a $1 -s "$1" -r aashutosh0012@gmail.com aashutosh0012@gmail.com

 

Most used common Examples

cat .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

#alias to list files
alias l='ls -ltrh'

#alias to list all files including hidden -a
alias la='ls -latrh'

# Oracle Database aliases
alias sql='sqlplus / as sysdba'
alias ORCL1='export ORACLE_SID=ORCL1; . oraenv'
alias ORCL2='export ORACLE_SID=ORCL2; . oraenv'
alias ORCL3='export ORACLE_SID=ORCL3; . oraenv'

# Alias to list running oracle's pmon processes
alias pmon='ps -ef | grep pmon'