Skip to content

Instantly share code, notes, and snippets.

@gdellicarpini
Last active April 8, 2024 19:02
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • 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 user@192.168.1.100"
    
  • 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"
    
@muriloinflue
Copy link

muriloinflue commented Nov 22, 2018

Nice gist. Thanks!

@ozyalhan
Copy link

Still works, thanks!

@baso034
Copy link

baso034 commented Apr 8, 2020

thx, it worked.

@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

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