Tip: Add Directory to $PATH - muhubi/PalWorldServer-Linux GitHub Wiki
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.
-
Check to see what is in your $PATH by using this command
echo $PATH
-
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) -
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.
-
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 endPATH=~/Steam/steamapps/common/PalServer:$PATH
. I recommend adding a note preceding the added string to explain what you are doing for future reference. -
To commit the change to the .bashrc file, press [ctrl + x] on your keyboard (like the "cut" command on Windows)
-
Pres [Y] to confirm committing the changes
-
Press [enter] to write the changes to .bashrc file, this will then exit the .bashrc file and close the nano text editor
-
Type
exit
to end your current session and then log back in using your user credentials -
Verify that your DIRECTORY has been added to $PATH
echo $PATH