[Linux] Useful Functions and Aliases

You are here:
  • Main
  • Linux
  • [Linux] Useful Functions and Aliases
< All Topics

Hello everybody,

today we’re going to talk about useful aliases and functions that you can define in your bash profile, following this previous article.

Backup File

function backup_file(){
cp -p $1 $1.$(date +%d%m%y_%H%M)

In this way you can create a backup in very simple and short way and with the same naming convention.

Get Oracle log location

function log(){
alert=$(sqlplus -s / as sysdba <<EOF
set heading off
select inst_id,name,value from v\$diag_info where name = 'Diag Trace';
ls $(echo $alert | tail -1 | awk '{print $NF}')/alert*.log

In this way you don’t need to remember your ORACLE_BASE and DB_NAME, just type log and you will have your actual alert log.

Get all running Oracle services

function services(){
DB_NAME=$(sqlplus -s / as sysdba <<EOF
set heading off
select name from v\$database;
srvctl status service -d $DB_NAME

In this way you can check all services of your database through srvctl. This is helpful if your db_name is slightly different from instance name.

Stop all runing docker containers

alias st_ru_dock="docker ps | awk '{print \$1}' | grep -v CONTA | xargs docker stop"

In this way, with a single command you can stop all running docker containers.

That’s it, this are my set of useful aliases and functions.


Table of Contents