Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
I set a PATH as follows:
# PATH=/sbin:/usr/sbin:$PATH
# export PATH
After I set this PATH, I only can use it if I don't logout
or reboot. How can I keep it permanently without doing it
again and again? (I did click "Save Current setting" before
I logout.) The same thing happens when I configure my NIC
as well...... How can I solve these problems???
Thx
if i'm not mistaken there are a few files that are read each time you log in.
.profile in your home dir
/etc/.profile
.bashrc in your home dir
you should save the files in another name and then put that line with path=etc...
this should make the changes permanent.
if it doesn't work don't forget to put back the old file so that you won't have any problems.
i think it's best to try them one at a time.
System-wide config for bash goes into the file /etc/profile.
And if you would like to add this extra path info for a single user, then add it to the hidden file .bah_profile
when I check the hidden file /root/.bash_profile, I saw
PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH:$HOME/bin
(I didn't add anything yet!)
Is that mean I can use any command under those directory?
But when I typed some commands such as route, the message
still show up: "command not find". If I have to add those
path in /root/.bash_profile, how should I type it?
And if I add this path in /etc/profile, is that mean
everyone who logon can use it without adding it?
thx again
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,602
Rep:
/etc/profile is a system wide config file that affects all users. When you login do you always do it as root? If you do you should really create a non-privilaged user and login with that.
This time I login as another user that I created and it's
working(I can use those commands...). However, if I use su instead of su - to change into superuser, I still can't use those commands, why? What's the difference between them?
Also, I add a path :/sbin:/usr/sbin follow by the PATH in .bash_profile under another user's home directory.
And then I login as that user and tried to use commands
such as route, but it's still no working. I think I am
quite confused about this...
Thx
Let's say your new user name is steve. When steve login and system starts a bash shell (assuming you use bash for your shell) it reads the /home/steve/.bash_profile
When you su to root access then a new bash shell isn't started so therefore the files in /root isn't run. Thus the path isn't modified.
Also some commands aren't ment to be run as non-privilaged users. Route is one of them, this is for safety and to prevent accidental use of them.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.