adb命令是adb这个程序自己的命令。adb shell是Android系统自带的命令,都保存在Android系统的/system/bin目录下,命令文件本质是shell脚本。

ADB命令

adb devices:获取当前所有已连接设备的list。
adb get-state:获取设备的状态。
设备的状态有三种:device、offline、unknow。

状态 意义
device 设备已连接
offline 设备脱机
unknow 设备状态不可知

adb kill-server:停止adb服务。
adb start-server:开启adb服务。
这两个状态通常配对使用。
adb logcat:输出Android系统日志。
adb bugrepot:打印dumpsys、dumpstate、logcat的输出,用于错误分析。
adb install:用于app安装,-r参数覆盖安装。
adb uninstall:用于app卸载。
adb pull:用于将Android系统中的文件或文件夹复制到本地。
adb push:用于将本地文件或文件夹复制到Android系统指定文件目录下。
这两个命令如果处理的是系统文件或文件夹需要先获取到root权限然后remount系统文件获取读写权限。
adb root、adb remount:用于获取root权限再重新挂载系统文件获取读写权限。
adb reboot:重启android系统。
adb forward:用于将宿主机上的某个端口重定向到Android机上的某个端口。例如:adb forward tcp:123 tcp:8888 这条命令就会把发往主机123端口的数据转发到Android机的8888端口,一般用于远程控制等。
adb connect:用于无线adb连接,要求宿主机和Android机在同一个局域网络下。例如:adb connect 192.168.1.100,这个ip地址就是手机在局域网中的ip。缺点是延迟大。
adb shell:可以执行Android系统命令。
下面介绍的都是adb shell命令。

pm

