Category Archives: Linux

[Solved] Failed to start LSB: Bring up/down networking.

Because my virtual machine is copied from other machines, after importing the new machine, there is no problem. The next day, the network can not be connected, so the following error appears

[root@centos ~]# /etc/init.d/network restart
Restarting network (via systemctl):  Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.
                                                           [FAILED]
[root@centos ~]# systemctl status network
● network.service - LSB: Bring up/down networking
   Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2018-03-20 06:32:23 EDT; 23s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 20428 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS)
  Process: 20597 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)

Mar 20 06:32:22 centos systemd[1]: Starting LSB: Bring up/down networking...
Mar 20 06:32:22 centos network[20597]: Bringing up loopback interface:  [  OK  ]
Mar 20 06:32:22 centos network[20597]: Bringing up interface eth0:  Error: ...n.
Mar 20 06:32:22 centos network[20597]: [FAILED]
Mar 20 06:32:23 centos network[20597]: Bringing up interface eth1:  Connect...9)
Mar 20 06:32:23 centos network[20597]: [  OK  ]
Mar 20 06:32:23 centos systemd[1]: network.service: control process exited,...=1
Mar 20 06:32:23 centos systemd[1]: Failed to start LSB: Bring up/down netwo...g.
Mar 20 06:32:23 centos systemd[1]: Unit network.service entered failed state.
Mar 20 06:32:23 centos systemd[1]: network.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

Baidu had a lot of problems, all of them said it was the problem of MAC address when copying

Here are my solutions:

#Turning off NetworkManager, the management suite that comes with the system, will solve the problem.
[root@centos ~]# systemctl stop NetworkManager
[root@centos ~]# systemctl disable NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
[root@centos ~]# 
#restart network
[root@centos ~]# /etc/init.d/network restart
Restarting network (via systemctl):                        [  OK  ]

[Solved] Centos7 Failed to start iptables.service: Unit not found

In CentOS 7 or RHEL 7 or Fedora, firewalls are managed by firewalld

Add

firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent is permanent and expires after reboot without this parameter)

firewall-cmd --zone=public --add-port=1000-2000/tcp --permanent

Reload

firewall-cmd --reload

View

firewall-cmd --zone=public --query-port=80/tcp

Delete

firewall-cmd --zone=public --remove-port=80/tcp --permanent

Turn on Firewall

systemctl start firewalld.service

Turn off firewall

systemctl stop firewalld.service

View running status

firewall-cmd --state //running

[Solved] Nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argument

First attach the error message:

 1 (myblog) root@Dapeng:/home/uwsgi# service nginx status 
 2 ● nginx.service - A high performance web server and a reverse proxy server
 3    Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
 4    Active: active (running) since Thu 2019-05-02 13:49:36 CST; 29s ago
 5   Process: 17090 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
 6   Process: 17101 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 7   Process: 17094 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 8  Main PID: 17103 (nginx)
 9     Tasks: 2
10    Memory: 1.8M
11       CPU: 35ms
12    CGroup: /system.slice/nginx.service
13            ├─17103 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
14            └─17104 nginx: worker process                           
15 
16 May 02 13:49:36 Dapeng systemd[1]: Stopped A high performance web server and a reverse proxy server.
17 May 02 13:49:36 Dapeng systemd[1]: Starting A high performance web server and a reverse proxy server...
18 May 02 13:49:36 Dapeng systemd[1]: nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argument
19 May 02 13:49:36 Dapeng systemd[1]: Started A high performance web server and a reverse proxy server.

My operating system is Ubuntu 16.04. After suddenly restarting nginx today, I found a 502 error reported to me. After looking at the status of nginx, there was an error prompt, just like the title. So Google found a link in a crooked nut’s personal blog, which solved my problem. I only work as a porter here, Small partners with problems can also refer to. Attached is the Ubuntu community reference link: bug for Ubuntu

This problem has been solved as a bug, but fortunately, there is a big solution

1 It seems to be a race between systemd and nginx. As if systemd was expecting the PID file to be populated before nginx had the time to create it.
2 
3 Workaround:
4 
5  mkdir /etc/systemd/system/nginx.service.d
6  printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" > /etc/systemd/system/nginx.service.d/override.conf
7  systemctl daemon-reload

