======================================================================== TERMUX REBUILD GUIDE — Samsung S25 Ultra Written for: start from nothing (fresh install OR after factory reset) Two jobs covered: (A) ADB / debloat set-up (B) OCR — turning image-PDFs into readable text ======================================================================== HOW TO READ THIS FILE - Do the steps IN ORDER the first time. - Anything in a box like this: some command gets typed (or pasted) into Termux exactly as written, then press Enter. - "~ $" or "$" at the start of a Termux line is just the prompt — you do NOT type that bit. Only type what comes after it. - Wait for each command to finish before doing the next. - If it asks "Do you want to continue? [Y/n]" — type y and Enter. ======================================================================== SECTION 0 — INSTALL TERMUX ITSELF ======================================================================== Do NOT install Termux from the Play Store version (it's outdated/broken). Get it from F-Droid or GitHub: - F-Droid app -> search "Termux" -> install - or GitHub: github.com/termux/termux-app/releases (get the .apk that matches your phone — for the S25 Ultra that's the arm64-v8a one) Open Termux once it's installed. You'll get a black screen with a prompt. ======================================================================== SECTION 1 — FIRST-TIME BASE SET-UP (do this once) ======================================================================== STEP 1.1 Update Termux's own package lists and upgrade what's there: pkg update && pkg upgrade -y (If it asks about keeping or replacing config files, just press Enter to accept the default.) STEP 1.2 Give Termux access to your phone's storage (so it can reach your documents, Downloads, etc.): termux-setup-storage Your phone will pop up a permission request — tap ALLOW. After this, your phone's internal storage is reachable at: ~/storage/shared (So your Downloads folder = ~/storage/shared/Download ) ======================================================================== SECTION 2 — JOB A: ADB + DEBLOAT SET-UP ======================================================================== WHAT THIS IS: ADB lets you disable Samsung/Google apps you don't want, WITHOUT root and WITHOUT deleting them (fully reversible). You run it from the phone to itself over wifi. STEP 2.1 Install the Android tools (this is what gives you the "adb" command): pkg install android-tools -y STEP 2.2 Turn on Wireless debugging on the phone: Settings -> Developer options -> Wireless debugging -> ON (If you don't see Developer options: Settings -> About phone -> Software information -> tap "Build number" 7 times.) STEP 2.3 PAIR (first connect only). On the Wireless debugging screen tap "Pair device with pairing code". It shows an IP:PORT and a 6-digit code. In Termux (put in the numbers IT shows you): adb pair 192.168.1.88:PORT It asks for the code — type the 6 digits, Enter. NOTE: the pairing port is a random one, different every time. Use whatever number the phone is showing right then. STEP 2.4 Switch to the FIXED port 5555 so you don't have to re-pair every time. On the MAIN Wireless debugging screen it shows an "IP address & Port" (a DIFFERENT port from the pairing one). Connect to that first: adb connect 192.168.1.88:39531 (use the IP:PORT the phone actually shows). Then flip it to permanent 5555: adb tcpip 5555 adb connect 192.168.1.88:5555 Your phone's IP is under: Settings -> About phone -> Status information. Or type ip addr in Termux and look for the 192.168.x.x address. STEP 2.5 If it ever says "more than one device / emulator", you've got a stale connection. Kill it: adb disconnect 192.168.1.88:39531 Then carry on with plain adb shell . STEP 2.6 USEFUL LISTING COMMANDS (to see what's on the phone): adb shell pm list packages (all installed) adb shell pm list packages -s (system apps only) adb shell pm list packages -s -u (system, incl. uninstalled) adb shell pm list packages -d (disabled ones) adb shell pm list packages -e (enabled ones) STEP 2.7 TO DISABLE something (reversible — this is the safe way, NOT uninstall): adb shell pm disable-user --user 0 PACKAGE.NAME.HERE TO PUT IT BACK: adb shell pm enable --user 0 PACKAGE.NAME.HERE >>> IMPORTANT: after a phone REBOOT, wireless debugging drops the 5555 connection. To get back in you just redo STEP 2.4 (the connect + tcpip 5555 + connect lines). Pairing (2.3) is NOT needed again unless you factory reset. ======================================================================== SECTION 3 — JOB B: OCR (image-PDF -> readable text) ======================================================================== There are TWO routes here. They do different things. You said you'd rather test both, so both are below. Accuracy matters more than speed for you, so notes reflect that. ROUTE 1 = OCRmyPDF -> gives you the SAME pdf but with a hidden, selectable/searchable TEXT LAYER added on top of the scan. This is the "searchable PDF" one. Easiest, cleans/deskews pages first. ROUTE 2 = PaddleOCR -> reads the scans and spits out the TEXT into separate text files. Best RAW accuracy on messy/low-quality scans. More set-up. You can install one or both. They don't clash. ------------------------------------------------------------------------ ROUTE 1 — OCRmyPDF (searchable PDF, hidden text layer) ------------------------------------------------------------------------ STEP R1.1 Install it (this pulls in Tesseract + Ghostscript too): pkg install ocrmypdf -y STEP R1.2 Do ONE file to test. Say your file is in Downloads: cd ~/storage/shared/Download ocrmypdf --deskew "myfile.pdf" "myfile_OCR.pdf" - "myfile.pdf" = your original (unchanged) - "myfile_OCR.pdf" = new copy WITH the searchable text layer --deskew straightens crooked scans for better accuracy. STEP R1.3 BATCH — do a WHOLE FOLDER at once. Put all your image-PDFs in one folder (e.g. make a folder called "scans" inside Download), then: cd ~/storage/shared/Download/scans for f in *.pdf; do ocrmypdf --deskew "$f" "OCR_$f"; done Every PDF gets an "OCR_" searchable copy alongside it. Originals untouched. Handy extras you can add before the "$f": --rotate-pages auto-fix upside-down / sideways pages --clean clean speckles before reading (accuracy on grubby scans) e.g.: ocrmypdf --deskew --rotate-pages --clean "$f" "OCR_$f" ------------------------------------------------------------------------ ROUTE 2 — PaddleOCR (best raw accuracy, outputs text files) ------------------------------------------------------------------------ STEP R2.1 Install the bits it needs: pkg install python libjpeg-turbo libpng poppler -y pip install paddlepaddle paddleocr pdf2image (poppler + pdf2image = the part that splits a PDF into page images, which is the "break the PDF into pictures" step you described. PaddleOCR then reads those pictures.) STEP R2.2 Make a tiny reusable script. Type this once: nano ocr.py An editor opens. Paste this in (it reads every PDF in the current folder and writes a matching .txt for each): ----------------------------- paste from here ----------------------------- import os, glob from pdf2image import convert_from_path from paddleocr import PaddleOCR ocr = PaddleOCR(use_angle_cls=True, lang='en') for pdf in glob.glob("*.pdf"): name = os.path.splitext(pdf)[0] pages = convert_from_path(pdf, dpi=300) out = [] for i, page in enumerate(pages): img = f"_tmp_{i}.png" page.save(img) res = ocr.ocr(img, cls=True) for line in (res[0] or []): out.append(line[1][0]) os.remove(img) with open(name + ".txt", "w") as f: f.write("\n".join(out)) print("done:", name + ".txt") ------------------------------ to here ------------------------------------ Save and exit nano: press Ctrl+O then Enter (saves), then Ctrl+X (exit). dpi=300 = high accuracy. Bump to 400 for tiny/faint text (slower). STEP R2.3 RUN it on a folder of PDFs: cd ~/storage/shared/Download/scans cp ~/ocr.py . python ocr.py Each PDF gets a matching .txt file next to it with the read-out text. (First run downloads the language model — one-off, needs internet.) ======================================================================== SECTION 4 — ONE-BLOCK RECOVERY (after a FACTORY RESET) ======================================================================== WHAT THIS IS: once Termux is freshly installed (Section 0) and you've run the two base commands (1.1 and 1.2), paste this SINGLE block to reinstall EVERYTHING above in one go. Then you're back to where you were. Copy-paste the whole block at once: pkg update -y && pkg upgrade -y && \ pkg install -y android-tools ocrmypdf python libjpeg-turbo libpng poppler && \ pip install paddlepaddle paddleocr pdf2image && \ echo "ALL DONE — adb, OCRmyPDF and PaddleOCR are installed." After that block finishes: - For ADB: redo Section 2 from STEP 2.2 (pair + connect). - Your ocr.py script (Route 2) is NOT restored by the block — keep a copy of THIS text file and just redo STEP R2.2 to recreate it. ======================================================================== QUICK REMINDER OF WHICH IS WHICH ======================================================================== OCRmyPDF = searchable PDF, text layer baked in, easiest. -> Route 1 PaddleOCR = separate .txt files, best on rough scans. -> Route 2 Both take a whole folder at once. Originals are never changed. ========================================================================