255|yfve_8q:/ # pm
Package manager (package) commands:helpPrint this help text.path [--user USER_ID] PACKAGEPrint the path to the .apk of the given PACKAGE.dump PACKAGEPrint various system state associated with the given PACKAGE.list featuresPrints all features of the system.has-feature FEATURE_NAME [version]Prints true and returns exit status 0 when system has a FEATURE_NAME,otherwise prints false and returns exit status 1list instrumentation [-f] [TARGET-PACKAGE]Prints all test packages; optionally only those targeting TARGET-PACKAGEOptions:-f: dump the name of the .apk file containing the test packagelist librariesPrints all system libraries.list packages [-f] [-d] [-e] [-s] [-3] [-i] [-l] [-u] [-U] [--uid UID] [--user USER_ID] [FILTER]Prints all packages; optionally only those whose name containsthe text in FILTER.  Options are:-f: see their associated file-d: filter to only show disabled packages-e: filter to only show enabled packages-s: filter to only show system packages-3: filter to only show third party packages-i: see the installer for the packages-l: ignored (used for compatibility with older releases)-U: also show the package UID-u: also include uninstalled packages--uid UID: filter to only show packages with the given UID--user USER_ID: only list packages belonging to the given userlist permission-groupsPrints all known permission groups.list permissions [-g] [-f] [-d] [-u] [GROUP]Prints all known permissions; optionally only those in GROUP.  Options are:-g: organize by group-f: print all information-s: short summary-d: only list dangerous permissions-u: list only the permissions users will seeresolve-activity [--brief] [--components] [--user USER_ID] INTENTPrints the activity that resolves to the given INTENT.query-activities [--brief] [--components] [--user USER_ID] INTENTPrints all activities that can handle the given INTENT.query-services [--brief] [--components] [--user USER_ID] INTENTPrints all services that can handle the given INTENT.query-receivers [--brief] [--components] [--user USER_ID] INTENTPrints all broadcast receivers that can handle the given INTENT.install [-lrtsfdg] [-i PACKAGE] [--user USER_ID|all|current][-p INHERIT_PACKAGE] [--install-location 0/1/2][--originating-uri URI] [---referrer URI][--abi ABI_NAME] [--force-sdk][--preload] [--instantapp] [--full] [--dont-kill][--force-uuid internal|UUID] [--pkg PACKAGE] [-S BYTES] [PATH|-]Install an application.  Must provide the apk data to install, either as afile path or '-' to read from stdin.  Options are:-l: forward lock application-R: disallow replacement of existing application-t: allow test packages-i: specify package name of installer owning the app-s: install application on sdcard-f: install application on internal flash-d: allow version code downgrade (debuggable packages only)-p: partial application install (new split on top of existing pkg)-g: grant all runtime permissions-S: size in bytes of package, required for stdin--user: install under the given user.--dont-kill: installing a new feature split, don't kill running app--originating-uri: set URI where app was downloaded from--referrer: set URI that instigated the install of the app--pkg: specify expected package name of app being installed--abi: override the default ABI of the platform--instantapp: cause the app to be installed as an ephemeral install app--full: cause the app to be installed as a non-ephemeral full app--install-location: force the install location:0=auto, 1=internal only, 2=prefer external--force-uuid: force install on to disk volume with given UUID--force-sdk: allow install even when existing app targets platformcodename but new one targets a final API levelinstall-create [-lrtsfdg] [-i PACKAGE] [--user USER_ID|all|current][-p INHERIT_PACKAGE] [--install-location 0/1/2][--originating-uri URI] [---referrer URI][--abi ABI_NAME] [--force-sdk][--preload] [--instantapp] [--full] [--dont-kill][--force-uuid internal|UUID] [--pkg PACKAGE] [-S BYTES]Like "install", but starts an install session.  Use "install-write"to push data into the session, and "install-commit" to finish.install-write [-S BYTES] SESSION_ID SPLIT_NAME [PATH|-]Write an apk into the given install session.  If the path is '-', datawill be read from stdin.  Options are:-S: size in bytes of package, required for stdininstall-commit SESSION_IDCommit the given active install session, installing the app.install-abandon SESSION_IDDelete the given active install session.set-install-location LOCATIONChanges the default install location.  NOTE this is only intended for debugging;using this can cause applications to break and other undersireable behavior.LOCATION is one of:0 [auto]: Let system decide the best location1 [internal]: Install on internal device storage2 [external]: Install on external mediaget-install-locationReturns the current install location: 0, 1 or 2 as per set-install-location.move-package PACKAGE [internal|UUID]move-primary-storage [internal|UUID]pm uninstall [-k] [--user USER_ID] [--versionCode VERSION_CODE] PACKAGE [SPLIT]Remove the given package name from the system.  May remove an entire appif no SPLIT name is specified, otherwise will remove only the split of thegiven app.  Options are:-k: keep the data and cache directories around after package removal.--user: remove the app from the given user.--versionCode: only uninstall if the app has the given version code.clear [--user USER_ID] PACKAGEDeletes all data associated with a package.enable [--user USER_ID] PACKAGE_OR_COMPONENTdisable [--user USER_ID] PACKAGE_OR_COMPONENTdisable-user [--user USER_ID] PACKAGE_OR_COMPONENTdisable-until-used [--user USER_ID] PACKAGE_OR_COMPONENTdefault-state [--user USER_ID] PACKAGE_OR_COMPONENTThese commands change the enabled state of a given package orcomponent (written as "package/class").hide [--user USER_ID] PACKAGE_OR_COMPONENTunhide [--user USER_ID] PACKAGE_OR_COMPONENTsuspend [--user USER_ID] TARGET-PACKAGESuspends the specified package (as user).unsuspend [--user USER_ID] TARGET-PACKAGEUnsuspends the specified package (as user).grant [--user USER_ID] PACKAGE PERMISSIONrevoke [--user USER_ID] PACKAGE PERMISSIONThese commands either grant or revoke permissions to apps.  The permissionsmust be declared as used in the app's manifest, be runtime permissions(protection level dangerous), and the app targeting SDK greater than Lollipop MR1.reset-permissionsRevert all runtime permissions to their default state.set-permission-enforced PERMISSION [true|false]get-privapp-permissions TARGET-PACKAGEPrints all privileged permissions for a package.get-privapp-deny-permissions TARGET-PACKAGEPrints all privileged permissions that are denied for a package.get-oem-permissions TARGET-PACKAGEPrints all OEM permissions for a package.set-app-link [--user USER_ID] PACKAGE {always|ask|never|undefined}get-app-link [--user USER_ID] PACKAGEtrim-caches DESIRED_FREE_SPACE [internal|UUID]Trim cache files to reach the given free space.create-user [--profileOf USER_ID] [--managed] [--restricted] [--ephemeral][--guest] USER_NAMECreate a new user with the given USER_NAME, printing the new user identifierof the user.remove-user USER_IDRemove the user with the given USER_IDENTIFIER, deleting all dataassociated with that userset-user-restriction [--user USER_ID] RESTRICTION VALUEget-max-usersget-max-running-userscompile [-m MODE | -r REASON] [-f] [-c] [--split SPLIT_NAME][--reset] [--check-prof (true | false)] (-a | TARGET-PACKAGE)Trigger compilation of TARGET-PACKAGE or all packages if "-a".  Options are:-a: compile all packages-c: clear profile data before compiling-f: force compilation even if not needed-m: select compilation modeMODE is one of the dex2oat compiler filters:assume-verifiedextractverifyquickenspace-profilespacespeed-profilespeedeverything-r: select compilation reasonREASON is one of:first-bootbootinstallbg-dexoptab-otainactiveshared--reset: restore package to its post-install state--check-prof (true | false): look at profiles when doing dexopt?--secondary-dex: compile app secondary dex files--split SPLIT: compile only the given split nameforce-dex-opt PACKAGEForce immediate execution of dex opt for the given PACKAGE.bg-dexopt-jobExecute the background optimizations immediately.Note that the command only runs the background optimizer logic. It mayoverlap with the actual job but the job scheduler will not be able tocancel it. It will also run even if the device is not in the idlemaintenance mode.reconcile-secondary-dex-files TARGET-PACKAGEReconciles the package secondary dex files with the generated oat files.dump-profiles TARGET-PACKAGEDumps method/class profile files to/data/misc/profman/TARGET-PACKAGE.txtsnapshot-profile TARGET-PACKAGE [--code-path path]Take a snapshot of the package profiles to/data/misc/profman/TARGET-PACKAGE[-code-path].profIf TARGET-PACKAGE=android it will take a snapshot of the boot imageset-home-activity [--user USER_ID] TARGET-COMPONENTSet the default home activity (aka launcher).set-installer PACKAGE INSTALLERSet installer package nameget-instantapp-resolverReturn the name of the component that is the current instant app installer.set-harmful-app-warning [--user <USER_ID>] <PACKAGE> [<WARNING>]Mark the app as harmful with the given warning message.get-harmful-app-warning [--user <USER_ID>] <PACKAGE>Return the harmful app warning message for the given app, if presentuninstall-system-updatesRemove updates to all system applications and fall back to their /system version.<INTENT> specifications include these flags and arguments:[-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>][-c <CATEGORY> [-c <CATEGORY>] ...][-n <COMPONENT_NAME>][-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...][--esn <EXTRA_KEY> ...][--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...][--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...][--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...][--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...][--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...][--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>][--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]](mutiple extras passed as Integer[])[--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]](mutiple extras passed as List<Integer>)[--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]](mutiple extras passed as Long[])[--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]](mutiple extras passed as List<Long>)[--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]](mutiple extras passed as Float[])[--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]](mutiple extras passed as List<Float>)[--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]](mutiple extras passed as String[]; to embed a comma into a string,escape it using "\,")[--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]](mutiple extras passed as List<String>; to embed a comma into a string,escape it using "\,")[-f <FLAG>][--grant-read-uri-permission] [--grant-write-uri-permission][--grant-persistable-uri-permission] [--grant-prefix-uri-permission][--debug-log-resolution] [--exclude-stopped-packages][--include-stopped-packages][--activity-brought-to-front] [--activity-clear-top][--activity-clear-when-task-reset] [--activity-exclude-from-recents][--activity-launched-from-history] [--activity-multiple-task][--activity-no-animation] [--activity-no-history][--activity-no-user-action] [--activity-previous-is-top][--activity-reorder-to-front] [--activity-reset-task-if-needed][--activity-single-top] [--activity-clear-task][--activity-task-on-home] [--activity-match-external][--receiver-registered-only] [--receiver-replace-pending][--receiver-foreground] [--receiver-no-abort][--receiver-include-background][--selector][<URI> | <PACKAGE> | <COMPONENT>]
yfve_8q:/ #

pm意思是PackageManager,可以获取到Android系统中的应用信息。
pm list package:获取所有安装在设备上的应用包名。

参数 意义
-s 列出所有系统应用包名
-3 列出第三方的应用包名
-f 列出应用包名、apk名、存放位置
-i 列出应用包名、安装来源

