Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set aliases globally for all users

Tags:

bash

unix

I have certain paths, which are too long to type, so I need to wrap all those in one script as alias and source that script to my existing package code.

These should set alias permanently over that server or over the package, so every user can use the alias instead typing the whole path.

alias bc='bc -l'
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i' 
alias grep='grep --color'
alias update='yum update'
alias update='yum -y update'

I have tried this but it isn't working.

like image 940
naveen kanni Avatar asked Dec 14 '22 13:12

naveen kanni


1 Answers

Old thread, but I figured out what to do using the great post from Shivams. The following is step by step of what I did on Raspberry Pi:

sudo nano /etc/bash.bashrc

Add the aliases to the bottom, you can keep comments to be useful, such as:

alias ll="ls -al" #Adds alias for ll to show all files and folders

alias cls="clear" #Adds alias for cls to clear screen

alias temp="vcgencmd measure_temp" #Get the system temperature

Ctrl+s to save, then then Ctrl+x to exit

They won't work for your current session, so log off the terminal and back in.

like image 85
Aubs Avatar answered Dec 31 '22 14:12

Aubs