Creating a bash alias on a Synology DiskStation
The Problem
On main usage of my SSH access to my Synology DiskStation is to start the headless JDownloader that’s stored inside a subfolder on my user profile there. This includes logging in, changing directory to the JD path and executing the jar file there. Because JD is often updated and the Java process itself can become quite garbaged over time I need to do this quite regularly. Wouldn’t it be nice to have a single custom command I could use after logging in? Use an alias! It’s also available on a DiskStation.
Creating the aliases
To write your aliases create a file named bash_aliases.txt
somewhere, e.g. under /volume1/homes/YOUR_USER/
and open it with an editor of your choice. Now type in an alias following the template
alias COMMAND='what ; to ; do'
For example I created an alias called ‘startjd’ which first goes into the directory cd JDownloader
and then executes the jar file with java -jar JDownloader.jar -norestart
and going up again cd ..
.
Link your aliases to bashrc
Now we need to tell bash to use our textfile to look for aliases. Simply use these commands to create a symlink between the textfile and the .bashrc. And execute them as your user, not root!
cd /var/services/homes/username
ln -s /volume1/docker/bash_aliases.txt .bashrc
. ~/.bashrc
You’re done. You can check if the symlink is created successfully by typing ls -al
and you should see something like this
Now you can use your alias command in your terminal. :)