How do I run a program I created on Linux from my device as a command?
I'm using Ubuntu
It's like running a Hello World or a program with the hi command.
The ultimate goal is
1. Make the command available to all users on the same machine, then
Place the generated executable in the directory contained in the
PATH environment variable
(Configure permissions if necessary)
/usr/local/bin typically placed around
2. Make the command available only to yourself, then
Add directory instructions for your personal binary to the environment variable
PATH that you set.
Place executable files in that directory (as well as setting permissions if necessary)
/home/alice/bin to avoid causing trouble to others
$hi I tried to run the program I wanted to test, but I couldn't.
Then you can supplement
$./hi and directory specification
I guess so.
If it's C, it's
and so on.
For sh script,
How about that?
The prerequisite is to have permission to execute the file, so if necessary, set it to
Alternatively, you can specify it with the
Answer three ways to do it.
Example) Absolute Path
Example) For Relative Paths
Example) Find and run the environment variable
The act of allowing commands to be found in the environment variable
PATH is commonly referred to as
passing. Use the
export command to modify the environment variable
PATH to "pass through."
The export is discarded when you log out or exit the terminal.
It's troublesome to type every time, so I'll write it down in the configuration file.
© 2023 OneMinuteCode. All rights reserved.