Linux command to get the necessary software testing practitioners (full article)

Go straight

/

Command cd

  1. How to enter the parent directory
    cd ..

  2. How to enter the current user's home directory
    cd ~

  3. How to enter the two directory
    cd ../ ..

  4. Into the current directory command
    cd.

  5. How to enter the directory / usr / isTester
    cd / usr / isTester

/

Mv command

  1. Moving a folder (isTester folder, move to / APP / www directory)
    Music Videos ~ / isTester / / APP / www

  2. Moving a document (isTester.ini moved to / APP / www directory)
    Music Videos isTester.ini / APP / www

  3. Istester.tar.gz move the current directory to / usr / ido directory and rename it to istester1228.tar.gz
    mv isTester.tar.gz /usr/ido/istester1228.tar.gz

  4. Move the file to the parent directory
    mv isTester.tar.gz ../

  5. A command to move the two files isTester.tar idoxu.tar to the directory / APP / the WWW
    mv isTester.tar idoxu.tar -t / APP / the WWW

/

Cp command

  1. Copy the current directory to a backup directory deployment package isTester.tar.gz / APP / www / bak directory
    cp isTester.tar.gz / APP / www / bak

  2. Copy the folder isTester to deploy directory / APP / the WWW
    cp -r isTester / / APP / the WWW

/

Mkdir command

In the directory / APP / the WWW,
cd / APP / the WWW

  1. Create a new folder isTester
    mkdir isTester

  2. Create three folders isTester2 isTester3 isTester1
    mkdir isTester1 isTester2 isTester3

  3. Create a multi-level folder idoxu / 20.18123 million / 01
    mkdir -p idoxu / 20.18123 million / 01

/

Command history

  1. View command history record
    history

  2. Mkdir command to view the execution history
    history | grep mkdir

  3. Execution history, the number of 178 orders
    ! 178

/

Command tail

  1. Real-time refresh log
    tail -f isTester.log

  2. The latest real-time refresh 500 log
    tail -500f isTester.log

/

Tar command

  1. Compress a file isTester.ini
    tar -cvf isTester.tar isTester.ini

  2. Readme.ini compress multiple files isTester.ini
    tar -cvf all.tar isTester.ini readme.ini

  3. Compressed Folders isTester /
    tar -cvf isTester.tar isTester /

  4. The package in the current directory, all jpg files into isTesterjpg.tar
    tar -cvf isTesterjpg.tar * .jpg

  5. The package in the current directory, all jpg files into isTesterjpg.tar.gz
    tar -zcvf isTesterjpg.tar.gz * .jpg

  6. Decompression isTesterjpg.tar
    tar -xvf isTesterjpg.tar

  7. IsTesterjpgtargz jie_ya
    tar zxvf isTesterjpgtargz

/

Ls command

  1. Lists all subdirectories and files in the current directory.
    ls

  2. All files listed in the directory (including hidden pieces **)
    LS -a

  3. Details are listed in the file (including permissions, owner, file size, etc.)
    LS the -l

  4. Set out in detail the contents of the current directory of all to "isTester" the beginning of the
    ls -l isTester *

/

Ps command

  1. View all processes
    ps -A

  2. View java process
    ps -ef | grep java

  3. Show all process information, along with the command line
    ps -ef

/

Command top

  1. Display process information
    top

  2. Monitoring the status of each logical CPU
    top, press 1

  3. Highlight the current running process
    top, press b

  4. Show full command
    top, press c

  5. Exit top program
    by q

/

Wget command

Linux system is a tool wget to download a file for Linux users is an essential tool

File address
http://51.istester.com/isTester.png

  1. IsTester.jpg download file
    wget  http://51.istester.com/isTester.png

  2. IsTester.jpg download files, and store named isTester_Logo.jpg
    wget -o isTester_Logo.jpg
    http://51.istester.com/isTester.png

  3. Download isTester.jpg file download form the background
    wget -b  http://51.istester.com/isTester.png

/

Command find

The find command is very powerful, but also very practical, completed in two, the first time today.
Give you assignments, several scenes are more practical.

  1. In / root / isTester directory and its subdirectories to find a file named isTester.ini
    find / root / isTester / -name isTester.ini

  2. Find any file with the extension "ini" in the current directory and its subdirectories
    find. -Name "* .ini"

  3. Looking for changes in the time / root / isTester directory file within 5 days
    find / root / isTester / -mtime -5

  4. Looking for changes in the time / root / isTester directory files in the previous 3 days of
    find / root / isTester / -mtime +3

  5. Find all directories under the / root / isTester directory
    find. -Type d

  6. Find all files in / root / isTester directory
    find / root / isTester / -type f

/

Command continues to find (Advanced)

