Common Linux Commands

Ls Common Commands

Ls -a lists all files in the current directory, including hidden files. Ls -r Deserializes the files in the normal list order. Ls -t Sorts the files by file modification timeCopy the code

CD Common commands

CD /usr/local/src Switch to the specified path (use the absolute path) CD ~ Go to the current user's home directory CD - Go to the last directory CD.. Go to the upper directory CD. Go to the current directoryCopy the code

Rm Common Commands

Rm -r Directory name Deletes all data in the current directory, including the files in the current directory. Rm -f file name Forcibly deletes a file. Rm -rf directory name Forcibly deletes all files in the current directory, including the files in the current directoryCopy the code

Grep Common Commands

The grep command is used to search for the string that meets the requirements in the file.

Grep < command name > < String to be matched > < File path >Copy the code

Common instruction names

-a –after-context displays the content beyond and after the line that conforms to the template style

echo "aaaa\nbbbb\ncccc\ndddd" | grep -A 1 aaaa 
echo "aaaa\nbbbb\ncccc\ndddd" | grep --after-context 1 aaaa
Copy the code

Output: aaaa // The line highlights BBBB


-b — byter-offset Prints the matching line and displays the line before it

echo "aaaa\nbbbb\ncccc\ndddd" | grep -b aaaa
echo "aaaa\nbbbb\ncccc\ndddd" | grep --byte-offset aaaa
Copy the code

Output: 0:aaaa


-c –count Displays the number of lines that match the string

echo "aaaa\nbbbb\ncccc\ndddd" | grep -c aaaa
echo "aaaa\nbbbb\ncccc\ndddd" | grep --count aaaa
Copy the code

The output is as follows: 1


Other commands

Mkdir Create an empty folder. Rmdir Delete an empty folder. Touch Create an empty file Mv Source file Address Destination address Moves the file to a new addressCopy the code

Android Common Commands

The adb command

Gets the current interface element

adb shell dumpsys activity top
Copy the code

Getting a Task list

adb shell dumpsys activity activities
Copy the code

App entrance

adb logcat | grep -i displayed
Copy the code

Start the application

adb shell am start -W -n com.xxx.android/.view.WelcomeActivity -S
Copy the code

Lists the currently connected devices

adb devices -l
Copy the code

Output content:

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

Connect to specified device

adb -s <SERIAL> shell
Copy the code

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

adb -s 7d97e1fa shell
Copy the code

Screen capture

adb shell screencap /sdcard/screen.png
Copy the code

Taking screen shots

adb pull /sdcard/screen.png 
Copy the code

Record video

adb shell screenrecord /sdcard/demo.mp4
Copy the code

Get recorded video

adb pull /sdcard/demo.mp4
Copy the code

Dumpsys command

Testing interface performance

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

adb shell dumpsys gfxinfo package-name
Copy the code

Output performance information about the latest frames

adb shell dumpsys gfxinfo package-name framestats
Copy the code

Check network diagnosis information

The NetStats service provides network usage statistics collected since the last startup of the device

adb shell dumpsys netstats detail
Copy the code

Check battery diagnosis information

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

adb shell dumpsys batterystats options
Copy the code

A list of options

option Introduction to the
–checkin Generate the output of the check-in report
-c Writes the current statistics in checkin format
–proto Writes current summary statistics in PROto format (no history)
–history Only historical data is displayed
–history-start < num > Only historical data starting at a given time offset is displayed
–history-create-events < num >
Create < num > battery history events.
–charged Output only data since the last charge.
–daily Output only complete daily data
–reset Reset statistics to clear all current data
–write Force statistics currently collected to be written to disk
–new-daily Create and write a new daily statistics record immediately.
–read-daily Read loads the last written daily statistics.
–settings Dumps the Settings keys/values associated with Batterystats
–cpu Dumping CPU statistics is used for debugging purposes

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

adb shell dumpsys batterystats --checkin
Copy the code

Output content:

9, 0, I, vers, 35187, QKQ1.191117.002, RKQ1.200826.002 9, 0, I, uid, 1000, com. Beautiful miui. Screenrecorder 9, 0, I, uid, 1000, com. Android. Dynsystem 9, 0, I, uid, 1000, com. Beautiful miui. Powerkeeper 9, 0, I, uid, 1000, com. Beautiful miui. Qr 9, 0, I, uid, 1000, com. Beautiful miui. Contentcatcher 9, 0, I, uid, 1000, com. Xiaomi. Powerchecker 9, 0, I, uid, 1000, com. BSP. Catchlog 9, 0, I, uid, 1000, beautiful miui. Systemui. 9, 0, the plugin I, uid, 1000, com. Xiaomi. Mi_connect_service 9, 0, I, uid, 1000, com.android.net workstack. Inprocess 9, 0, I, uid, 1000, com. Beautiful miui. Securitycenter 9, 0, I, uid, 1000, com. Beautiful miui. Thirdappassistant 9, 0, I, uid, 1000, com. Xiaomi. Aiasst. 9, 0, vision, uid, 1000, com. Beautiful miui. Notification 9, 0, I, uid, 1000, com. Beautiful miui. 9, 0, the daemon, uid, 1000, com. Wapi. Wapicertmanage...Copy the code

More details see website: developer.android.com/studio/comm…