`
i_am_birdman
  • 浏览: 273946 次
  • 性别: Icon_minigender_1
  • 来自: 厦门
社区版块
存档分类
最新评论

linux的.bash_history

 
阅读更多
今天看到一个人写的文章,说通过.bash_history来获取SSH的私钥,很危险的说。

那么linux的.bash_history的作用是什么呢?这是一个博客上写的:

Bash shell在“~/.bash_history”(“~/”表示用户目录)文件中保存了500条使用过的命令,这样可以使你输入使用过的长命令变得容易。每个在系统中拥有账号的用户在他的目录下都有一个“.bash_history”文件。

鉴于其危险性,bash shell应该保存少量的命令,并且在每次用户注销时都把这些历史命令删除。
第一步:

“/etc/profile”文件中的“HISTFILESIZE”和“HISTSIZE”行确定所有用户的“.bash_history”文件中可以保 存的旧命令条数。强烈建议把把“/etc/profile”文件中的“HISTFILESIZE”和“HISTSIZE”行的值设为一个较小的数,比如 30。编辑profile文件(vi /etc/profile),把下面这行改为(有的系统没有,插入即可):
HISTFILESIZE=30
HISTSIZE=30
这表示每个用户的“.bash_history”文件只可以保存30条旧命令。

第二步:

网管还应该在"/etc/skel/.bash_logout" 文件中添加下面这行"rm -f $HOME/.bash_history" 。这样,当用户每次注销时,“.bash_history”文件都会被删除.
分享到:
评论

相关推荐

    Linux查看History记录加时间戳的小技巧

    Linux查看History记录加时间戳小技巧 熟悉bash的都一定知道使用history可以输出你曾经输入过的历史命令,例如 [root@servyou_web ~]# history | more 6 ./test.sh 7 vim test.sh 8 ./test.sh 但是这里只显示了...

    Linux基础之一实例解说目录文件命令

    .bash_history Desktop .gnome-desktop .sawfish 3、-A 显示所有文件和目录(它比-a少显示.和..两项)。 4、-l 以长格式显示 [root@localhost /root]# ls -l total 0 lrwxrwxrwx 1 root root 12 6月 19 11:20 ...

    操作系统安全:history历史命名完整性配置.docx

    在Linux中,我们可以通过history来查看历史命令,用来确认在某个时刻使用了哪个命令。但是,history的默认的,只会输出命令的序号以及命令。这时我们就需要对history进行一些配置,让它报告命令执行的具体时间。 ...

    Pro.Bash.Programming.Scripting.the.GNULinux.Shell.2nd.Edition

    Learn how Bash’s readline and history libraries can save typing when getting user input. Learn to use features new to Bash 4.0. Build shell scripts that get information from the Web. Who this book is...

    linux安全加固加固

    进入用户目录/home/oracle/,查看.bash_history文件: 首先通过 netstat -lnp 去查看当前开放的端口 对应的系统进程,发现可疑的直接干掉干掉之前确定是是否存在影响,若存在相关影响 应通报上级 若存在大量空连接...

    Linux的英文原版书(Ubuntu) part2

    [edubt]A_History_and_Politics_Lesson.pdf [edubt]Backing_Up_Data.pdf [edubt]Booting_Ubuntu_for_the_First_Time.pdf [edubt]Cool_Shell_Tricks.pdf [edubt]Digital_Audio.pdf [edubt]Digital_Photos.pdf [edubt]...

    Linux的英文原版书(Ubuntu)part1

    [edubt]A_History_and_Politics_Lesson.pdf [edubt]Backing_Up_Data.pdf [edubt]Booting_Ubuntu_for_the_First_Time.pdf [edubt]Cool_Shell_Tricks.pdf [edubt]Digital_Audio.pdf [edubt]Digital_Photos.pdf [edubt]...

    linux服务器清空MySQL的history历史记录 删除mysql操作记录

    1. 不再保存历史记录或者减少历史记录保存数量修改/etc/profile将HISTSIZE=1000 改成 0 或 要保留的数量清除用户home路径下的 .bash_history 代码如下:echo ” > /home/user/.bash_history 2. 立即清空里的history...

    linux bash手册(英文,version 4.2)

    linux平台的bash shell开发帮助文档(手册),英文版,版本4.2。日常开发shell翻阅, 章节如下: Definitions:: Some definitions used i n the rest of this manual. Basic Shell Features:: The shell "building ...

    linux中 shell 历史命令记录功能

    在 Linux 下面可以使用 history 命令查看用户的所有历史操作,同时 shell 命令操作记录默认保存在用户目录的 .bash_history 文件中。通过这个文件可以查询 shell 命令的执行历史,有助于运维人员进行系统审计和问题...

    命令行实用程序,用于管理SQLite数据库中的Shell历史记录。-Linux开发

    〜/ .bash_history被重复数据删除并导入到数据库中。 要求SQLite主目录安装安装下载一个Historian命令行实用程序,用于管理SQLite数据库中的Shell历史记录。 〜/ .bash_history被重复数据删除并导入到数据库中。 ...

    history保存用户操作日志,登陆时间,防止会话退出时覆盖

    linux系统history记录保存用户操作日志,登陆时间,防止会话退出时覆盖 以下是代码: #说明: /etc/profile 中结尾添加如果下指令 #保存并执行如下使之生效:source /etc/profile #history #HISTFILESIZE:表示文件的...

    linux常用命令

    linux网络服务(dns,dhcp,ftp,samba,nfs,apache,mail....) ldap,samba windows--vmware workstation(hyper-v)--centos 6.4--putty,vnc ibm--aix==>ibm p/z/i ... .bash_history .bashrc install.log.syslog .ssh

    reset-chromebook

    警告:1; 警报:3。 有关错误和警告的详细信息,请参见顶部注释块。 ... 警报消息的链接: >>>>>请检查并... bash_history - . bash_alias // Reset the chromebook in the Chromebook settings Restore the following

    shell基础

    通过 vim /etc/shells 可以查看linux支持哪些shell echo输出命令 echo [选项] [输出内容];-e 支持反斜杠控制的字符转换...-w 把缓存中历史命令写入到历史命令保存文件 ~/.bash_history 历史命令默认保存1000条,这个默

    linux扫描弱口令上线发包的教程

    3)众所周知,默认的命令历史会显示之前敲过的1000条命令,假如linux被非法用户使用,通过history查看命令历史是一件很危险的事。所以,我们可以将命令历史的行数改的比较短,或者注销后直接清空来保证安全(export ...

    Linux高级bash编程

    高级bash编程 高级Bash脚本编程指南(一) 目录 ++++ 第一部分. 热身 1. 为什么使用shell编程 2. 带着一个Sha-Bang出发(Sha-Bang指的是#!) 2.1. 调用一个脚本 2.2. 初步的练习 第二部分. 基本 3. 特殊...

    .Linux.Hacker

    Chapter 8: Command Line History Chapter 9: System Administration Tasks Chapter 10: Apachectl and Httpd Examples Chapter 11: Bash Scripting Chapter 12: System Monitoring and Performance

    如何让history命令显示日期和时间

    我们都对 history 命令很熟悉。它将终端上 bash 执行过的所有命令存储到 .bash_history 文件中,来帮助我们复查用户之前执行过的命令。这篇文章主要介绍了让history命令显示日期和时间的方法,需要的朋友可以参考下

    Shell.Programming.in.Unix.Linux.and.OS.X.4th.Ed

    Shell Programming in Unix, Linux and OS X is a thoroughly updated revision of Kochan and Wood’s classic Unix Shell Programming tutorial. Following the methodology of the original text, the book ...

Global site tag (gtag.js) - Google Analytics