命令最后可以加上FILTER过滤关键字,查找关键字代表的应用。
pm path [PACKAGE_NAME]:列出对应包名应用的.apk文件路径。
pm list instrumentation: 列出含有单元测试 case 的应用,后面可跟参数 -f (与 pm list package 中一样),以及 [TARGET-PACKAGE]。
pm dump [PACKAGE_NAME]:列出指定包名应用的 dump 信息,里面有各种信息,自行查看。
pm install [APK_PAHT]:安装APK。
pm uninstall [PACKAGE_NAME]:卸载包名APP。
pm clear:清除应用信息。
pm set-install-location,pm get-install-location:设置应用安装位置,获取应用安装位置。
[0/auto]:默认为自动。
[1/internal]:默认为安装在手机内部。
[2/external]:默认安装在外部存储。

am

yfve_8q:/ # am -h
Activity manager (activity) commands:helpPrint this help text.start-activity [-D] [-N] [-W] [-P <FILE>] [--start-profiler <FILE>][--sampling INTERVAL] [--streaming] [-R COUNT] [-S][--track-allocation] [--user <USER_ID> | current] <INTENT>Start an Activity.  Options are:-D: enable debugging-N: enable native debugging-W: wait for launch to complete--start-profiler <FILE>: start profiler and send results to <FILE>--sampling INTERVAL: use sample profiling with INTERVAL microsecondsbetween samples (use with --start-profiler)--streaming: stream the profiling output to the specified file(use with --start-profiler)-P <FILE>: like above, but profiling stops when app goes idle--attach-agent <agent>: attach the given agent before binding--attach-agent-bind <agent>: attach the given agent during binding-R: repeat the activity launch <COUNT> times.  Prior to each repeat,the top activity will be finished.-S: force stop the target app before starting the activity--track-allocation: enable tracking of object allocations--user <USER_ID> | current: Specify which user to run as; if notspecified then run as the current user.--windowingMode <WINDOWING_MODE>: The windowing mode to launch the activity into.--activityType <ACTIVITY_TYPE>: The activity type to launch the activity as.start-service [--user <USER_ID> | current] <INTENT>Start a Service.  Options are:--user <USER_ID> | current: Specify which user to run as; if notspecified then run as the current user.start-foreground-service [--user <USER_ID> | current] <INTENT>Start a foreground Service.  Options are:--user <USER_ID> | current: Specify which user to run as; if notspecified then run as the current user.stop-service [--user <USER_ID> | current] <INTENT>Stop a Service.  Options are:--user <USER_ID> | current: Specify which user to run as; if notspecified then run as the current user.broadcast [--user <USER_ID> | all | current] <INTENT>Send a broadcast Intent.  Options are:--user <USER_ID> | all | current: Specify which user to send to; if notspecified then send to all users.--receiver-permission <PERMISSION>: Require receiver to hold permission.instrument [-r] [-e <NAME> <VALUE>] [-p <FILE>] [-w][--user <USER_ID> | current] [--no-hidden-api-checks][--no-window-animation] [--abi <ABI>] <COMPONENT>Start an Instrumentation.  Typically this target <COMPONENT> is in theform <TEST_PACKAGE>/<RUNNER_CLASS> or only <TEST_PACKAGE> if thereis only one instrumentation.  Options are:-r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT).  Use with[-e perf true] to generate raw output for performance measurements.-e <NAME> <VALUE>: set argument <NAME> to <VALUE>.  For test runners acommon form is [-e <testrunner_flag> <value>[,<value>...]].-p <FILE>: write profiling data to <FILE>-m: Write output as protobuf to stdout (machine readable)-f <Optional PATH/TO/FILE>: Write output as protobuf to a file (machinereadable). If path is not specified, default directory and file name willbe used: /sdcard/instrument-logs/log-yyyyMMdd-hhmmss-SSS.instrumentation_data_proto-w: wait for instrumentation to finish before returning.  Required fortest runners.--user <USER_ID> | current: Specify user instrumentation runs in;current user if not specified.--no-hidden-api-checks: disable restrictions on use of hidden API.--no-window-animation: turn off window animations while running.--abi <ABI>: Launch the instrumented process with the selected ABI.This assumes that the process supports the selected ABI.trace-ipc [start|stop] [--dump-file <FILE>]Trace IPC transactions.start: start tracing IPC transactions.stop: stop tracing IPC transactions and dump the results to file.--dump-file <FILE>: Specify the file the trace should be dumped to.profile [start|stop] [--user <USER_ID> current] [--sampling INTERVAL][--streaming] <PROCESS> <FILE>Start and stop profiler on a process.  The given <PROCESS> argumentmay be either a process name or pid.  Options are:--user <USER_ID> | current: When supplying a process name,specify user of process to profile; uses current user if not specified.--sampling INTERVAL: use sample profiling with INTERVAL microsecondsbetween samples--streaming: stream the profiling output to the specified filedumpheap [--user <USER_ID> current] [-n] [-g] <PROCESS> <FILE>Dump the heap of a process.  The given <PROCESS> argument maybe either a process name or pid.  Options are:-n: dump native heap instead of managed heap-g: force GC before dumping the heap--user <USER_ID> | current: When supplying a process name,specify user of process to dump; uses current user if not specified.set-debug-app [-w] [--persistent] <PACKAGE>Set application <PACKAGE> to debug.  Options are:-w: wait for debugger when application starts--persistent: retain this valueclear-debug-appClear the previously set-debug-app.set-watch-heap <PROCESS> <MEM-LIMIT>Start monitoring pss size of <PROCESS>, if it is at orabove <HEAP-LIMIT> then a heap dump is collected for the user to report.clear-watch-heapClear the previously set-watch-heap.bug-report [--progress | --telephony]Request bug report generation; will launch a notificationwhen done to select where it should be delivered. Options are:--progress: will launch a notification right away to show its progress.--telephony: will dump only telephony sections.force-stop [--user <USER_ID> | all | current] <PACKAGE>Completely stop the given application package.crash [--user <USER_ID>] <PACKAGE|PID>Induce a VM crash in the specified package or processkill [--user <USER_ID> | all | current] <PACKAGE>Kill all background processes associated with the given application.kill-allKill all processes that are safe to kill (cached, etc).make-uid-idle [--user <USER_ID> | all | current] <PACKAGE>If the given application's uid is in the background and waiting tobecome idle (not allowing background services), do that now.monitor [--gdb <port>]Start monitoring for crashes or ANRs.--gdb: start gdbserv on the given port at crash/ANRwatch-uids [--oom <uid>]Start watching for and reporting uid state changes.--oom: specify a uid for which to report detailed change messages.hang [--allow-restart]Hang the system.--allow-restart: allow watchdog to perform normal system restartrestartRestart the user-space system.idle-maintenancePerform idle maintenance now.screen-compat [on|off] <PACKAGE>Control screen compatibility mode of <PACKAGE>.package-importance <PACKAGE>Print current importance of <PACKAGE>.to-uri [INTENT]Print the given Intent specification as a URI.to-intent-uri [INTENT]Print the given Intent specification as an intent: URI.to-app-uri [INTENT]Print the given Intent specification as an android-app: URI.switch-user <USER_ID>Switch to put USER_ID in the foreground, startingexecution of that user if it is currently stopped.get-current-userReturns id of the current foreground user.start-user <USER_ID>Start USER_ID in background if it is currently stopped;use switch-user if you want to start the user in foregroundunlock-user <USER_ID> [TOKEN_HEX]Attempt to unlock the given user using the given authorization token.stop-user [-w] [-f] <USER_ID>Stop execution of USER_ID, not allowing it to run anycode until a later explicit start or switch to it.-w: wait for stop-user to complete.-f: force stop even if there are related users that cannot be stopped.is-user-stopped <USER_ID>Returns whether <USER_ID> has been stopped or not.get-started-user-state <USER_ID>Gets the current state of the given started user.track-associationsEnable association tracking.untrack-associationsDisable and clear association tracking.get-uid-state <UID>Gets the process state of an app given its <UID>.attach-agent <PROCESS> <FILE>Attach an agent to the specified <PROCESS>, which may be either a process name or a PID.get-config [--days N] [--device] [--proto]Retrieve the configuration and any recent configurations of the device.--days: also return last N days of configurations that have been seen.--device: also output global device configuration info.--proto: return result as a proto; does not include --days info.supports-multiwindowReturns true if the device supports multiwindow.supports-split-screen-multi-windowReturns true if the device supports split screen multiwindow.suppress-resize-config-changes <true|false>Suppresses configuration changes due to user resizing an activity/task.set-inactive [--user <USER_ID>] <PACKAGE> true|falseSets the inactive state of an app.get-inactive [--user <USER_ID>] <PACKAGE>Returns the inactive state of an app.set-standby-bucket [--user <USER_ID>] <PACKAGE> active|working_set|frequent|rarePuts an app in the standby bucket.get-standby-bucket [--user <USER_ID>] <PACKAGE>Returns the standby bucket of an app.send-trim-memory [--user <USER_ID>] <PROCESS>[HIDDEN|RUNNING_MODERATE|BACKGROUND|RUNNING_LOW|MODERATE|RUNNING_CRITICAL|COMPLETE]Send a memory trim event to a <PROCESS>.  May also supply a raw trim int level.display [COMMAND] [...]: sub-commands for operating on displays.move-stack <STACK_ID> <DISPLAY_ID>Move <STACK_ID> from its current display to <DISPLAY_ID>.stack [COMMAND] [...]: sub-commands for operating on activity stacks.start <DISPLAY_ID> <INTENT>Start a new activity on <DISPLAY_ID> using <INTENT>move-task <TASK_ID> <STACK_ID> [true|false]Move <TASK_ID> from its current stack to the top (true) orbottom (false) of <STACK_ID>.resize <STACK_ID> <LEFT,TOP,RIGHT,BOTTOM>Change <STACK_ID> size and position to <LEFT,TOP,RIGHT,BOTTOM>.resize-animated <STACK_ID> <LEFT,TOP,RIGHT,BOTTOM>Same as resize, but allow animation.resize-docked-stack <LEFT,TOP,RIGHT,BOTTOM> [<TASK_LEFT,TASK_TOP,TASK_RIGHT,TASK_BOTTOM>]Change docked stack to <LEFT,TOP,RIGHT,BOTTOM>and supplying temporary different task bounds indicated by<TASK_LEFT,TOP,RIGHT,BOTTOM>move-top-activity-to-pinned-stack: <STACK_ID> <LEFT,TOP,RIGHT,BOTTOM>Moves the top activity from<STACK_ID> to the pinned stack using <LEFT,TOP,RIGHT,BOTTOM> for thebounds of the pinned stack.positiontask <TASK_ID> <STACK_ID> <POSITION>Place <TASK_ID> in <STACK_ID> at <POSITION>listList all of the activity stacks and their sizes.info <WINDOWING_MODE> <ACTIVITY_TYPE>Display the information about activity stack in <WINDOWING_MODE> and <ACTIVITY_TYPE>.remove <STACK_ID>Remove stack <STACK_ID>.task [COMMAND] [...]: sub-commands for operating on activity tasks.lock <TASK_ID>Bring <TASK_ID> to the front and don't allow other tasks to run.lock stopEnd the current task lock.resizeable <TASK_ID> [0|1|2|3]Change resizeable mode of <TASK_ID> to one of the following:0: unresizeable1: crop_windows2: resizeable3: resizeable_and_pipableresize <TASK_ID> <LEFT,TOP,RIGHT,BOTTOM>Makes sure <TASK_ID> is in a stack with the specified bounds.Forces the task to be resizeable and creates a stack if no existing stackhas the specified bounds.update-appinfo <USER_ID> <PACKAGE_NAME> [<PACKAGE_NAME>...]Update the ApplicationInfo objects of the listed packages for <USER_ID>without restarting any processes.writeWrite all pending state to storage.<INTENT> specifications include these flags and arguments:[-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>][-c <CATEGORY> [-c <CATEGORY>] ...][-n <COMPONENT_NAME>][-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...][--esn <EXTRA_KEY> ...][--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...][--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...][--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...][--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...][--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...][--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>][--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]](mutiple extras passed as Integer[])[--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]](mutiple extras passed as List<Integer>)[--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]](mutiple extras passed as Long[])[--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]](mutiple extras passed as List<Long>)[--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]](mutiple extras passed as Float[])[--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]](mutiple extras passed as List<Float>)[--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]](mutiple extras passed as String[]; to embed a comma into a string,escape it using "\,")[--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]](mutiple extras passed as List<String>; to embed a comma into a string,escape it using "\,")[-f <FLAG>][--grant-read-uri-permission] [--grant-write-uri-permission][--grant-persistable-uri-permission] [--grant-prefix-uri-permission][--debug-log-resolution] [--exclude-stopped-packages][--include-stopped-packages][--activity-brought-to-front] [--activity-clear-top][--activity-clear-when-task-reset] [--activity-exclude-from-recents][--activity-launched-from-history] [--activity-multiple-task][--activity-no-animation] [--activity-no-history][--activity-no-user-action] [--activity-previous-is-top][--activity-reorder-to-front] [--activity-reset-task-if-needed][--activity-single-top] [--activity-clear-task][--activity-task-on-home] [--activity-match-external][--receiver-registered-only] [--receiver-replace-pending][--receiver-foreground] [--receiver-no-abort][--receiver-include-background][--selector][<URI> | <PACKAGE> | <COMPONENT>]
yfve_8q:/ #

