Tag Archives: linux

Opensuse12.3 enable / disable touchpad

Use the command:

xinputlist 

View devices

Find the ID of the touchpad. For example, my id = 15

Then use the command:

xinput set-prop 15 “Device Enabled”0

The last “0” is to close the touchpad, and “1” is to open the touchpad

OpenSUSE test is available. I always use the external keyboard, but I can’t use the touch pad. Anyway, I don’t need it. It’s better to turn it off. Maybe I can save some power?Ha ha
ha

Solve the problem of USB mouse failure in the laptop mode of Ubuntu

A while ago, in order to solve the problem of not saving the brightness of the boot, the laptop mode management system was installed

But recently, I happened to find that the mouse can’t be used after the power is off. Because I have no time and seldom use the notebook in battery mode, I never care about it.

If you are free today, try the online method. Solve this problem. The method is as follows

First, input lsusb in the terminal, and the display is as follows:

$lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 003: ID 058f:a014 Alcor Micro Corp. 
Bus 001 Device 004: ID 0bda:0139 Realtek Semiconductor Corp. 
Bus 002 Device 003: ID 093a:2521 Pixart Imaging, Inc. 
Bus 002 Device 004: ID 1a2c:0002 

If you find multiple devices. But I don’t know which is the USB mouse. Don’t worry. I don’t know. Then look down.

Enter the following command:
0

lsusb -xv

It shows a lot of detailed information. What can we do.

Can’t you read it?

Of course not. We export the result with the following command.

lsusb -xv > ~/mouse.txt

And then do it

gedit ~/mouse.txt

We went to the “mouse” editor, and we went up there. Just look for the ID of the mouse.

Bus 002 device 003: ID 093A: 2521 pixart imaging, Inc.
this is what I found. Remember 093A: 2521

Then open the configuration with the following command.

sudo gedit /etc/laptop-mode/conf.d/usb-autosuspend.conf

Search again for “autosuspend”_ USBID_ BLACKLIST=”

I found it. Under my picture

In the double quotation marks at the end of the second line of yellow, fill in the ID of the mouse. That’s 093a:2521

. Is the mouse still working normally after saving and unplugging?

PS: my current computer is ubuntu12.04

reference resources: http://forum.ubuntu.org.cn/viewtopic.php?t=391117

Change the path in the user directory in Chinese Ubuntu to English

In order to make it easy for users to use, it is installed in the “home”, “music”, “pictures” and “natural” It’s all in Chinese.

Most of the time, I like to put some files to be operated on the desktop. There are many command-line operations in Linux, so it’s hard to avoid using the command line to operate things on the desktop. Then I need to “CD desktop”. When I hit “desktop”, I need to switch the input method. It’s troublesome So I tried to find a way to change the path under the user directory to English, while the other Chinese remained unchanged. The method is as follows:

Open the terminal and enter the command in the terminal

        export LANG=en_US

        xdg-user-dirs-gtk-update

Jump out of the dialog box and ask if you want to convert the directory to an English path, agree and close it.
enter the command in the terminal:

        export LANG=zh_CN

Close the terminal and restart. Next time you enter the system, the system will prompt you whether to change the converted directory back to Chinese. Select no more prompt and cancel the modification. The Chinese to English conversion of the main directory is completed~

Reprinted from: http://my.oschina.net/myriads/blog/2867

The Ubuntu status bar shows the network speed, memory and CPU utilization ratio

Install indicator sysmonitor

1. Add source

sudo add-apt-repository ppa:fossfreedom/indicator-sysmonitor

2. Update source

sudo apt update

3. Installation

sudo apt install indicator-sysmonitor

Start monitor-4

nohup indicator-sysmonitor &

Note: when starting with nohup, the indicator sysmonitor will not exit when closing the terminal.

Nginx reverse proxy MySQL

1. Scene

Mysql database in the pure Intranet environment, no public IP, no VPN.

2. Programme

Install nginx on a server with public IP and in the same Intranet environment with MySQL service to realize the routing and forwarding of MySQL access.

3. Nginx installation

Nginx version needs 1.9 or above. Nginx not only implements HTTP reverse proxy, but also supports TCP reverse proxy.

1) When compiling nginx, you need to add the parameter — with stream to load NGX_ stream_ core_ Module

Examples

./configure –prefix=/opt/software/nginx –with-http_ stub_ status_ module –with-http_ ssl_ module –with-stream –with-stream_ ssl_ module –with-pcre=/usr/local/src/pcre-8.35

4. Nginx configuration file nginx.conf

Monitor port 3307 with public IP server, and jump to port 3306 of 172.31.88.27.

Special note: stream should be in the same level directory as HTTP

