Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux commands commonly used in the work of software test engineers

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Linux system has many advantages, such as open source, free non-commercial version, multi-task and multi-user operation, so Linux system occupies an overwhelming market share in the non-desktop category. For Internet technical workers, controlling common Linux commands is also a compulsory course. The following is a list of some Linux commands commonly used by the author in his work.

Cd changes directories

Cd.. Return to the previous directory

Cd. Enter the current directory

Cd-returns the previous directory, that is, the previous directory is not the previous directory

Ls view files and directories

Usage: ls [parameters] [file]

Parameters:

Ls-l displays the permissions and properties of the file

Ls-a lists all files, including hidden files (. File at the beginning)

Ls-h lists the file capacity in a more readable way (GB,kB, etc.)

Ls-al-l and-an attribute combination

Ls command

Stat displays file details

Display file permissions, attributes, size, modification time, access time, etc. in more detail than ls-l

Usage: stat file name

Stat command

How to view the permissions of a file can be achieved by two commands: stat and ls-l

Grep text search / filtering

Usage: grep [parameter] search string is usually used with the pipe command to search for a character in a file

Parameters:

-I is not case sensitive

-v reverse search, showing lines that are not search strings

-c count the number of occurrences

-n output line number by the way

Filter the text with 123under the 1234 folder

Grep is used with pipe commands

Find lookup file

Usage: find [PATH] [option] [- print]

Parameters:

-name filename # find a file named filename

-perm # search by execute permission

-user username # search by file owner

-group groupname # find by group

-mtime-n + n # find files according to the time when the files are changed.-n refers to within n days, + n refers to n days ago.

-ctime-n + n # find the file by the time it was created.-n refers to within n days, and + n refers to n days ago.

-size +-n [c] # look for files with a length of n blocks [or n bytes] (+-greater than less)

Example 1. Find all .log files in the tmp directory and output

Find all the .log files in the tmp directory

Example 2. Find a file with "root" in the proc directory with permission of 777 and output

Find files with 777 permissions with "root"

Example 3. Find the file created by the user for root in the tmp directory and export it

Find the file created by the user for root

Example 4. Find files in the tmp directory that have been updated within 1 day

Find files that have been updated within 1 day

Example 5. Look for files with a file size less than 72 bytes in the tmp directory

Find files with a file size less than 72 bytes

The difference between the grep and find commands: grep searches for text, find searches for files, in other words, grep is a line to find matching criteria, and find is a file to search for matching criteria.

PS process View command

Use this command to determine which processes are running and their running status, whether the process ends, whether the process has zombies, and which processes take up too much resources. Ps shows the status of instantaneous processes and is not dynamically continuous. If you want to monitor processes in real time, you should use the top command.

-A shows all the processes

-an all processes not related to terminal

-x is generally used with parameter a to list more complete information

-f make a more complete output

Ps-T-p-T start thread view

Top to view the CPU/ memory usage of each process

A commonly used performance analysis tool under Linux, which can display the resource consumption of each process in the system in real time (cpu/ memory)

Usage: top [parameters]

Parameters:

-d shows the interval between two refreshes, such as-d 5, which means that the interval between two refreshes is 5 seconds.

-I disable the display of idle or zombie processes

-n NUM displays the number of updates and then exits. For example,-n 5 means that top updates the data five times and then exits.

-p PID only monitors that the ID;PID of the specified process is a numeric value

-H-p to view the running status of threads in a process

Top command

The similarities and differences between the top and ps commands:

Similarities: both top and ps can view process information

Difference: ps sees process information at the moment of command execution, while top commands can continuously monitor processes; ps only looks at processes, while top can also monitor system performance, such as cpu/ memory / load, etc.

Kill, kill all deletion process

Kill [signal code] PID signal code can be omitted. The commonly used signal code is-9, which indicates forced termination.

Kill all process name kills all processes directly through the name of the program

Force termination of a process with a PID of 28233

Kill a process named GameServer

The difference between kill and killall: kill is followed by PID,killall, followed by process name

An additional point of knowledge: the init process

Init is one of the indispensable programs in the operation of Linux system. The so-called init process is a user-level process started by the kernel. Init is always the first process (its process number is always 1), while all other processes are descendants of the init process. The init process cannot be killed, nor can it be killed!

Pwd displays the current directory

Displays the current command, which is very simple

Help\ man help command

With these two commands, you can see how to use any Linux commands you don't know how to use.

Usage:

Command-- help

Man command

Help output of ls

The parameters described in this paper are commonly used and are not complete. This series is only suitable for beginners. Please neglect or help to put forward some suggestions.

Original link: http://www.magedu.com/71909.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report