Category Archives: Linux

How to Check Password Modification Complexity

Password modification complexity check

The corresponding password policy modules of Linux are: PAM_ Passwdqc and PAM_ pwquality . PAM_The passwdqc module corresponds to /etc/login.defs ,pam_ Pwquality corresponds to /etc/security/pwquality.conf

Module adding method: etc/pam.d/passwd

vi /etc/pam.d/passwd
password required retry=3


echo "password required retry=3" >> /etc/pam.d/passwd

Open the password complexity verification configuration file / etc / security/ pwquality.conf

vi /etc/security/pwquality.conf
retry=3Defines the number of retries that can be made if the login/change password fails.
Difok=0#defines that there must be several characters in the new password to be different from the old one. but if more than 1/2 of the characters in the new password are different from the old one, that new password will be accepted.
minlen=0#defines the minimum length of the user's password.
dcredit=0#defines how many digits must be included in the user's password.
ucredit=0#defines how many uppercase letters must be included in the user's password.
lcredit=0#defines how many lowercase letters must be included in the user's password.
ocredit=0# defines how many special characters (other than numbers and letters) must be included in the user's password.
# where =-1 means that at least one

Modify password validity file/etc/login.defs

PASS_MAX_DAYS   99999     #The maximum validity of the password, 99999: permanent period
PASS_MIN_DAYS 0 # whether the password can be changed, 0 can be changed, non-0 how many days after the password can be changed
PASS_MIN_LEN 5 #Minimum length of password, use pam_cracklib module, this parameter is no longer valid
PASS_WARN_AGE 7 # how many days before the password expires to notify the user to change the password when they log in

[How to Fix]Element is not attached to the page document record

Record the click problem of the select box in automatic test

1. Paste the code first

#Open the Google Chrome
#input the Google
#Click the I'm feel Luckly
driver.find_element_by_css_selector("#tsf > div:nth-child(2) > div.A8SBwf > div.FPdoLc.tfB0Bf > center > input.RNmpXc").click();
# click about us
driver.find_element_by_css_selector("#nav-list > li:nth-child(2) > a").click();
#Cyclic click on select checkbox
for index in range(len(driver.find_elements_by_tag_name("option"))):
    select = driver.find_element_by_id("lang-chooser");
    select_value = select.find_elements_by_tag_name("option");

First, by_ tag_ The name method gets the option information in the select box, which is returned in the form of list


Then use the for loop to traverse the list of select options through the index number, and remove the current option of click ()
because each click on the select option will refresh the whole web page, an error will be reported

element is not attached to the page document

So we need to use it driver.refresh() method to refresh the current page, and then get the elements of the select option box again to click

Latex: How to Modify the Size of the Font

There are these types of fonts in latex:


Generally speaking, the default font size is \normalsize. We can redefine the default font size at the beginning:


Just change the value of 12pt. Latex provides three sizes: 10 / 11 / 12pt

Or directly define the text size:

\fontsize{5.0pt}{\baselineskip}\selectfont  text

Change 0.5 to the number you want.

How to Export All data in DataGridView to Local Excel

Export all data in DataGridView to local excel

When the method is called, the parameter can be written into its own DataGridView name

 #region DataGridView Export to local Excel file method
        public void DownloadDataGridView(DataGridView dgv)
            SaveFileDialog saveFileDialog = new SaveFileDialog
                Filter = "Execl files (*.xls)|*.xls",
                FilterIndex = 0,
                RestoreDirectory = true,
                CreatePrompt = true,
                Title = "Exported Excel"
            if (saveFileDialog.FileName == "")
            }//end if
            Stream myStream = saveFileDialog.OpenFile();
            //use the default encode
            StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding(-0));
            string str = "";
                for (int i = 0; i < dgv.ColumnCount; i++)
                    str += dgv.Columns[i].HeaderText;
                    str += "\t";
                }//end for
                for (int j = 0; j < dgv.Rows.Count - 1; j++)
                    string strTemp = "";
                    for (int k = 0; k < dgv.Columns.Count; k++)
                        object obj = dgv.Rows[j].Cells[k].Value;
                        if (obj != null)
                            strTemp += dgv.Rows[j].Cells[k].Value.ToString();
                        }//end if
                            strTemp = "";
                        }//end else
                        strTemp += "\t";
                    }//end for k
                }//end for j
                MessageBox.Show("Success to Export the Excel File:\n" + saveFileDialog.FileName);
            }//end try
            catch (Exception ex)
            }//end catch
            }//end finally

