and is followed by the absolute path to the interpreter.
Step 2 — RWXperson swinging an axe with the caption “I love my job”If we try to run tiempo -h to get the help screen, it will throw an error about not having correct permissions.
This is because by default any file you create does not have execution permissions, meaning it cannot be run directly by the operating system.
There are three types of permissions: Read, Write, and Execute.
To check the permissions of a file or directory we can run ls -l <file_name>.
There may be a lot of symbols and letters, but to make things simple:r is for readw is for writeand x is for execute.
And to change the permissions (or mode) we can use this handy command chmod, which ch(anges) the mod(e) of the file.
In our case, all we need to run in our consolechmod +x bin/tiempoThis line adds execution permission to our file and now we can run tiempo -h from our directory in the console.
Step 3 — Back to the BinUp until now, this command will only work by calling the path to the bin directory.
But, we want to be able to call it anywhere.
To do this, we must abstract the path finding done by the operating system.
$PATH is our answer.
In UNIX based systems, there is an environment variable called $PATH that Is used to look up commands.
To check your path, type echo $PATH.
These are all the locations the operating system will look for commands in the console.
So, if we wanted to add a path to our specific program, all we have to do is run#in terminalexport PATH=$PATH:/path/to/the/fileNote: The name of the command by default is the name of the file.
Now everything will work as expected from anywhere in the profile!.The final issue occurs, however, when we restart.
Since $PATH environment variable is created each time we begin a session and our changes aren’t saved in between session, the new path we added only exists until we close the console.
To alleviate this, all we need to do add the path to the correct file when the shell launches.
Since bash is our shell, we will add the following code to our .
bashrc file in our home directory.
bashrcexport PATH=$PATH:/place/with/the/fileNote: This file is specific for the shell that you are using, and must be configured for every shell that is being used.
Wrap UpNow everything works the way it is intended and we can check the weather from anywhere in our console.
Many languages have libraries and frameworks that automates this task for you.
For example, you do not need to do this process every time you install a new ruby gem or some python libraries.
However, this is important to know for smaller scale testing and to understand the process in case you choose to automate this in the future.
htm#filepermissionsMake your own gem – RubyGems GuidesTutorials, guides, FAQs for RubyGems package managementguides.