Linux QA

gitee: https://gitee.com/dhclly/icedog.script.test/blob/master/doc/linux/linux-qa.md

1. linux 中的 ll(大写是LL) 是什么?

https://www.cnblogs.com/kongzhongqijing/p/3488884.html

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:
          inet 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://blog.csdn.net/u013408061/article/details/83039439

https://www.zmrbk.com/post-2030.html

在linux下执行脚本不注意输错内容需要删除时总是出现^H

^H不是H键的意思,是backspace。主要是当你的终端backspace有问题的时候才需要设置。

解决方法有两种:

  1. 要使用回删键(backspace)时,同时按住ctrl键
  2. 设定环境变量
    • 在脚本的开头或结尾 参数 stty erase ^H stty erase ^?
    • 在bash下:$stty erase ^?
      或者把 stty erase ^? 添加到.bash_profile
    • 在csh下:$stty erase ^H
    • 或者把 stty erase ^H 添加到.cshrc
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值