banner
Previous Page
PCLinuxOS Magazine
PCLinuxOS
Article List
Disclaimer
Next Page

Create A /bin Executable Directory In Your /home Directory

by Matthew Kelley, via Google+
Reprinted with permission

Here's a Linux tip for the newer users. It’s something that might make a few things clearer, while making your system a bit easier to use.

Some distributions give you a /home/USERNAME/bin folder. The idea behind this folder is that it gives you a place to put executable scripts. If the folder is pre-existing on your distro, it will almost assuredly be placed in your PATH.

Your PATH, for our purposes, is defined as the listing of directories that your shell searches for executable files. In simple terms, it's the difference between pulling up the terminal and being able to execute a program by typing in "fu", versus typing /home/USERNAME/applications/fu_folder/fu.

If you don't already have a "bin" folder (and you don’t, by default, in PCLinuxOS), you can create one, and then manually add it to your path by editing your /home/USERNAME/.bashrc file and adding export PATH=$PATH:$HOME/bin.

Now, there are many different ways to use this folder and your PATH to your advantage, but I'll give you a simple usage scenario using the “Run Program” dialog box that is called with the Alt + F2 command on most desktop environments.

Lets say you have downloaded a game that isn't in your distribution's repositories. (Reminder: PCLinuxOS users are discouraged from installing applications from outside the official PCLinuxOS repository). We'll go with the roguelike game "Infra Arcana," in this instance. Let's assume we unzip the game to /home/USERNAME/applications/InfraArcana, and that the game's executable is called "ia."

The first thing we'll do is create a script called ia.sh, inside the InfraArcana folder. The contents of this script will be as follows. Of course, you'll have to change the USERNAME, as necessary:

#!/bin/bash

cd /home/USERNAME/applications/InfraArcana/

./ia

exit 0

The script above does two things. It changes the working directory to the one the game will need, and it issues the command to start the game.

Next, we'll set the script as executable. You can do this by right clicking on the script in most file managers and selecting "Properties" and then "Permissions" and toggling it to executable. Alternatively you can bring up the terminal, change to the game’s directory and issue the command chmod +x ia.sh.

Now, we can change to the /home/USERNAME/bin folder in our terminal and create a symbolic link to this script. You can do this from the command line with

ln -s /home/USERNAME/applications/InfraArcana/ia.sh infra

What this does is create a symbolic link named "infra" in the /home/USERNAME/bin folder (similar to a shortcut on Windows) that points to our script in the game folder.

At this point, you will find that you can launch the game by bringing up the terminal and typing in "infra" and hitting enter. You can also launch other programs installed by your package manager. Alt-F2, which brings up a "run" dialog on most desktop environments, will also launch the game with "infra."



Previous Page              Top              Next Page
Copyright (c) 2013, The PCLinuxOS Magazine. All Rights Reserved.