गाइडप्रकाशित: 5 मिनट में पढ़ें

फोन पर ही adb shell commands चलाएं: Android terminal, No Root

बिना PC और root के फोन पर ही adb shell चलाएं। App shell और adb shell user के rights का फर्क, और pm, am, settings, dumpsys, wm, cmd जैसे काम के commands।

फोन पर ही adb shell जैसे commands चलाने के लिए आपको PC या root की ज़रूरत नहीं। Android 11+ की Wireless debugging से कोई app फोन के अपने adb daemon से जुड़ सकता है, और तब commands shell user के rights से चलते हैं, वही rights जो PC से adb shell पर मिलते हैं। ADB Kit app का Shell tab ठीक यही देता है: एक असली terminal, जिसमें pm, am, settings, dumpsys, wm और cmd सब चलते हैं। नीचे दोनों तरह के shell का फर्क और काम के commands हैं।

दो तरह के shell: फर्क समझें

App shell (connected नहीं)adb shell (Wireless debugging से connected)
ADB Kit में labelApp shell · limitedadb shell · full access
किसके rightsसिर्फ इस app की permissionsshell user, जैसे PC का adb shell
pm disable-user, pm grant, settings put globalनहीं चलेंगेचलेंगे
input tap, screencap, dumpsys का पूरा outputज़्यादातर नहींहाँ
ls, cat, ping, getpropहाँहाँ
Root (su)नहींनहीं

ध्यान दें: adb shell भी root नहीं है। System partition बदलना, दूसरे apps का private data (/data/data/...) पढ़ना, ये काम इससे नहीं होते। पर settings बदलना, apps disable करना, permission देना-हटाना जैसे ज़्यादातर काम हो जाते हैं।

ADB Kit में Shell setup

  1. Google Play से ADB Kit install करें।
  2. Home की guide से Wi-Fi, Developer options और Wireless debugging ON करें, फिर Start pairing और notification में 6 अंकों का code डालें। (पूरा तरीका)
  3. Shell tab खोलें। ऊपर adb shell · full access दिखे तो आप connected हैं। App shell · limited दिखे तो Use adb दबाएं।

Shell tab की खूबियां:

  • एक ही shell खुला रहता है, तो cd, history (↑) और shell की अपनी Tab completion चलती है।
  • Ctrl+C से चलता हुआ command रोकें। top, vi, less जैसे full-screen programs भी चलते हैं।
  • Termux जैसी दो extra key rows: ESC, Tab, CTRL, ALT, arrows, HOME, END, PGUP, PGDN।
  • cd टाइप करते ही folders/files के suggestions आते हैं, tap करके नाम पूरा करें।
  • Snippets: बार-बार के commands save करें, एक tap में चलें।
  • दो उंगलियों से pinch करके text छोटा-बड़ा करें।
  • ⋮ menu में Import file और Export file।

काम के commands

Apps (pm, cmd package)

pm list packages -3              # आपके install किए apps
pm list packages -s | grep google # system apps में खोजें
pm path com.whatsapp             # APK कहाँ है
pm disable-user --user 0 com.example.bloat
pm enable com.example.bloat      # वापस चालू
pm clear com.example.app         # app का data मिटाएं
pm grant com.example.app android.permission.CAMERA
cmd package list packages -d     # disabled apps

System apps disable करते समय सावधान रहें। गलत app (जैसे launcher या SystemUI से जुड़ा) बंद करने से फोन अजीब व्यवहार कर सकता है। हर बदलाव pm enable से वापस हो सकता है।

Apps खोलना और रोकना (am)

am start -a android.settings.SETTINGS
am start -a android.intent.action.VIEW -d https://adbkit.com
am force-stop com.example.app

Settings (settings)

settings get system screen_off_timeout
settings put system screen_off_timeout 600000      # 10 मिनट
settings put global animator_duration_scale 0.5    # animations तेज़
settings put global window_animation_scale 0.5
settings put global transition_animation_scale 0.5

जानकारी (dumpsys, getprop)

getprop ro.product.model
getprop ro.build.version.release
dumpsys battery
dumpsys meminfo com.example.app
dumpsys window | grep -i mCurrentFocus   # अभी कौन सा app सामने है

Screen (wm, input, screencap)

wm size                  # resolution
wm density               # DPI
wm density 400           # DPI बदलें
wm density reset         # वापस
input keyevent KEYCODE_HOME
screencap -p /sdcard/Download/shot.png

wm density बदलने पर screen का सब कुछ छोटा-बड़ा हो जाता है। अजीब लगे तो wm density reset चलाएं। Xiaomi/Redmi/POCO पर input और pm grant के लिए USB debugging (Security settings) ON होना चाहिए (Xiaomi गाइड)।

ज़्यादा commands: ADB commands cheat sheet।

Commands को automate करें

ADB Kit के Auto script tab में commands की list (recipe) बनाएं, जैसे "animations तेज़ करो + screen timeout 10 मिनट"। Recipe को एक tap में या रोज़ एक तय समय पर schedule करके चला सकते हैं, और JSON file में import/export कर सकते हैं। Schedule के समय Wireless debugging ON होना चाहिए, वरना run failed दर्ज होता है और notification आता है।

Files कहाँ जाती हैं

Shell शुरू में /sdcard (shared storage) में खुलता है। App shell में Android कुछ folders पढ़ने नहीं देता। तब ऊपर एक bar दिखता है: Only adb can open these files, जिससे adb shell पर उसी folder में आ सकते हैं। PC की तरह adb push/pull की जगह ⋮ menu का Import file और Export file इस्तेमाल करें।

आम दिक्कतें

  • Permission denied: आप App shell में हैं, या command को root चाहिए। ऊपर label देखें और Use adb दबाएं।
  • Security exception (Xiaomi पर): USB debugging (Security settings) ON करें।
  • Restart के बाद connection नहीं: Wireless debugging फिर से ON करें, ADB Kit खुद reconnect करेगा (क्यों बंद होता है)।
  • Command बहुत देर चलकर रुक गया: Settings › Shell में command time limit है (default 15 सेकंड), वह recipes और schedule वाले runs पर लागू होता है।

Safety

Internet से कॉपी किए commands बिना समझे न चलाएं। pm uninstall, pm clear और settings put असली बदलाव करते हैं। कोई बदलाव करने से पहले पुरानी value settings get से नोट कर लें, ताकि वापस कर सकें।