I'm trying to change the $PATH of an individual user in fish-shell so that berryconda runs before default python.
I've found my way to the config.fish file and added what the file says to add for login shells.
if status --is-login
set PATH /root/berryconda3/bin/python $PATH
end
My issue is this doesn't seem to change the $PATH at all and I also only want it to occur for one specific user anyway so I don't think this is correct. How can I go about changing the $PATH of an individual user in fish-shell.
Add the following to the user's ~/.config/fish/config.fish file:
contains /root/berryconda3/bin/python $PATH
or set -gx PATH /root/berryconda3/bin/python $PATH
Using if status is-login to guard the modification is reasonable if you only want it to be done for the first shell launched by a terminal. However, it may never be true if the terminal is configured to launch the shell without marking it a login shell.
Also, that point points to a file in the root acount home dir. That may not be accessible by a non-root user and in any case it is bad idea to have non-root accounts depending on files in the root user home dir.
Related
When I use command sudo vipw to edit my password file, It's always use vi as editor. I don't like this very much and want to change it to vim.
I already tried:
Add export EDITOR=/usr/local/bin/vim in /etc/profile.
But shell told me "export: Command not found". I thought the reason is export is built-in function only in bash. And I don't want to change my shell.
AddEDITOR=/usr/lcoal/bin/vim in default block of /etc/login.conf
Add setenv EDITOR vim in /root/.cshrc, /.cshrc, ~/.cshrc
All above didn't work at all.
I have google for hours but could not find anything help.
Your /etc/sudoers file doesn't keep your EDITOR environment variable.
I personally have an /etc/sudoers.d/local file, something like
# We don't need to worry about wheel users breaking in to get root access because they already have it.
Defaults:%wheel env_keep+="HOME EDITOR",!set_home,shell_noargs
I'm not sure why this isn't the default, since wheel users have already been given full access. But it's apparently prevailing wisdom to continue hassling them.
Note: If you're using an older /etc/sudoers file that doesn't support an /etc/sudoers.d directory, these lines can be dropped in there... or you could add #includedir /etc/sudoers.d as the last line of your /etc/sudoers file to enable an /etc/sudoers.d directory. Um, yes, the # is a required part of that line, because someone thought it was important for that directive to look like a comment.
Try adding this to the root user /root/.chsrc:
setenv EDITOR vim
or to set it globally to all users using shell tcsh/csh add it in /etc/csh.cshrc
From the man:
A login shell begins by executing commands from the system files /etc/csh.cshrc
and /etc/csh.login. It then executes commands from files in the user's home directory:
first ~/.tcshrc or, if ~/.tcshrc is not found, ~/.cshrc ...
Non-login shells read only /etc/csh.cshrc and ~/.tcshrc or ~/.cshrc on startup.
Also verify vim is installed since is not by default, you could try:
pkg install vim-console
setting the EDITOR or VISUAL environment variable is the key.
if you don't want to go to the trouble of modifying config files (which is indeed the long term solution) then you could sudo su - to get to the root prompt and then you could export EDITOR=/usr/bin/vim before running vipw
There is an empty file called .selected_editor in $HOME (/root).
Remove it and the next call to vipw will ask you to select the editor.
I'm very new to this so apologies if it doesn't make sense. I can't log into my computer (fedora 27) because I think I've incorrectly assigned an environmental variable called PATH.
I tried to set a path for an environmental variable by using
vi ~/.bashrc
PATH=usr/local/bin
once I exited vi the terminal would keep popping up with the question 'do you want to install sed? N/y'
I exited the terminal and started a new one but the same problem occurred.
I thought if I restarted my machine it may resolve itself but now I can't log back onto my personal user account. I input my password and it accepts it, starts to load the homepage but then asks for my password again. I can't think of what I did apart from set the local environment variable PATH.
I can log onto the root user so my question is does anyone know how to change the local environmental variable on my personal account while being logged onto the root user?
vi /home/user/.bashrc
Something like that?
Change the PATH Variable to something like this:
PATH=$PATH:usr/local/bin
I have set the LD_LIBARY_PATH in the /etc/profile.d folder of my CentOS distro, and it works properly for all users.
However, when I fire up screen, it does not inherit it. Is there any way to set the LD_LIBRARY_PATH for screen for all users (without editing all .bashrc files for all users) ?
Thank you
I think you're looking to set the enviroment variable for the system. Just add it to /etc/environment and when a user logs in the variables will be set.
You'll need root access in order to update it. So make sure to edit with sudo.
/etc/environment
LD_LIBRARY="{insert path here}"
The file that needs to be modified is the
/etc/bashrc Now screen can see properly the LD_LIBRARY_PATH variable
I am developing web applications using Ruby on Rails and Sublime Text 3 on OS X 10.8.4. I recently installed the package RubyTest. The tests only work when Sublime is launched using the command
subl
in terminal. Otherwise I get the error message:
/bin/sh: rspec: command not found
I think that's meant to be the case; that's implied in RubyTest's readme file on github.
However I'd like to retain the ability to launch from the dock. Is there a way I can do this?
Unfortunately, OSX applications do not pick up on your $PATH variable set in Terminal. To change the internal PATH settings in Mountain Lion (this method hasn't been tested with previous versions, although it should work), you'll need to edit /etc/launchd.conf:
Make sure you have admin privileges.
Open Terminal or your favorite substitute and see if there's anything in the file /etc/launchd.conf:
cat /etc/launchd.conf
If you get an error like
cat: /etc/launchd.con: No such file or directory
then continue with the next step. If the cat command does display some content, copy it to the clipboard.
Create a new text file with the following content, modified to fit your needs:
setenv PATH /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/Users/YourUserName/bin:/path/to/gems/bin
If the cat command displayed some content in the previous step, paste it into the new file before the setenv PATH command. If it already contains a setenv PATH command, just modify it to add the directories you need, such as /path/to/gems/bin
Save the new file in your home directory (/Users/YourUserName) as launchd.conf.
Go back to Terminal and enter:
sudo mv ~/launchd.conf /etc
to use admin power to move the new file to /etc, replacing anything that was there before. Depending on your previous usage of the sudo command, you may get a short "be careful doing what you're doing" message, but either way you'll need to enter your password. /etc is not directly accessible through the Save dialog unless you're a real power user and know how to get around OSX's file system restrictions.
Reboot your computer
And you should be all set. If you're interested, launchd and launchctl use the csh/tcsh syntax, so you can't use the bash/zsh export PATH=/usr/local/bin:... format.
I'm using AIX 5.3 with sudo 1.6.9p23. Sudoers file grants user fcomartin permission to run any command as user oas:
fcomarti ALL=(oas) ALL
User oas has a bash script called menu, from which it launches another scripts depending on the selected option. The problem is that some of the secondary scripts redirects standard output to text file "temp" which is owned by oas user, when this happens the system tells me that user do not have the right permissions to write.
User fcomarti uses ksh, then the used command is as follows:
sudo -u oas bash menu
(bash because user oas uses bash) Menu starts, menu launches monitorAv script, inside monitorAv is the line echo > temp, it then tells user fcomarti it do not have the right permissions to write.
The script is running as user oas, not as user fcomarti, so if it is trying to write to a file in a directory owned by fcomarti it is probably not going to have the appropriate permissions.
You could make user oas share a group with user fcomarti and then grant group write permissions on certain directories, or you can have the script output to a location that is writeable by the oas user (e.g., /tmp, or some directory you have explicitly created for that purpose, such as the HOME directory for user oas).
I've finally solved the problem, the sintaxis of sudo is as follows:
sudo -u oas bash -c "cd /Oas/bin; menu"
This is because some of the secondary scripts launched by menu, needs an absolute route to work.