LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 04-29-2013, 02:50 AM   #1
PeterUK
Member
 
Registered: May 2009
Posts: 277

Rep: Reputation: 16
Slackware- Help installing a permanent path


Hi!

I would like to get a path added permanently:

At the moment I add the path by

export PATH=$PATH:/path/

and it works but I need to do every time I open a terminal window.

I did looked at the etc/profile but it looked rather a long file and I am not sure where to put it.

Also I've read some post and did man bash and look and it say It will load some files like .profile .bash* but there are not in etc.

Are they in another directory?

Also from the post say profile file is only load it when you log in so maybe I rather have .bash which it should be loaded every time I open a terminal, right? But I cannot find that file.
 
Old 04-29-2013, 02:56 AM   #2
wildwizard
Member
 
Registered: Apr 2009
Location: Oz
Distribution: slackware64-14.0
Posts: 755

Rep: Reputation: 226Reputation: 226Reputation: 226
If you go right to the bottom of the bash man page you will see the list of files it uses and when and where they should be.

The file you probably want is ~/.bashrc

This file will not exist until you create it, so that is why you don't see anything now in fact none of the per user files will exist as they are only required for user specific settings.
 
Old 04-29-2013, 03:47 AM   #3
PeterUK
Member
 
Registered: May 2009
Posts: 277

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by wildwizard View Post
If you go right to the bottom of the bash man page you will see the list of files it uses and when and where they should be.

The file you probably want is ~/.bashrc

This file will not exist until you create it, so that is why you don't see anything now in fact none of the per user files will exist as they are only required for user specific settings.
Thank you!

that is right I didnt really know where was ~/ so I did cd ~/ found out that is root dir.

So I went and follow your advice and look at the bash doc and read for bashrc it looks ok so I did create a file in root folder with this content:

# Set the adding path $PATH:
PATH="/home/to/scripts"

And now every time I open the terminal its working! :-)

Thanks!

I am going to leave the thread open for a bit to see if anyone has input about the content in the .bashrc file.
 
Old 04-29-2013, 04:14 AM   #4
Bazzaah
Member
 
Registered: Mar 2007
Distribution: Slackware64-current, Slackware64 14
Posts: 324

Rep: Reputation: 49
~/ is just a shorthand for referring to your current user's home directory. If you are logged in as root (and you shouldn't be) ~/ will take you to root's home directory. If you are logged in as your user, ~/ will take you to your user's home directory (i.e. /home/user).

Your .bashrc should be in your user's home directory. I am assuming here that you do not log in as root and that you created a user account when you installed Slackware.
 
Old 04-29-2013, 05:13 AM   #5
PeterUK
Member
 
Registered: May 2009
Posts: 277

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by Bazzaah View Post
~/ is just a shorthand for referring to your current user's home directory. If you are logged in as root (and you shouldn't be) ~/ will take you to root's home directory. If you are logged in as your user, ~/ will take you to your user's home directory (i.e. /home/user).

Your .bashrc should be in your user's home directory. I am assuming here that you do not log in as root and that you created a user account when you installed Slackware.
Thanks!

I know I keep looking at advice that should not be longed in as root, But I did create the user but I have not being using it.

I know I should, last weekend look at root folder and I realize that my user folder should have looked like that! :-/

But I like the ability to put/edit files into the system folder without have to look into a terminal or keep typing my root password or getting message I dont have permission for this or for that.

Can this sorted by having a way to start the file management system, and perhaps a terminal as root too. I know in mu Ubuntu machine I could have done su and then all was as root.

I just think it complicate more the administration of the machine, plus you sometime have to be dealing with group permission and all that. I know is wrong but in a way make things easier and faster to do it.
 
Old 04-29-2013, 05:39 AM   #6
Bazzaah
Member
 
Registered: Mar 2007
Distribution: Slackware64-current, Slackware64 14
Posts: 324

Rep: Reputation: 49
Quote:
Originally Posted by PeterUK View Post
Thanks!

I know I keep looking at advice that should not be longed in as root, But I did create the user but I have not being using it.

I know I should, last weekend look at root folder and I realize that my user folder should have looked like that! :-/

But I like the ability to put/edit files into the system folder without have to look into a terminal or keep typing my root password or getting message I dont have permission for this or for that.

Can this sorted by having a way to start the file management system, and perhaps a terminal as root too. I know in mu Ubuntu machine I could have done su and then all was as root.

I just think it complicate more the administration of the machine, plus you sometime have to be dealing with group permission and all that. I know is wrong but in a way make things easier and faster to do it.
It's not a great idea to be logged in as root permanently. You can easily break your system and put your important data at risk. Up to you of course but I doubt you'd find anyone on here who thinks that logging in as root is a good idea.

It's no real effort to use su or su - or sudo and I would suggest that you use your user account and one of those when you need elevated privileges. But, as I say, it's up to you.
 
