Skip to content

Instantly share code, notes, and snippets.

@gdellicarpini
Last active July 21, 2024 22:28
Show Gist options
  • Save gdellicarpini/f0229a26e453eb4aea2e9a7299540346 to your computer and use it in GitHub Desktop.
Save gdellicarpini/f0229a26e453eb4aea2e9a7299540346 to your computer and use it in GitHub Desktop.
Add permanent aliases in Linux CentOS

Aliases for all users

  • Create a file in /etc/profile.d/ directory

      - myAlias.sh
    
  • Define the alias in the file

      alias gotoserver1="ssh [email protected]"
    
  • Give right permission to the file

      chmod 755 myAlias.sh
    
  • Restart SSH session exiting terminal and opening a new one (or use source /etc/profile.d/myAlias.sh)

Alias for a specific user

  • To create an alias permanently add the alias to your .bashrc file

      sudo vi ~/.bashrc
    
  • And then add your alias at the bottom

      alias ls="ls -l"
    
@jasonwiener
Copy link

thanks!

@Bonjur
Copy link

Bonjur commented Jan 20, 2021

Still works, thanks!

ofc 🤣

@lennydavila
Copy link

If you want it permanent which is what the tile says ( Add permanent aliases in Linux CentOS ) should we also finish with
source ~/.bashrc

@lx78WyY0J5
Copy link

lx78WyY0J5 commented Jul 21, 2024

Dont work for me PERMANENTLY
After sourcing the .sh it work, but when you close & reopen terminal, it wont work anymore
Not on a SSH, i'm using a VM with debian 12

It's so much better to just do it in ~/.bash_aliases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment