2016-04-21 62 views
0

我也跟着不同的指南:https://apple.stackexchange.com/questions/50649/how-to-make-bash-terminal-app-remember-history-of-previous-sessions保留(MAC OSX)终端使用的会话间历史

并称为三个命令:

sudo -iu root 
cd ~(myusername) 
chown (myusername) .bash_history 

但现在在终端的每一个开始,我得到下面的输出:

Last login: Thu Apr 21 15:39:19 on ttys000 
-bash: USERNAME: No such file or directory 

我仍然无法使用向上箭头键在我的历史记录中检索最近的命令。我知道我不应该执行我不知道其含义的命令。任何人都可以用正确的方向指向我的终端,并且在关闭终端时帮助保存历史记录吗?

回答

0

你输入的确切命令是什么?我的意思是,大概你确实用你的名字取代了(myusername)不是吗?和命令

cd ~(myusername) 

对我没有意义。本身,

cd ~ 

将带你到你的主目录。

好的。基本的故障排除(把你的答案放在这里)。加载终端和类型(请注意,有没有必要使用sudo任何的这个):

cd ~ # changes to your home directory 
ls -la .bash_history # checks the permissions and ownership of your bash_history 

你bash的历史应具有以下权限(或类似):

[email protected] 1 headbanger staff 10619 20 Apr 17:08 .bash_history 

所以,我要解决这个为我的帐户,我会输入:

chown headbanger:staff .bash_history # if you aren't the owner, it will be necessary to use sudo here. 
chmod "u+rw,go-rwx" .bash_history # greybeards will use Octal 600 for this 

我已经避免使用八进制chmod使这更具可读性。 chmod中的字母表示以下内容:

u User 
g Group 
o Other 
a All (u,g & o) 

- Remove permission 
+ Add permission 
= Set permission 

r Read 
w Write 
x Execute 

让我们知道你是怎么做的!

+0

因此,对于你的第一个评论我用CD〜akashkakumani 然后我跟着你的后半生与akashkakumani更换headbanger的建议,但是当我重新启动我的终端,我仍然留: – user2977578

+0

上次登录:星期六04月23日16时22分47秒在ttys000 -bash:USERNAME:没有这个文件或目录 wireless1x-155-41-93-240:〜akashkakumani $ – user2977578

+0

这是一个小问题 - 但'cd〜akashkakumani'和'cd〜'会做同样的事情。请你可以显示'ls -la .bash_history'的结果 – headbanger