Monday, 19 November 2012

How to enable history in elementary os luna even after the restarting the computer or closing the terminal

Note: Elementary os luna is still in development and will have many bugs still to be resolved. So these types of issues may occur. This is not to blame the developers but I hope it will be helpful to some body who is using it and has been affected by this issue.

I'm using the daily builds of elementary os luna. I use terminal a lot and uses many command line and terminal shortcuts daily to make my jobs easier. One of such command line short cut is uing Ctr+r to search for the previously used commands. But elementary luna it was not working after I have restarted my computer or even in another terminal. I did a bit of research and found out the issue and fixed it.

I used to ssh to my VPS box and every time manually typing the ssh command to the server is just time wasting. So I thought a bit of research will fix the issue for ever. First I checked the .bashrc,/etc/bash.bashrc,/etc/profile etc files to check whether there is given any commands to clear history to log out or even not to use the history of one terminal in another. But there was nothing configured like that (BTW, It is insane to do like that).

Then next I opened the .bash_history file at my home directory in vim and got the first clue. It was showing [readonly] at the bottom of that file in vim. Why should the file at my home directory should be read only to me? Atleast I'm (should be) the owner of that file and I should be able to modify it. Right?

Next step obviously was to check who is the owner of that file. I typed the below command and found the issue.

[email protected]:~$ ls -lhtr .bash_history
-rw------- 1 root root 3.8K Nov 13 02:06 .bash_history

Why should root user to be the owner of the .bash_history? So that was the issue. Even though it was in my home directory, root user was the owner of that file. Now we have found the cause of the issue. Then the fix was easy. Just assign correct ownership to the .bash_history file and check whether it is working correctly now. I typed the below commands to fix the issue. Replace sree with your username in the below commands. Please note there are two dots (.) in the below command.

1. [email protected]:~$ sudo chown sree. .bash_history
[sudo] password for sree: 

2. [email protected]:~$ ls -lhtr .bash_history
-rw------- 1 sree sree 3.8K Nov 13 02:06 .bash_history

I opened another terminal and typed Ctr+r ssh. Voila ! it is now showing the previously used ssh commands. So the issue has been fixed and it is working fine now.

I do not know whether all the elementary os luna users experience this issue or it is particular to me only. But if it is affecting all the luna users, I do not know why the developers chose to use weired configuration like this for .bash_history file. I'm sure that they will be most using the terminals and terminal shortcuts and bash history will be most useful to them.

Note: Please note that elementary os luna is still in development and the version which I installed was using the daily builds and updating it daily. Now the beta version is out there and I do not know whether it is also affecting the beta users. If any of you are experiencing this issue, please let us know in the comments.

No comments:

Post a Comment