文章目录
  1. 1. ftp命令用法
  2. 2. vmware下虚拟机网络问题
  3. 3. eno16777736更名
  4. 4. fedora更新源
  5. 5. dnf makecache
  6. 6. 设置开机启动命令、vm下与主机共享目录 //mark
  7. 7. 设置默认进入文本模式
  8. 8. fedora设置root用户自动登入
  9. 9. ssh登不上
  10. 10. fedora21编译boost 1.59.0
  11. 11. linux杀死进程指令
  12. 12. 批量解压包脚本
  13. 13. linux下boost
  14. 14. fedora

Matrix的设计者-建筑师
Linux配置,shell脚本…

ftp命令用法

  1. ftp登入:
    1
    FTP 10.8.3.140

vmware下虚拟机网络问题

  1. 仅主机模式
    vm网卡编辑

vm网卡编辑与vm下Linux系统IP保持一致
Linux系统IP设置

网卡文件名可以跟配置文件不一致

[root@localhost network-scripts]# vi ifcfg-eno16777736

1
2
3
4
5
6
7
8
9
DEVICE=eth0
HWADDR=00:0c:29:44:a0:6c
BOOTPROTO=static
IPADDR=10.8.3.200
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
# USERCTL=no
# PEERDNS=no

网卡信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@localhost network-scripts]# ifconfig
eno33554984: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.142.136 netmask 255.255.255.0 broadcast 192.168.142.255
inet6 fe80::20c:29ff:fe44:a076 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:44:a0:76 txqueuelen 1000 (Ethernet)
RX packets 314 bytes 33774 (32.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 343 bytes 60050 (58.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19 base 0x2080

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.8.3.200 netmask 255.255.255.0 broadcast 10.8.3.255
inet6 fe80::20c:29ff:fe44:a06c prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:44:a0:6c txqueuelen 1000 (Ethernet)
RX packets 6121 bytes 542018 (529.3 KiB)
RX errors 0 dropped 9 overruns 0 frame 0
TX packets 345 bytes 57581 (56.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19 base 0x2000

eno16777736更名

/etc/sysconfig/network-scripts/ifcfg-eno16777736网卡名字改为ifcfg-eth0,并修改配置文件为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
TYPE=Ethernet
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
IPADDR=10.8.3.211
NETMASK=255.255.255.0
GATEWAY=10.8.3.254
# BROADCAST=10.8.1.255
HWADDR=00:0C:29:44:a0:6c
GATEWAY=10.8.3.254
#PEERDNS=yes
DNS1=10.8.3.254
#USERCTL=no
#NM_CONTROLLED=no
#IPV6INIT=no
#IPV6ADDR=FD55:faaf:e1ab:1B0D:10:14:24:106/64

主要将DEVICE=eth0

该网卡配置文件为vm下桥接网卡信息

  1. 修改grub文件来禁用内核继续使用该命名规则,步骤:
    编辑grub配置文件”/etc/sysconfig/grub“:
    在”GRUB_CMDLINE_LINUX“变量中添加一句”net.ifnames=0 biosdevname=0“.
    如下:
1
2
3
4
5
6
7
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rd.lvm.lv=fedora/root rd.lvm.lv=fedora/swap rhgb quiet net.ifnames=0 biosdevname=0"
GRUB_DISABLE_RECOVERY="true"
  1. 重新生成grub配置并更新内核参数:
    运行命令: grub2-mkconfig -o /boot/grub2/grub.cfg
  2. 添加udev的规则(很有必要!)
    需要在”/etc/udev/rules.d“目录中创建一个网卡规则”70-persistent-net.rules“,并写入下面的语句:
    SUBSYSTEM==”net”,ACTION==”add”,DRIVERS==”?“,ATTR{address}==”您的网卡MAC地址”,ATTR{type}==”1” ,KERNEL==”eth“,NAME=”eth0”
    如下
1
[root@localhost ~]# vi /etc/udev/rules.d/70-persistent-net.rules
1
SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=00:0c:29:44:10:6c",ATTR{type}=="1",KERNEL="eth*",NAME="eth0"
  1. reboot重启系统

fedora更新源

#cd /etc/yum.repos.d
把原来的问文件删除 rm -rf
然后

1
2
#wget http://mirrors.163.com/.help/fedora-163.repo
#wget http://mirrors.163.com/.help/fedora-updates-163.repo

需要注释掉配置文件里面的https://mirrors一行,不然应该很慢

1
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=updates-released-f$releasever&arch=$basearch

dnf makecache

makecache命令参数是指让DNF重新获取并建立软件源元数据信息缓存

http://mirrors.sohu.com/help/fedora.html

VM下桥接网卡,应该将vm下虚拟机设置为dhcp自动获取ip

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
HWADDR=00:0c:29:44:a0:6c
TYPE=Ethernet
#BOOTPROTO=none
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
NAME=eth0
UUID=9c475afb-16b6-4659-864a-d5172d727625
ONBOOT=yes
# DNS1=10.8.6.254
# IPADDR=192.168.200.132
# IPADDR=192.168.85.100

PREFIX=24
# GATEWAY=192.168.200.1
IPV6_PEERDNS=no
IPV6_PEERROUTES=no

设置开机启动命令、vm下与主机共享目录 //mark

http://blog.csdn.net/wujin8589/article/details/52062413

二、解决安装VMWare tools后/mnt中有hgfs但没共享文件
前提:在虚拟机软件中设置了共享目录
此时在linux中进入 /mnt/hgfs 文件夹,但发现共享的文件没有显示
使用以下办法解决(root权限):
sudo passwd root
输入root的密码就可以正常切换到root权限了

  1. vmware-hgfsclient 命令查看当前有哪些共享的目录,这里我只使用了shared文件夹
  2. 使用 mount -t vmhgfs .host:/shared /mnt/hgfs 命令挂载该共享文件夹(注意:带.号的哦),其中.host:/Documents是共享名,只需把Documents换成
    使用vmware-hgfsclient 命令得到的目录,/mnt/hgfs是挂载点
  3. 到此为止是可以使用该共享文件夹了,但每次都得重复mount一次,所以需要设置为随机启动后自动挂载
    编辑 /etc/fstab,添加下面一行
    .host:/shared /mnt/hgfs vmhgfs defaults 0 0 (按需写)

设置默认进入文本模式

http://www.2cto.com/os/201309/246497.html
1.如果你想让系统默认从文本模式启动的话,则应该依次输入以下两条命令:

sudo rm /etc/systemd/system/default.target //这条命令是删除原来的默认启动模式

sudo ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target //这条命令是添加新的启动模式,将文本模式设置成默认启动模式

2.如果你想让系统默认从图形界面启动的话,则应该依次输入以下两条命令:

sudo rm /etc/systemd/system/default.target //这条命令是删除原来的默认启动模式

sudo ln -s /lib/systemd/system/graphical.target /etc/systemd/system/default.target //这条命令是添加新的启动模式,将图形模式设置成默认启动模式

注意一下:

当你修改系统默认启动模式为文本模式后,重新启动操作系统后,linux就会默认进入tty1(终端1)的文本模式。如果你想要进入图形界面,则可以输入一面这条命令:

startx //这是以普通用户登陆图形界面,如果你想以超级用户(root)进入图形界面的话,则应该输入sudo startx。

fedora设置root用户自动登入

1
vi /etc/gdm/custom.conf

让root自动登入

ssh登不上

情况一:VM下host能与虚拟机互相Ping通,但是SSH却登不上提示密码错误(实际密码没错错误)

实际解决
VM下Linux与宿主win10系统的以太网卡IP相同,导致SSH登入不上

注意:如果Linux桥接的网卡有设网关,VM下Linux网卡要手动设置网关和IP;如:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
TYPE=Ethernet
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.8.3.200
#NETMASK=255.255.255.0
#GATEWAY=10.8.3.254
# BROADCAST=10.8.1.255
HWADDR=00:0C:29:44:a0:6c
GATEWAY=10.8.3.254
#PEERDNS=yes
#DNS1=10.8.3.254
#USERCTL=no
#NM_CONTROLLED=no
#IPV6INIT=no
#IPV6ADDR=FD55:faaf:e1ab:1B0D:10:14:24:106/64

fedora21编译boost 1.59.0

参考文章

  1. 配置编译选项

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    [root@localhost boost_1_59_0]# ./bootstrap.sh --with-libraries=all --with-toolset=gcc
    Building Boost.Build engine with toolset gcc... tools/build/src/engine/bin.linuxx86/b2
    Detecting Python version... 2.7
    Detecting Python root... /usr
    Unicode/ICU support for Boost.Regex?... not found.
    Generating Boost.Build configuration in project-config.jam...

    Bootstrapping is done. To build, run:

    ./b2

    To adjust configuration, edit 'project-config.jam'.
    Further information:

    - Command line help:
    ./b2 --help

    - Getting started guide:
    http://www.boost.org/more/getting_started/unix-variants.html

    - Boost.Build documentation:
    http://www.boost.org/build/doc/html/index.htm

    https://yq.aliyun.com/articles/67001
  2. 编译

    1
    ./b2 toolset=gcc
  3. 报错:

    1
    2
    3
    Building Boost.Build engine with toolset gcc... 
    Failed to build Boost.Build build engine
    Consult 'bootstrap.log' for more details.

解决:
权限不够

1
chmod +x ./tools/build/src/engine/build.sh

  • fedora21安装完Qt后报错:
    1
    2
    3
    /opt/Qt5.4.1/5.4/gcc/include/QtGui/qopengl.h:122: error: GL/gl.h: No such file or directory
    # include <GL/gl.h>
    ^

或者:

1
:-1: error: cannot find -lGL

解决:

1
[root@localhost ~]# yum install  mesa-libGL-devel

参考: https://forum.facepunch.com//f/hwsw/beeol/GL-gl-h-No-such-file-or-directory/1/

linux杀死进程指令

用 ps -e

1
kill -9   `进程ID`


1
killall  `进程名称`

可以用ps -e | grep run找出带run字符的进程名字

查找相关进程

1
2
3
4
[root@localhost ~]# ps -ef | grep SLE
root 16445 4393 0 16:02 pts/0 00:00:00 ./SLE_take
root 16449 16281 0 16:02 pts/1 00:00:00 grep --color=auto SLE
[root@localhost ~]# kill -9 16445

ps -ef | grep SLE找出带SLE的进程名字

kill -9 + PID杀死进程

批量解压包脚本

  • 批量解压目录下所有.tgz包
    1
    # 解压本目录所有.zxvf文件
    for tar in *.tgz;  do tar xvf $tar; done
1
2
# 解压本目录所有.tar.gz文件
for tar in *.gz; do tar xzvf $tar; done

mark:脚本有错,只能一条一条的运行,2个语句块放到一起会报错,想想如何解决写到一起??

linux下boost

  1. 查看boost版本:
    1
    # find / -name libboost*
  • 去除.sh脚本里的^M
    1
    2
    敲出^M字符的方法,ctrl+v然后ctrl+m就可以了。
    #sed -i 's/^M//g' filename

fedora

  • 创建root用户密码:
    sudo passwd

  • fedora27安装 synergy-1.10.0-40.stable.275cdc1c.centos.el7.x86_64.rpm

rpm -ivh synergy-1.10.0-40.stable.275cdc1c.centos.el7.x86_64.rpm

报错:
[root@localhost Downloads]# rpm -ivh synergy-1.10.0-40.stable.275cdc1c.centos.el7.x86_64.rpm
error: Failed dependencies:
libdns_sd.so.1()(64bit) is needed by synergy-1.10.0-40.stable.275cdc1c.el7.x86_64

解决:

1
dnf install avahi-compat-libdns_sd

能安装成功,但是启动报错
System tray is unavailable,don’t close your window

看linux桌面环境
[root@acer Downloads]# gnome-shell –version
GNOME Shell 3.26.1

rfsdlfjlasfjdlkj

  • fedora28开启sshd
  1. 确认是否安装ssh包
    rpm -qa | grep openssh-server

  2. 修改配置文件

    1
    2
    3
    4
    5
    vi /etc/ssh/sshd_config

    PermitRootLogin yes //是否允许root直接登录

    Port 22 //监听的端口号,默认是22,可以自定义。
1
chkconfig sshd on

重启

1
service sshd restart


  • ubuntu18.04安装shadows

https://blog.csdn.net/bingyu9875/article/details/54600691

https://blog.csdn.net/totorocyx/article/details/80032556

报错:

1
takethat@t470p:~$ sslocal -c /home/takethat/shadowsocks.json
INFO: loading config from /home/takethat/shadowsocks.json
2018-05-28 18:32:33 INFO     loading libcrypto from libcrypto.so.1.1
Traceback (most recent call last):
  File "/usr/local/bin/sslocal", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/local.py", line 39, in main
    config = shell.get_config(True)
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/shell.py", line 262, in get_config
    check_config(config, is_local)
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/shell.py", line 124, in check_config
    encrypt.try_cipher(config['password'], config['method'])
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py", line 44, in try_cipher
    Encryptor(key, method)
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py", line 83, in __init__
    random_string(self._method_info[1]))
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py", line 109, in get_cipher
    return m[2](method, key, iv, op)
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py", line 76, in __init__
    load_openssl()
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py", line 52, in load_openssl
    libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p,)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 379, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 384, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1: undefined symbol: EVP_CIPHER_CTX_cleanup
takethat@t470p:~$

解决办法

1
2
3
4
5
6
7
 vi /usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py
将第52行libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p,)
改为libcrypto.EVP_CIPHER_CTX_reset.argtypes = (c_void_p,)
将第111行libcrypto.EVP_CIPHER_CTX_cleanup(self._ctx)
改为libcrypto.EVP_CIPHER_CTX_reset(self._ctx)