And then we can restart it

[Solved] Linux No access to the system error: Failed to load SELinux policy. Freezing

Cause of error

SELinux is shut down by configuration, resulting in misoperation

The value of the "SELINUX" parameter in the configuration file /etc/selinux/config should be changed to
# SELINUX=enforcing Original configuration
SELINUX=disabled Correct

However, "SELINUXTYPE" is mistaken for "SELINUX" and the SELINUXTYPE parameter is set as follows
#SELINUXTYPE=targeted Original configuration This does not need to be changed.
SELINUXTYPE=disabled Error

Wrong result

After restart, the machine will report a failed to load SELinux policy. Freezing error, which causes it to fail to start all the time

Solution:

1. On the startup page, select the kernel you want to start and press e to enter grub edit page

2. Find the line linux16 in lang = zh_ Cn.utf-8 space plus SELinux = 0 or forcing = 0 (Note: I joined SELinux = 0 to take effect.)

3. Then start with Ctrl + X to see the familiar login interface

4. Modify SELinux configuration file and close SELinux properly

vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#    enforcing - SELinux security policy is enforced.
#    permissive - SELinux prints warnings instead of enforcing.
#    disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#    targeted - Targeted processes are protected,
#    minimum - Modification of targeted policy. Only selected processes are protected. 
#    mls - Multi Level Security protection.
SELINUXTYPE=targeted

After modification, restart

Git | fatal: refusing to merge unrelated histories [How to Solve]

Scenario: create an empty warehouse in gitee and push the existing warehouse. Through remote add origin < git path> specified warehouse, error message: error: failed to push some refs to ' https://gitee.com/XXXX/XXXXX.git ' Terminal Information:

JerrydeMacBook-Pro:web-h5 jerrylam$ git push      
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

After executing git push --set-upstream origin master, it reports another error, as follows .

JerrydeMacBook-Pro:web-h5 jerrylam$ git push --set-upstream origin master
To https://gitee.com/XXXX/web.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/XXXX/web.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Try git pull origin master , the error message is as follows

JerrydeMacBook-Pro:web-h5 jerrylam$ git pull origin master
From https://gitee.com/XXXX/web.git
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

Solutions

# Change the previous git pull origin master to the following code

git pull origin master --allow-unrelated-histories

Finally, we can push it

JerrydeMacBook-Pro:web-h5 jerrylam$ git push origin master
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 3.77 KiB | 3.77 MiB/s, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: Powered by Gitee.com
To https://gitee.com/XXXX/web.git
   f6b4cf0..c538ad9  master -> master

When push doesn’t go up, first git pull ensures the latest code

git pull  --allow-unrelated-histories
# Or specify branches
git pull origin master --allow-unrelated-histories

[Solved] Git Bash error: could not lock config file Java/jdk1.7.0_71/.gitconfig: Permission denied

 

Git is installed for the first time today. It appears when it is configured according to the tutorial

$ git config --global color.diff auto
error: could not lock config file C:/Program Files/Java/jdk1.7.0_71/.gitconfig: Permission denied

After several attempts, solution :
find git installation directory, set the properties of git-bash.exe, and tick “run this program as administrator” on the compatibility property page

The following is a record of the course at that time:

When I first met this problem, I guessed that git needed administrator permission, so I asked which git was, and I looked where git was

$ which git
/mingw64/bin/git

Then add administrator rights to the properties of/mingw64/bin/GIT. Exe. Naively, I thought it was solved in this way, but the result was:

$ git config --global color.diff auto
bash: /mingw64/bin/git: Permission denied

So I thought that the program that calls git.exe needs administrator permission. But who calls git.exe?Also try to modify the permissions of/CMD/git.exe,/bin/bash.exe,/bin/git.exe, and still report the same error

When there was no way out, I suddenly found git-bash.exe in the GIT root directory. As soon as I saw it, I modified the permissions of git-bash.exe and found that the problem was solved! After removing the previous redundant permissions, there is still no problem

It is concluded that just setting the permission of git-bash.exe is enough

