我尝试在bash脚本中使用history命令,但它没有工作。
bash文件的代码:
#!/bin/bash
# Copy history to file history
#cd /media/saleel_almajd/Study/linux/my_scripts/
echo "start Copy history to /media/saleel_almajd/Study/linux/my_scripts/history.txt"
export HISTTIMEFORMAT='%F %T ' #to make history and date apear
我用skype在我的电脑里有一个windows 7。现在,我备份skype历史记录并格式化pc,然后安装Mint linux os.
现在。我正在安装skype,但是我怎样才能import old skype history in new skype mint linux os?
薄荷linux中的logs of skype history存储在哪里?知道吗?
我正在Windows上运行一个Docker容器,使我能够在某些需要的项目中使用Linux。当使用CLI时,我无法使用光标键来导航命令/命令历史记录。我希望按下向上/向下箭头可以在以前运行的命令中导航,而左/右箭头则允许我将光标移动到当前所选命令的一部分,以便从那个位置进行编辑。相反,当我按下光标键时,我会看到输出到控制台的字符(即向上、向下、左、右解析为^[[A、^[[B、^[[C和^[[D )。
是否缺少启用预期行为的选项/安装?
我看过关于设置-o的信息,但我没有历史条目:
# set -o | grep history
# set -o
Current option settings
e
我试着给历史指令加一个时间戳
export HISTTIMEFORMAT='%F %T '
,但是历史上记录的命令(旧的和新的)没有显示时间戳。
输出,输出
history | tail
445 exoirt HISTTIMEFORMAT='F% T%'
446 export HISTTIMEFORMAT='F% T%'
447 history
448 history | tail
449 ls
450 cd
451 ls
452 cd
453 ls
454 cd
我期望在数字和列之间提
当我通过SSH从计算机执行命令到我的Linux服务器时,它不会保存在bash历史记录中。
我的.bash_profile设置如下:
[USER@ /home/USER]2 $cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PAT
我想知道是否有办法“模仿”linux .bash_history。它应该是这样的:
def write_history(cmd):
try:
with open("/root/.python_history","a") as history:
history.write(str(cmd) + "\n")
history.close()
except:
with open("/root/.python_history","w") as history:
最近,有人以非根用户的身份闯入了我们的linux服务器。
摘录自.bash_history:
[...]
perl
perl
set +o history
set +o history
set +o history
passwd
sdfsdf
passwd
exit
我假设set +o history切换命令记录到.bash_history
是否有办法使历史记录不能被禁用?
有没有办法找出如果历史被残废的话会发生什么?
我试图在PowerShell核心中存在别名的情况下运行Bash命令。
我想澄清bash的历史。下面是示例代码:
# Launch PowerShell core on Linux
pwsh
# Attempt 1
history -c
Get-History: Missing an argument for parameter 'Count'. Specify a parameter of type 'System.Int32' and try again.
# Attempt 2
bash history -c
/usr/bin/bash: history
假设我有两个bash历史文件,如下所示:
history1.txt 1.txt
1 ls
2 cd foo
...
921 history > history1.txt
history2.txt 2.
154 vim /etc/nginx/nginx.conf
155 service nginx restart
...
1153 history > history2.txt
我知道我可以轻松地编写一个bash脚本,将这两个文件合并在一起,这样生成的文件就包含了第1行到1153行,而没有重复的历史条目.类似于下面的bash脚本:
merge.
我试图在bash脚本中调用以下内容:
`history -a current_history`
它应该使用这个会话执行的命令创建文件。
在shell环境中工作非常好。
在bash脚本中不工作。
我看到的信息表明,您必须在bash脚本中以不同的方式调用历史,格式如下:
#!/bin/bash
HISTFILE=~/.bash_history # Set the history file.
HISTTIMEFORMAT='%F %T ' # Set the hitory time format.
set -o history # Enable the
在交互登录时,我得到:
dircolors: no SHELL environment variable, and no shell type option given
但我确实有SHELL变量集:
% set | grep SHELL
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
在~/.bash_profile i中,类似于这样的源.dircolors:
eval "`dircolors ~/.dircolors`"
我已
在Linux中,我们通常使用大量的命令,很难记住所有这些命令。
history
命令提供了我们以前使用过的命令列表,但限制较少。新命令被覆盖在旧命令上,然后旧命令就丢失了。我认为在某个地方,命令的日志存储在系统中。
那个日志可以打开和读取吗?如果可能的话,我们可以更改它可以处理的最大日志大小吗?
history命令的输出是否取决于登录用户?
我们有一个常见的Linux测试env,其中多个人工作(通过ssh使用Putty连接),我们需要存储从所有终端触发的命令,这样我们就可以跟踪每个命令,每个命令都是由哪个IP/用户触发的,而TTY是从哪个命令启动的,这样我们就可以使用“最后”命令来验证它。
我已经相应地改变了我的.bash_profile
# Will Give me ip of person logged in
WHOAMI=`who -m | cut -d '(' -f 2| cut -d ')' -f1`
# Will give me tty ID
MYTTY=`who -m | awk
我有一个Centos 6服务器,我已经升级了几个软件包。据推测,我可以用yum history undo <packageName>降低他们的评级,但我得到的只是每个包的downgrade failed。
在文档中,它说如果存储库中有一个旧版本,它就会降级。所以我的问题是:哪个存储库?显然,我有的,包括最新的版本。我如何配置这样的东西?
在我的反驳者中,唯一启用的回复是:
Centos-6 - Base
Extra Packages for Enterprise Linux 6 - x86_64
Extra Packages for Enterprise Linux 6 - Tes
我执行以下操作是为了使历史更加合理(例如,在排除故障时,查看何时运行命令是相当关键的)
shopt -s histappend; # Append commands to the bash history (~/.bash_history) instead of overwriting it # https://www.digitalocean.com/community/tutorials/how-to-use-bash-history-commands-and-expansions-on-a-linux-vps
export PROMPT_COMMAND="history
Webalizer停止以生成统计信息。
当我尝试检查数据库时,我看到:
# webalizer --db-info
Stone Steps Webalizer v3.10.2.5 (Linux 4.6.4-grsec-zfs+)
Using database /home/www/1/statystyka/webalizer.db
Reading history file... /home/www/1/statystyka/webalizer.hist
Cannot find the last URL (ID: 752154) of an active visit (ID: 3)
Savin
我已经在我的账户上安装了python 3.3.6和ipython 3.0.0。我在Linux集群(RedHad4.9)上。当我启动ipython时,我收到以下消息:
WARNING: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
WARNING: IPython History requires SQLite, your history will not be saved.
我不确定什么是virtualenv,也不知道为什么
我已经将以下代码保存为.sh文件,并从我的根目录执行它:
有几个错误:
script.sh: line 65: conditional binary operator expected
script.sh: line 65: syntax error near `=~'
script.sh: line 65: `while [[ $1 =~ ^\- ]]; do'
然后,当我运行git-rewrite-history命令时,我收到一个错误:
'git-rewrite-history' is not recognized as an internal or ext