Tag Archives: linux

Linux’s method of clearing DNS cache and refreshing DNS in shell terminal (Ubuntu, Debian)

preface

Use the following command to query DNS in Linux system

dig baidu.com @114.114.114.114

Or use the default DNS server to query

nslookup baidu.com

The following methods may not all work, but you can always find one that works

1.network-manager and networking

In some Linux operating systems, such as the specific version of Ubuntu, DNS is managed by network manager.
In these systems, you need to run the command:

sudo service network-manager restart

In other systems, you can use the following command:

sudo service networking restart

2.ubuntu

In Ubuntu 12.04, you can try the following command:

sudo kill -HUP $(pgrep dnsmasq)

In Ubuntu 16.04 and Debian 9, you can refresh DNS with the following command

sudo systemd-resolve --statistics

On Ubuntu 17.04 and later, use the following command:

sudo systemd-resolve --flush-caches

3 /etc/ resolv.conf

/etc/ resolv.conf This file stores the address of the DNS server. Directly modifying this file can only temporarily change the default DNS address and restore the settings after restart.
You can modify this file directly for temporary use

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8

After modification, Ping or NSLOOKUP again will get the IP address from the new DNS server
for the method of permanent modification, see how do I add a DNS server via resolv.conf?

4.nscd

NSCD is a good DNS caching service. Use the following command to install it:

apt install nscd  #debian ubuntu

If you have NSCD installed on your Linux system, you can use the following command to refresh DNS:

sudo /etc/init.d/nscd restart

Resources:
How do I clear the DNS cache?
flush DNS cache in Ubuntu

Common linux commands — find command’s Exec

Linux command — exec of find command

Example 1: the LS – L command is placed in the – exec option of the find command. Example 2: find the files whose change time is before n days in the directory and delete them. Example 3: find the files whose change time is before n days in the directory and delete them. Give a prompt before deleting. Example 4: grep is used in – exec Command instance 5: find the file and move to the specified directory instance 6: execute CP command with exec option

We often use the find query file. After querying, we will do some common operations, such as deleting RM – RF. At this time, we don’t want to use the pipe character, so we can use exec to solve this problem.

Exec explains:

-The exec parameter is followed by a command, such as RM – F, whose termination is marked by a semicolon. Therefore, the semicolon after this command is indispensable. Considering that the semicolon has different meanings in different systems, a backslash is added in front of it.

The curly brackets represent the file name found by find.

When using find, as long as you write the desired operation in a file, you can use exec to cooperate with find search, which is very convenient. In some operating systems, only the – exec option is allowed to execute commands such as LS or LS – L. Most users use some options to find old files and delete them. It is suggested that before the RM command is executed to delete a file, it is better to use the LS command to check that they are the files to be deleted. The exec option is followed by the command or script to be executed, followed by a pair of {}, a space and a \, and finally a semicolon. In order to use the exec option, you must also use the print option. If you verify the find command, you will find that the command only outputs the relative path and file name from the current path.

Example 1: the LS – L command is placed in the – exec option of the find command

1. Command:
find. – type F – exec LS – L {}; the find command matches all the ordinary files in the current directory and lists them with the LS – L command in the – exec option.

This command is a bit of a pit, but it’s really easy to use. It’s because I received a prompt when I entered: find omitted the – exec parameter

2. Solution:
(1) pay attention to a pair of {}, a space and a \, and finally a semicolon
(2) use “;” ‘;’ in; to arouse them.

Example 2: search the directory for the files whose change time is n days ago and delete them

1. Command:

find . -type f -mtime +14 -exec rm {} ;

Before deleting files in any way in the shell, you should check the corresponding files first, and be careful. When using commands such as MV or RM,
you can use the – exec option security mode, which will prompt you before operating on each matched file.

Example 3: find the files whose change time is n days ago in the directory and delete them. Give a prompt before deleting them

1. Command:

find . -name “*.log” -mtime +5 -ok rm {} ;

Find all the files in the current directory that end with. Log and have been changed for more than 5 days, delete them, and give a prompt before deleting them. Press y to confirm and N to cancel.

Example 4: using grep command in – Exec

1. Command:

find /etc -name “passwd” -exec grep “root” {} ;

Any form of command can be used in the – exec option. In the above example, we use the grep command. The find command first matches all the files named “passwd”, and then executes the grep command to see if there is a root user in these files.

Example 5: find the file and move it to the specified directory

1. Command:

find . -name “*.log” -exec mv {} … ;    //… Is the path name

Example 6: executing CP command with exec option

1. Command:

find . -name “*.log” -exec cp {} test3 ;

I’m not careful. Test3 is a directory, otherwise CP won’t go in.

Exec format error: Java

welcome to my blog

Problem Description: decompress the jdk8 installation package, configure the environment variables, execute the Java command, and report an error: exec format error: Java

Reason: I didn’t look carefully when downloading the compressed package. As a result, the download is wrong. The download is ARM architecture, and the Ubuntu/Linux I use is x64 architecture

Download the correct compressed package and re operate

Error in PIP command execution – syntax error: invalid syntax

An error occurred during PIP executing the command. The exception code is as follows:

Traceback (most recent call last):
  File "/usr/bin/pip", line 7, in <module>
    from pip._internal.main import main
  File "/usr/lib/python2.6/site-packages/pip/_internal/main.py", line 13, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/lib/python2.6/site-packages/pip/_internal/cli/autocompletion.py", line 11, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/lib/python2.6/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/usr/lib/python2.6/site-packages/pip/_internal/cli/cmdoptions.py", line 105
    binary_only = FormatControl(set(), {':all:'})
SyntaxError: invalid syntax

Solution:
Add Python installation path to the configuration file:
VI/etc/profile

# python
export PATH=/usr/local/python3/bin:$PATH

Update configuration file
source/etc/profile

Error starting day: SELinux is not supported with the overlay 2

Environment: centos7

Command: systemctl start docker

          systemctl status docker -l

Error starting day: SELinux is not supported with the overlay 2 graph driver on this kernel. Either boot into a new kernel or disable SELinux in docker (- – SELinux enabled = false)

Solution:

It means: SELinux in this Linux kernel does not support overlay 2 graph driver. There are two solutions: either start a new kernel or disable SELinux in docker, – SELinux enabled = false

To edit the docker profile again:

vi /etc/sysconfig/docker

Change to:

Then systemctl start docker is ready

Viewing the file system format of disk partition under Linux

Link to the original text:

https://www.cnblogs.com/youbiyoufang/p/7607174.html

————————————————————————-

DF – t can only view mounted partitions and file system types.

Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda1 ext4 20642428 3698868 15894984 19% /
tmpfs tmpfs 32947160 0 32947160 0% /dev/shm

Fdisk – L displays all mounted and unmounted partitions, but does not display the file system type.

Disk /dev/sda: 299.4 GB, 299439751168 bytes
255 heads, 63 sectors/track, 36404 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk identifier: 0x000576df

Device Boot Start End Blocks Id System
/dev/sda1 * 1 2611 20971520 83 Linux
/dev/sda2 2611 3134 4194304 82 Linux swap/Solaris
/dev/sda3 3134 36404 267248282 83 Linux

Parted – L to see the types of unmounted file systems and which partitions are not formatted.

Model: LSI MR9240-8i (scsi)
Disk /dev/sda: 299GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 1049kB 21.5GB 21.5GB primary ext4 boot
2 21.5GB 25.8GB 4295MB primary linux-swap(v1)
3 25.8GB 299GB 274GB primary ext4

Lsblk – F can also view unmounted file system types.