stream {
    upstream mysql3306 {
        hash $remote_addr consistent;
        server 172.31.88.27:3306 weight=5 max_fails=3 fail_timeout=30s;
    }
	
	 server {
        listen 3307;
        proxy_connect_timeout 10s;
        proxy_timeout 200s;
        proxy_pass mysql3306;
    }
}

 

Log separation using tool cronlog

Foreword: Tomcat log is cut by date

Using cronolog to segment the image of tomcat9 catalina.out Log; Tomcat’s catalina.out The log file cannot be divided by date. All the log files are output and written to a single file catalina.out In this way, the. Out log will become larger and larger, and the cost of operation and maintenance will increase. To archive log files by date, cronolog can be used to realize log segmentation.

1. Step 1: cronlog installation

Use the yum command to install cronlog

yum install cronolog

2. Step 2: modify catalina.sh Documents

Directory: Tomcat/bin/ catalina.sh

Original setting:

After modification:

shift
 # touch "$CATALINA_OUT"
  if [ "$1" = "-security" ] ; then
    if [ $have_tty -eq 1 ]; then
      echo "Using Security Manager"
    fi
    shift
    eval $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
      -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
      -classpath "\"$CLASSPATH\"" \
      -Djava.security.manager \
      -Djava.security.policy=="\"$CATALINA_BASE/conf/catalina.policy\"" \
      -Dcatalina.base="\"$CATALINA_BASE\"" \
      -Dcatalina.home="\"$CATALINA_HOME\"" \
      -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
      org.apache.catalina.startup.Bootstrap "$@" start \
      2&>&1 | /usr/local/sbin/cronolog "$CATALINA_BASE/logs/catalina-%Y-%m-%d.out" &

  else
    eval $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
      -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
      -classpath "\"$CLASSPATH\"" \
      -Dcatalina.base="\"$CATALINA_BASE\"" \
      -Dcatalina.home="\"$CATALINA_HOME\"" \
      -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
      org.apache.catalina.startup.Bootstrap "$@" start \
      2&>&1 | /usr/local/sbin/cronolog "$CATALINA_BASE/logs/catalina-%Y-%m-%d.out" &

  fi

3. Step 3: restart Tomcat

Restart Tomcat and the log will take effect according to the date. A screenshot of the log file is shown below.

 

 

Kill Tomcat process in windows and Linux environment (solve the problem of other ports being occupied)

Killing process in Windows

1. First of all, find out the PID of the process number that occupies port 8080 ( tomcat, the default is port 8080. If you modify the monitoring port of tomcat, please write in your Tomcat port number or other port numbers ) what I query is port 7777

​netstat -ano | findstr 8080

The last column of the command output indicates the number of the process occupying port 7777, assuming 10976

2. Kill the process, thus freeing the port

taskkill /f /pid 10976 

 

 

Closing Tomcat process under Linux operating system

1. See if Tomcat is already running

ps -ef |grep tomcat 

If Tomcat is running, the result will be similar to the following:

sun 5144 1 0 10:21 pts/1 00:00:06 /java/jdk/bin/java -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

-Djava.endorsed.dirs=/java/tomcat/common/endorsed -classpath :/java/tomcat/bin/bootstrap.jar:/java/tomcat/bin/commons-logging-api.jar

-Dcatalina.base=/java/tomcat -Dcatalina.home=/java/tomcat -Djava.io.tmpdir=/java/tomcat/temp org.apache.catalina.startup.Bootstrap start

From the above output information, we can know that the process number of Tomcat execution is 5144.

2. Execute the following command to kill the 5144 process

pid = 5144 kill -9 5144 

3. Get the occupancy of a certain port (for example, get the occupancy of port 5533 below)

sudo lsof -i :5533

The result is as follows: you can see that the process number is 2960, we just need to kill it.

COMMAND  PID        USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
java    2960 zhengcanrui   55u  IPv6 0xb866409b03202701      0t0  TCP *:5533 (LISTEN)

Kill process command:

kill -9 2960

Java Running Error: Could not find or load main class

[problem description]

User root is created in the/root/exercise folder HelloWorld.java The code is as follows:

Compile and run the file as follows:

Compile HelloWorld.java Generate bytecode file HelloWorld.class , running HelloWorld.class Error: could not find or load main class.

 

[cause analysis]

The current directory is the directory where the. Class file is located. To run the. Class bytecode file, you need to add the current directory to the system variable classpath to find the Java class in the current directory.

 

[solution]

Step 1: add the classpath system variable at the end of the profile file in/etc.:,. To represent the current path.

The classpath in the original/etc/profile file is:

CLASSPATH=$JAVA_ HOME/jre/lib/ext:$JAVA_ HOME/lib/ dt.jar :$JAVA_ HOME/lib/ tools.jar .