Latex: How to enter an underline

By default, latex sets the_ “As a part of the subscript representation in the mathematical model, this kind of processing is very unpleasant in many cases, such as the underlined variable: host in the code_ Name or something. Although you can use “host”\_ “Name” and so on, but it’s not easy to read. The following method can deal with most problems.


If not, please refer to



%%%%%%%Handling underlines._%%%%%%%%%
%%%%%%%Handling underlines._%%%%%%%%%


Git: How to delete stash content

Delete the content of stash, feel the whole world is clean:

In fact, there are just a few commands:

Git stash list / / view the stash list

If you get this result, your stash has nothing
in it

This means that there is a queue
in the queue


Then you can execute git stash clear: note that this is to clear all your content

$ git stash drop [email protected]{0}  This is the first queue to be deleted


Linux: How to Fix undefined reference to `itoa’

I wrote a simple C program in Linux, which used Itoa. But when compiling, I prompted “undefined reference to ` Itoa ‘”, I thought it would be OK to add – LC, but the result was the same. Internet found that some people say that this function does not exist in Linux, generally use sprintf to replace it. Look at the following code and comments:

#include <stdio.h>
#include <stdlib.h>
//#include <unistd.h>
#include <string.h>

int num = 0;
char namebuf[100];
char prefix[] = "/tmp/tmp/p";

char* gentemp()
    int length, pid;

    pid = getpid();
    strcpy(namebuf, prefix);
    length = strlen(namebuf);
    //itoa(pid, &namebuf[length], 10);      // Unix version: itoa() does not exist in header file <stdlib.h>
    sprintf(namebuf+length, "%d", pid);     // Converting integers to strings using sprintf
    strcat(namebuf, ".");
    length = strlen(namebuf);
    printf("before do...while\n");
    char command[1024] = {0};
        //itoa(num++, &namebuf[length], 10);
        sprintf(namebuf+length, "%d", num++);
        sprintf(command, "touch %s", namebuf);  // Creating files via touch
        printf("command = %s, namebuf[%d]=%d\n", command, num-1, num-1);
    } while (num < 50 && access(namebuf, 0) != -1); // access to determine whether a file exists
    printf("end of do...while\n");

    return namebuf;

int main( void )
    char *p = gentemp();
    printf("%s\n", p);

    return 0;

How to set fixed IP address for Raspberry Pie

Recently, we need to realize the communication between three raspberry pie terminals in an Internet composed of two switches

Because raspberry pie has a gigabit network port, we need to match the IP addresses of three raspberry pies in the same network segment. So we need to change the address.

Unlike the computer version of Ubuntu system, raspberry pie is not easy to implement interface settings. Under Ubuntu, you just need to click the network icon, and then edit the wired link in the edit link at the bottom.

The method of configuring IP address for raspberry pie is as follows:

1. Now the terminal input ifconfig to view the local cable link interface

You can see that there is a wired connection port of enxb827bb3ef8a on the top, which is the name of the wired gateway. Or you can see it through the following of hwaddr

Remember the name

2. Terminal input:

sudo nano /etc/network/interfaces

Then a black interface (network configuration file) will be opened, which may display the following contents:

Then add the following:

auto lo
iface lo inet loopback
auto enxb827bb3ef8a  //It is the name of the previous view
iface enxb827bb3ef8a inet static
address    //IP address
netmask    //NetMask
gateway     //Gateway

