相同的文件内容的shell, 相同的权限, 出现部分情况下无法正确执行的情况

遇到过一起, window下创建的shell, 拷贝到linux下同php无法正确全部执行其中的shell内容, 后来打开看了发现, window下创建的脚本通过vim打开多个 xxx.sh" [dos] 12L, 330C 其中的 [doc] 导致脚本一些执行上的问题
通过cat -A xxx.sh 显示的换行符为 ^M$, linux下创建的文件换行符为 $
转换window换行符为linux sed -i 's/\r//' 文件名
即使解决了换行符问题, 还有新的编码问题出现, 所以脚本千万别在window机器下编写拷贝到linux机器中, 需要通过linux创建文件编辑, window拷贝内容粘贴进去最靠谱

设置普通用户输入sudo,免密进入root账户

方法一:
编辑并在用户相关的内容后面添加需要免密登录的帐号
vim /etc/sudoers
> admin ALL=(ALL) NOPASSWD: ALL

方法二: (未测试)
开始系统内部的wheel用户组,
在/etc/suoers 中编辑配置文件如下:
%wheel ALL=(ALL) NOPASSWD: ALL
比如新开账户为mike,
useradd mike|echo "1234546"|passwd mike
id mike(查看用户归属用户组)---uid 和 gid
uid=505(mike) gid=505(mike) groups=505(mike)
通过usermod 命令更改用户所属用户组

[root@backup ~]# usermod mike -g wheel
[root@backup ~]# id mike
uid=505(mike) gid=10(wheel) groups=10(wheel)

更改为wheel组下的 ,
然后在mike用户下再sudo su 切换既不用输入密码了

假设访问页面地址为: http://www.abc.com/test.jsp

www.abc.com 域名解析到ip: 192.168.0.1 则curl访问方式为如下:

curl -H "Host:www.abc.com"  "http://192.168.0.1/test.jsp"
  • 实际测试http协议没问题, https协议就像下面一样了
[root@localhost ~]# curl -H "Host:wx.jiayuanshu.net"  "https://139.224.18.242"
curl: (60) Issuer certificate is invalid.
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
  • 解决办法, https时使用 --resolve 方法去实现
curl -H "Host:wx.jiayuanshu.net"  "http://139.224.18.242"
curl --resolve 139.224.18.242:443 "https://wx.jiayuanshu.net"