Place new folder into default path

I have placed a directory named “platform-tools” under my UM 18.04 home directory. I would like to be able to run these files without using the full path name. I have googled the issue, and there seem to be many methods to accomplish this, but I don’t fully understand most of the directions.

Method 1
add line
export PATH="$PWD/platform-tools:$PATH"

Method 2
run the following commands:
$ PATH = /usr/local/sbin:/usr/local/bin:~/platform-tools
$ source /etc/environment && export PATH

Just looking for some advice before messing everything up and having to restore from a backup. Thanks.

This is from,series%20of%20pathnames%2C%20each%20delimited%20by%20a%20colon.

PATH=$PATH:whateverdirectoryyouwant:/my/other/new/path;export PATH

Thanks. That site was easier for me to follow than the others. I did not realize you could set the path just for the current login. That might be my best solution.

However, it did not fix my issue. And I am even more confused. ADB does not run. I do the PATH command, ADB runs. But fastboot in the same directory is not recognized unless I go to the desired directory and run ./fasboot. Below is a list of my commands supporting the description of my experience:

[email protected]:~$ adb

Command 'adb' not found, but can be installed with:

sudo apt install adb

[email protected]:~$ PATH=$PATH:/home/jaybo/platform-tools;export PATH
[email protected]:~$ adb devices
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached

[email protected]:~$ 

$ sudo fastboot devices
sudo: fastboot: command not found

[email protected]:~$ cd platform-tools
[email protected]:~/platform-tools$ ls
adb  dmtracedump  etc1tool  hprof-conv  make_f2fs  mke2fs.conf  sload_f2fs         sqlite3
api  e2fsdroid    fastboot  lib64       mke2fs     NOTICE.txt  systrace

[email protected]:~/platform-tools$ sudo fastboot devices
sudo: fastboot: command not found
[email protected]:~/platform-tools$ sudo ./fastboot devices
XXXXXXXX	fastboot

[email protected]:~/platform-tools$

what are the permissions of fastboot in platform-tools/ ?

sudo resets PATH to its original state. See sudo -E (preserve-env)

[email protected]:~/platform-tools$ ls -ld
drwx------ 5 jaybo jaybo 4096 Jul 11 13:57 .
[email protected]:~/platform-tools$

I do not see perms for fastboot

look at the secure_path in the /etc/sudoers file, you can add platform-tools/ in there.

I do not see a /etc/sudoers, but I do see a /etc/sudoers.d. It contains a 99-snapd.conf file.

Permission for fastboot:
[email protected]:~/platform-tools$ ls -l fastboot
-rwxrwxr-x 1 jaybo jaybo 1943040 Jun 16 22:42 fastboot
[email protected]:~/platform-tools$

Should I change fastboot permissions?

fastboot perms are ok, the issue is that sudo resets PATH.

you should have a /etc/sudoers file, ls -l /etc
-r--r----- 1 root root 755 Jan 17 2018 sudoers
you can see it as root or sudo cat /etc/sudoers
To change it, use sudo visudo

1 Like

I see sudoers using

sudo cat /etc/sudoers


ls -l /etc

However, it is not clear to me what to change when using sudo visudo

sudo visudo, look for the line Defaults secure_path= (mine is the third line after the comments) and add to the end of that path, your path /home/jaybo/platform-tools Save, exit. Now, go to your home dir and type sudo fastboot devices It should work.

Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/jaybo/platform-tools"

Thanks. That worked.