当我通过 ssh 进入远程服务器时,我喜欢改变终端的颜色。我使用setterm远程 ~/.bashrc 文件来完成这项工作。但是,当 I 时exit,终端颜色不会重置为本地颜色。
我解决了这个问题,但我不确定这是否是最好的解决方案。这是我能想到的。
在远程服务器上的 ~/.bash_logout 上,我输入:
echo -e "\033[0m"
/usr/bin/clear
Run Code Online (Sandbox Code Playgroud)
只是出于好奇:有人知道更好的方法吗?(我echo -e "\033[0m"从http://edoceo.com/liber/linux-bash-shell得到了这条线)
我用过IPTraf, Iftop, vnstat, bwm-ng, ifconfig -a。它们都没有帮助我找到从我的应用程序以 KB 或 MB 格式发送/接收的实时数据包。原因是我正在编写一个应用程序,我需要非常确定我的压缩是正确的,但我无法测试以继续前进。
我可以用什么来跟踪非常具体和准确的实时网络统计数据?

我正在寻找监视麦克风的命令行实用程序,如果您开始讲话,则写入文件。应调整记录周期。
解决办法是:
sox -t alsa default recording.wav silence 1 0.1 5% 1 1.0 5%
Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个启动命令screen,创建四个具有不同名称的会话,并运行四个不同的命令。
我知道如何手动执行此操作:
1. screen
2. ./command1 args
3. CTRL-A :sessionname Session 1
4. CTRL-A C
5. (GOTO 2)
Run Code Online (Sandbox Code Playgroud)
我可以用 bash 脚本或其他东西来做到这一点吗?我该怎么做?
我想看看一周前的某一天我在 bash 命令行上输入了什么。有没有办法检索命令行历史记录?也许像下面这样?
> history --include-date | grep 2012-02-27`
Run Code Online (Sandbox Code Playgroud) 所以bash 手册页解释了什么是登录和交互式 shell:
登录 shell 是参数零的第一个字符是 - 或以 --login 选项开头的 shell。
交互式 shell 是一个没有非选项参数并且没有 -c 选项的启动,其标准输入和错误都连接到终端(由 isatty(3) 确定),或者一个以 -i 选项启动。如果 bash 是交互式的,则设置 PS1 并且 $- 包括 i,允许 shell 脚本或启动文件测试此状态。
我认为这意味着我们可以有 4 种不同类型的 shell:
但是为什么我们首先要有交互式/非交互式和登录/非登录 shell?为什么品种多?如果我们只有一种壳,我们会失去什么?
此外,当试图通过运行确定我是否在登录 shell 中时echo $-,它输出:
himBH
Run Code Online (Sandbox Code Playgroud)
关于这些标志的解释这里,但是h,H和m没有解释。有没有描述所有这些标志的地方?
我正在使用 bash 4.3.11(1) 并安装了以下历史插件(通过.bash_it):
# enter a few characters and press UpArrow/DownArrow
# to search backwards/forwards through the history
bind '"^[[A":history-search-backward'
bind '"^[[B":history-search-forward'
Run Code Online (Sandbox Code Playgroud)
当我登录到交互式会话时一切正常,但是当我通过ssh host 'ls -als'例如运行远程命令时,我看到以下输出:
: ssh host 'ls -als'
/home/ubuntu/.bash_it/plugins/enabled/history.plugin.bash: line 3: bind: warning: line editing not enabled
/home/ubuntu/.bash_it/plugins/enabled/history.plugin.bash: line 4: bind: warning: line editing not enabled
Run Code Online (Sandbox Code Playgroud)
当我echo -e '\0033\0143'在每次绑定调用后修改历史插件时,我不再收到警告,但我的控制台已被清除。不是一个巨大的缺点,但知道一种更简洁的方法来抑制远程命令的这种情况会很好。
# Works, but annoyingly clears console
# enter a few characters and press UpArrow/DownArrow
# to search backwards/forwards through the history …Run Code Online (Sandbox Code Playgroud) 我已经被说服(在 Stack Overflow 上)在 vi 模式下使用我心爱的 bash。到目前为止,我已经习惯了它,我喜欢它。
但是我确实错过了一个功能:在 emacs 模式下,您可以通过按“ESC”来输入上一个命令的最后一个参数。(也就是说,按 Esc 后跟 .)
是否有默认绑定可以在 vi 模式下插入最后一个参数?我找不到一个,我真的很想念这个命令......
我有一个编译问题,当我检查我的 lib/ 目录时,我从“ls”得到这个输出:

红/黑组合是什么意思?
我按照此处的建议检查了“dircolors -p”的输出(文件名以红色背景显示是什么意思),但我找不到答案。
此外,权限/用户/大小/时间戳位置的问号是什么意思?
谢谢你的帮助
bash ×10
linux ×5
shell ×5
command-line ×4
audio ×1
bashrc ×1
colors ×1
gnu-screen ×1
history ×1
ls ×1
monitoring ×1
networking ×1
sox ×1
ssh ×1
traffic ×1