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

What are the common commands of Shell scripts in linux

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly shows you the "what are the common commands in Shell scripts in linux", which are easy to understand and clear, and hope to help you solve your doubts? let me lead you to study and learn what commands are commonly used in Shell scripts in linux.

Common commands for Shell scripts

Ls common commands

Ls-a lists all files in the current directory, including hidden files ls-r normal enumeration order deserialization output ls-t sort by file modification time output ls-S sort by file size output ls-l list file name, file permissions, owner, file size and other information

Cd common commands

Cd / usr/local/src switch to the specified path (using absolute path) cd ~ enter the current user's home directory cd-enter the last directory cd.. Enter the next level directory cd. Enter the current directory

Rm common commands

Rm file name deletion file rm-r directory name deletes all data in the current directory, including current directory file rm-f file name forced deletion file rm-rf directory name forcefully deletes all files in the current directory, including current directory files

Grep common commands

The grep command is used to find strings that match the criteria in the file.

Grep

Common instruction name

A

-- after-context

Displays content outside and after the line that matches the template style

Echo "aaaa\ nbbbb\ ncccc\ ndddd" | grep-A1 aaaa echo "aaaa\ nbbbb\ ncccc\ ndddd" | grep-- after-context 1 aaaa

Output:

Aaaa / / Line highlight

Bbbb

-b

-- byte-offset

Output the matching line and show the number of lines before the line

Echo "aaaa\ nbbbb\ ncccc\ ndddd" | grep-b aaaaecho "aaaa\ nbbbb\ ncccc\ ndddd" | grep-- byte-offset aaaa

Output:

0:aaaa

-c

-- count

Output the number of lines that match the matching string

Echo "aaaa\ nbbbb\ ncccc\ ndddd" | grep-c aaaaecho "aaaa\ nbbbb\ ncccc\ ndddd" | grep-- count aaaa

Output:

one

Other commands

Pwd display current page full path mkdir create empty folder rmdir delete empty folder touch create empty file name view current file content cat-n file name view current file content and list line number cp source file address destination address copy file to new address mv source file address destination address move file to new address

Android common commands

Adb command

Get the current interface element

Adb shell dumpsys activity top

Get task list

Adb shell dumpsys activity activities

App entrance

Adb logcat | grep-I displayed

Start the application

Adb shell am start-W-n com.xxx.android/.view.WelcomeActivity-S

List currently connected devices

Adb devices-l

Output:

List of devices attached 7d97e1fa device usb:336871424X product:umi model:Mi_10 device:umi

Connect the specified device

Adb-s shell

Example: (the value of SERIAL is the output value of adb devices-l)

Adb-s 7d97e1fa shell

Screenshot

Adb shell screencap / sdcard/screen.png

Get a screenshot

Adb pull / sdcard/screen.png

Record video

Adb shell screenrecord / sdcard/demo.mp4

Get recorded video

Adb pull / sdcard/demo.mp4

Dumpsys command

Test interface performance

The output contains performance information about the animation frames that occur during the recording phase. The following command uses gfxinfo to collect interface performance data for the specified package name:

Adb shell dumpsys gfxinfo package-name

Output recent frame performance information

Adb shell dumpsys gfxinfo package-name framestats

Check network diagnostic information

The netstats service provides network usage statistics collected since the device was last started

Adb shell dumpsys netstats detail

Check battery diagnostic information

The batterystats service generates statistics about the battery usage of the device

Adb shell dumpsys batterystats options

Options list

Introduction to option-checkin generates the output of check-in report-c writes current statistics in check-in format-proto writes current summary statistics in proto format (no history)-history displays only historical data-history-start

< num >

Displays only historical data starting from a given time offset-history-create-events

< num >

Create

< num >

A battery history event. -- charged only outputs data since the last charge. -- daily only outputs complete daily data-- reset reset statistics, clears all current data-- write forces currently collected statistics to be written to disk-- new-daily immediately creates and writes new daily statistics records. -- read-daily reads the daily statistics of the last write loaded. -- settings dumps setting keys / values related to Batterystats-- cpu dumps cpu statistics for debugging purposes

Use the following command to generate batterystats output in a computer-readable CSV format:

Adb shell dumpsys batterystats-checkin

Output:

9,0,i,vers,35,187,QKQ1.191117.002,RKQ1.200826.0029,0,i,uid,1000,com.miui.screenrecorder9,0,i,uid,1000,com.android.dynsystem9,0,i,uid,1000,com.miui.powerkeeper9,0,i,uid,1000,com.miui.qr9,0,i,uid,1000,com.miui.contentcatcher9,0,i,uid,1000,com.xiaomi.powerchecker9,0,i,uid,1000,com.bsp.catchlog9,0,i,uid,1000,miui.systemui.plugin9,0,i,uid,1000,com.xiaomi.mi_connect_service9,0 I,uid,1000,com.android.networkstack.inprocess9,0,i,uid,1000,com.miui.securitycenter9,0,i,uid,1000,com.miui.thirdappassistant9,0,i,uid,1000,com.xiaomi.aiasst.vision9,0,i,uid,1000,com.miui.notification9,0,i,uid,1000,com.miui.daemon9,0,i,uid,1000,com.wapi.wapicertmanage... These are all the contents of the article "what are the common commands for Shell scripts in linux?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Servers

Wechat

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

12
Report