This article is output by FunTester learning community partners, there will be a variety of learning notes to share, welcome to pay attention to support.

The file system

  • / bin, / usr/bin, / usr/local/bin)
    • This directory holds frequently used commands
  • (/ usr/sbin/sbin, / usr/local/sbin)
    • A hypervisor used by a system administrator
  • /home
    • Home directory for common users. One subdirectory for each user
  • /root
    • This directory is the home directory for system administrators, also known as superprivileges
  • /lib
    • System boot required dynamic connection shared library, similar to Windows DLL files
  • /lost+found
    • This directory is usually empty. When the system is shut down illegally, some files are stored in this directory
  • /etc
    • All configuration files and subdirectories required for system administration
  • /usr
    • This is a very important directory, with many applications and files in it
    • Similar to program File directory under Windows
  • /boot
    • This is where the core files for starting Linux are stored, including some connections and image files
  • /proc
    • This directory is a virtual directory that is a map of system memory and can be accessed directly to obtain system information
  • /srv
    • Short for service, this directory holds data that needs to be extracted after the service is started
  • /sys
    • 2.6 Kernel new file system SYSfs
  • /tmp
    • Storing temporary files
  • /dev
    • Like Windows device Manager, all hardware is stored as files
  • /media (centos6)
    • Linux will mount the identified devices to this directory
  • /run
    • Temporary files generated by the process
  • /mnt
    • The user temporarily mounts another file system, such as a USB flash drive
  • /opt
    • Host installation additional software directory
  • /usr/local
    • A program installed by compiling source code
  • /var
    • Logs and things that change frequently

Linux workaround

MobaTextEditor garbled characters resolved

  • /bin/bash^M: Bad interpreter: No such file or directory

The root causes are as follows

On Windows, the end of each line is \n\r. On Linux, the end of the file is \n, so that when Windows writes and edits shell scripts to Linux, there is an extra character \r at the end of each line, which is displayed as ^M. Using MobaTextEditor to read files from Windows to Linux will cause garbled charactersCopy the code

The solution

  1. Sed -i ‘s/\r$//’ filename #flename indicates the name of the shell script
  2. Run the dos2unix xxx.sh command

Vim command

Vim has three modes

  1. Command line mode (cursor location)
    1. HJKL // up and down left and right
    2. 0 $// start line end line
    3. Gg G // Bottom of page
    4. 3G // Go to the third line
    5. U // Undo restore
    6. Yy // Copy a whole line
    7. Dd // Delete an entire line
    8. // Paste and cut
  2. Text input mode
  3. Last-line mode (also called exit mode)

Working mode setting

  1. :set // Specifies information
  2. :set nu // Add the number of rows
  3. :set noun //
  4. :set cursorline // Add underline

Character replacement and lookup

  1. Characters locate
    • / Keyword Parameter n/ n Matches the keyword up/down
  2. Characters to replace
:s/aa/bb # Replace the first AA on the cursor line with bb: S/AA /bb/g # Replace all aa on the cursor line with BB :% S /aa/bb/g # Replace aa with BB :3,10s/aa/bb/g # Replace lines 3 through 10 / aa for bb: % s \ \ \ / / g # \ replaced by/in full (special characters: ^, $, *, /, / and. All need to be escaped, preceded by \) :%s,\\,/,g # or separated by comma (/ can not escape) :%s,aa,bb,gic # Full aa (regardless of case) replaced with bb, each substitution prompt whether to replaceCopy the code

Edit multiple files at the same time

:sp filename

  1. CTRL + W to enter the file window above
  2. CTRL + W press the cursor to enter the file window below

Attached is the shell script used

#! /bin/bash
## 
## Construct trivial file and calculate MD5 value
## author: brh
## date: 2020-10-09
##

case $1 in
"-h")
	echo "1: ./xxx.sh touch_file num"
	echo "2: ./xxx.sh touch_md5_file num"
	echo "3: ./xxx.sh check_md5_file num"

;;

"touch_file")
	#Generate trivial filesfor((i=1; i<=$2; i++)); do echo $i > $i.txt done ;; "touch_md5_file")	## Calculate trivial file MD5 and savefor((i=1; i<=$2; i++)); do md5sum $i.txt > $i.txt.md5 done ;; "check_md5_file")	## check whether trivial file MD5 is consistentfor((i=1; i<=$2; i++)); do md5num1=`md5sum $i.txt` md5num2=`cat $i.txt.md5` if [ "$md5num1"x = "$md5num2"x ]; Then echo "$i.testt MD5 "else echo "$i.testt MD5" fi done; esacCopy the code

FunTester.Tencent Cloud Author of the Year,Boss direct hire contract author.Official GDevOps media partner, non-famous test development.

  • FunTester test framework architecture diagram
  • FunTester test project architecture diagram
  • Selenium4 IDE features: Elastic testing, looping, and logical judgment
  • Groovy uses topics in JMeter
  • Thread-safe classes are used in performance testing
  • Manual testing or automated testing?
  • Summary of Automatic Test failures on the Web
  • Socket interface asynchronous authentication practice
  • Use ThreadLocal to solve thread synchronization problems
  • Replay browser multiple request performance testing practices