然后再次尝试启动。

在ubuntu18.04使用命令apt install shadowsocks安装的是shadowsocks 2.9.0-2,重启操作系统后没有这个报错

ubuntu删除firefox
dpkg –get-selections |grep firefox

  • 少动态库
    [root@localhost SOFTWARE_PACKAGE_DEBUG]# ldd AGM_Client
    ./AGM_Client: ./libc.so.6: version GLIBC_2.18' not found (required by /lib/libstdc++.so.6) ./AGM_Client: ./libc.so.6: versionGLIBC_2.17’ not found (required by /lib/libstdc++.so.6)
  • 加载动态库失败,没有定义函数符号
    1
    ./test_GC_ZZ14A /home/takethat/AGM__Driver_ZZ14A/GC-AGM_ZZ14A/libGC_ZZ14A.so 
    Cannot load library: /home/takethat/AGM__Driver_ZZ14A/GC-AGM_ZZ14A/libGC_ZZ14A.so: undefined symbol: sbs_n455_dio_set

原因:

sbs_n455_dio_set这个函数有声明,但是没有定义,可能这个函数是定义在另一个动态库里;

  • ssh别的主机失败,但是别的主机SSH过来却可以
    scp命令也是相同的情况

报错:

1
[root@localhost ~]# ssh 192.168.242.132
ssh: connect to host 192.168.242.132 port 22: Connection timed out

文章目录
  1. 1. ftp命令用法
  2. 2. vmware下虚拟机网络问题
  3. 3. eno16777736更名
  4. 4. fedora更新源
  5. 5. dnf makecache
  6. 6. 设置开机启动命令、vm下与主机共享目录 //mark
  7. 7. 设置默认进入文本模式
  8. 8. fedora设置root用户自动登入
  9. 9. ssh登不上
  10. 10. fedora21编译boost 1.59.0
  11. 11. linux杀死进程指令
  12. 12. 批量解压包脚本
  13. 13. linux下boost
  14. 14. fedora