TeLinux v2 is a secure, Python-based automation tool that transforms your Telegram chat into a dual-mode Linux controller.
It features a Hybrid Architecture:
- Chat Shell: For quick, non-blocking commands (
ls,whoami,dnf). - Web Terminal: A full interactive terminal inside Telegram for complex tasks (
cmatrix,vim,htop).
- 💻 Hybrid Terminal: * Standard: Text-based output for simple commands.
- Interactive (New!): Launches a secure Web App for tools that require live input.
- 🛡️ Smart Freeze Protection: The bot detects interactive commands (like
topornano) and automatically offers to open them in the Web Terminal instead of freezing the chat. - 🌐 Cloudflare Tunneling: Secure, unlimited access to your terminal over the internet without port forwarding.
- 🚀 Fire-and-Forget GUI: Launch graphical apps (
firefox,vscode) on your PC screen instantly. - 📂 Bidirectional File Transfer: Download (
/pull) or Upload files easily. - ⚡ Auto-Sudo: Privileged commands (
dnf,systemctl) are automatically run with sudo.
- OS: Fedora, Ubuntu, Debian, Arch, etc.
- Python: 3.12+
- Core Tools:
python3-pip,ttyd,cloudflared - Telegram: Bot Token from @BotFather.
Fedora (Universal Method):
# 1. Install Python pip and ttyd
sudo dnf install python3-pip ttyd
# 2. Add Cloudflare Repo manually (Fixes config-manager errors)
sudo curl -fsSL [https://pkg.cloudflare.com/cloudflared-ascii.repo](https://pkg.cloudflare.com/cloudflared-ascii.repo) | sudo tee /etc/yum.repos.d/cloudflared.repo
# 3. Update and Install Cloudflared
sudo dnf makecache
sudo dnf install cloudflaredUbuntu / Debian:
sudo apt install python3-pip ttyd
# Note: You must manually download the 'cloudflared' .deb from Cloudflare's website.pip install python-telegram-bot psutilThis script handles the complex startup of the Web Terminal, the Tunnel, and the Bot automatically.
-
Create the script in your Home folder:
nano ~/start_telinux.sh -
Paste the following code: (
⚠️ IMPORTANT: Replace/home/youruserwith your actual home path!)#!/bin/bash # --- CONFIGURATION --- # SET THIS TO YOUR ACTUAL USER HOME PATH USER_HOME="/home/ayukashyap" BOT_SCRIPT="$USER_HOME/TeLinux/tele_shell.py" # 1. Cleanup old processes killall ttyd cloudflared 2>/dev/null sleep 2 # 2. Start Web Terminal (ttyd) cd $USER_HOME nohup ttyd -p 7681 -W bash > $USER_HOME/ttyd.log 2>&1 & sleep 5 # 3. Start Cloudflare Tunnel (Stable Mode: IPv4 + HTTP2) nohup cloudflared tunnel --edge-ip-version 4 --protocol http2 --url [http://127.0.0.1:7681](http://127.0.0.1:7681) > $USER_HOME/tunnel.log 2>&1 & sleep 15 # 4. Extract Dynamic URL grep -o 'https://.*\.trycloudflare\.com' $USER_HOME/tunnel.log | head -n 1 > $USER_HOME/current_url.txt # 5. Start the Bot python3 $BOT_SCRIPT
-
Make it executable:
chmod +x ~/start_telinux.sh
To run the bot 24/7 in the background:
-
Create the service file:
mkdir -p ~/.config/systemd/user nano ~/.config/systemd/user/pcbot.service
-
Paste this configuration: (
⚠️ Check theExecStartpath matches your script location)[Unit] Description=TeLinux Hybrid System After=network.target [Service] # UPDATE THIS PATH TO MATCH YOUR SCRIPT ExecStart=/home/ayukashyap/start_telinux.sh Restart=always RestartSec=10 Environment=PYTHONUNBUFFERED=1 [Install] WantedBy=default.target
-
Enable and Start:
systemctl --user daemon-reload systemctl --user enable --now pcbot.service
Edit tele_shell.py to add your credentials:
TOKEN = "YOUR_BOT_TOKEN_HERE"
AUTHORIZED_USER_ID = 123456789| Command | Description |
|---|---|
/start |
Initialize connection and check status. |
/help |
View all available features. |
/health |
View CPU, RAM, and Disk usage stats. |
/pull [file] |
Download a file to your phone. |
cmatrix / top |
New: Opens the interactive Web Terminal. |
ls / dnf |
Standard chat-based execution. |
TeLinux v2 uses a Traffic Controller logic:
- Interactive Commands: Apps like
vim,nano,adb shellare detected and redirected to the Web Terminal. - Background Tasks: Apps like
firefoxare launched in a detached session on the host display. - Standard Tasks: Simple outputs are sent back as chat messages.
This project is open-source. Feel free to fork and customize!