The find command is very powerful, but also very practical, completed in two, the first time today.
Give you assignments, several scenes are more practical.

  1. In the current directory, all files in the common search for the word istester
    find ./ -type f | xargs grep " istester"

  2. In the current directory, delete everything within one day
    find ./ -mtime -1 -print | xargs rm -rf

  3. In the current directory, delete everything in the previous 10 days (when practical operation, need to be cautious, make sure to build in their own directory, do not delete the system directory ...)
    the Find ./ -mtime +10 -print | xargs RM -rf

  4. Delete files with zero size files
    find ./ -size 0 | xargs rm -rf

/

Rm command

rm is commonly used commands, functions of the command to delete the directory / file (can be deleted at the same time, multiple files / directories)
Of course, this is a very dangerous command, it is recommended to use less misuse (such as recurrent rm * -rf command with caution)

  1. Delete / root / files in isTester / directory isTester.ini (you will be asked whether to delete)
    RM /root/isTester/isTester.ini

  2. Forcibly removed under / root / isTester / directory file isTester.ini (direct deleted, the system will not prompt)
    RM -f /root/isTester/isTester.ini

  3. Delete all .log files in the / root / isTester / directory
    rm -f /root/isTester/*.log

  4. Ido / delete files in the / root / isTester / folders directory
    rm -r / root / isTester / ido /

  5. Ido / files in to forcibly remove / root / isTester / folders directory
    rm -rf / root / isTester / ido /

  6. Delete all the contents of / root / isTester / directory
    rm -rf / root / isTester / *

/

File Operations Command Series

  1. Create a file, you have to know which of command? (Write at least two ways)

    . 1) Touch isTester.ini

    2) VI isTester.md
    . 3) echo 'only Test'> isTester.com
    . 4) CP isTester.ini isTester666.ini
    . 5) LS> filelist.txt

  2. At the same time create a file idoxu.ini isTester6.ini
    Touch isTester6.ini idoxu.ini

  3. While creating 2000 files isTester0001.ini - isTester2000.ini
    Touch istester {0001..2000} .ini

  4. Change the file isTester.ini time to the current time
    touch isTester.ini

/

View Files series of commands

/ **

command prompt
#cat by the first line displays the file content
#tac beginning to show from the last row, you can see the tac is cat written backwards!
#more page by page display file contents
#less and more similar, but better than more, he can move forward flip!
#head look at the first few lines
#tail look at the tail lines
#nl show when stopped by the output line number!
** /

  1. IsTester.ini view the file contents
    cat isTester.ini

  2. Look file isTester.ini first 20 rows of content
    head -n 20 isTester.ini

  3. IsTester.ini see the file contents last 30 lines
    tail -n 30 isTester.ini

  4. Content of 10 to 20 lines display the file isTester.ini the
    head -n 20 isTester.ini | tail -n 10

  5. IsTester.ini reverse displays the file contents of the first 10 rows of the
    tac isTester.ini | head -n 10

  6. IsTester.ini display file contents of the first 10 rows, and displays the line number
    nl isTester.ini | head -n 10

/

Yum & scp command

Suppose the current server ip 192.168.1.23

  1. 192.168.1.23 192.168.1.22 copy files from a Linux server to server isTester.ini
    scp [email protected]: /root/idoxu/isTester.ini / root / idoxu

  2. Linux servers from 192.168.1.22 copy directory isTester / server to 192.168.1.23
    scp -r [email protected]: / root / idoxu / isTester / / root / idoxu

  3. Linux installation scp command (assuming a centos server command yum)
    yum the install-OpenSSH Clients

/

command

clear
df
du
ifconfig

  1. View the current server ip
    ifconfig

  2. View the current server hard disk space
    df -h

  3. View directory isTester / space occupied
    du -sh isTester

  4. Clear the current terminal screen
    clear

/

Vi + chmod command

/ **
vi + create a file to edit the file.
chmod command is used to change the access linux file system or directory.
** /

  1. Create a file isTester.ini
    vi isTester.ini

  2. Contents of the file to "Learn Linux Day 21, the I'm Idolaoxu, in shenzhen.
    "
    Input i, enter edit mode, typing, esc command mode: wq save.

  3. Anyone can file isTester.ini to read
    chmod + r isTester.ini

  4. The isTester.ini set only the file owner can execute
    chmod u + x isTester.ini

  5. Set all permissions to the file isTester.ini
    chmod 777 isTester.ini (or chmod a = rwx isTester.ini)

Note: chmod command usage, there are many, as are several, to meet the daily needs.

/

End, command, these almost enough.

If you encounter some non-high-frequency command, self-Baidu / Google can get.

Guess you like

Origin www.cnblogs.com/codecca/p/11944133.html