NAME FSTYPE LABEL UUID MOUNTPOINT
sda 
|-sda1 ext4 c4f338b7-13b4-48d2-9a09-8c12194a3e95 /
|-sda2 swap 21ead8d0-411f-4c23-bdca-642643aa234b [SWAP]
`-sda3 ext4 2872b14e-45va-461e-8667-43a6f04b7bc9

 

file -s /dev/sda3

/dev/sda3: Linux rev 1.0 ext4 filesystem data (needs journal recovery) (extents) (large files) (huge files)

Prompt error: rpmdb open failed using yum

On the CentOS system, an error is reported when using the yum command to install the package

rpmdb: Thread/process 6539/140448388269824 failed: Thread died in Berkeley DB library
error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db3 -  (-30974)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:

The reason is that the RPM database is damaged

Restore to normal after rebuilding the database:

cd /var/lib/rpm/
for i in `ls | grep 'db.'`;do mv $i $i.bak;done
rpm --rebuilddb
yum clean all

 

Ubuntu 20.04 installing gfortran-6/ libgfortran.so .3

When I try to run the do command under GAMIT on Ubuntu 20.04, it shows:

root@DESKTOP-LF0EAC9:/etc/apt# doy
doy: error while loading shared libraries: libgfortran.so.3: cannot open shared object file: No such file or directory

among libgfortran.so . 3 depending on gfortran-6, try to install gfortran-6:

root@DESKTOP:/etc/apt# apt install gfortran-6
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package gfortran-6

The problem here is that Ubuntu 20.04 does not support G + ± 6. Add the following source to/etc/apt/ sources.list For the method of adding source, see the link

deb http://gb.archive.ubuntu.com/ubuntu/ bionic main universe

function

sudo apt-get update

Install GCC + + – 6

apt-get install g++-6

Setting the default version of GCC

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 6

Install gfortran-6

 apt install gfortran-6

Install successfully, run doy

root@DESKTOP-LF0EAC9:/etc/apt# doy 2020 001
Date 2020/01/01  0:00 hrs, DOY   1 JD  2458849.5000 MJD  58849.0000
GPS Week  2086 Day of week  3, GPS Seconds 259200 Day of Week Wed
Decimal Year 2020.000000000 GRACE Seconds 631108800.0

Run successfully

Start rqt_ Graph, prompt / opt / ROS / melody / share / PR2_ motor_ diagnostic_ Under tool plugin.xml There is something wrong with the file

Question: as the title, open it plugin.xml It was found to be blank.

Solution: find the GitHub of PR2, download and copy it to/opt/ROS/melody/share/PR2_ moto_ diagnostic_ Tool/or create your own plugin.xml File, which will be installed on GitHub plugin.xml Copy in the code in.

[new problem] prompts that we do not have permission to create a file in this path, so we need to increase the permission to obtain the super user permission: $sudo Chmod 777/opt/ROS/melody/share/PR2_ motor_ diagnostic_ tool/。 Then create a new one plugin.xml File, copy the code in and save it.

Error creating bean with name ‘enablererediskeyspacenotificationsinitializer’

After the server is shut down, restart it, and start the web application log on it to print an error. Error creating bean with name ‘enablererediskeyspacenotificationsinitializer’ searches the Internet and finds that many of the answers are caused by the redis annotation related to springboot, and it is necessary to set redis.

But the problem is that this is not springboot, and there is no redis setting, because it was good before. After a long time, none of the reliable people suddenly thought about whether the problem lies in redis. Let’s take a look at the process of redis first,

ps -ef | grep Redis

Sure enough, redis didn’t start at all. First, open the redis service and see if it will change and if the error will change

Find the redis location
Find – name redis cli
(if redis or other services start, you can find the process number such as 12345, ll/proc/12345/CWD through PS – EF | grep XXXX to find the corresponding service location. )

Start the redis service
to the corresponding path to start the service
redis server /Redis conf
(note that the paths of redis server and redis conf are at the same level or not. )

Service start, web application process kill and restart, no error. So the reason for this error is related to whether the redis service is started or not.