Locating Bash .rc files in FreeBSD?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm using FreeBSD with bash as the shell. I also use SSH with both FreeNAS and pfSense, both FreeBSD based.



I'm getting confused about setting up bash options, and some clarification would really help. I'm trying to get various shell options to be used in future sessions (and exported to shells called from sessions) but I'm not having much luck. Perhaps I don't know how to find the correct file to put them in, or the correct way to put them there.



My main problem is probably just finding the rc file used for the session (!!)
If I login as root, then execute su, then set will show me a different list of environment variables. But as I haven't changed user, I'm confused why my rc file doesn't seem to be the same. (the files I've found don't have different entries for the environment variables I'm looking at). The output of set shows ENV=/USERNAME/.shrc but when I edit this file and log back in, I don't see any changes to my session so I'm guessing this isn't where to look? But I've tied editing ~/.bashrc as well, and that doesn't seem to do anything either.



There should be a way to find out directly which .rc file was used to initiate the session, but I don't know how to do this, especially as both FreeNAS and pfSense might have their own customised locations.



Whether it's using one or two rc files, how can I find which rc file I would have to edit, to modify future sessions that are the same as the present session? And does it use one rc file or two different files if you first login as root and then su?










share|improve this question





















  • Why are you logging in as root?
    – Kusalananda
    Oct 9 '17 at 16:46











  • Because it's an offline isolated test system, it's console rather than SSH over the wires, and because it allows me to isolate issues related to user rights/permissions (as I'm not very experienced yet). Once it's working nicely, I'll set up the server I'm actually going to use and su once logged in. Good question thanks though.
    – Stilez
    Oct 9 '17 at 16:58















up vote
0
down vote

favorite












I'm using FreeBSD with bash as the shell. I also use SSH with both FreeNAS and pfSense, both FreeBSD based.



I'm getting confused about setting up bash options, and some clarification would really help. I'm trying to get various shell options to be used in future sessions (and exported to shells called from sessions) but I'm not having much luck. Perhaps I don't know how to find the correct file to put them in, or the correct way to put them there.



My main problem is probably just finding the rc file used for the session (!!)
If I login as root, then execute su, then set will show me a different list of environment variables. But as I haven't changed user, I'm confused why my rc file doesn't seem to be the same. (the files I've found don't have different entries for the environment variables I'm looking at). The output of set shows ENV=/USERNAME/.shrc but when I edit this file and log back in, I don't see any changes to my session so I'm guessing this isn't where to look? But I've tied editing ~/.bashrc as well, and that doesn't seem to do anything either.



There should be a way to find out directly which .rc file was used to initiate the session, but I don't know how to do this, especially as both FreeNAS and pfSense might have their own customised locations.



Whether it's using one or two rc files, how can I find which rc file I would have to edit, to modify future sessions that are the same as the present session? And does it use one rc file or two different files if you first login as root and then su?










share|improve this question





















  • Why are you logging in as root?
    – Kusalananda
    Oct 9 '17 at 16:46











  • Because it's an offline isolated test system, it's console rather than SSH over the wires, and because it allows me to isolate issues related to user rights/permissions (as I'm not very experienced yet). Once it's working nicely, I'll set up the server I'm actually going to use and su once logged in. Good question thanks though.
    – Stilez
    Oct 9 '17 at 16:58













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm using FreeBSD with bash as the shell. I also use SSH with both FreeNAS and pfSense, both FreeBSD based.



I'm getting confused about setting up bash options, and some clarification would really help. I'm trying to get various shell options to be used in future sessions (and exported to shells called from sessions) but I'm not having much luck. Perhaps I don't know how to find the correct file to put them in, or the correct way to put them there.



My main problem is probably just finding the rc file used for the session (!!)
If I login as root, then execute su, then set will show me a different list of environment variables. But as I haven't changed user, I'm confused why my rc file doesn't seem to be the same. (the files I've found don't have different entries for the environment variables I'm looking at). The output of set shows ENV=/USERNAME/.shrc but when I edit this file and log back in, I don't see any changes to my session so I'm guessing this isn't where to look? But I've tied editing ~/.bashrc as well, and that doesn't seem to do anything either.



There should be a way to find out directly which .rc file was used to initiate the session, but I don't know how to do this, especially as both FreeNAS and pfSense might have their own customised locations.



Whether it's using one or two rc files, how can I find which rc file I would have to edit, to modify future sessions that are the same as the present session? And does it use one rc file or two different files if you first login as root and then su?