Old 04-29-2013, 05:41 AM   #7
wildwizard
Member
 
Registered: Apr 2009
Location: Oz
Distribution: slackware64-14.0
Posts: 755

Rep: Reputation: 226Reputation: 226Reputation: 226
Some terminology and other hints :-

/root (root's home dir) you should call it root's home directory and not the root dir as the 2 are not always the same thing
/ this is the root directory

On some UNiX systems past root's home dir and / were the one and the same, but they aren't in Linux so you should call them accordingly

the command "cd" without any parameters is the same as "cd ~" (shortcuts are good)

You will also note the when you're in your home dir that the command prompt changes

in my home dir :-
michael@indigo:~$

in /home (type "cd .." from your home dir and watch the change)
michael@indigo:/home$

The ~ is the shorthand for the complete path which is /home/michael

Slackware also has su, anytime you need to access root you can just type it in and voila your root.

Not sure why you need to be root all the time, I rarely have the need for it outside of system updates.
 
Old 04-29-2013, 06:25 AM   #8
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.1
Posts: 7,030
Blog Entries: 52

Rep: Reputation: Disabled
PeterUK
I really think you need to do some reading about running Slackware, have a look here:

http://docs.slackware.com/toc:start
 
Old 04-29-2013, 06:38 AM   #9
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.0
Posts: 558
Blog Entries: 2

Rep: Reputation: 73
Quote:
Originally Posted by PeterUK View Post
But I like the ability to put/edit files into the system folder without have to look into a terminal or keep typing my root password or getting message I dont have permission for this or for that.
That's poor practice.

You should never mess around with system files unless you are doing it via a package management system. Otherwise you won't be able to keep track of it. If you ever upgrade or have to reinstall Slackware, the odds are that you will never get it working as well as you had it before.
 
Old 04-29-2013, 06:40 AM   #10
PeterUK
Member
 
Registered: May 2009
Posts: 277

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by brianL View Post
PeterUK
I really think you need to do some reading about running Slackware, have a look here:

http://docs.slackware.com/toc:start
That is a lot to read! :-/

Thanks for the tip! I know there is a lot to learn but hey I cannot do it all in one day! :-(
 
Old 04-29-2013, 06:48 AM   #11
PeterUK
Member
 
Registered: May 2009
Posts: 277

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by wildwizard View Post
Some terminology and other hints :-

/root (root's home dir) you should call it root's home directory and not the root dir as the 2 are not always the same thing
/ this is the root directory

On some UNiX systems past root's home dir and / were the one and the same, but they aren't in Linux so you should call them accordingly

the command "cd" without any parameters is the same as "cd ~" (shortcuts are good)

You will also note the when you're in your home dir that the command prompt changes

in my home dir :-
michael@indigo:~$

in /home (type "cd .." from your home dir and watch the change)
michael@indigo:/home$

The ~ is the shorthand for the complete path which is /home/michael

Slackware also has su, anytime you need to access root you can just type it in and voila your root.

Not sure why you need to be root all the time, I rarely have the need for it outside of system updates.
I'm coming from 10.04 I remember I keep typing my root password and sometime I have to look for some terminal command here and there on the net.

lately I was thinking on switch to the user account but for the only reason that the files say owner root, and there were pulled from the back up and there was a user now I am not sure if I am going to have problem with permission issues?
 
Old 04-29-2013, 06:54 AM   #12
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.1
Posts: 7,030
Blog Entries: 52

Rep: Reputation: Disabled
Quote:
Originally Posted by PeterUK View Post
That is a lot to read! :-/

Thanks for the tip! I know there is a lot to learn but hey I cannot do it all in one day! :-(
I wouldn't expect you to.
Read any relevant bits as and when you need to.
 
Old 04-29-2013, 07:13 AM   #13
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,042

Rep: Reputation: 761Reputation: 761Reputation: 761Reputation: 761Reputation: 761Reputation: 761Reputation: 761
There are a couple of ways to set the PATH environment variable: system-wide and individual user.

System-wide is exactly what it sounds like: any user logging in on the system will receive the setting; individual user, on the other hand, is only set for specific users.

There is a directory, /etc/profile.d. In there are files that are executed at log in for every user (including the root user). You can create a file in /etc/profile.d for system-wide use (but you would not do so for a specialized, individual user).

Here's an example: I have an application, the Generic Mapping Tools, or GMT, that is used to manipulate geographic data sets and, you know, draw maps. Because GMT is optional software (and it's big) I install in the /opt directory; /opt is not on any user PATH, so I need to add it system-wide (so anybody can use it). I do that in /etc/profile.d with this file, named gmt.sh:
Code:
cat /etc/profile.d/gmt.sh
#!/bin/sh

export GMTHOME="/opt/GMT"
export NETCDFHOME="/opt/netCDF"
export MANPATH="${MANPATH}:${GMTHOME}/man"
export MANPATH="${MANPATH}:${NETCDFHOME}/man"
# Set the local system $PATH:
PATH="${PATH}:${GMTHOME}/bin"
PATH="${PATH}:${NETCDFHOME}/bin"
Translated, the above defines GMTHOME and NETCDFHOME (netCDF is a set of software libraries and self-describing, machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data used by GMT) then uses those tokens to add paths to the manual pages and the bin directories for both GMT and netCDF. Whenever any user logs in, those PATHs are set in their shell environment.

To add a file like this to /etc/profile.d, you must be root (but use su - to become root, don't log in as root as normal practice) and create the file with a text editor (vi, vim, emacs, whatever):
Code:
log in as you
su -
<enter the root password>
cd /etc/profile.d
vi gmt.sh
<type the lines>
ZZ        <save the file>
chmod 755 gmt.sh
Ctrl-D    <exit from su ->
The file must be executable, thus the chmod 755 gmt.sh.

That's it, log out, log back in, then
Code:
echo ${GMTHOME}
/opt/GMT
That will show you that you did it right.

You can do the same thing for individual users by adding the above lines (don't include the #!/bin/sh though) in the user's home directory .profile or .bash_profile or .bashrc.

I prefer .profile or .bash_profile, which is executed at log in (/etc/profile and the content of /etc/profile.d are executed at log in to set user environment variables). .bashrc, on the other hand, is executed for interactive non-log in shells.

Hope this helps some.
 
Old 04-30-2013, 12:14 PM   #14
PeterUK
Member
 
Registered: May 2009
Posts: 277

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by tronayne View Post
There are a couple of ways to set the PATH environment variable: system-wide and individual user.

System-wide is exactly what it sounds like: any user logging in on the system will receive the setting; individual user, on the other hand, is only set for specific users.

There is a directory, /etc/profile.d. In there are files that are executed at log in for every user (including the root user). You can create a file in /etc/profile.d for system-wide use (but you would not do so for a specialized, individual user).

Here's an example: I have an application, the Generic Mapping Tools, or GMT, that is used to manipulate geographic data sets and, you know, draw maps. Because GMT is optional software (and it's big) I install in the /opt directory; /opt is not on any user PATH, so I need to add it system-wide (so anybody can use it). I do that in /etc/profile.d with this file, named gmt.sh:
Code:
cat /etc/profile.d/gmt.sh
#!/bin/sh

export GMTHOME="/opt/GMT"
export NETCDFHOME="/opt/netCDF"
export MANPATH="${MANPATH}:${GMTHOME}/man"
export MANPATH="${MANPATH}:${NETCDFHOME}/man"
# Set the local system $PATH:
PATH="${PATH}:${GMTHOME}/bin"
PATH="${PATH}:${NETCDFHOME}/bin"
Translated, the above defines GMTHOME and NETCDFHOME (netCDF is a set of software libraries and self-describing, machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data used by GMT) then uses those tokens to add paths to the manual pages and the bin directories for both GMT and netCDF. Whenever any user logs in, those PATHs are set in their shell environment.

To add a file like this to /etc/profile.d, you must be root (but use su - to become root, don't log in as root as normal practice) and create the file with a text editor (vi, vim, emacs, whatever):
Code:
log in as you
su -
<enter the root password>
cd /etc/profile.d
vi gmt.sh
<type the lines>
ZZ        <save the file>
chmod 755 gmt.sh
Ctrl-D    <exit from su ->
The file must be executable, thus the chmod 755 gmt.sh.

That's it, log out, log back in, then
Code:
echo ${GMTHOME}
/opt/GMT
That will show you that you did it right.

You can do the same thing for individual users by adding the above lines (don't include the #!/bin/sh though) in the user's home directory .profile or .bash_profile or .bashrc.

I prefer .profile or .bash_profile, which is executed at log in (/etc/profile and the content of /etc/profile.d are executed at log in to set user environment variables). .bashrc, on the other hand, is executed for interactive non-log in shells.

Hope this helps some.
Today I try to type a command and it will not work, so in order to get it going again I have to remove the .bashrc file I created. When I have time I will try to approach or file all those path to be added to my bashrc file. :-(
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Permanent $PATH edits x81kilo Linux - Newbie 2 09-20-2010 05:34 PM
$CFLAGS and $PATH - how to change them so that they stay permanent kiwi_MTBer Linux - Newbie 8 04-16-2009 09:51 PM
Permanent PATH variable with azureus dreamcatcheromerta Linux - Newbie 4 11-06-2008 07:31 PM
Permanent Alias In Slackware dmcbeing Linux - Software 2 11-10-2005 11:18 AM
Permanent Command Aliases - Slackware 9.1 erraticassassin Slackware 3 01-09-2005 03:08 PM


All times are GMT -5. The time now is 11:15 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration