Category Archives: Linux

[Solved] shc -f xxx.sh shc: invalid first line in scrip

shc -f xxx.sh shc: invalid first line in scrip
Problem: The following error occurs when running shc
Code: $ shc -f test1.sh shc: invalid first line in script
Analysis: The script works fine
$cat test1.sh
echo “hello”
cal
Code:
$ shc -f test1.sh
shc: invalid first line in script: echo “hello”
shc: Success
Reason:

You have to put the sha-bang (e.g. #!/bin/bash) at the beginning of the script, since shc need to know which shell is using. Here is an excerpt from the manual page:

Explanation:
Add to the first line of the script ( #! /bin/bash)
Pro-tested available!

[Solved] httpd:httpd:Could not reliably determine the server‘s fully qualif domain name,using ::1 for Se

In the process of building lamp environment, installing Apache reported an error: starting httpd:httpd :Could not reliably determine the server’s fully qualif domain name,using ::1 for ServerName

Solution:

Edit server profile

vi /etc/httpd/conf/httpd.conf

Find the servername in the file www.example.com : 80 “change to” servername ” www.localhost.com : 80 ”
you can use ‘/’ to find (/ servername) www.example.com : 80)
and remove the previous # cancel comment

Set the server to boot

chkconfig httpd on

Restart Apache

/etc/init.d/httpd restart

Solution to gzip: stdin: invalid compressed data — format violated error in decompressing. Tgz file under Linux

When executing the tar – zxvf xxxx.tgz command,
prompt the following information:
gzip: stdin: invalid compressed data – format violated
tar: child returned status 1
tar: error is not recoverable: exiting now
method 1

    1. reason: the compressed package is not compressed in gzip format, so there is no need to add Z instruction. Solution: use tar – xvf xxxxx.tgz command (i.e. remove Z parameter)

Method 2

      1. rename the downloaded file to tar suffix, MV xx.tgz xx.tar, and then execute the decompression command: tar – zxvf XX. Tar </ OL>

Method 3
add after WGet

 --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" 

For example:

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.tar.gz"

or

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" -c -O 数据集名字 "对应的网页下载链接"

Error in compiling Android AOSP by Ubantu [How to Solve]

Error:

You asked for an OpenJDK 7 build but your version is

java version “1.7.0_75” Java(TM) SE Runtime Environment (build 1.7.0_75-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode).

Reason:

AOSP (Android Open Source Project)
) Compilation requires openjdk, not oracle’s JDK version

This environment version.

Versions that can be compiled.

[Solved] tar (child): bzip2: Cannot exec: No such file or directory tar (child): Error is not recoverable: ex

What should I do if I get an error unpacking?
tar (child): bzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

The problem is that the corresponding decompression software bzip2 is not installed
yum install bzip2

Decompress again, success!!!

NVIDIA SMI error after Ubuntu 20.04 restart [How to Solve]

prompt: after the article is written, the directory can be automatically generated. For how to generate it, please refer to the help document on the right </ font> for details

Contents of articles

Problem description, problem analysis and solution 1 Analysis 2 solution


Problem description

after rebooting ubuntu20.04, the resolution of the interface is not correct, and the following error appears when viewing the information of the graphics card: </ font>

> nvidia-smi
NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver

before the restart, there was no operation on the graphics card driver, just a system update using sudo apt get upgrade</ font>


Problem analysis and solution

1 Analysis

first of all, make sure that the driver of the graphics card has not moved, and the graphics card and other related hardware has not been replaced. Then, before the restart, the operation for the system is just to update the relevant software in the system by using sudo apt get upgrade. Therefore, it is speculated that the system kernel was updated during the update, and the new system kernel may not match the current graphics driver. Use the following command to view the kernel of the current system and all versions of the kernel that exist in the current system: </ font>

> uname -r
5.4.0-77-generic
> grep menuentry /boot/grub/grub.cfg
if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
  menuentry_id_option=""
export menuentry_id_option
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-fb3b617b-7620-428a-83de-08de34328e80' {
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-fb3b617b-7620-428a-83de-08de34328e80' {
	menuentry 'Ubuntu, with Linux 5.4.0-77-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-77-generic-advanced-fb3b617b-7620-428a-83de-08de34328e80' {
	menuentry 'Ubuntu, with Linux 5.4.0-77-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-77-generic-recovery-fb3b617b-7620-428a-83de-08de34328e80' {
	menuentry 'Ubuntu, with Linux 5.4.0-74-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-74-generic-advanced-fb3b617b-7620-428a-83de-08de34328e80' {
	menuentry 'Ubuntu, with Linux 5.4.0-74-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-74-generic-recovery-fb3b617b-7620-428a-83de-08de34328e80' {
menuentry 'Windows Boot Manager (on /dev/sda3)' --class windows --class os $menuentry_id_option 'osprober-efi-14CC-72D3' {
menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {

found that in addition to the current version of the kernel, there is another (relatively old) version of the kernel: 5.4.0-74-generic
therefore, in order to verify whether it is related to kernel update, restart the system, select Ubuntu advance option in grub startup interface, and start with a lower version kernel. Results after the restart, the resolution of the interface returned to normal, NVIDIA SMI could also find the related information of the graphics card driver</ font>

2 solution

to determine the problem, there are two main solutions: </ font>

Delete and uninstall the old version of the graphics card driver, and re install the graphics card driver on the basis of the new kernel. Continue to use the kernel version 5.4.0-74-generic when installing the graphics card driver, and uninstall the newly updated kernel version 5.4.0-77-generic. Then disable the kernel update and keep the current kernel

> # sudo vim /etc/default/grub
# View the currently installed kernel
> dpkg --get-selections| grep linux-image
linux-image-5.4.0-74-generic install
linux-image-5.4.0-77-generic install
linux-image-generic install
# Uninstall the corresponding kernel
> sudo apt-get remove linux-image-5.4.0-77-generic
# Disable kernel updates and keep the current kernel unupdated
> sudo apt-mark hold linux-image-5.4.0-74-generic 
> sudo apt-mark hold linux-headers-5.4.0-74-generic
> sudo apt-mark hold linux-modules-extra-5.4.0-74-generic

The problem of inconsistent host names in building rabbitmq on Linux

1. Environment:

centos 7.3

2. Problem description

Today, the following error occurred in the process of deploying rabbitmq as a front-end and back-end message push

$ rabbitmqctl set_permissions -p/duni ".*" ".*" ".*"

Error: unable to connect to node rabbit@bbbbdddd: nodedown

DIAGNOSTICS
===========

attempted to contact: [rabbit@bbbbdddd]

rabbit@bbbbdddd:
  * connected to epmd (port 4369) on bbbbdddd
  * epmd reports node 'rabbit' running on port 25672
  * TCP connection succeeded but Erlang distribution failed

  * Hostname mismatch: node "rabbit@localhost" believes its host is different. Please ensure that hostnames resolve the same way locally and on "rabbit@localhost"


current node details:
- node name: 'rabbitmq-cli-92@bbbbdddd'
- home dir: /var/lib/rabbitmq
- cookie hash: h6TDjQ+DgPaVGJLMjcG4TA==

I can’t connect to the host where I deployed rabbitmq bbbbdddd

3. Google

Google found the corresponding problem in stack overflow

Here we say to give rabbitmq command permission, delete the service and then re install it. After trying, I found that I can’t do it…

Continue with Google, and some people say to correct Erlang’s Cookie:

Erlang will generate two cookie files: C: windows. Erlang. Cookie and C: user. Erlang. Cookie. Check whether the contents of the two files are consistent. If not, replace one with the other.

Windows platform, er… My environment is Linux, and I didn’t find two . Erlang. Cookie files in the root directory

$ find/--name .erlang.cookie
/var/lib/rabbitmq/.erlang.cookie

So I gave up.

4. Solutions

The final solution is to set the host name and restart the rabbitmq service

# Kill the rabbitmq process first
$ ps -ef | grep rabbitmq | grep -v grep | awk '{print $2}' | xargs kill -9

# set hostname (assume host ip is: 192.168.1.1, hostname set to: mq)
$ echo 192.168.1.1 mq > /etc/hosts
$ echo rabbitmq > /etc/hostname
$ export HOSTNAME=mq

# Restart rabbitmq
$ rabbitmq-server -detached
# Start the web socket service
$ rabbitmq-plugins enable rabbitmq_management rabbitmq_web_stomp
# Set up users and give them administrator privileges
$ rabbitmqctl add_user duni duni
$ rabbitmqctl set_user_tags duni administrator
# set user directory
$ rabbitmqctl set_permissions -p/duni ".*" ".*" ".*"

[Solved] Using GCP copy to report errors in Linux: DBUS. Exceptions. Dbusexception: org. Freedesktop. DBUS. Error. Notsupported:

1 Error when using gcp copy in linux
Error reported when using gcp copy in Linux.dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

zhihui@zhihui-MS-7B46:~/shl_proj/1_project$ cp -r /media/zhihui/sd/shl_dataset/ ./
Traceback (most recent call last):
  File "/usr/bin/gcp", line 678, in <module>
    gcp = GCP()
  File "/usr/bin/gcp", line 190, in __init__
    sessions_bus = dbus.SessionBus()
  File "/usr/lib/python2.7/dist-packages/dbus/_dbus.py", line 211, in __new__
    mainloop=mainloop)
  File "/usr/lib/python2.7/dist-packages/dbus/_dbus.py", line 100, in __new__
    bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)
  File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 122, in __new__
    bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
zhihui@zhihui-MS-7B46:~/shl_proj/1_project$ vim ~/.bashrc 

2 solutions

1. Modify the ~ /. Bashrc file and add the following

alias cp='dbus-launch gcp'

2. Let the changes take effect

source ~/.bashrc

Then try copying it again!

Git Clone RPC failed;curl 18 transfer closed with outstanding read data remaining

Git clone times RPC failed; Curl 18 transfer closed with outstanding read data remaining error

Reason 1: buffer overflow

Solution: command line input

git config http.postBuffer 524288000

If clone still fails to execute the above command, consider possible reason 2: slow network download speed

Solution: command line input

git config --global http.lowSpeedLimit 0
git config --global http.lowSpeedTime 999999

If clone still fails, shallow clone first, and then update the remote database to the local database

git clone --depth=1 http://gitlab.xxx.cn/yyy/zzz.git
git fetch --unshallow

Git error bad signature [How to Solve]

When submitting the file to the warehouse, the following error is thrown:

Report an error

Roc@DESKTOP-AF552U2 MINGW64 /e/note/Git (master)
$ git add git_GitHub.md
error: bad signature
fatal: index file corrupt

Cause Analysis

Because index file generally refers to the file .git/index in git. This file saves the information in the temporary storage area (index information). You can use git ls-files –stage to view the contents of the staging area. This file is very important! But now it reports index file corrupt, indicating that this file has been damaged. Fortunately, we have a way to regenerate this file: git read-tree or directly git reset.

Solution

  1. Enter the project directory: cd /path/to/dir
  2. Delete or rename the .git/index file: rm -f .git/index or mv .git/index{,.bak}
  3. Rebuild .git/index: git read-tree or directly git reset
Roc@DESKTOP-AF552U2 MINGW64 /e/note (master)
$ mv .git/index .git/index.bak

Roc@DESKTOP-AF552U2 MINGW64 /e/note (master)
$ git reset
Unstaged changes after reset:
M       Git/git_use.md
M       Git/git_para.md

Roc@DESKTOP-AF552U2 MINGW64 /e/note (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   "Git/git\347\232\204\345\210\235\346\254\241\344\275\277\347\224\250.md"
        modified:   "Git/git\347\232\204\351\200\211\351\241\271\345\217\202\346\225\260.md"

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        Git/git failed to push some refs to github.md
        "Git/git \346\212\245\351\224\231 index file corrupt.md"
        "Git/git\350\277\236\346\216\245GitHub\344\273\245\345\217\212\346\216\250\351\200\201\350\207\263\344\273\223\345\272\223.md"

no changes added to commit (use "git add" and/or "git commit -a")

Roc@DESKTOP-AF552U2 MINGW64 /e/note (master)
Done!