linuxdirectory

How to make an alias's command for changing directories work for all users without changing the path for every user


I've made a script in "/etc/profile.d/" that creates aliases upon login. However, all the commands work with only my user's directory. For example, if I have 3 users: Bob, Dan, and Nat, the alias I created would be alias Doc='cd /home/Bob/Documents'. I'd like to change the "Bob" part of the directory so if Nat or Dan use it, it'll work for them.

I've tried getting the users to change it themselves, but after a while it becomes repetitive to do so for every change I make. Please help, I'm new to Linux.


Solution

  • I'd like to change the "Bob" part of the directory so if Nat or Dan use it, it'll work for them.

    alias Doc='cd /home/$USER/Documents'