Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Every time I launch a terminal it attempts to execute sudo apt-get update

This happens regardless of which terminal emulator is used - both guake and gnome-terminal do it at least.

It also does the behavior upon creating new tabs within either terminal application or when logging into different ttys. Any time a new bash is started it seems.

Additionally, the command inexplicably fails (command not found) - though it executes perfectly if I type it in manually.

How can I make this strange terminal quirk desist?

enter image description here

share|improve this question
    
My limited knowledge whispers to me this is something to do with an environmental variable...? I didn't see anything unusual in ~/.bashrc or in the output of env (who can tell I'm grasping at straws?) –  Insperatus Dec 12 '12 at 6:09
add comment

2 Answers 2

up vote 3 down vote accepted

The error message

sudo apt-get update: command not found

means that something is trying to execute a command called "sudo apt-get update", not the command sudo with arguments apt-get and update.

There must be such a command in one of the several scripts that are invoked when bash starts. It could be any of:

  • /etc/profile
  • ~/.bash_profile
  • ~/.bash_login
  • ~/.profile
  • ~/.bashrc

or something invoked by any of them. Try grepping for apt-get in those files. If that fails, look at other scripts and commands they invoke.

For example, I just reproduced the error message by (temporarily) adding this line:

"sudo apt-get full-upgrade"

(including the quotes) to my ~/.bashrc.

You can also try running bash -lx from the prompt; -l makes it a login shell, and -x causes it to trace commands. To save the output in a file:

bash -lx < /dev/null > bash-lx.log 2>&1
share|improve this answer
    
Thanks for your thorough answer. I unfortunately didn't see anything causing this problem. Take a look: /etc/profile ~/.bash_profile - doesn't exist on my machine ~/.bash_login - doesn't exist on my machine ~/.profile ~/.bashrc /etc/bash.bashrc bash-lx.log(created via your command) As for scripts invoked by the above files I checked /usr/share/bash-completion/bash_completion - didn't see anything. –  Insperatus Dec 12 '12 at 17:26
    
It is my ~/.bash_aliases of all things. This line was the culprit:alias add-ppa='sudo add-apt-repository'&&'sudo apt-get update' I feel quite silly now having expended all this effort, thanks for your help. I'd forgotten I was messing around trying to make an alias for adding a ppa. I didn't know how to make it auto-confirm the ppa. –  Insperatus Dec 12 '12 at 17:41
add comment

As everyone is saying, most likely is your .profile. But it also says that command is not found because the path to the binary is not specified (in case you want to actually run this command).

share|improve this answer
1  
It's likely that the apt-get line appears before he sets PATH in his startup script, hence the command not found error. –  Eric W. Dec 12 '12 at 6:48
    
Thanks! I had added a lousy line in my ~/.bash_aliases! –  Insperatus Dec 12 '12 at 17:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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