The unknown host problem of FTP IPv6 in zZW Linux

I encountered unknown host problem when ftp with ipv6 in linux

1.[a4_csbdc@bdc8165 ~]$ cat /etc/issue
Red Hat Enterprise Linux Server release 5.5 (Tikanga)

in Red Hat Enterprise Linux Server release 5.5 (Tikanga)  FTP

[a4_csbdc@bdc8165 ~]$ rpm -qa |grep ftp
ftp-0.17-37.el5
lftp-3.7.11-4.el5
tftp-server-0.49-2
vsftpd-2.0.5-24.el5

[a4_csbdc@bdc8165 ~]$ ftp [2001:202:32:0:250::XXXX:XXXX:57c0]
ftp: [2001:202:32:0:250:XXXX:XXXX:57c0]: unknown host

[a4_csbdc@bdc8165 ~]$ lftp bdcuser:bdcuser\!35tt436w@[2001:202:32:0:250::XXXX:XXXX:57c0]:21 # Change to lftp command, then you can log in. Note that the backslash in the password bdcuser\!35tt436w is an escape character that is used to escape the ! sign is used.
lftp bdcfff@2001:202:32:0:250:XXXX:XXXX:57c0:~> ls
drwxrwxr-x 6 505 505 4096 Sep 20 11:50 BDC_FTP
-rw-r–r– 1 505 505 212 Oct 23 11:52 SUMMARY_FILE_20181023211157.verf
-rw-r–r– 1 505 505 150 Oct 24 11:45 SUMMARY_FILE_20181024210500.verf
-rw-r–r– 1 505 505 103 Oct 25 11:45 SUMMARY_FILE_20181025210500.verf

2.Change to another machine

[csbdc@sv0379 ~]$ cat /etc/issue
Red Hat Enterprise Linux Server release 6.0 (Santiago)
Kernel \r on an \m

[csbdc@sv0379 ~]$ rpm -qa |grep ftp
ftp-0.17-51.1.el6.x86_64
vsftpd-2.2.2-6.el6.x86_64
report-plugin-ftp-0.18-7.el6.x86_64
gvfs-obexftp-1.4.3-9.el6.x86_64
report-config-ftp-0.18-7.el6.x86_64
tftp-0.49-5.1.el6.x86_64
lftp-4.0.9-1.el6.x86_64

[csbdc@sv0379 ~]$ ftp 2001:202:32:0:250:XXXX:XXXX:57c0 #可以成功
Connected to 2001:202:32:0:250:XXXX:XXXX:57c0 (2001:202:32:0:250:XXXX:XXXX:57c0).
220 (vsFTPd 2.2.2)
Name (2001:202:32:0:250:XXXX:XXXX:57c0:csbdc): bdcuser
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
229 Entering Extended Passive Mode (3000|).
150 Here comes the directory listing.
drwxrwxr-x 6 505 505 4096 Sep 20 11:50 BDC_FTP
-rw-r–r– 1 505 505 212 Oct 23 11:52 SUMMARY_FILE_20181023211157.verf
-rw-r–r– 1 505 505 150 Oct 24 11:45 SUMMARY_FILE_20181024210500.verf
-rw-r–r– 1 505 505 103 Oct 25 11:45 SUMMARY_FILE_20181025210500.verf
226 Directory send OK.

3. Initially, I think it is the version of the FTP client that comes with linux, but I didn’t find any information about it.

ftp-0.17-37 does not support IPV6 (below Red Hat Enterprise Linux version 6)

ftp-0.17-51.1 can support IPV6 (for Red Hat Enterprise Linux version 6 and above)

Go build Error: cannot find package “fmt” in any of [How to Solve]

0. The project codes are as follows: 

The project code is written in gopath/SRC/Demo1/main/main.go

The go build command is executed under the gopath directory

1. The screenshot of error report is as follows: 2

Error reason: the wrong configuration of the root is caused by the FMT package in the error message. It points to F:: (go/bin/SRC) FMT, which indicates that our root is configured as the F:: (go/bin) directory. By default, go goes to the root/SRC directory to find the package directly introduced in our code

2. The solution is to modify the root and change the root to F: 2

After modification, recompile it