share|improve this question













I'm using FreeBSD with bash as the shell. I also use SSH with both FreeNAS and pfSense, both FreeBSD based.



I'm getting confused about setting up bash options, and some clarification would really help. I'm trying to get various shell options to be used in future sessions (and exported to shells called from sessions) but I'm not having much luck. Perhaps I don't know how to find the correct file to put them in, or the correct way to put them there.



My main problem is probably just finding the rc file used for the session (!!)
If I login as root, then execute su, then set will show me a different list of environment variables. But as I haven't changed user, I'm confused why my rc file doesn't seem to be the same. (the files I've found don't have different entries for the environment variables I'm looking at). The output of set shows ENV=/USERNAME/.shrc but when I edit this file and log back in, I don't see any changes to my session so I'm guessing this isn't where to look? But I've tied editing ~/.bashrc as well, and that doesn't seem to do anything either.



There should be a way to find out directly which .rc file was used to initiate the session, but I don't know how to do this, especially as both FreeNAS and pfSense might have their own customised locations.



Whether it's using one or two rc files, how can I find which rc file I would have to edit, to modify future sessions that are the same as the present session? And does it use one rc file or two different files if you first login as root and then su?







bash freebsd environment-variables






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Oct 9 '17 at 15:32









Stilez

441211




441211











  • Why are you logging in as root?
    – Kusalananda
    Oct 9 '17 at 16:46











  • Because it's an offline isolated test system, it's console rather than SSH over the wires, and because it allows me to isolate issues related to user rights/permissions (as I'm not very experienced yet). Once it's working nicely, I'll set up the server I'm actually going to use and su once logged in. Good question thanks though.
    – Stilez
    Oct 9 '17 at 16:58

















  • Why are you logging in as root?
    – Kusalananda
    Oct 9 '17 at 16:46











  • Because it's an offline isolated test system, it's console rather than SSH over the wires, and because it allows me to isolate issues related to user rights/permissions (as I'm not very experienced yet). Once it's working nicely, I'll set up the server I'm actually going to use and su once logged in. Good question thanks though.
    – Stilez
    Oct 9 '17 at 16:58
















Why are you logging in as root?
– Kusalananda
Oct 9 '17 at 16:46





Why are you logging in as root?
– Kusalananda
Oct 9 '17 at 16:46













Because it's an offline isolated test system, it's console rather than SSH over the wires, and because it allows me to isolate issues related to user rights/permissions (as I'm not very experienced yet). Once it's working nicely, I'll set up the server I'm actually going to use and su once logged in. Good question thanks though.
– Stilez
Oct 9 '17 at 16:58





Because it's an offline isolated test system, it's console rather than SSH over the wires, and because it allows me to isolate issues related to user rights/permissions (as I'm not very experienced yet). Once it's working nicely, I'll set up the server I'm actually going to use and su once logged in. Good question thanks though.
– Stilez
Oct 9 '17 at 16:58











1 Answer
1






active

oldest

votes

















up vote
1
down vote













The FreeBSD default root shell is /bin/tcsh. You should not change the shell for the root user.
You can comfortably use the bash shell. But then change the shell for your own user. If you need root privileges you should get the habit of using su -c or even better: sudo. If you do that you really do not care what the shell for the root user is.
If you insist on changing the shell for root - then use the "toor" (root backwards) user. It still operates as uid 0 but it is safe to change the shell.



You reference ~/.bashrc but this is relative. On a typical FreeBSD install this will be expanded to /home/<username>/.bashrc for regular users and /root/.bashrc for the root user.



You write that you login as root. I recommend that you do not do that but rather log in as a regular user.



When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This means that .bashrc is not invoked on login! Only if you start it as an interactive shell.



You are probably looking for ~/.bash_profile - see https://forums.freebsd.org/threads/2682/






share|improve this answer




















  • This gave me a good hint. Based on this answer, I looked up the bash startup and the files it's hard-coded to check, and found one of those was in use (~/.profile), so it wasn't checking the files I expected. As to the account, it's an offline test system. Root via console is safe to use. Obviously on a live system one would su. But well spotted and thank you anyhow for the tip.
    – Stilez
    Oct 9 '17 at 17:04











  • FreeBSD comes with very good documentation. Learn to use "man". It is a short read for bash and gives your answers: freebsd.org/cgi/man.cgi?query=bash As a beginner make sure you get good habits. Even though you have console access I would recommend not to use root as login.
    – Claus Andersen
    Oct 10 '17 at 8:37










  • Good. My point was that .profile was mentioned on the bash man page. All the TERM stuff is related to another questions :-) (Which is hard to grok from the man pages!)
    – Claus Andersen
    Oct 10 '17 at 8:47










  • I've been using it solidly in every case, for the entire time I've been trying to learn the OS, as well as Google/SE. I asked because changing the files referred to by pages in man did nothing. It's such a huge subject that it's not always easy even to know what to look for. Man assumes some clue what to look for, and a well defined topic suited to its pages - knowing where might be promising to look. With the best will in the world, that's not always a beginners situation.
    – Stilez
    Oct 10 '17 at 8:48











  • (Above 2 comments are reversed, I deleted and reposted mine due to 5 min timeout about the same time its reply was posted.)
    – Stilez
    Oct 10 '17 at 8:56











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f397049%2flocating-bash-rc-files-in-freebsd%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













The FreeBSD default root shell is /bin/tcsh. You should not change the shell for the root user.
You can comfortably use the bash shell. But then change the shell for your own user. If you need root privileges you should get the habit of using su -c or even better: sudo. If you do that you really do not care what the shell for the root user is.
If you insist on changing the shell for root - then use the "toor" (root backwards) user. It still operates as uid 0 but it is safe to change the shell.



You reference ~/.bashrc but this is relative. On a typical FreeBSD install this will be expanded to /home/<username>/.bashrc for regular users and /root/.bashrc for the root user.



You write that you login as root. I recommend that you do not do that but rather log in as a regular user.



When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This means that .bashrc is not invoked on login! Only if you start it as an interactive shell.



You are probably looking for ~/.bash_profile - see https://forums.freebsd.org/threads/2682/






share|improve this answer




















  • This gave me a good hint. Based on this answer, I looked up the bash startup and the files it's hard-coded to check, and found one of those was in use (~/.profile), so it wasn't checking the files I expected. As to the account, it's an offline test system. Root via console is safe to use. Obviously on a live system one would su. But well spotted and thank you anyhow for the tip.
    – Stilez
    Oct 9 '17 at 17:04











  • FreeBSD comes with very good documentation. Learn to use "man". It is a short read for bash and gives your answers: freebsd.org/cgi/man.cgi?query=bash As a beginner make sure you get good habits. Even though you have console access I would recommend not to use root as login.
    – Claus Andersen
    Oct 10 '17 at 8:37










  • Good. My point was that .profile was mentioned on the bash man page. All the TERM stuff is related to another questions :-) (Which is hard to grok from the man pages!)
    – Claus Andersen
    Oct 10 '17 at 8:47










  • I've been using it solidly in every case, for the entire time I've been trying to learn the OS, as well as Google/SE. I asked because changing the files referred to by pages in man did nothing. It's such a huge subject that it's not always easy even to know what to look for. Man assumes some clue what to look for, and a well defined topic suited to its pages - knowing where might be promising to look. With the best will in the world, that's not always a beginners situation.
    – Stilez
    Oct 10 '17 at 8:48











  • (Above 2 comments are reversed, I deleted and reposted mine due to 5 min timeout about the same time its reply was posted.)
    – Stilez
    Oct 10 '17 at 8:56















up vote
1
down vote













The FreeBSD default root shell is /bin/tcsh. You should not change the shell for the root user.
You can comfortably use the bash shell. But then change the shell for your own user. If you need root privileges you should get the habit of using su -c or even better: sudo. If you do that you really do not care what the shell for the root user is.
If you insist on changing the shell for root - then use the "toor" (root backwards) user. It still operates as uid 0 but it is safe to change the shell.



You reference ~/.bashrc but this is relative. On a typical FreeBSD install this will be expanded to /home/<username>/.bashrc for regular users and /root/.bashrc for the root user.



You write that you login as root. I recommend that you do not do that but rather log in as a regular user.



When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This means that .bashrc is not invoked on login! Only if you start it as an interactive shell.



You are probably looking for ~/.bash_profile - see https://forums.freebsd.org/threads/2682/






share|improve this answer




















  • This gave me a good hint. Based on this answer, I looked up the bash startup and the files it's hard-coded to check, and found one of those was in use (~/.profile), so it wasn't checking the files I expected. As to the account, it's an offline test system. Root via console is safe to use. Obviously on a live system one would su. But well spotted and thank you anyhow for the tip.
    – Stilez
    Oct 9 '17 at 17:04











  • FreeBSD comes with very good documentation. Learn to use "man". It is a short read for bash and gives your answers: freebsd.org/cgi/man.cgi?query=bash As a beginner make sure you get good habits. Even though you have console access I would recommend not to use root as login.
    – Claus Andersen
    Oct 10 '17 at 8:37










  • Good. My point was that .profile was mentioned on the bash man page. All the TERM stuff is related to another questions :-) (Which is hard to grok from the man pages!)
    – Claus Andersen
    Oct 10 '17 at 8:47










  • I've been using it solidly in every case, for the entire time I've been trying to learn the OS, as well as Google/SE. I asked because changing the files referred to by pages in man did nothing. It's such a huge subject that it's not always easy even to know what to look for. Man assumes some clue what to look for, and a well defined topic suited to its pages - knowing where might be promising to look. With the best will in the world, that's not always a beginners situation.
    – Stilez
    Oct 10 '17 at 8:48











  • (Above 2 comments are reversed, I deleted and reposted mine due to 5 min timeout about the same time its reply was posted.)
    – Stilez
    Oct 10 '17 at 8:56













up vote
1
down vote










up vote
1
down vote









The FreeBSD default root shell is /bin/tcsh. You should not change the shell for the root user.
You can comfortably use the bash shell. But then change the shell for your own user. If you need root privileges you should get the habit of using su -c or even better: sudo. If you do that you really do not care what the shell for the root user is.
If you insist on changing the shell for root - then use the "toor" (root backwards) user. It still operates as uid 0 but it is safe to change the shell.



You reference ~/.bashrc but this is relative. On a typical FreeBSD install this will be expanded to /home/<username>/.bashrc for regular users and /root/.bashrc for the root user.



You write that you login as root. I recommend that you do not do that but rather log in as a regular user.



When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This means that .bashrc is not invoked on login! Only if you start it as an interactive shell.



You are probably looking for ~/.bash_profile - see https://forums.freebsd.org/threads/2682/






share|improve this answer












The FreeBSD default root shell is /bin/tcsh. You should not change the shell for the root user.
You can comfortably use the bash shell. But then change the shell for your own user. If you need root privileges you should get the habit of using su -c or even better: sudo. If you do that you really do not care what the shell for the root user is.
If you insist on changing the shell for root - then use the "toor" (root backwards) user. It still operates as uid 0 but it is safe to change the shell.



You reference ~/.bashrc but this is relative. On a typical FreeBSD install this will be expanded to /home/<username>/.bashrc for regular users and /root/.bashrc for the root user.



You write that you login as root. I recommend that you do not do that but rather log in as a regular user.



When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This means that .bashrc is not invoked on login! Only if you start it as an interactive shell.



You are probably looking for ~/.bash_profile - see https://forums.freebsd.org/threads/2682/







share|improve this answer












share|improve this answer



share|improve this answer










answered Oct 9 '17 at 15:53









Claus Andersen

1,392414




1,392414











  • This gave me a good hint. Based on this answer, I looked up the bash startup and the files it's hard-coded to check, and found one of those was in use (~/.profile), so it wasn't checking the files I expected. As to the account, it's an offline test system. Root via console is safe to use. Obviously on a live system one would su. But well spotted and thank you anyhow for the tip.
    – Stilez
    Oct 9 '17 at 17:04











  • FreeBSD comes with very good documentation. Learn to use "man". It is a short read for bash and gives your answers: freebsd.org/cgi/man.cgi?query=bash As a beginner make sure you get good habits. Even though you have console access I would recommend not to use root as login.
    – Claus Andersen
    Oct 10 '17 at 8:37










  • Good. My point was that .profile was mentioned on the bash man page. All the TERM stuff is related to another questions :-) (Which is hard to grok from the man pages!)
    – Claus Andersen
    Oct 10 '17 at 8:47










  • I've been using it solidly in every case, for the entire time I've been trying to learn the OS, as well as Google/SE. I asked because changing the files referred to by pages in man did nothing. It's such a huge subject that it's not always easy even to know what to look for. Man assumes some clue what to look for, and a well defined topic suited to its pages - knowing where might be promising to look. With the best will in the world, that's not always a beginners situation.
    – Stilez
    Oct 10 '17 at 8:48











  • (Above 2 comments are reversed, I deleted and reposted mine due to 5 min timeout about the same time its reply was posted.)
    – Stilez
    Oct 10 '17 at 8:56

















  • This gave me a good hint. Based on this answer, I looked up the bash startup and the files it's hard-coded to check, and found one of those was in use (~/.profile), so it wasn't checking the files I expected. As to the account, it's an offline test system. Root via console is safe to use. Obviously on a live system one would su. But well spotted and thank you anyhow for the tip.
    – Stilez
    Oct 9 '17 at 17:04











  • FreeBSD comes with very good documentation. Learn to use "man". It is a short read for bash and gives your answers: freebsd.org/cgi/man.cgi?query=bash As a beginner make sure you get good habits. Even though you have console access I would recommend not to use root as login.
    – Claus Andersen
    Oct 10 '17 at 8:37










  • Good. My point was that .profile was mentioned on the bash man page. All the TERM stuff is related to another questions :-) (Which is hard to grok from the man pages!)
    – Claus Andersen
    Oct 10 '17 at 8:47










  • I've been using it solidly in every case, for the entire time I've been trying to learn the OS, as well as Google/SE. I asked because changing the files referred to by pages in man did nothing. It's such a huge subject that it's not always easy even to know what to look for. Man assumes some clue what to look for, and a well defined topic suited to its pages - knowing where might be promising to look. With the best will in the world, that's not always a beginners situation.
    – Stilez
    Oct 10 '17 at 8:48











  • (Above 2 comments are reversed, I deleted and reposted mine due to 5 min timeout about the same time its reply was posted.)
    – Stilez
    Oct 10 '17 at 8:56
