am start:启动一个Activity。
例如:
启动相机:
am start -n com.android.camera/.Camera
先停止目标应用,再启动:
am start -S com.android.camera/.Camera
等待应用完成启动:
am start -W com.android.camera/.Camera
启动默认浏览器打开一个网页:
am start -a android.intent.action.VIEW -d http://www.baidu.com
启动拨号器拨打 10086:
am start -a android.intent.action.CALL -d tel:10086

am instrument , 启动一个 instrumentation , 单元测试或者 Robotium 会用到。

am monitor , 监控 crash 与 ANR。

am force-stop , 后跟包名,结束应用。

am startservice , 启动一个服务。

am broadcast , 发送一个广播。
后面的参数有:
[-a ]
[-d <DATA_URI>]
[-t <MIME_TYPE>]
[-c [-c ] …]
[-e|–es <EXTRA_KEY> <EXTRA_STRING_VALUE> …]
[–ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> …]
[-e|–ei <EXTRA_KEY> <EXTRA_INT_VALUE> …]
[-n ]
[-f ] []
例如:
adb shell am broadcast -a com.android.test --es test_string “this is test string” --ei test_int 100 --ez test_boolean true

input

yfve_8q:/ # input
Usage: input [<source>] <command> [<arg>...]The sources are: dpadkeyboardmousetouchpadgamepadtouchnavigationjoysticktouchscreenstylustrackballThe commands and default sources are:text <string> (Default: touchscreen)keyevent [--longpress] <key code number or name> ... (Default: keyboard)tap <x> <y> (Default: touchscreen)swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)draganddrop <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)press (Default: trackball)roll <dx> <dy> (Default: trackball)
yfve_8q:/ #

