[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 609
  • Last Modified:

How can I simulate a logout/login in Terminal to change path in Mac OS X 10.6 (Snow Leopard)?

Using Terminal in Mac OS X Snow Leopard, I have changed my path by adding a file to the /etc/paths.d directory. One way to make this take effect is to logout, then log back in.

However, I have used another method in the past, but can't remember what it was. There is a command that can be run from within Terminal that will basically "reboot" the user's settings without having to log out.

I think it had something to do with launchctl or launchd or another one of the launch-related utilities.

Anyone know what this command is?
0
lisfolks
Asked:
lisfolks
  • 4
  • 3
1 Solution
 
SamMacPCCommented:
paths.d looks like it's a text file, not a folder. If you want to log out, you can use the shutdown command, you may be able to just use kill + launchd to start and stop the process you want, but this is dangeous, depending on the state the system is in.
0
 
roylongCommented:
If I was you I'd add the new path to the .profile instead of the way you have done it.

You can then source the the file from the Terminal::

source ~/.profile
0
 
lisfolksAuthor Commented:
SamMacPC:
1. /etc/paths.d is a folder. It is the preferred way, since Leopard, to add path items. Simply add a file, containing the path item, into that folder, and it will be appended onto the end of the Apple-provided path. You can name the file anything you want, so I name mine according to the app related to the path item I'm adding.  Here is more detail:
http://arstechnica.com/civis/viewtopic.php?f=19&t=49946&p=1607692

This works for the manpath as well.

2. I wanted to avoid a logout or shutdown.

roylong:
'Source' is a good method, if I were using the .profile. However, I would like to avoid that method. I like using the /etc/paths.d method.

I used the method I'm trying to find when adding other files; it's just been awhile, and I can't remember where I found it, either.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
roylongCommented:
doesn't the paths.d get used everytime the .profile and .bashrc get sourced?
0
 
lisfolksAuthor Commented:
Well, I'm not sure. As far as I have found, 'source' is a built-in shell command. In Bash, it is a synonym for the '.' (dot) command. It simply runs a specified script. So, the command 'source .profile' simply runs the .profile script.

Given that, does running the .profile script cause the paths.d and .bashrc to run as well? I'm going to think not.

As for the command I was looking for, I was able to find what I did when I last updated my paths.d with a new file: I simply exited Terminal completely, then opened it again. The path then showed as being updated.

Now, my question is: does that update the path for the underlying OS as well? I never thought about that before. It seems that it would because I don't think Terminal is doing anything separate with the path. Whatever path shows in Terminal is what the system as a whole is using, no?
0
 
lisfolksAuthor Commented:
Okay, I'm thinking that no, updating the path in the Terminal still will require a logout/login to be effective in what I incorrectly called the "the underlying OS". This is because, if I understand the UNIX underpinnings correctly, the Mac interface is using a TTY terminal set at login. When I use the Terminal app, I am opening a new TTY terminal. All terminals AFTER that one will use the updated path - but since the interface TTY was opened earlier, it will still be using the previous path. Logging out, then logging back in, will set the interface TTY to the new path.

Is that correct?
0
 
roylongCommented:
That sounds correct.  I'll take another look later.
0
 
lisfolksAuthor Commented:
I'm accepting my own answer for this question as I believe it is correct. Since it was not formally verified, though, I gave it a 'B' grade - it is an "educated guess" at this point.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now