DebianThis forum is for the discussion of Debian Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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/games
Another 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.
Yes if I log in through the root user then there is no issue. The thing is by using su every time I set the path root@debian:/home/test# PATH="/sbin:$PATH" I want to fix it? Is there any way?
root@haswell:~# cat .profile
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
# set PATH so it includes sbin if it exists fscking buster change to apt/dpkg
if [ -d "/sbin" ] ; then
PATH="/sbin:$PATH"
fi
Thanks for the replay.I try but no success.Following is my .profile after adding ending three lines.
Code:
root@debian:/home/test# vi .profile
Code:
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
# set PATH for /sbin
if [ -d "/sbin" ] ; then
PATH="/sbin:$PATH"
fi
Then reboot my system
Code:
test@debian:~$ su
Password:
root@debian:/home/test# fdisk -l
bash: fdisk: command not found
root@debian:/home/test#
You need to change the path environment for your user not roots or as suggested use su - instead. You can always use the absolute path but that would require you knowing where a particular command is located.
You can logout/login instead of rebooting...
I believe /usr/local/sbin, /usr/sbin and /sbin were removed from users' $PATH at some point, in some previous release...
Just add a line similar to this to ~/.profile:
Code:
export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
There are some possible pitfalls with using "su" instead of "su -". i.e. it can cause dotfiles within your environment to become owned by root, which is almost always a bad thing - but users tend to learn that for themselves after breaking things a few times.
Most of us have managed for years without destroying everything, so I don't personally see the issue with sbin directories being in users' paths. Because at times, one wants to see output from tools like ifconfig or whatever, without being root.
As long as I've been regularly using debian /sbin has never been in a users path environment. As far as I know there is no path "standard" and while debian does not include it for a user, Red Hat does.
When root you can change everything so there is always the chance you can destroy something.
I believe /usr/local/sbin, /usr/sbin and /sbin were removed from users' $PATH at some point, in some previous release
You probably confuse Debian with Ubuntu. Since Ubuntu by default locks root account and forces use of sudo, it overrides regular users' PATH set (by Debian) in /etc/login.def via /etc/environment.
Thanks for the replay.I try but no success.Following is my .profile after adding ending three lines.
Code:
root@debian:/home/test# vi .profile
Code:
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
# set PATH for /sbin
if [ -d "/sbin" ] ; then
PATH="/sbin:$PATH"
fi
Then reboot my system
Code:
test@debian:~$ su
Password:
root@debian:/home/test# fdisk -l
bash: fdisk: command not found
root@debian:/home/test#
You have to make certain it is being sourced from something and as has been mentioned the differences in how you invoke the shell switch. Put it in your normal user .profile too that way it will always be available.
Code:
if [ -f ~/.profile ]; then
. ~/.profile
fi
In both of the .bashrc files and then a source ~/.bashrc to have the file re-read and the changes applied no need of a reboot. Make certain you have another Terminal window open as if you mess it up and the shell is useless you will have no way to change it as it will not load a usable shell again. You would need to boot with rescue usb/dvd and mount the partition and change it that way.
As long as I've been regularly using debian /sbin has never been in a users path environment. As far as I know there is no path "standard" and while debian does not include it for a user, Red Hat does.
I expect you're quite correct.
Quote:
Originally Posted by shruggy
You probably confuse Debian with Ubuntu. Since Ubuntu by default locks root account and forces use of sudo, it overrides regular users' PATH set (by Debian) in /etc/login.def via /etc/environment.
No, I'm most likely thinking of Slackware, or even one of the BSD's. I haven't used 'buntu in around 13 years.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.