1

I'm tired of always writing sudo apt-get install <package> whenever I need to download something, so is there a way for me to make the terminal understand that when I write sagi <package>, I really mean sudo apt-get install <package>?

1 Answers1

4

Add this line to your ~/.bashrc

alias sagi='sudo apt-get install'

Then run source ~/.bashrc for the change to take effect.

Alternatively, you could add the line to .bash_aliases. This is a nice way to separate simple aliases from more substantive code that you might want to run when you start your bash shell. By default, your .bashrc should load in any definitions you make in .bash_aliases.

You may not have this file, so first:

touch ~/.bash_aliases

If the file already exists, touch will simply update its timestamp. If not, it will create it. Either way, open up your favorite text editor and add the alias line from above.

Zanna
  • 70,465
2-bits
  • 243
  • 1
    Actually, ~/.bash_aliases might be a more proper place. – heynnema May 24 '17 at 19:24
  • You might be right, I'll tweak the answer slightly – 2-bits May 24 '17 at 19:25
  • 1
    if you use the file ~/.bash_aliases you have to source it in ~/.bashrc, like:

    if [ -f ~/.bash-aliases ]; then . ~/.bash-aliases fi

    – jarleih May 24 '17 at 20:27
  • @jarleih I checked mine, it was already in there. I believe it's added by default. But you're right, it's not a guarantee. Things can change – 2-bits May 24 '17 at 20:46