I was editing my .bash_profile and .bash_login, and I accidentally added a circular reference so that two files were including each other. After closing the session and trying to sign in again, the circular reference hangs the process. Fortunately, this was on WSL so I can edit the file using Windows, and I also had a separate session still open so I didn't even need to. However, hypothetically if this was not the case, how would one sign in to Linux without loading the profile files, or how could one sign in and remove the circular reference?
123733
I mistakenly have source .bash_profile in the bashrc file and vice versa. Now when I tried to ssh into the machine (ec2), it will stuck at loading bash and get connection closed in a second. Is there a way I could fix it? Could I mount the disk to another ec2 instance to fix the bash files?  Update 1: I tried the following: %  ssh -i &quot;my-pem.pem&quot; -t ubuntu@&lt;server_address&gt;.amazonaws.com &quot;/bin/bash --noprofile --norc&quot; Connection to &lt;server_address&gt;.amazonaws.com closed.  Nothing else showed up. Do you have any idea on what was going wrong? For sanity check, if I do ssh -i &quot;my-pem.pem&quot;ubuntu@&lt;server_address&gt;.amazonaws.com, the message will be ...  28 packages can be updated. 0 of these updates are security updates. To see these additional updates run: apt list --upgradable  New release '20.04.2 LTS' available. Run 'do-release-upgrade' to upgrade to it.   Last login: Mon Feb 22 23:17:41 2021 from ip Connection to &lt;server_address&gt;.amazonaws.com closed.  Solution Just ssh onto the machine and immediately do Ctrlc and fix the bash files.
44810
For whatever reason, we do no longer need to be root (or using sudo) to run /sbin/shutdown, /sbin/reboot etc.  This seems to be because those executables are now symlinks to /bin/systemctl which handles everything as normal user.  However, what if I want shutdown and reboot to require root authentication again? How can I achieve this?
95185
A sample script can be as below:  #!/bin/bash sudo su ls /root   When using ./test.sh as the normal user, instead run ls as super user and exit, it switches to root; and when I logout, it executes ls /root as the normal user.  Can anybody tell me about the mechanism about it?
101171
I can't find .bash_profile in Ubuntu 14.04 in my /home/user directory. I used the ls -a command to see the .bash_profile, but there isn't such a file.
97625
Answers to the questions on  and , along with poking through (and reading headers of) $HOME and /etc/, indicate a number of files that can be used to set environment variables, including:   ~/.profile  ~/.bashrc  ~/.bash_profile  ~/.gnomerc ~/.Rprofile  /etc/bash_bashrc  /etc/profile /etc/screenrc    I gather that files in /etc/ work for all users whereas files in $HOME are user-specific. I also gather that .profile is loaded at login whereas .bashrc loaded when /bin/bash is executed. I also understand that different programs have different settings files (e.g. .Rprofile for R). But I would appreciate some clarification:   Are *rc and *profile files fundamentally different? What is the scope of such files (e.g. which files are are commonly used with Linux) Is there a hierarchy (e.g. .bashrc overwrites variables set in .settings) What is a good reference for this class of files? For the options in these files?   Linked questions
86461
I use Ubuntu 15.10 and I'm very new in Linux. After reading in Wikipedia , and after executing a symlink creation command in the Ubuntu Unix-bash terminal, I ought to better understand the structure of a symlink I worked with several times when creating (and "destroying") Ubuntu learning environments.  There is a short syntax I ran each time when installing a PHPmyadmin (PMA) service. Without running it, the service just didn't work. From the information I gathered, this following syntax creates a symlink that connects Apache to a certain PMA file that includes conf directions.  This is the syntax I ran each time:  cd /etc/apache2/conf-enabled/ sudo ln -s /etc/phpmyadmin/apache.conf phpmyadmin.conf service apache2 restart   I want to better understand what is actually being done here, for example:   Why is the cd navigation even needed? Couldn't we specify which files we want to work on from the root (computer) folder and that's it? Why is the -s after the ln?  I navigated to both directories in the ln command but I couldn't find phpmyadmin.conf in either of them - So, how can the system know where it is (assuming there is no system-wide search for it).
117402
I created a new user with useradd name and forgot to use -d -m to create their home directory.  I tried making one, copying the contents of /etc/skel, and chowning everything to the new user.    Aliases don't work, such as ll, and I just have a $ at the command prompt, instead of name@server ~$. Also, using the scroll wheel dumps garbage on the command line :(  How do I fix this, or is it easier to delete the user and start over?
64994
file contains just 1 line:  aaa   when I run "cat file" it mixes to username  user /dir : cat file aaauser /dir :   What could be the problem ?  Extra Info:  perhaps this is not properly set in bashrc ? ?  PS1='\u \W : '   UPDATE:  shouldnt there be a solution other than including a newline to the file ?  Why would there be no care for the elements that can distort the command line prompt ? ( by not having a new line )
79887
Ubuntu 18.04.4 (automatic upgrade from 18.04.3 just a few weeks ago) /bin/bash  After I log in from the Gnome shell, this message appears while the screen is just plain purple and before the desktop appears:  Error found when loading /home/hfinger/.profile:    /home/hfinger/.profile: line 1: #: command not found   /home/hfinger/.bashrc: line 1: syntax error near unexpected token '(' /home/hfinger/.bashrc: line 1: '# ~/.bashrc: executed by bash(1) for non-login shells.'    As a result the session will not be configured correctly.   You should fix the problem as soon as feasible.     Trouble is, what is the problem? I have searched AskUbuntu but no-one appears to have experienced this exact problem. I don't think it is the upgrade because it had been running for about a month before this problem appeared.    I have never touched these two files because I am quite happy to let the system create and configure them. Also, I try to keep Ubuntu as vanilla as possible to avoid having to restore settings after upgrading to a new release. For what it is worth, here are the first lines of each of these files:    .profile, line 1: # ~/.profile: executed by the command interpreter for login shells.   .bashrc, line 1: # ~/.bashrc: executed by bash(1) for non-login shells.     How do I need to fix these files? What additional information should I provide so that someone more knowledgeable than I can solve this dopey problem?
68421
I was swapping some readline settings in my .bashrc earlier today and mistyped the following (bind since it's not in .inputrc):  bind "mark-symlinked-directories on"  I forgot to put a set in there before mark-symlinked-directories, the end result of which was that my "d" key stopped working in the terminal.  Lame.  Some messing around with other bindings indicated that whatever the first letter of the last "word" was would be unusable, i.e.,  bind "page-completions off" messed up c  bind "visible-stats on" messed up s  bind "completion-query-items 42" messed up i  My question is why?  What is bind doing that renders those keys useless, and why that specific key?
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!
95330
Ok. So, I'm used to Ubuntu and CentOS more than redhat, so I'm hoping there's some obvious solution to this that I'm missing.  I've installed Anaconda (Python). I've placed it in:  /opt/anaconda3   I would like for myself and all users to be able to have the following in their paths:  /opt/anaconda3/bin   I have googled around and have gained a lot of conflicting information about how to "properly" accomplish my mission.  Stuff I have tried:   Adding a bash script to /etc/profile.d Editing /etc/profile Editing /etc/bashrc Adding to root bashrc Editing user .bashrc   All edits involved some form of:  PATH=/opt/anaconda3/bin:$PATH   or  export PATH=/opt/anaconda3/bin:$PATH   Option 2 yielded the addition of /opt/anaconda3/bin to the path for multiple users, but after terminal restarts still did not run the commands within bin (i.e. conda install, ipython notebook, etc.)  Any ideas?
27663
I just ran this a few seconds ago. I managed to do Ctrl - C as soon as I realized what I started doing.  So far the only directory it's started going through is /bin.  I'm afraid to do anything else. So far I realized I can't use su as my normal user anymore.  Luckily I still have another root terminal open. What do I do?
105424
I would like to create a symlink to ~/foo/ but when I write that, ~ is always resolved to the absolute home path. I've used ../s in the past and they work fine, is ~ not allowed?  The reason I'd like to do that is because ~ has a different absolute path depending on the machine and Linux/OSX, but always points to my home directory.  I'd like to include such a link in a git repo sync'd across several machines.
14348
It's a situation that has happened quite often to me: after I press (with a different intention) Ctrl-S in a terminal, the interaction (input or output) with it is frozen. It's probably a kind of "scroll lock" or whatever.  How do I unfreeze the terminal after this?  (This time, I have been working with apt-shell inside a bash inside urxvt--not sure which of them is responsible for the special handling of Ctrl-S: I was searching the history of commands backwards with C-r, as usual for readline, but then I wanted to go "back" forwards through the history with the usual--at least in Emacs--C-s (, , ), but that caused the terminal to freeze. Well, scrolling/paging to view past things still works in the terminal, but no interaction with the processes run there.)
25210
When I log in, I see the error:     bash: alias: alias: not found   If I source my .bashrc file, the message appears again.  What is causing this?
64393
As of late, and without my deliberately doing anything to make it happen, my Bash prompt has an  (i.e. @) prepended to it. This did not previously happen. Nor can I see anything in my ~/.bashrc that seems as though it ought to be making this happen.  This is on Debian Jessie GNU/Linux, using GNU Bash.  For example, my current Bash sessions look like this:  @sampablokuper@debianbox:~$ python3 Python 3.4.2 (default, Oct  8 2014, 13:14:40)  [GCC 4.9.1] on linux Type "help", "copyright", "credits" or "license" for more information. @&gt;&gt;&gt; 1+2 3 @&gt;&gt;&gt; exit() @sampablokuper@debianbox:~$    whereas originally, they would have looked like this:  sampablokuper@debianbox:~$ python3 Python 3.4.2 (default, Oct  8 2014, 13:14:40)  [GCC 4.9.1] on linux Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; 1+2 3 &gt;&gt;&gt; exit() sampablokuper@debianbox:~$    Here are all the lines from my ~/.bashrc that appear to in any way relate to the Bash prompt:  # set variable identifying the chroot you work in (used in the prompt below) if [ -z "${debian_chroot:-}" ] &amp;&amp; [ -r /etc/debian_chroot ]; then     debian_chroot=$(cat /etc/debian_chroot) fi  # set a fancy prompt (non-color, unless we know we "want" color) case "$TERM" in     xterm-color) color_prompt=yes;; esac  # uncomment for a colored prompt, if the terminal has the capability; turned # off by default to not distract the user: the focus in a terminal window # should be on the output of commands, not on the prompt #force_color_prompt=yes  if [ -n "$force_color_prompt" ]; then     if [ -x /usr/bin/tput ] &amp;&amp; tput setaf 1 &gt;&amp;/dev/null; then         # We have color support; assume it's compliant with Ecma-48         # (ISO/IEC-6429). (Lack of such support is extremely rare, and such         # a case would tend to support setf rather than setaf.)         color_prompt=yes     else         color_prompt=     fi fi  if [ "$color_prompt" = yes ]; then     PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' else     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi unset color_prompt force_color_prompt  # If this is an xterm set the title to user@host:dir case "$TERM" in xterm*|rxvt*)     PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"     ;; *)     ;; esac   How can I get my Bash prompt to appear as it did originally?