This gave me a good hint. Based on this answer, I looked up the bash startup and the files it's hard-coded to check, and found one of those was in use (~/.profile), so it wasn't checking the files I expected. As to the account, it's an offline test system. Root via console is safe to use. Obviously on a live system one would su. But well spotted and thank you anyhow for the tip.
– Stilez
Oct 9 '17 at 17:04





This gave me a good hint. Based on this answer, I looked up the bash startup and the files it's hard-coded to check, and found one of those was in use (~/.profile), so it wasn't checking the files I expected. As to the account, it's an offline test system. Root via console is safe to use. Obviously on a live system one would su. But well spotted and thank you anyhow for the tip.
– Stilez
Oct 9 '17 at 17:04













FreeBSD comes with very good documentation. Learn to use "man". It is a short read for bash and gives your answers: freebsd.org/cgi/man.cgi?query=bash As a beginner make sure you get good habits. Even though you have console access I would recommend not to use root as login.
– Claus Andersen
Oct 10 '17 at 8:37




FreeBSD comes with very good documentation. Learn to use "man". It is a short read for bash and gives your answers: freebsd.org/cgi/man.cgi?query=bash As a beginner make sure you get good habits. Even though you have console access I would recommend not to use root as login.
– Claus Andersen
Oct 10 '17 at 8:37












