gitee:
1. Linux 中的 ll(大写是 LL) 是什么?
ll 并不是 Linux 下一个基本的命令, 它实际上是 ls -l 的一个别名.
Ubuntu 默认不支持命令 ll, 必须用 ls -l, 这样使用起来不是很方便.
如果要使用此命令, 可以作如下修改:
打开~/.bashrc
找到 #alias ll='ls -l', 去掉前面的 #就可以了.(关闭原来的终端才能使命令生效)
这样个人用户可以使用 ll 命令, 当切换成超级用户后, 使用 ll 命令时提示找不到命令, 那是因为你只是修改了个人用户的配置, 所以, 切换成 root 后做相同的操作即可解决问题.
启示: 我们可以通过修改~/.bashrc 添加任何其他的命令别名.
2. 如何查看当前 Linux 的发行版本?
参考链接: http://www.jinbuguo.com/systemd/os-release.html
对于 Linux 系统而已, 有成百上千个发行版, 每个版本都有细微差别, 可以依次尝试如下方式查看发行版的版本号和相关信息:
- cat /etc/os-release
- cat /etc/issue
- lsb_release -a
- cat /etc/RedHat-release(针对 RedHat,Fedora)
- cat /proc/version
- cat /etc/debian_version
如果都不行, 可以在 /etc 目录找找看可能有系统信息的文件.
3.Linux 下, 延长 SSH 的连接超时时间
https://www.cnblogs.com/longshiyVip/p/4774177.html
当用 SSH Secure Shell 连接 Linux 时, 如果几分钟没有任何操作, 连接就会断开, 必须重新登陆才行, 每次都重复相同的操作, 很是烦人, 本文总结了两种解决的方法.
方法 1: 更改 SSH 服务器的配置文件 / etc/SSH/sshd_config
ClientAliveInterval 指定了服务器端向客户端请求消息的时间间隔, 默认是 0, 不发送. 而 ClientAliveInterval 60 表示每分钟发送一次, 然后客户端响应, 这样就保持长连接了. 这里比较怪的地方是: 不是客户端主动发起保持连接的请求(如 FTerm, CTerm 等), 而是需要服务器先主动.
另外, 至于 ClientAliveCountMax, 使用默认值 3 即可. ClientAliveCountMax 表示服务器发出请求后客户端没有响应的次数达到一定值, 就自动断开, 正常情况下, 客户端不会不响应.
- ClientAliveCountMax
- Sets the number of client alive messages (see below) which may be sent without sshd(8) receiving any messages back from the client.
- If this threshold is reached while client alive messages are being sent, sshd will disconnect the client, terminating the ses-sion.
- It is important to note that the use of client alive messages is very different from TCPKeepAlive (below).
- The client alive messages are sent through the encrypted channel and therefore will not be spoofable.
- The TCP keepalive option enabled by TCPKeepAlive is spoofable.
- The client alive mechanism is valuable when the client or server depend on knowing when a connection has become inactive.The default value is 3.
- If ClientAliveInterval (see below) is set to 15, and ClientAliveCountMax is left at the default,
- unresponsive SSH clients will be disconnected after approximately 45 seconds.
- This option applies to protocol version 2 only.
- ClientAliveInterval
- Sets a timeout interval in seconds after which if no data has been received from the client,
- sshd(8) will send a message through the encrypted channel to request a response from the client.
- The default is 0, indicating that these messages will not be sent to the client. This option applies to protocol version 2 only.
- VIM /etc/SSH/sshd_config
找到 ClientAliveInterval 参数, 如果没有就自己加一行.
ClientAliveInterval 参数的数值是秒, 比如你设置为 540, 就是 9 分钟.
ClientAliveInterval 540
对于 ClientAliveCountMax, 指如果发现客户端没有相应, 则判断一次超时, 这个参数设置允许超时的次数, 比如 10.
- ClientAliveInterval 540
- ClientAliveCountMax 10;
则代表允许超时 5400 秒 = 90 分钟.
方法 2: 配置客户端
Linux 下的 SSH 命令
VIM /etc/SSH/ssh_config
然后找到里面的 ServerAliveInterval 参数, 如果没有你同样自己加一个就好了. 参数意义相同, 都是秒数, 比如 9 分钟:
ServerAliveInterval 540
方法 3:SecureCRT
在使用的终端的设置界面, 找到有设置发送协议 NO-OP 等设置, 设置上即可.
方法 4:putty
启用 putty keepalive
putty -> Connection -> Seconds between keepalives ( 0 to turn off ), 默认为 0, 改为 60.
4.Linux 里面有很多以 .d 结尾的目录, d 代表什么意思? daemon or dir?
https://zhidao.baidu.com/question/574268665.html
一般为了保持对原有配置方式的兼容, 而增加的. d 结尾目录...
如: /etc/X11/xorg.conf 这原本是个文件, 现在也有了一个 / etc/X11/xorg.conf.d 这样的目录, 显卡驱动的相关设置原本是放在 / etc/X11/xorg.conf 这个文件中的, 现在为了配置文件的简洁和灵活性, 可以将配置按照情况分配, 扔到 / etc/X11/xorg.conf.d 里面去... 像 "规则" 一样的方式来添加... 系统会自动去这个 / etc/X11/xorg.conf.d 里面去找这些规则并按照规则进行设置. 这样可以保持之前相对于之前的 / etc/X11/xorg.conf 方法的兼容性...
又如: 在 yum 系发行版中,/etc/yum.repo 是 yum 的配置文件, 可以将所有的 yum 源都扔到 yum.repo 文件中, 现在也可以将不同的源配置文件都扔到 / etc/yum.repo.d 里面去, 而只在 yum.repo 中设置一些比较有共性的配置选项. 这样哪个源不想要了就从 / etc/yum.repo.d 里面删了就行了不影响其他的.. 再增加源也是相同的道理...
还有 / etc/env.d,/etc/profile.d,/etc/udev.rules.d 等... 都是一样的~
所以, 现在可以回答你的问题了,.d 实际是表示 directory, 目录的意思...
1 楼所述的 daemon, 有些命令等会以 d 结尾, 确实是 daemon 的意思, 如 ftpd. 现在好多程序会增加 - d 或者 --daemon 参数也就是后台执行选项....
另, 在 ls -l 显示的文件属性中, 第一个字符 d 也表示目录的含义.
drwxr-xr-x 3 ksl ksl 4096 Jun 30 23:02 Templates
5.Linux 命令 ipconfig -a 的结果里面的 RX 和 TX 是什么意思?
- eth0 Link encap:Ethernet HWaddr 02:42:AC:11:00:
- .NET addr:172.17.0.4 Bcast:172.17.255.255
- UP BROADCAST RUNNING MULTICAST MTU:1500 M
- RX packets:101 errors:0 dropped:0 overruns:
- TX packets:0 errors:0 dropped:0 overruns:0
- collisions:0 txqueuelen:0
- RX bytes:7178 (7.0 KiB) TX bytes:0 (0.0 B)
tx 是发送(transport),rx 是接收(receive).
6.Linux 使用退格键时出现 ^H ^? 解决方法
https://www.zmrbk.com/post-2030.html
在 Linux 下执行脚本不注意输错内容需要删除时总是出现 ^H
^H 不是 H 键的意思, 是 backspace. 主要是当你的终端 backspace 有问题的时候才需要设置.
解决方法有两种:
要使用回删键 (backspace) 时, 同时按住 ctrl 键
设定环境变量
在脚本的开头或结尾 参数
stty erase ^H stty erase ^?
在 bash 下:$stty erase ^?
或者把 stty erase ^? 添加到. bash_profile 中
在 csh 下:$stty erase ^H
或者把 stty erase ^H 添加到. cshrc 中
来源: http://www.bubuko.com/infodetail-3089003.html