Thank you everyone for your helpful insights.
For any other noobs like me reading this thread to clarify the steps from my first post.
Going forward I will compile code (e.g parted) into a dedicated ‘apps’ directory in my home dir, and not as root, like this…
cd /home/flex/apps/src
git clone https://git.savannah.gnu.org/git/parted.git
cd parted/
./bootstrap
./configure --prefix=/home/flex/apps --disable-static --disable-device-mapper
make
In my case I would aim to run the binary for testing purposes so would probably just run the binaries from where ever they get created.
Alternatively, to fully install I would still choose to have them install in to my home directory as follows which achieves that goal because of ./configure --prefix=/home/flex/apps
above.
make install
I guess the binary will get “installed” into something like…
/home/flex/apps/[bin or sbin]/[name_of_app_binary]
Now since my aim here is for testing only and I want to ensure no overlap of an app I am testing that is also a system app I would do these steps, even though as explained above they are not strictly necessary.
- Make sure the installed dir is NOT in my PATH. ($echo $PATH)
- Rename the locally compiled application (e.g: parted → parted-v3.66)
- Create an alias in my ~/.bashrc to the re-named app so I can access it from anywhere and not have to specify the full path to it.
alias parted-v3.66="/home/flex/apps/sbin/parted-v3.66"
And Finally
To satisfy my OCD: just to go back to a question I asked above that probably came across confusing.
Firstly, I understand that /usr/sbin is symlinked to /usr/bin.
This is the first part of my $PATH:
/home/flex/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin
With these…
/usr/local/sbin/parted (v3.66)
/usr/sbin/parted (v3.6)
If I do…
$parted -v
it sees (v3.66) which makes sense.
Then if I do this…
sudo mv /usr/local/sbin/parted /usr/local/sbin/parted-patched
$parted -v
What happens? I would expect it to see v3.6 now because the only parted that exists on my system is in /usr/sbin which is v3.6.
Instead within the same bash shell Konsole window/tab I get this:
bash: /usr/local/sbin/parted: No such file or directory
If I open a new bash shell window in Konsole it then works as expected and $parted -v (sees v3.6)
But again if from this new shell window if I then do this:
sudo mv /usr/local/sbin/parted-patched /usr/local/sbin/parted
parted -v
I would expect it to see v3.66 since /usr/local/sbin/parted is v3.66 and it exists now again in the file system. Instead parted -v
still sees v3.6.
I guess I stumbled upon behavior of Konsole or maybe bash or something where it caches into memory the state of the file system when you initially open a command line screen? You can imagine how confusing this past few days were for me trying to process a lot of new concepts and stuff that seemed to contradict everything!
Thank you,
Flex