Good. My point was that .profile was mentioned on the bash man page. All the TERM stuff is related to another questions :-) (Which is hard to grok from the man pages!)
– Claus Andersen
Oct 10 '17 at 8:47




Good. My point was that .profile was mentioned on the bash man page. All the TERM stuff is related to another questions :-) (Which is hard to grok from the man pages!)
– Claus Andersen
Oct 10 '17 at 8:47












I've been using it solidly in every case, for the entire time I've been trying to learn the OS, as well as Google/SE. I asked because changing the files referred to by pages in man did nothing. It's such a huge subject that it's not always easy even to know what to look for. Man assumes some clue what to look for, and a well defined topic suited to its pages - knowing where might be promising to look. With the best will in the world, that's not always a beginners situation.
– Stilez
Oct 10 '17 at 8:48





I've been using it solidly in every case, for the entire time I've been trying to learn the OS, as well as Google/SE. I asked because changing the files referred to by pages in man did nothing. It's such a huge subject that it's not always easy even to know what to look for. Man assumes some clue what to look for, and a well defined topic suited to its pages - knowing where might be promising to look. With the best will in the world, that's not always a beginners situation.
– Stilez
Oct 10 '17 at 8:48













(Above 2 comments are reversed, I deleted and reposted mine due to 5 min timeout about the same time its reply was posted.)
– Stilez
Oct 10 '17 at 8:56





(Above 2 comments are reversed, I deleted and reposted mine due to 5 min timeout about the same time its reply was posted.)
– Stilez
Oct 10 '17 at 8:56


















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f397049%2flocating-bash-rc-files-in-freebsd%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?