I'm pretty new to Linux. I have been trying to install ant, java, and the android sdk. In the process have been messing with my ~/.profile and also with my /etc/.profile (dangerous, I know). Well I did something wrong and restarted my computer and when I would try to login, it would kick me back to the login screen. I eventually used a tty to rename my ~/.profile and made a new ~/.profile where I just deleted the last part of the profile. Here is the original file that messed me up which I renamed .profile.copy:

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting





In the ~/.profile that actually works now, I just deleted the line

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

and all the lines below it. Now ant command and sdk command don't work, of course. If I add the lines back in though, I will break my computer again.

When I was originally changing my ~/.profile, I didn't figure out for a while that you had to restart your computer for the changes to the ~/.profile to take effect (or at least sometimes you have to?). That is why there is repeating similar lines. I don't quite even understand what I'm doing when it comes to changing environment variables, and any help understanding what I can and can't add back into my ~/.profile would be ever so much appreciated.

Here's my /etc/.profile in case there's something here broke too:

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "$PS1" ]; then
  if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
      PS1='$ '

# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
  unset i

Thanks in advance to any help understanding what's going on in these files and how I can get them working again without breaking my computer!

  • Why $+PATH?!? Use the existing example: PATH="$HOME/bin:$PATH" to add new directories to PATH. – Radu Rădeanu Jul 24 '14 at 0:00
  • You also don't need to add /usr/bin and other default PATH entries if you follow the syntax @RaduRădeanu posted. Your effective line should be PATH="$PATH::~/.rvm/bin:~/adt/sdk/tools:~/adt/sdk/platform-tools:~/apache-ant-1.9.4/bin". – saiarcot895 Jul 24 '14 at 0:08

Try this changes:


export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

I removed some redundant path and I defined variable to improve readability

When you change your .profile you should run:

   source ~/.profile

or logout from terminal session and login again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.