ChinaUnix首页 > 精华文章 > HP-UX > 正文

[精华] 请教:一个菜鸟的疑惑?


http://www.chinaunix.net 作者:huoniao  发表于:2007-04-14 10:17:13
发表评论】 【查看原文】 【HP-UX讨论区】【关闭

为什么在有的系统中不能使用history命令?



 hpux 回复于:2003-02-10 09:54:06

#man sh-posix
查找HISTFILE项,有详细解释。


 feeling 回复于:2003-02-10 10:28:47

[/feeling]type history
history is an exported alias for fc -l
[/feeling]alias |grep history
history='fc -l'

history命令是一个别名,源自fc

你可以打一个alias查看一下是否有history,没有的话就自己添加一个:
alias history='fc -l'


 huoniao 回复于:2003-02-10 10:44:16

alias中是有的啊,但就是用不了.提示如下:
# history
/sbin/sh: fc: Cannot access or open the history file.
但是.sh_history也存在啊,
# ll .sh_history
-rw-------   1 root       sys             24 Jul  8  2002 .sh_history
到底为什么?谢谢


 feeling 回复于:2003-02-10 11:15:26

root用户?

用户命令历史列表文件.sh_history是只有该用户才可以读写的,别的用户没有读写权限。
你用的是root用户吗!?
如果不是,当然会出错了,因为依照你的情况来看该文件只有root用户才能够读写。


 hpux 回复于:2003-02-10 13:54:36

你是直接用root登录的吗?还是通过别的用户用su切换来的?
如果是切换请用:
#su -
以保证.sh_history文件可用!


 huoniao 回复于:2003-02-10 14:08:45

我是用root直接登陆的啊,奇怪.楼上的方法也试了,不行 :(


 huoniao 回复于:2003-02-11 10:32:43

帮帮我吧


 hpux 回复于:2003-02-11 10:39:38

#echo $HISTFILE
的结果是什么?


 huoniao 回复于:2003-02-11 10:47:12

sh: HISTFILE: Parameter not set.


 hpux 回复于:2003-02-11 10:54:35

Now do this:
#export HISTFILE=//.sh_history


 huoniao 回复于:2003-02-12 08:38:08

谢谢热心的斑竹,现在的问题是这样:history可以看了。但新使用的指令却不能实时加到.sh_history这个文件中去。看到的都是本来存在的内容!


 hpux 回复于:2003-02-12 08:44:02

#export HISTSIZE=128
足够大了吧;再试试看!


 huoniao 回复于:2003-02-12 13:50:35

哎,还是不行.有劳斑竹帮我仔细看看,多谢:
who
root       pts/ta       Feb 12 13:39
jh_db1#[/]history
sh: fc: Cannot access or open the history file.
jh_db1#[/]export HISTFILE=//.sh_history
jh_db1#[/]export HISTSIZE=128
jh_db1#[/]set

HISTFILE=//.sh_history
HISTSIZE=128
HOME=/
IFS=' 
'
LINENO=1
LINES=55
LOGNAME=root
MAIL=/var/mail/root
MAILCHECK=600
MANPATH=/usr/share/man/%L:/usr/share/man:/usr/contrib/man/%L:/usr/contrib/man:/usr/local/man/%L:/usr/local/man:/opt/upgrade/share/man/%L:/opt/upgrade/share/man:/opt/pd/share/man/%L:/opt/pd/share/man:/opt/pd/share/man/%L:/opt/pd/share/man:/opt/pd/share/man/%L:/opt/pd/share/man:/opt/ignite/share/man/%L:/opt/ignite/share/man:/opt/mx/share/man:/usr/dt/share/man:/opt/samba/man:/opt/resmon/share/man://opt/perl/man:/opt/scr/share/man:/opt/hparray/share/man/%L:/opt/hparray/share/man:/opt/aCC/share/man/%L:/opt/aCC/share/man:/opt/audio/share/man:/opt/ansic/share/man/%L:/opt/ansic/share/man:/opt/langtools/share/man/%L:/opt/langtools/share/man:/opt/image/share/man:/opt/imake/man
OPTARG
OPTIND=1
PATH=/usr/sbin:/usr/bin:/opt/ansic/bin:/usr/ccs/bin:/usr/contrib/bin:/opt/hparray/bin:/opt/nettladm/bin:/opt/upgrade/bin:/opt/fcms/bin:/opt/pd/bin:/usr/bin/X11:/usr/contrib/bin/X11:/opt/mx/bin:/opt/resmon/bin://opt/perl/bin:/opt/scr/bin:/usr/sbin/diag/contrib:/opt/aCC/bin:/opt/langtools/bin:/opt/ignite/bin:/opt/imake/bin:/opt/sanmgr/commandview/client/sbin:/oramon/tngevt/bin:/oramon/tngevt/scripts:/sbin:/home/root
PPID=15698
PS1='jh_db1#[/]'
PS2='>; '
PS3='#? '
PS4='+ '
PWD=/
RANDOM=17223
SECONDS=83
SHELL=/sbin/sh
SYSTYPE=HP-UX
TERM=vt100
TMOUT=0
TZ=EAT-8
_=HISTSIZE=128
c=/oramon/tngevt/tmp
dir=/oramon/tngevt/gui/bin
setu=0
tfn=/oramon/tngevt/opr/config/jh_db1/cai_wtor_node
this_node=jh_db1
jh_db1#[/]alias
autoload='typeset -fu'
command='command '
functions='typeset -f'
history='fc -l'
integer='typeset -i'
local=typeset
nohup='nohup '
r='fc -e -'
stop='kill -STOP'
suspend='kill -STOP $$'
type='whence -v'
who=/usr/bin/who
jh_db1#[/]history
1newfs -F vxfs -o largefiles /dev/vg00/rlv_u02
21ewfs -F vxfs -o largefiles /dev/vg00/rlv_u02
31ewfs -F vxfs -o largefiles /dev/vg00/rlv_u02
4newfs -F vxfs -o largefiles /dev/vg01/rlv_u02
5mewfs -F vxfs -o largefiles /dev/vg01/rlv_u02
6mewfs -F vxfs -o largefiles /dev/vg01/rlv_u02
71ewfs -F vxfs -o largefiles /dev/vg01/rlv_u02
8newfs -F vxfs -o largefiles /dev/vg01/rlv_m01
9mount -o largefiles /dev/vg01/lv_m01 /u02
10newfs -o largefiles -F vxfs /dev/vg01/rlv_m02
11mount -o largefiles /dev/vg01/lv_m02 /u03
12newfs -F vxfs -o largefiles /dev/vg01/lv_m03 /u04
13newfs -F vxfs -o largerfiles /dev/vg01/rlv_m03
14m
jh_db1#[/]


 hpux 回复于:2003-02-12 14:26:40

#vi /etc/profile
...
export HISTFILE=$HOME/.sh_history 
export HISTSIZE=1024 
...
重新登录,试试看!


 huoniao 回复于:2003-02-12 14:41:53

可以了,不胜感谢!斑竹实在是太负责了.


 gg2003 回复于:2007-04-14 10:17:13

thank you




原文链接:http://bbs.chinaunix.net/viewthread.php?tid=12157
转载请注明作者名及原文出处