.bash-profile

MacOSX how to autorun a script after su - root?

微笑、不失礼 提交于 2019-12-12 05:17:33
问题 Lets assume i am normal user, the i will switch to root: user ~ $ su - root Password: root ~ # So once i logged in as root , i want to run following command automatically: source .bash_profile How can i have that above command run automatically please? 回答1: According to the bash man page, .bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells. In your case, you don't need to source .bash_profile like this. You just need to put source .bash

How to set path environment variable in linux in C language code

心不动则不痛 提交于 2019-12-12 04:54:54
问题 I want to set a path environment variable in bash by C program. So I coded using 'setenv' function, But it was not the answer to solve. Could anybody suggest another way to solve this problem in C programming? I thought the other solution that the program read the profile file, then modify and save, but actually when I opened this file there's no string I wanted about PATH variable. 回答1: You can use setenv() and putenv() to set environment variables. But these will only be set for the given

Rscript using incorrect R version

感情迁移 提交于 2019-12-12 02:59:23
问题 Similar to this question which has no working answer. I am attempting to use Rscript on linux redhat 6.6, however Rscript uses the incorrect R version. How can I get Rscript to use the latest R version? Running Rscript --version yields R scripting front-end version 2.13.0 (2011-04-13) Whereas running R yields: R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" Copyright (C) 2015 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) Whereis on both R and

Adding directory to my path through ~/.bash_profile in bash?

末鹿安然 提交于 2019-12-12 01:59:49
问题 I want to add a directory to my PATH through the ~/.bash_profile file, though I don't have a file like this in my Ubuntu. I have the following code, which will check whether people have that file or not, and if not will create one and add all the existing path directories and the one entered by the user. #!/bin/bash echo "Please enter a directory that you want to add to your PATH: " read dr if [ -f ~/.bash_profile ] then # Add the read 'dr' directory to the end of the line that starts # with

Unable to add escape sequences dynamically for 'PS1'

好久不见. 提交于 2019-12-11 23:55:01
问题 Say I want to include an escape sequence dynamically: if [ -n $something ]; then user="\u" else user="admin" fi PS1='$user@\h$ ' The problem is, instead of filling in the user name, my prompt looks like this: \u@ubuntu-1$ Even if I escape the backslash ( user="\\u" ) it still does not print out the user name. How do I get the prompt to look like this: andreas@ubuntu-1$ 回答1: Use double quotes when you are trying to interpolate variables and want them to expand. You also have another option,

Bash Command which Rails does Not Find

社会主义新天地 提交于 2019-12-11 10:54:49
问题 Passenger says: Ruby on Rails application could not be started ... Command 'exiftool' not found (MiniExiftool::Error) When I login with ssh and I type exiftool in any directory the command works properly. I have the follwing line in both .bash_profile and .bashrc export PATH=$PATH:$HOME/bin Is it possible that Rails (MiniExiftool plugin) does not recognize that bash command? How can I fix this behaviour? 回答1: The PATH for the user your server runs as does not include the directory that

Why the command in /root/.bash_profile start twice?

不想你离开。 提交于 2019-12-11 08:42:08
问题 Here is my /root/.bash_profile : export DISPLAY=:42 && cd /home/df/SimulatedRpu-ex/bin && ./SimulatedRpu-V1 & When I start my server,I run ps aux | grep SimulatedRpu and here is the output: root 2758 0.2 1.0 62316 20416 ? Sl 14:35 0:00 ./SimulatedRpu-V1 root 3197 0.5 0.9 61428 19912 pts/0 Sl 14:35 0:00 ./SimulatedRpu-V1 root 3314 0.0 0.0 5112 716 pts/0 S+ 14:35 0:00 grep SimulatedRpu So,the program print error message about the port is already used. But why the command in /root/.bash_profile

Joining array into $PATH in bash on OSX

 ̄綄美尐妖づ 提交于 2019-12-11 08:15:13
问题 Trying to customize the $PATH env variable on OSX with the following in .profile : PATH=( $HOME/bin /usr/local/bin /usr/bin /bin /usr/sbin/ /sbin ) PATH=$(IFS=:; echo "${PATH[*]}") export PATH When this is loaded, I verified the path by doing echo $PATH and the output looks correct: echo $PATH /Users/apple/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin However, it doesn't look like any of the above path works. ls - bash: (something like not able to find command ls, which is in /usr/bin)

How do I make ruby's `system` call aware of my `.bash_profile` aliases?

泄露秘密 提交于 2019-12-11 02:28:02
问题 I'd like to be able to call one of my shortcuts (i.e., aliases) from within a ruby program. In other words, I want system('cpl') to be the equivalent of writing cd ~/Documents/CPlusPlus at the command line, because my .bash_profile includes the line alias cpl="cd ~/Documents/cplusplus" I'm on a Mac OSX, and while my .bash_profile lives in the usual place ( ~ ), I might be writing ruby in/to any old folder. I am using Ruby 2.2.0 which is located in /usr/local/bin/ruby . 回答1: From source docs:

Showing git branch in shell prompt?

北城余情 提交于 2019-12-10 15:26:18
问题 I am trying to get my shell prompt to display the current git branch name. I have read a few tutorials and blog posts etc. and as far as I understand I'm doing everything correctly but it doesn't seem to be working. I would like the prompt to look like this: dannys-macbook:hillcrest-store [master]$ but currently it looks like this: dannys-macbook:hillcrest-store danny$ I have added the following to ~/.bash_profile: PATH=$PATH:/usr/local/bin; export PATH COLOR1="\[\e[1;32m\]" COLOR2='\[\e[1;1m