I've been creating a project for managing my complete terminal environment. One of the things I manage are the dotFiles. So I have separate dotfiles for e.g.   ivonet-alias.sh ivonet-docker.sh ivonet-functions.sh etc.   When I run setup.sh from my project I install symlinks (ln) to my ivonet-*.sh files in my HOME folder. Now to activate them I do the following (once):  prefix="ivonet" resource="${HOME}/.zshrc" echo "" &gt;&gt;${resource} echo "# Personal dotFile resources:" &gt;&gt;${resource} echo "for f in \${HOME}/.${prefix}-*.sh; do source \${f}; done" &gt;&gt;${resource}   On my own machine I use oh-my-zsh shell and I make it so that that file is changed so that when I open a new terminal session all my dotfiles are sourced in. This works fine but now a couple of colleagues asked to use my setup for dotfiles too and I gave them my repo and it didn't work as I had hoped. The were not using zsh but bash, but even that was not uniform.  When I changed the setup to write to .bashrc it worked for one colleague but not for the other. So in the end I had to do it multiple ways.    once in .profile twice in .bash_profile once in .bashrc   Can anyone help me on how I can determine where to make the changes?  I would like to be able to check this from a script something like:  check=$(which bash) if [[ -z "${check}" ]]; then    #do stuff here fi   but I have no idea how to do this. I know it looks like this  but I'm more interested on how I can automatically determine which file is loaded.
31487
I've used a number of different *nix-based systems of the years, and it seems like every flavor of Bash I use has a different algorithm for deciding which startup scripts to run.  For the purposes of tasks like setting up environment variables and aliases and printing startup messages (e.g. MOTDs), which startup script is the appropriate place to do these?  What's the difference between putting things in .bashrc, .bash_profile, and .environment?  I've also seen other files such as .login, .bash_login, and .profile; are these ever relevant?  What are the differences in which ones get run when logging in physically, logging in remotely via ssh, and opening a new terminal window?  Are there any significant differences across platforms (including Mac OS X (and its Terminal.app) and Cygwin Bash)?
22485
In my .zshrc I tried to make a few aliases .I looked into a lot of places, but I couldn't find out a way that worked. I used this code below:    # Set personal aliases, overriding those provided by oh-my-zsh libs,  # plugins, and themes. Aliases can be placed here, though oh-my-zsh  # users are encouraged to define aliases within the ZSH_CUSTOM folder.  # For a full list of active aliases, run alias. # # Example aliases alias zshconfig="mate ~/.zshrc" alias ohmyzsh="mate ~/.oh-my-zsh" alias n= "nano"   alias m= "mkdir" alias w= "cd ~/Documents/UoMWorkspace/Semester2"   alias j= "cd ~/Documents/UoMWorkspace/Semester2/COMP17412"   Then I wrote a command source ~/.zshrc. Still it didn't resolve the issue. I get error messages like zsh: command not found: j  Could anyone help me with any suggestions and let me know what am I doing wrong?
124117
There is a script which just adds extra lines to my /etc/hosts file to enable local development. Since it's pretty useful, I decided to keep it in a gist. When one of my friends downloaded the shell-script, changed the necessary permissions and tried to run it, it failed. The error shown is:  $ ./dev-mode : No such file or directory  Even though the script runs perfectly file on my computer. The /etc/hosts file exists in both our computers, the permissions and the owners are the same. Every thing is absolutely similar. Then he made a new file, copied the contents of the script to the new file, and changed the necessary permissions, and it RAN! To my eyes, there is no conceivable difference between the two files, but a diff does that they are difference, but doesn't highlight any line or any character... Nothing. The permissions are same, etc. Does ubuntu treat downloaded files somehow differently, and stop it from running? Absolutely same files, one runs and the other doesn't
53485
[Reviewers: note that the question was completely rewritten after the close votes.]  I recently found how I can define aliases for bash in the ~/.bashrc.  But since I tried that, I see the followig messages eveery time I open a terminal.  I added some bash aliases to my I was trying to create shortcuts using alias but I unsuccessful and somehow managed to get the message below every time I open up a new terminal.  bash: alias: UIC: not found bash: alias: =: not found bash: alias: sudo openvpn --config ~/vpn/UIC-alopez78.ovpn: not found bash: alias: mat: not found bash: alias: =: not found bash: alias: cd /home/alexisblopez/MATLAB/R2014a/bin/: not found bash: alias: lab: not found bash: alias: =: not found bash: alias: ./matlab: not found ~$    Its's confusing; it does not say error, but because my aliases do not work, I think I did something wrong with them - I don't know what!
48133
I like to use tools like history, script, and asciinema to record and review xterm (i.e. bash/sh) sessions for typical, general administration reasons, and also, sometimes for comprehensive study/revision; as a learning tool.   I thought of setting the default $SHELL as a direct path to said tools and/or commands, like:   /bin/script transcript.log;  /bin/asciinema rec -w0.5 term_log.json;  But these tools typically rely on having a default $SHELL set (i.e. /bin/bash, /bin/sh, /bin/zsh, etc.). Also, I feel like re-defining system variables (i.e. $SHELL, $TERM, etc.) or trying to get it working with config (*.conf) and dot (~/.bashrc / ~/.bash_profile) files is gona be riddled with all kinds of holes and potential problems. However, every time I decide or realize that I want a transcript of a session, it's after the fact, or I'll be halfway through the interesting part already, or some such scenario.   What's the correct, or best practice to set something like this up to simply log everything (preferably stdin, stdout (and stderr when applicable), etc.) automatically?
43537
Just installed Ubuntu 14.04.1 LTS.  According to .profile,  # ~/.profile: executed by the command interpreter for login shells.  # This file is not read by bash, if ~/.bash_profile or ~/.bash_login exists.   There is no ~/.bash_profile or ~/.bash_login.  It does not seem to source .profile when opening a terminal.   Why doesn't it source .profile when opening a terminal? Why is .profile there if it is not sourced? How do I know/control what is sourced when a new terminal is opened? When a new terminal is opened, does it do a "login"? Where is a good place to add $HOME/bin to my path? .bashrc? Will that cause a problem because .profile has the same code?
28646
I've read in a couple of places that the PATH is set in /etc/profile or the .profile file that's in the home dir.  Are these the only places that the path is set in? I want a better understanding of it.  In the /etc/profile file, as the following comment says "system-wide .profile file for the Bourne shell". Does that mean that profile files are the main configuration files for bash?  In that file I don't see the PATH var being set at all. In the .profile file in the home directory there's this line:  PATH="$HOME/bin:$PATH"   That's resetting PATH by the looks because it's concatenating the already set $PATH string with $HOME/bin: right? But if etc/profile and ~/.profile are the only files setting PATH where is $PATH coming from in that line of code if it's not defined in /etc/profile?  Can someone experienced please give a broad and detailed explanation of the PATH variable? Thanks!
63641
To create persistent environment variables, I add the script file to /etc/profile.d directory, for example:   # my script export MY_VAR=var_value   This works properly for current user:   alex@alex-64:~$ echo $MY_VAR var_value   Now I need the same environment variables for the root user, but /etc/profile.d script doesn't work for root:   alex@alex-64:~$ echo $MY_VAR var_value alex@alex-64:~$ sudo su root@alex-64:/home/alex# echo $MY_VAR  root@alex-64:/home/alex#    How can I set the same variables for the root?
66951
I have this script:  echo $HOME cd $HOME cd / cd /usr/local/src/   When I run it like this  . script.sh   I get this output:  /home/user : No such file or directory : No such file or directory : No such file or directory   If I run it normally (I added #!/bin/bash before the first line)  sh script.sh   I get this output:  : not found.sh: 2: script.sh /home/user script.sh: 3: Can't cd to /home/user script.sh: 4: Can't cd to / script.sh: 5: Can't cd to /usr/local/src/   The script was run from $HOME directory each time. If I run each command one by one from shell, it executed without problems (invoking cd $HOME from within $HOME simply didn't change directory).  What must I do to make this work?
75991
What is the proper way to modify environment variables like PATH in OS&nbsp;X?  I've looked on Google a little bit and found three different files to edit:   /etc/paths ~/.profile ~/.tcshrc   I don't even have some of these files, and I'm pretty sure that .tcshrc is wrong, since OS&nbsp;X uses bash now. Where are these variables, especially PATH, defined?  I'm running  (Leopard).
98746
Does Linux have the capability to use "junctioned" symbolic links? I'm not sure if this is an actual term or not, so let me explain the concept.  I have a git repository containing all my configuration dot files in ~/dotfiles. I use symbolic links into this directory in order to "activate" them. For example, by executing ln -s ~/dotfiles/bash/bash_profile ~/.bash_profile to produce the link:  ~/.bash_profile -&gt; ~/dotfiles/bash/bash_profile   However, I find myself in a situation where I want to combine the contents of multiple files. For example, I want the ~/.bash_profile symbolic link to point to two separate files, one for each project. E.g.:  ~/.bash_profile (1) -&gt; ~/dotfiles/bash/bash_profile (2) -&gt; ~/dotfiles/proj/bash_profile   I know I can simply concatenate the two files (e.g., cat ~/dotfiles/{bash,proj}/bash_profile &gt; ~/.bash_profile), but if I can do the same thing with symbolic links, I would prefer to.  I imagine that if such a feature exists (Nix is pretty huge), then under the hood it would have to map the two different files together, hiding all sorts of complexities under the hood (mapping file offsets of all non-first "mapped" files, locking all files when writing to the junctioned symbolic link, etc, etc).  If such a feature doesn't exist, are there are plans to implement it?
25388
So, I don't have .bash_profile neither .profile in my home folder. How do I create them? After that, what should I do so every time I open the terminal these files get read?
76958
Suppose I have a bash file called myBash.bash. It resides in:    /myDirect/myFolder/myBash.bash   Now I want to use the string /myDirect/myFolder (the location of myBash.bash) inside the script. Is there a command I can use to find this location?  Edit: The idea is that I want to set-up a zip-folder with code that can be started by a bash script inside that zip-file. I know the relative file-paths of the code inside that zip-file, but not the absolute paths, and I need those. One way would be to hard-code in the path, or require the path of the file to be given as a variable. However I would find it easier if it was possible for the bash-file to figure out where it is on its own and then create the relevant paths to the other file from its knowledge of the structure of the zip-file.
2114
Normally we can source ~/.bashrc file using this command  source ~/.bashrc   but if I write this in a shell script and execute it, nothing happens. Why? Is there any way to do this?  My script:  #!/bin/bash chmod a+x ~/.bashrc source ~/.bashrc   Also tried . (dot) instead of source. Same result.
96718
I'd like a way to add things to $PATH, system-wide or for an individual user, without potentially adding the same path multiple times.  One reason to want to do this is so that additions can be made in .bashrc, which does not require a login, and is also more useful on systems which use (e.g.) lightdm, which never calls .profile.  I am aware of questions dealing with  from $PATH, but I do not want to remove duplicates.  I would like a way to add paths only if they are not already present.
85395
I am using a scrtipt with instruction 'SH -c command', where command is an alias from bash, this alias can not be interpreted into Bourne shell. ¿Do you have any idea for set this alias into Bourne shell and getting that it works in the new shell? Thanks everyone !
47349
Sometimes when I simply type a valid command like 'find ...', or anything really, I get back the following, which is completely unexpected and confusing (... is command name I type): sh: $'\302\211...': command not found  There is some corruption going on I think. I don't use color in my prompt, I am using the Bash shell in POSIX mode as sh (chsh to /bin/sh and so on - $SHELL is sh). What is going on and why does this keep happening? Anything I can debug? I think this is more of an xterm issue than sh, or at least a combination of the two. Files, for context: My /etc/profile, as distributed with Arch Linux x86-64: # /etc/profile  #Set our umask umask 022  # Set our default path PATH=&quot;/usr/local/sbin:/usr/local/bin:/usr/bin&quot; export PATH  # Load profiles from /etc/profile.d if test -d /etc/profile.d/; then         for profile in /etc/profile.d/*.sh; do                 test -r &quot;$profile&quot; &amp;&amp; . &quot;$profile&quot;         done         unset profile fi  # Source global bash config if test &quot;$PS1&quot; &amp;&amp; test &quot;$BASH&quot; &amp;&amp; test -r /etc/bash.bashrc; then         . /etc/bash.bashrc fi  # Termcap is outdated, old, and crusty, kill it. unset TERMCAP  # Man is much better than us at figuring this out unset MANPATH  My /etc/shrc follows below. It's something I created as a way to have sh parse some file on startup, for a non-login shell; it is achieved using ENV variable set in /etc/environment with the line ENV=/etc/shrc: PS1='\u@\H \w \$ ' alias ls='ls -F --color' alias grep='grep -i --color' [ -f ~/.shrc ] &amp;&amp; . ~/.shrc  My ~/.profile, I am launching X when logging in through first virtual tty: [[ -z $DISPLAY &amp;&amp; $XDG_VTNR -eq 1 ]] &amp;&amp; exec xinit -- -dpi 111  My ~/.xinitc, as you can see I am using the system as a Virtual Box guest: xrdb -merge ~/.Xresources  VBoxClient-all  awesome &amp;  exec xterm  And finally, my ~/.Xresources, no fancy stuff here I guess: *faceName: Inconsolata *faceSize: 10 xterm*VT100*translations: #override &lt;Btn1Up&gt;: select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)  xterm*colorBDMode: true xterm*colorBD: #ff8000 xterm*cursorColor: S_red  Since ~/.profile references among other things /etc/bash.bashrc, here is its content: # # /etc/bash.bashrc #  # If not running interactively, don't do anything [[ $- != *i* ]] &amp;&amp; return  PS1='[\u@\h \W]\$ ' PS2='&gt; ' PS3='&gt; ' PS4='+ '  case ${TERM} in   xterm*|rxvt*|Eterm|aterm|kterm|gnome*)     PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf &quot;\033]0;%s@%s:%s\007&quot; &quot;${USER}&quot; &quot;${HOSTNAME%%.*}&quot; &quot;${PWD/#$HOME/~}&quot;'                                                              ;;   screen)     PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf &quot;\033_%s@%s:%s\033\\&quot; &quot;${USER}&quot; &quot;${HOSTNAME%%.*}&quot; &quot;${PWD/#$HOME/~}&quot;'     ;; esac  [ -r /usr/share/bash-completion/bash_completion   ] &amp;&amp; . /usr/share/bash-completion/bash_completion  I have no idea what that case statement does, by the way, it does look a bit suspicious though, but then again, who am I to know.