The added classpath is: classpath =.: $Java_ HOME/jre/lib/ext:$JAVA_ HOME/lib/ dt.jar :$JAVA_ HOME/lib/ tools.jar

Step 2: input source/etc/profile on the command line to make the system variables in/etc/profile effective and then run.

Note: you can modify system variables only if the current user is root. If you enter source/etc/profile on the command line, the system variable will only take effect temporarily. If you close terminal, the system variable will be restored to its original state. Because the system variable is loaded at system startup, the system variable will be loaded automatically only at the next system restart, so you don’t need to enter source/etc/profile again.

The results are as follows

Unknown error: cannot find chrome binary when running selenium under Linux

For Linux system, running Selnium script will report the following error

Traceback (most recent call last):
  File "./obp_pb_get_csv.py", line 73, in <module>
    browser = webdriver.Chrome('/usr/bin/chromium') # Get local session of chrome
  File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 46, in __init__
    self.service.start()
  File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/service.py", line 64, in start
    raise WebDriverException("Can not connect to the ChromeDriver")
selenium.common.exceptions.WebDriverException: Message: 'Can not connect to the ChromeDriver'

Solution:

1. Confirm whether Chrome browser is installed, command: Chrome browser - version 0

2. If not, use the following command to install: sudo apt get install chromium browser

3. Get chromedriver and visit the following link http://chromedriver.storage.googleapis.com/index.html

4. Decompress Chromdriver.zip

5. Move the file to the path/usr/bin, command: sudo MV chromedriver/usr/bin

6. Switch to/usr/bin directory, command: CD/usr/bin

7. Make it executable, command: sudo Chmod a + X chromedriver

8. Perform the following code tests:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get("http://www.google.com")
print driver.page_source.encode('utf-8')
driver.quit()
display.stop()

 

The solution of transaction check error when installing Gnome with Yum command

Question:

Installing and downloading graphical interface Gnome

Yum groupinstall “desktop”
Yum groupinstall “X window system”
Yum groupinstall “Chinese support” (optional)

The screenshot of the later error is as follows:

resolvent:

Use the command: Yum remove networkmanager-1: 0.8.1-43.el6.x86_ 64 first delete the conflicting package shown in the red box in the above screenshot.

Shell script execution error: “syntax error near unexpected token”

Shell script execution error: “syntax error near unexpected token”

Step 1: execute VI – B test.sh Step 2: replace: Shift +: Colon & gt; enter: S/^ m// g

Today, I wrote a shell script (which was written on windows and moved to Linux). When it was executed, I always reported the following error:

at first, I thought it was a script syntax problem, and I couldn’t execute it. Then I changed it to the simplest one. Later, I searched the Internet for it. It was not a script syntax problem, but a coding problem. There are two steps to solve the problem

Step 1: execute VI – B test.sh

test.sh Is the script to execute

Step 2: replace: Shift +: Colon & gt; enter: S/^ m// g

In the last line mode:
Input: % s/^ m// g
^ m is not "^" plus "m", but generated by "Ctrl + V" and "Ctrl + m".

The original reference is as follows:
transferred from: https://blog.csdn.net/xyp84/article/details/4435899

long long ago… Old teletypewriters used two characters to start a new line. One character moves the carriage back to the first position (called carriage return, ASCII code 0d), and the other character moves one line on the paper (called line feed, ASCII code 0A). When computers came out, memory used to be very expensive. Some people don't think it's necessary to use two characters at the end of a line. UNIX developers decided that they could use a single character to indicate the end of a line. Linux follows UNIX, too. Apple developers have defined the use of. The guys who developed MS-DOS and windows decided to use the old-fashioned.
Because MS-DOS and windows use carriage return + line feed to indicate line feed, you can use VIM under Linux to view the code written in VC under windows, and the "^ m" symbol at the end of the line.

To solve this problem in VIM is very simple. You can kill all "^ m" by using the replacement function in vim. Type the following replacement command line:

1)vi -b setup.sh

2) On the command line & lt; press ESC, and then shift +: Colon & gt; enter% s/^ m// g

Note: the ^ m character in the above command line is not "^" plus "m", but generated by "Ctrl + V" and "Ctrl + m" keys.

After this replacement, the save can be executed. Of course, there are other alternatives, such as:

a. Some Linux versions have dos2unix programs that can be used to remove ^ M.

b. Cat filename1 | tr - D "/ R" & gt; newfile removes ^ m to generate a new file, as well as sed command. All replaceable commands can be used to generate a new file.

As mentioned above, deleting the ^ mshell script will run normally. Later, I asked my colleague that he had modified the program path in his Windows Notepad, resulting in an extra ^ m in each line.