Then press Ctrl + O to save, press enter to confirm, and press Ctrl + X to exit

Finally, use the sudo reboot command to restart

Hadoop 3.2.0 idea development environment construction and HDFS read write API operation

First of all, we need to build a Hadoop server

Please refer to: Hadoop 3.2.0 fully distributed cluster building and wordcount running

Create a new Maven project and add Hadoop related jar package


Write HDFS tool class

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;


 * @author LionLi
 * @date 2019-2-7
public class HDFSUtils {

    /** hdfs Server Address */
    private static final String hdfsUrl = "hdfs://";
    /** Access users */
    private static final String username = "root";

    public static void main(String[] args) throws Exception {
        String filePath = "/user/root/demo.txt";
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i < 100001; i++) {
            sb.append("hadoop demo " + i + "\r\n");
        HDFSCreateAndWriteFileValue(hdfsUrl,username, filePath,sb.toString());
        HDFSReadFileValue(hdfsUrl,username, filePath);

     * Read the contents of the file
     * @param url server address
     * @param user access user
     * @param filePath file path
    private static void HDFSReadFileValue(
            String url,String user, String filePath) throws Exception {
        Configuration conf = new Configuration();
        try (FileSystem fileSystem = FileSystem.get(new URI(url), conf, user)) {
            Path demo = new Path(filePath);
            if (fileSystem.exists(demo)) {
                System.out.println("/user/root/demo.txt file exist");
                FSDataInputStream fsdis =;
                byte[] bytes = new byte[fsdis.available()];
                System.out.println(new String(bytes));
            } else {
                System.out.println("/user/root/demo.txt file not exist");

     * Create and write the contents of the file
     * @param url server address
     * @param user Access user
     * @param filePath The path to the file to be created
     * @param value The value to be written
    private static void HDFSCreateAndWriteFileValue(
            String url,String user,String filePath,String value) throws Exception {
        Configuration conf = new Configuration();
        try (FileSystem fileSystem = FileSystem.get(new URI(url), conf, user)) {
            Path demo = new Path(filePath);
            if (fileSystem.exists(demo)) {
                System.out.println("/user/root/demo.txt file exist");
                if (fileSystem.delete(demo, false)) {
                    if (fileSystem.exists(demo)) {
                        System.out.println("/user/root/demo.txt failed to delete file");
                    } else {
                        System.out.println("/user/root/demo.txt success to delete file");
                        FSDataOutputStream fsdos = fileSystem.create(demo);
            } else {
                System.out.println("/user/root/demo.txt file not exist");
                FSDataOutputStream fsdos = fileSystem.create(demo);

test run

The test was successful

Windows command execution bypass


Double quotation marks. Brackets. The XOR combination can execute the command normally
and cannot add two. Will be treated as an escape character. Become a

Variable bypass

set a=1
echo a
echo %a%

set a=w
set b=ahomi

Use environment variables to bypass.

All environment variables can be viewed via set
echo net%programfiles:~10,1%user
Takes the environment variables of programfiles starting with the 10th bit. Take one bit. It is a space. Then it becomes net user

C#: How to get the value or text value of the select drop-down list

Such as the following code

to obtain the value

The HTML code

    <form id="form1" runat="server">
            	<select id="select1" runat="server">
                	<option value ="video1" runat="server">video 1</option>
                	<option value ="video2" runat="server">video 2</option>
                	<option value="video3" runat="server">video 3</option>
            	<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="start" />
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

C # code

protected void Button1_Click(object sender, EventArgs e)
        	String str = select1.Items[select1.SelectedIndex].Value;//Get the value of the drop-down list
        	Label1.Text = str;	// Display the values in the list through the Lable component

String STR = select1.items [select1.selecteDindex].Value; in the select1 for HTML code to the select components id

get Text

Text>e> v> String STR = sel>.items [select1.selecteDindex].Value; in the Value instead. The Text