Skip to content

Instantly share code, notes, and snippets.

@ibreathebsb
Last active September 2, 2018 07:08
Show Gist options
  • Save ibreathebsb/87a1acd10dcb99fd66d4024e66bf159e to your computer and use it in GitHub Desktop.
Save ibreathebsb/87a1acd10dcb99fd66d4024e66bf159e to your computer and use it in GitHub Desktop.

命令搜索顺序

  1. 对与使用绝对路径或相对路径下达的命令例如/bin/ls ./test 直接在路径中查找
  2. 在alias中查找
  3. 在shell的builtin指令中查找
  4. $PATH中查找第一个名称匹配额命令

bash环境变量初始化

login shellnon-login shell : login shell值的是通过账号密码输入登录后的shell,non-login shell指的是没有经过上述登录流程的shell,例如桌面环境下登录后,打开terminal,或者在login shellbash创建的新shell

login shell

  • /etc/profile: 系统整体配置
  • ~/.bash_profile 或者 ~/.bash_login 或者 ~/.profile: 用户自己的配置,最终都会读取~/.bashrc

读取/etc/profile的配置时,会获取/etc/profile.d/下面的脚本文件,并执行

non-login shell

只会读取~/.bashrc

source

通常bash配置在写入后不会立即更新,只有注销重新登录才会更新,但是可以通过命令直接更新source 配置文件

一些有用的配置文件

~/.bash_history: 记录bash命令记录

~/.bash_logout: login shell退出是执行的操作,默认只有清除屏幕内容

/etc/man.config: man的配置文件

配置终端

stty: set tty

stty -a: 列出当前所有配置:

isaac@hp:~/Notes/linux$ stty -a
speed 38400 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
# 省略了部分

inter: interupt中断当前正在运行的程序

quit: quit发送quit信号给当前程序

erase: 删除

kill: 发送kill信号

eof: end of input

stop: 停止当前程序的输出

start: 恢复被stop暂停的输出

susp:suspend 暂停当前程序

常用的组合按键:

ctrl + c: 终止当前进程

ctrl + d: eof

ctrl + u: 清空当前输入的命令

ctrl + s: 暂停当前程序的屏幕输出

ctrl + q: 恢复当前程序的屏幕输出

ctrl + z: 暂停当前程序

@ibreathebsb
Copy link
Author

rc stands for runcomm which means run command, but runtime configuration may be a better explanation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment