Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am running Ubuntu 12.04 LTS and for some reason there is no terminal history (hitting the up arrow for the previous command), nor is there auto-completion (hitting the tab key). These wonderful features have always worked on any UNIX machine I have used in the past. I looked into the keyboard shorcuts menu for the terminal and did not see anything there.

  1. How can I get the up arrow to give me the previous terminal command?
  2. How can I get the tab key to perform auto-completion?

Thanks in advance!

EDIT: Pretty sure I am using bash, echo $SHELL returns /bin/sh. I am running this on my local box. I'm not sure how to run history, but when I do ls -a I am not seeing the usual history file (I think it is called .history?)

share|improve this question
2  
Need a bit more info. Are you using bash? What does echo $SHELL return? Does running history show you the past commands? If tab doesn't work you have probably changed something. Are you sshing into this machine or is your local box? –  terdon Sep 22 '13 at 17:32
    
Please check out my edit! –  CodeKingPlusPlus Jan 18 at 18:21
    
Awh I thought this was going to be a question about getting completion for words recently printed to the terminal's stdout. I've always wanted that. Guess I should ask it. Although it's a StackOverflow question iff no quick solution currently exists. –  joeytwiddle Jan 18 at 18:39
add comment

1 Answer

up vote 2 down vote accepted

You're not using bash, you're using sh. What that means depends on your system, on Debian and Ubuntu, /bin/sh is a symlink to dash so that's what your default shell is. dash does not have the functionality you want, you need to switch to another shell like bash or zsh. You can do this with the command chsh:

$ chsh
Password: 
 Changing the login shell for terdon
 Enter the new value, or press ENTER for the default
  Login Shell [/bin/sh]: /bin/bash

Now, every new terminal you open will be running bash and the up arrow should give you the history.


Even on systems where sh is a link to bash, the two are not equivalent. As explained in man bash:

   If  bash  is  invoked  with  the name sh, it tries to mimic the startup
   behavior of historical versions of sh as  closely  as  possible,  while
   conforming  to the POSIX standard as well.  When invoked as an interac‐
   tive login shell, or a non-interactive shell with the  --login  option,
   it  first  attempts  to read and execute commands from /etc/profile and
   ~/.profile, in that order.  The  --noprofile  option  may  be  used  to
   inhibit  this  behavior.  When invoked as an interactive shell with the
   name sh, bash looks for the variable ENV, expands its value  if  it  is
   defined,  and uses the expanded value as the name of a file to read and
   execute.  Since a shell invoked as sh does not attempt to read and exe‐
   cute  commands from any other startup files, the --rcfile option has no
   effect.  A non-interactive shell invoked with  the  name  sh  does  not
   attempt  to  read  any  other  startup files.  When invoked as sh, bash
   enters posix mode after the startup files are read.
share|improve this answer
    
That appears to work. It looks like I don't have the permissions to change it though... –  CodeKingPlusPlus Jan 18 at 18:30
1  
@CodeKingPlusPlus to change what? chsh should be run as your normal user and asks for your normal user's password. –  terdon Jan 18 at 18:31
    
This is what it tells me: chsh: user 'codeking' does not exist in /etc/passwd –  CodeKingPlusPlus Jan 18 at 18:33
1  
@CodeKingPlusPlus sounds like your user does not have an entry in the local /etc/passwd file, have a look at this, can you log into a master node? You can also just run bash to get a bash shell. –  terdon Jan 18 at 18:37
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.