+1 vote
in Operating Systems by (348k points)

The "history" command does not show the list of commands I used on the terminal. When I run the "history" command, it returns "-sh: 1: history: not found". Also, the "tab" key does not complete the command I type on the terminal, although bash_completion is enabled in my " ~/.bashrc."

How can I fix it? It is painful to type all commands on the terminal in the absence of history and bash_completion.

1 Answer

+2 votes
by (56.5k points)
selected by
Best answer

From the output ("-sh: 1: history: not found") of the history command, it seems that your session is using 'sh' instead of 'bash'. When your user was created, the session was defaulted to 'sh', and hence you see these issues. 

To fix the issue with history and bash_completion, you need to make a small change in the "/etc/passwd" file. 

  • If you have sudo privileges, open "/etc/passwd" in an editor and search for your username. 
  • You will find "/bin/sh" on the line for your username. Change it to "/bin/bash".
  • Save the file and log out.
  • log in again and you will see history and bash_completion working.
Hope these steps help.

Related questions

+2 votes
1 answer
+3 votes
1 answer
+3 votes
1 answer