这个命令可以向 Android 设备发送按键事件,其源码 Input.java

input text , 发送文本内容,不能发送中文:
input text test123456
前提先将键盘设置为英文键盘

input keyevent , 发送按键事件,KeyEvent.java:
input keyevent KEYCODE_HOME
模拟按下 Home 键

input tap , 对屏幕发送一个触摸事件:
input tap 500 500
点击屏幕上坐标为 500 500 的位置

input swipe , 滑动事件:
input swipe 900 500 100 500
从右往左滑动屏幕

如果版本不低于 4.4 , 可以模拟长按事件:
input swipe 500 500 501 501 2000
其实就是在小的距离内,在较长的持续时间内进行滑动,最后表现出来的结果就是长按动作

screencap

截屏命令,格式:screencap [-hp] [-d display-id] [FILENAME]

yfve_8q:/ # screencap -h
usage: screencap [-hp] [-d display-id] [FILENAME]-h: this message-p: save the file as a png.-d: specify the display id to capture, default 0.
If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.
yfve_8q:/ #

# 截0号屏,保存至 /sdcard/screencap0.png
screencap -p /sdcard/screencap0.png
# 截1号屏,保存至 /sdcard/screencap1.png
screencap -p -d 1 /sdcard/screencap1.png

screenrecord

4.4 新增的录制命令,格式:screenrecord [options] [filename]

yfve_8q:/ # screenrecord --h
Usage: screenrecord [options] <filename>Android screenrecord v1.2.  Records the device's display to a .mp4 file.Options:
--size WIDTHxHEIGHTSet the video size, e.g. "1280x720".  Default is the device's maindisplay resolution (if supported), 1280x720 if not.  For best results,use a size supported by the AVC encoder.
--bit-rate RATESet the video bit rate, in bits per second.  Value may be specified asbits or megabits, e.g. '4000000' is equivalent to '4M'.  Default 20Mbps.
--bugreportAdd additional information, such as a timestamp overlay, that is helpfulin videos captured to illustrate bugs.
--time-limit TIMESet the maximum recording time, in seconds.  Default / maximum is 180.
--verboseDisplay interesting information on stdout.
--helpShow this message.Recording continues until Ctrl-C is hit or the time limit is reached.yfve_8q:/ #

录屏默认最大时长为180s,可以用–time-limit TIME修改,也可以通过Ctrl-C提前结束。

# 执行命令后操作手机,ctrl + c 结束录制,录制结果保存至 sdcard
screenrecord /sdcard/record.mp4

uiautomator

执行 UI automation tests , 获取当前界面的控件信息

yfve_8q:/ # uiautomator -h
Usage: uiautomator <subcommand> [options]Available subcommands:help: displays help messageruntest: executes UI automation testsruntest <class spec> [options]<class spec>: <JARS> < -c <CLASSES> | -e class <CLASSES> ><JARS>: a list of jar files containing test classes and dependencies. Ifthe path is relative, it's assumed to be under /data/local/tmp. Useabsolute path if the file is elsewhere. Multiple files can bespecified, separated by space.<CLASSES>: a list of test class names to run, separated by comma. Toa single method, use TestClass#testMethod format. The -e or -c optionmay be repeated. This option is not required and if not provided thenall the tests in provided jars will be run automatically.options:--nohup: trap SIG_HUP, so test won't terminate even if parent processis terminated, e.g. USB is disconnected.-e debug [true|false]: wait for debugger to connect before starting.-e runner [CLASS]: use specified test runner class instead. Ifunspecified, framework default runner will be used.-e <NAME> <VALUE>: other name-value pairs to be passed to test classes.May be repeated.-e outputFormat simple | -s: enabled less verbose JUnit style output.dump: creates an XML dump of current UI hierarchydump [--verbose][file][--compressed]: dumps compressed layout information.[file]: the location where the dumped XML should be stored, default is/sdcard/window_dump.xmlevents: prints out accessibility events until terminatedyfve_8q:/ #

runtest:executes UI automation tests RunTestCommand.java
dump:获取控件信息,DumpCommand.java
shell uiautomator dump
UI hierchary dumped to: /storage/emulated/legacy/window_dump.xml
不加 [file] 选项时,默认存放在 sdcard 下

ime

输入法,Ime.java

