Tip: Add Directory to $PATH - muhubi/PalWorldServer-Linux GitHub Wiki

How to Geek Reference

Adding commonly used directories to $PATH in Linux can be very useful, especially for a dedicated server where the commands being used are repetitive.

What is $PATH on your Linux Server, and why is it important?

The $PATH in Linux is the list of locations/directories that gets checked by the OS whenever a command is executed. This means that instead of typing cd ~/Steam/steamapps/common/PalServer before running ./PalServer, you can just type in PalServer into the shell to start the application.

Add a Directory to $PATH

For this Wiki, we will be referencing specifically the PalServer, but this translates to other directories.

  1. Check to see what is in your $PATH by using this command echo $PATH

  2. Use your preferred text editor to access the .bashrc file, for this example we will use the built-in nano editor nano .bashrc (sudo privileges are not required since we are editing the $PATH for the user and not root)

  3. This will open the .bashrc file using the nano text editor, exercise caution. Scroll to the bottom of the file and press [ENTER] to add a whitespace line.

  4. Append the following string to the end of the file export PATH=/DIRECTORY:$PATH (replace DIRECTORY with your directory). For our example add this exact string to the end PATH=~/Steam/steamapps/common/PalServer:$PATH. I recommend adding a note preceding the added string to explain what you are doing for future reference. image

  5. To commit the change to the .bashrc file, press [ctrl + x] on your keyboard (like the "cut" command on Windows) image

  6. Pres [Y] to confirm committing the changes image

  7. Press [enter] to write the changes to .bashrc file, this will then exit the .bashrc file and close the nano text editor image

  8. Type exit to end your current session and then log back in using your user credentials

  9. Verify that your DIRECTORY has been added to $PATH echo $PATH image