0

I am pretty new to linux/bash, and I have just recently learned about symlinks. I spend a lot of time at work logging on to various web servers using ssh and our server provider has some horrible long domains. Is it possible to use symlinks in a manner that will allow me to simply type a single designation to ssh to the server?

example:

ln -s ssh customer@host customer

then use 'customer' as a single command to run the ssh command ?

Suraj Rao
  • 627
  • 2
  • 7
  • 15
c2aFrederick
  • 3
  • 1
  • 2
  • 1
    Symlinks are for files - so you'll need to create a script with that command in it and the symlink it (or not). You're looking for the wrong thing here, use SSH configuration + bash aliases or functions instead. – muru Jun 23 '17 at 06:19

1 Answers1

1

What you want is an alias. An alias is made like this:
alias somecommand="someotherverylongcommandwithaverylongcommandname thearguments"
Then, you can run somecommand and it will run the other command. To make it permanent, however, you need to edit your ~/.bash_aliases file. Open it in your prefered text editor and put in the alias command. Then, the alias will be set on bash startup.
Note: You may need to create the ~/.bash_aliases file. Also, ~ is the /home/username folder. Also, the . at the beginning means that the file is hidden.

  • I would recommend to combine this with a ~.ssh/config configuration. so using an alias is only for a short naming, but using a custom-ssh config can shorten calling special connection configurations. – 0x0C4 Jun 23 '17 at 06:38
  • @lkj I didn't know about that file, but I chose to explain aliases as they are more variable. (You can use them with any command, not only with ssh) Thanks for the tip, though! – Kryštof Píštěk Jun 23 '17 at 06:40