yfve_8q:/ # ime -h
ime <command>:list [-a] [-s]prints all enabled input methods.-a: see all input methods-s: only a single summary line of eachenable <ID>allows the given input method ID to be used.disable <ID>disallows the given input method ID to be used.set <ID>switches to the given input method ID.resetreset currently selected/enabled IMEs to the default ones as if the device is initially booted with the current locale.
yfve_8q:/ #

ime list -s
com.google.android.inputmethod.pinyin/.PinyinIME
com.baidu.input_mi/.ImeService
列出设备上的输入法

adb shell ime set com.baidu.input_mi/.ImeService
Input method com.baidu.input_mi/.ImeService selected
选择输入法

wm

WindowManager.java

yfve_8q:/ # wm -h
Window manager (window) commands:helpPrint this help text.size [reset|WxH|WdpxHdp]Return or override display size.width and height in pixels unless suffixed with 'dp'.density [reset|DENSITY]Return or override display density.overscan [reset|LEFT,TOP,RIGHT,BOTTOM]Set overscan area for display.scaling [off|auto]Set display scaling mode.dismiss-keyguardDismiss the keyguard, prompting user for auth if necessary.
yfve_8q:/ #

wm size
Physical size: 1080x1920
获取设备分辨率

monkey

请参考 Android Monkey 的用法。

settings

Settings.java,请参考 探究下 Android4.2 中新增的 settings 命令。

yfve_8q:/ # settings
Settings provider (settings) commands:helpPrint this help text.get [--user <USER_ID> | current] NAMESPACE KEYRetrieve the current value of KEY.put [--user <USER_ID> | current] NAMESPACE KEY VALUE [TAG] [default]Change the contents of KEY to VALUE.TAG to associate with the setting.{default} to set as the default, case-insensitive only for global/secure namespacedelete NAMESPACE KEYDelete the entry for KEY.reset [--user <USER_ID> | current] NAMESPACE {PACKAGE_NAME | RESET_MODE}Reset the global/secure table for a package with mode.RESET_MODE is one of {untrusted_defaults, untrusted_clear, trusted_defaults}, case-insensitivelist NAMESPACEPrint all defined keys.NAMESPACE is one of {system, secure, global}, case-insensitive
yfve_8q:/ #

dumpsys

yfve_8q:/ # dumpsys --help
usage: dumpsysTo dump all services.
or:dumpsys [-t TIMEOUT] [--priority LEVEL] [--help | -l | --skip SERVICES | SERVICE [ARGS]]--help: shows this help-l: only list services, do not dump them-t TIMEOUT_SEC: TIMEOUT to use in seconds instead of default 10 seconds-T TIMEOUT_MS: TIMEOUT to use in milliseconds instead of default 10 seconds--proto: filter services that support dumping data in proto format. Dumps               will be in proto format.--priority LEVEL: filter services based on specified priorityLEVEL must be one of CRITICAL | HIGH | NORMAL--skip SERVICES: dumps all services but SERVICES (comma-separated list)SERVICE [ARGS]: dumps only service SERVICE, optionally passing ARGS to it
yfve_8q:/ #

可通过dumpsys命令查询系统服务的运行状态(对象的成员变量属性值)。
命令格式:dumpsys 服务名

服务名 类名 功能
activity ActivityManagerService AMS相关信息
package PackageManagerService PMS相关信息
window WindowManagerService WMS相关信息
input InputManagerService IMS相关信息
power PowerManagerService PMS相关信息
batterystats BatterystatsService 电池统计信息
battery BatteryService 电池信息
alarm AlarmManagerService 闹钟信息
dropbox DropboxManagerService 调试相关
procstats ProcessStatsService 进程统计
cpuinfo CpuBinder CPU
meminfo MemBinder 内存
gfxinfo GraphicsBinder 图像
dbinfo DbBinder 数据库
服务名 功能
SurfaceFlinger 图像相关
appops app使用情况
permission 权限
processinfo 进程服务
batteryproperties 电池相关
audio 查看声音信息
netstats 查看网络统计信息
diskstats 查看空间free状态
jobscheduler 查看任务计划
wifi wifi信息
diskstats 磁盘情况
usagestats 用户使用情况
devicestoragemonitor 设备信息

dumpsys package [PackageName]
会输出这个[PackageName]的activity、service、broadcastreceiver、permission等信息,等于直观的看这个[PackageName]的manifest.xml文件。

getprop

查看 Android 设备的参数信息,只运行getprop,结果以 key : value 键值对的形式显示,如要获取某个 key 的值:
adb shell getprop ro.build.version.sdk
获取设备的 sdk 版本

logcat

