How set PATH for root user in Debian.
by gardenair from LinuxQuestions.org on (#5DKPP)
hi,
In my Debian 10 laptop, I am facing a problem using fdisk command which is in /sbin. My path is
Code:test@debian:~$ su
Password:
root@debian:/home/test# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
root@debian:/home/test#I can't execute the command
Code:root@debian:/home/test# fdisk -l
bash: fdisk: command not foundIf I set my PATH to:
Code:root@debian:/home/test# PATH="/sbin:$PATH"then I get
Code:root@debian:/home/test# echo $PATH
/sbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
root@debian:/home/test#After that the fdisk -l command executes perfectly. The problem is that every time I reboot my laptop, I have to set the path again. I want to add it permanently.
There is a file /etc/login.defs, This setting is for root and for normal users(if I am correct). If I use the command, in the middle of the file there is a path. Can I edit it? if it the right file? if yes then where may I add my path?
root@debian:/home/test# vi /etc/login.defs
Code:#
# *REQUIRED* The default PATH settings, for superuser and normal users.
#
# (they are minimal, add the rest in the shell startup files)
ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/gamesAnother plase is Code:.profile which is hidden
root@debian:/home/test# ls -al
Please guide me on which file may I choose to edit for permanent changes and what should I add inside it. I don't know shell scripting I just want to add the path in my root user (by switching su from normal user) so I may use fdisk or any other utility in /sbin.
Thanks in advance.


In my Debian 10 laptop, I am facing a problem using fdisk command which is in /sbin. My path is
Code:test@debian:~$ su
Password:
root@debian:/home/test# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
root@debian:/home/test#I can't execute the command
Code:root@debian:/home/test# fdisk -l
bash: fdisk: command not foundIf I set my PATH to:
Code:root@debian:/home/test# PATH="/sbin:$PATH"then I get
Code:root@debian:/home/test# echo $PATH
/sbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
root@debian:/home/test#After that the fdisk -l command executes perfectly. The problem is that every time I reboot my laptop, I have to set the path again. I want to add it permanently.
There is a file /etc/login.defs, This setting is for root and for normal users(if I am correct). If I use the command, in the middle of the file there is a path. Can I edit it? if it the right file? if yes then where may I add my path?
root@debian:/home/test# vi /etc/login.defs
Code:#
# *REQUIRED* The default PATH settings, for superuser and normal users.
#
# (they are minimal, add the rest in the shell startup files)
ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/gamesAnother plase is Code:.profile which is hidden
root@debian:/home/test# ls -al
Please guide me on which file may I choose to edit for permanent changes and what should I add inside it. I don't know shell scripting I just want to add the path in my root user (by switching su from normal user) so I may use fdisk or any other utility in /sbin.
Thanks in advance.