yfve_8q:/ # logcat -h
Usage: logcat [options] [filterspecs]
options include:-s              Set default filter to silent. Equivalent to filterspec '*:S'-f <file>, --file=<file>               Log to file. Default is stdout-r <kbytes>, --rotate-kbytes=<kbytes>Rotate log every kbytes. Requires -f option-n <count>, --rotate-count=<count>Sets max number of rotated logs to <count>, default 4--id=<id>       If the signature id for logging to file changes, then clearthe fileset and continue-v <format>, --format=<format>Sets log print format verb and adverbs, where <format> is:brief help long process raw tag thread threadtime timeand individually flagged modifying adverbs can be added:color descriptive epoch monotonic printable uidusec UTC year zoneMultiple -v parameters or comma separated list of format andformat modifiers are allowed.-D, --dividers  Print dividers between each log buffer-c, --clear     Clear (flush) the entire log and exitif Log to File specified, clear fileset instead-d              Dump the log and then exit (don't block)-e <expr>, --regex=<expr>Only print lines where the log message matches <expr>where <expr> is a Perl-compatible regular expression-m <count>, --max-count=<count>Quit after printing <count> lines. This is meant to bepaired with --regex, but will work on its own.--print         Paired with --regex and --max-count to let content bypassregex filter but still stop at number of matches.-t <count>      Print only the most recent <count> lines (implies -d)-t '<time>'     Print most recent lines since specified time (implies -d)-T <count>      Print only the most recent <count> lines (does not imply -d)-T '<time>'     Print most recent lines since specified time (not imply -d)count is pure numerical, time is 'MM-DD hh:mm:ss.mmm...''YYYY-MM-DD hh:mm:ss.mmm...' or 'sssss.mmm...' format-g, --buffer-size                      Get the size of the ring buffer.-G <size>, --buffer-size=<size>Set size of log ring buffer, may suffix with K or M.-L, --last      Dump logs from prior to last reboot-b <buffer>, --buffer=<buffer>         Request alternate ring buffer, 'main','system', 'radio', 'events', 'crash', 'default' or 'all'.Multiple -b parameters or comma separated list of buffers areallowed. Buffers interleaved. Default -b main,system,crash.-B, --binary    Output the log in binary.-S, --statistics                       Output statistics.-p, --prune     Print prune white and ~black list. Service is specified asUID, UID/PID or /PID. Weighed for quicker pruning if prefixwith ~, otherwise weighed for longevity if unadorned. Allother pruning activity is oldest first. Special case ~!represents an automatic quicker pruning for the noisiestUID as determined by the current statistics.-P '<list> ...', --prune='<list> ...'Set prune white and ~black list, using same format aslisted above. Must be quoted.--pid=<pid>     Only prints logs from the given pid.--wrap          Sleep for 2 hours or when buffer about to wrap whichevercomes first. Improves efficiency of polling by providingan about-to-wrap wakeup.filterspecs are a series of <tag>[:priority]where <tag> is a log component tag (or * for all) and priority is:V    Verbose (default for <tag>)D    Debug (default for '*')I    InfoW    WarnE    ErrorF    FatalS    Silent (suppress all output)'*' by itself means '*:D' and <tag> by itself means <tag>:V.
If no '*' filterspec or -s on command line, all filter defaults to '*:V'.
eg: '*:S <tag>' prints only <tag>, '<tag>:S' suppresses all <tag> log messages.If not specified on the command line, filterspec is set from ANDROID_LOG_TAGS.If not specified with -v on command line, format is set from ANDROID_PRINTF_LOG
or defaults to "threadtime"-v <format>, --format=<format> options:Sets log print format verb and adverbs, where <format> is:brief long process raw tag thread threadtime timeand individually flagged modifying adverbs can be added:color descriptive epoch monotonic printable uid usec UTC year zoneSingle format verbs:brief      — Display priority/tag and PID of the process issuing the message.long       — Display all metadata fields, separate messages with blank lines.process    — Display PID only.raw        — Display the raw log message, with no other metadata fields.tag        — Display the priority/tag only.thread     — Display priority, PID and TID of process issuing the message.threadtime — Display the date, invocation time, priority, tag, and the PIDand TID of the thread issuing the message. (the default format).time       — Display the date, invocation time, priority/tag, and PID of theprocess issuing the message.Adverb modifiers can be used in combination:color       — Display in highlighted color to match priority. i.e. VERBOSEDEBUG INFO WARNING ERROR FATALdescriptive — events logs only, descriptions from event-log-tags database.epoch       — Display time as seconds since Jan 1 1970.monotonic   — Display time as cpu seconds since last boot.printable   — Ensure that any binary logging content is escaped.uid         — If permitted, display the UID or Android ID of logged process.usec        — Display time down the microsecond precision.UTC         — Display time as UTC.year        — Add the year to the displayed time.zone        — Add the local timezone to the displayed time."<zone>"    — Print using this public named timezone (experimental).yfve_8q:/ #

1. 缓冲区简介
android log输出量巨大,特别是通信系统的log,因此,android把log输出到不同的缓冲区中,目前定义了四个log缓冲区:

  1. Radio:输出通信系统的log
  2. System:输出系统组件的log
  3. Event:输出event模块的log
  4. Main:所有java层的log,遗迹不属于上面3层的log

缓冲区主要给系统组件使用,一般的应用不需要关心,应用的log都输出到main缓冲区中。

默认log输出(不指定缓冲区的情况下)是输出System和Main缓冲区的log。

2. Logcat参数和过滤项
日志输出命令,格式:logcat [参数] [过滤项], 其中 选项 和 过滤项 在 中括号 [] 中, 说明这是可选的。

参数 意义
-s 设置输出日志的标签, 只显示该标签的日志
-f [filename] 将日志输出到文件[filename]中,才用默认输出格式
-r [kbyte] 按照[kbyte]千字节输出日志,默认是16, 需要和 -f 参数一起使用
-n [count] 设置日志输出的最大数目为[count],默认是4, 需要和-r 参数一起使用
-v [format] 设置日志的输出格式为[format]
-c 清空所有的日志缓存信息
-d 将缓存的日志输出到屏幕上, 并且不会阻塞
-t 输出最近的几行日志, 输出完退出, 不阻塞
-g 查看日志缓冲区信息
-b [buffer] 加载可以使用的一个日志缓冲区供查看,默认是 main
-B 以二进制形式输出日志

一般长时间输出log的话建议-f,-n,-r三个参数连用,这样当一个文件日志输出满了之后可以马上在另一个中进行输出。

3. 过滤格式
过滤项格式 : [:priority] , 标签:日志等级, 默认的日志过滤项是 " *:I " ;

过滤项 意义
V Verbose (明细);
D Debug (调试);
I Info (信息);
W Warn (警告);
E Error (错误);
F Fatal (严重错误);
S Silent(Super all output) (最高的优先级, 可能不会记载东西);

-s参数
用来过滤日志文件的标签。如logcat -s System.out。
和grep命令相似,不过grep过滤标签和日志内容在内的所有内容,而-s只过滤标签。
-f参数
将日志输出到指定文件中。
和重定向符">"功能差不多。
-v参数
指定日志输出格式。logcat -v [格式]

格式 意义
time 日志格式:日期 时间 优先级 / 标签 (进程ID) : 进程名称 : 日志信息
threadtime 日志的输出时间和线程信息
prief 默认的日志格式:优先级 / 标签 (进程ID): 日志信息
progress 日志格式:优先级 (进程ID) : 日志信息
tag 日志格式:优先级 / 标签 : 日志信息
thread 日志格式:优先级 ( 进程ID : 线程ID) 标签 : 日志内容
raw 只输出日志信息, 不附加任何其他信息, 如 优先级 标签等
long 日志格式:[ 日期 时间 进程ID : 线程ID 优先级 / 标签] 日志信息

grep

yfve_8q:/ # grep
usage: grep [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A num] [-B num] [-C[num]][-e pattern] [-f file] [--binary-files=value] [--color=when][--context[=num]] [--directories=action] [--label] [--line-buffered][pattern] [file ...]
yfve_8q:/ #

grep是查找字符串命令。grep支持正则表达式。格式是:grep [参数] [pattern]

参数 意义
-a或–text 不要忽略二进制的数据。
-A<显示列数>或–after-context=<显示列数> 除了显示符合范本样式的那一列之外,并显示该列之后的内容。
-b或–byte-offset 在显示符合范本样式的那一列之前,标示出该列第一个字符的位编号。
-B<显示列数>或–before-context=<显示列数> 除了显示符合范本样式的那一列之外,并显示该列之前的内容。
-c或–count 计算符合范本样式的列数。
-C<显示列数>或–context=<显示列数>或-<显示列数> 除了显示符合范本样式的那一列之外,并显示该列之前后的内容。
-d<进行动作>或–directories=<进行动作> 当指定要查找的是目录而非文件时,必须使用这项参数,否则grep指令将回报信息并停止动作。
-e<范本样式>或–regexp=<范本样式> 指定字符串做为查找文件内容的范本样式。
-E或–extended-regexp 将范本样式为延伸的普通表示法来使用。
-f<范本文件>或–file=<范本文件> 指定范本文件,其内容含有一个或多个范本样式,让grep查找符合范本条件的文件内容,格式为每列一个范本样式。
-F或–fixed-regexp 将范本样式视为固定字符串的列表。
-G或–basic-regexp 将范本样式视为普通的表示法来使用。
-h或–no-filename 在显示符合范本样式的那一列之前,不标示该列所属的文件名称。
-H或–with-filename 在显示符合范本样式的那一列之前,表示该列所属的文件名称。
-i或–ignore-case 忽略字符大小写的差别。
-l或–file-with-matches 列出文件内容符合指定的范本样式的文件名称。
-L或–files-without-match 列出文件内容不符合指定的范本样式的文件名称。
-n或–line-number 在显示符合范本样式的那一列之前,标示出该列的列数编号。
-q或–quiet或–silent 不显示任何信息。
-r或–recursive 此参数的效果和指定"-d recurse"参数相同。
-s或–no-messages 不显示错误信息。
-v或–revert-match 反转查找。
-V或–version 显示版本信息。
-w或–word-regexp 只显示全字符合的列。
-x或–line-regexp 只显示全列符合的列。
-y 此参数的效果和指定"-i"参数相同。
–help 在线帮助。

【Android】adb命令和adb shell命令相关推荐

  1. python调用shell命令-Python调用shell命令常用方法(4种)

    方法一.使用os模块的system方法:os.system(cmd),其返回值是shell指令运行后返回的状态码,int类型,0表示shell指令成功执行,256表示未找到,该方法适用于shell命令 ...

  2. python 调用linux命令-Python调用shell命令常用方法

    Python调用shell指令 方法一.使用os模块的system方法:os.system(cmd),其返回值是shell指令运行后返回的状态码,int类型,0表示shell指令成功执行,256表示未 ...

  3. python调用shell命令-python调用shell命令小结

    在写python脚本的时候,经常需要调用系统命令,常用的python调用系统命令的方法主要有subprocess.call和os.popen.默认情况下subprocess.call的方法结果是返回值 ...

  4. linux help命令编写,Linux shell命令帮助格式详解

    前言 linux shell命令通常可以通过-h或--help来打印帮助说明,或者通过man命令来查看帮助,有时候我们也会给自己的程序写简单的帮助说明,其实帮助说明格式是有规律可循的 帮助示例 下面是 ...

  5. python使用shell命令_python 调用shell命令的方法

    在python程序中调用shell命令,是件很酷且常用的事情-- 1. os.system(command) 此函数会启动子进程,在子进程中执行command,并返回command命令执行完毕后的退出 ...

  6. lua执行shell命令6_Vim执行shell命令及使用Vim批量更改文件名

    写在前面:我"胡汉三"又回来了~上周顺利通过了试用期答辩,现在俺是一名正式的鹅厂人啦.哈哈哈~感谢各位可爱又热心的好伙伴对我的"不离不弃". 话休絮烦,今天分享 ...

  7. python shell常用命令_python 之 shell命令执行

    python中有几种常用的执行shell命令的模块 1,os.system() 2, os.popen() 3,pexpect.run() 下面介绍3个模块的差别 1,os.system() 直接执行 ...

  8. python shell常用命令_python执行shell命令

    1 os.system 可以返回运行shell命令状态,同时会在终端输出运行结果 例如 ipython中运行如下命令,返回运行状态status os.system('cat /etc/passwdqc ...

  9. android 按键消息,在android中模拟键盘消息(shell命令的方法)

    已找到解决方案[code] use: sendevent command format: sendevent device type code value [command] [device] [ty ...

  10. shell命令 vxworks5.5_vxWorks shell命令

    vxWorks 命令规则: 名词+动词,第二个单词开始大写 序号 状态 命令 备注 1 BSP c 改变配置 2 BSP p 打印当前配置信息 3 BSP @ 开始加载内核 4 BSP ctrl+x ...

最新文章

  1. [android] Serializable 和 Parcelable 区别
  2. SQL SERVER 数据库 怎么从一个服务器一个表中把数据插入到另一个服务器中的一个表内(纯复制)...
  3. 量化金融模型的基本Roadmap
  4. 吕述望 计算机网络专家,特稿: 中科院吕述望教授:互联网名不符实
  5. java echarts 散点图,echarts在地图上绘制散点图(任意点)
  6. 包教包会,7段代码带你玩转Python条件语句
  7. WordPress删除重复文章插件
  8. 找出所有子集的异或总和再求和
  9. Silverlight WCF RIA服务(二十九)Silverlight 客户端 10
  10. 支持向量机在风控竞赛数据集上的应用
  11. 火星时代python培训
  12. 高通mtk手机常用指令
  13. 并网光伏发电系统(simulink仿真)
  14. ONLYOFFICE 如何连接集成到 Wordpress 上
  15. 职业规划-三大职业生涯阶段
  16. -webkit-内核兼容处理
  17. VirtualBox 打开虚拟机后,上面的那栏菜单栏不见了的解决办法
  18. RabbitMQ入门中篇
  19. 摘自《大江大河1949》
  20. 使用容联云通信实现发送验证码

热门文章

  1. java 遍历String[]的常用两种方法
  2. 愿2014年02月14日,所有情人情人节快乐!
  3. 29-2-电容触摸屏控制芯片GT911
  4. 《Java特种兵》1.4 功底概述
  5. 金融保险中的几个概念
  6. TensorFlow 1.x 深度学习秘籍:6~10
  7. 濡沫江湖一直显示获取服务器地址,濡沫江湖采集点坐标大全
  8. C#导出到通讯录 生成微信头像跟VCF文件 并把头像保存在阿里云
  9. java中parseInt()方法
  10. [技术讨论] 交流MOSFET的损耗估算方法