Expanded Termux Commands Guide
## Basic Commands
1. **Navigation Commands**
- `pwd`: Prints the current directory.
- `ls`: Lists files and folders in the current directory.
- `cd <directory>`: Changes to a specific directory.
- `cd ..`: Moves up one level in the directory tree.
- `ls -l`: Lists files and folders with detailed information (permissions, sizes, etc.)
- `ls -a`: Lists all files, including hidden ones (files starting with a dot).
2. **File Management Commands**
- `touch <file_name>`: Creates an empty file.
- `mkdir <directory_name>`: Creates a new folder.
- `rm <file_name>`: Deletes a file.
- `rmdir <directory_name>`: Deletes an empty folder.
- `cp <source> <destination>`: Copies a file or folder.
- `mv <source> <destination>`: Moves or renames a file or folder.
- `find <directory> -name <filename>`: Searches for a file in a directory.
- `locate <filename>`: Locates a file (requires updated database).
## Intermediate Commands
1. **Editing Files**
- `nano <file_name>`: Opens a file in the Nano text editor.
- `cat <file_name>`: Displays the content of a file.
- `echo <text>`: Outputs text to the terminal or creates a file.
- `echo <text> > <file_name>`: Writes text to a file, overwriting it.
- `echo <text> >> <file_name>`: Appends text to a file.
2. **Package Management**
- `pkg update`: Updates the list of available packages.
- `pkg upgrade`: Upgrades all installed packages.
- `pkg install <package_name>`: Installs a new package.
- `pkg uninstall <package_name>`: Removes an installed package.
- `pkg search <package_name>`: Searches for a package in the Termux repository.
3. **Networking Commands**
- `ping <website>`: Checks if a website is reachable.
- `wget <url>`: Downloads a file from a URL.
- `curl <url>`: Fetches data from a URL.
- `ifconfig`: Displays network interface information.
- `netstat`: Shows network connections, routing tables, and interface statistics.
- `ssh <user>@<host>`: Connects to a remote system via SSH (Secure Shell).
## Advanced Commands
1. **System Information**
- `uname -a`: Displays system information.
- `df -h`: Shows available disk space in human-readable format.
- `top`: Displays running processes and system resource usage.
- `htop`: An enhanced version of `top` with a more user-friendly interface.
- `free -h`: Displays memory usage in human-readable format.
2. **File Compression**
- `tar -cvf <archive_name.tar> <file_or_folder>`: Creates a tar archive.
- `tar -xvf <archive_name.tar>`: Extracts a tar archive.
- `gzip <file_name>`: Compresses a file using gzip.
- `gunzip <file_name.gz>`: Decompresses a gzip file.
- `zip <archive_name.zip> <file1> <file2>`: Compresses files into a zip archive.
- `unzip <archive_name.zip>`: Extracts a zip archive.
3. **Permissions**
- `chmod <permissions> <file>`: Changes file permissions.
- `chmod 755 <file>`: Gives read, write, and execute permissions to the owner and read/execute
permissions to others.
- `chown <user>:<group> <file>`: Changes the owner and group of a file.
- `chgrp <group> <file>`: Changes the group of a file.
4. **Custom Scripts**
- `bash <script_name>`: Runs a shell script.
- `./<script_name>`: Executes a script in the current directory (requires executable permissions).
- `chmod +x <script_name>`: Makes a script executable.
- `crontab -e`: Edits the cron job list to schedule tasks.
5. **Termux-Specific Commands**
- `termux-setup-storage`: Grants Termux access to your phone's internal storage.
- `termux-info`: Displays information about your Termux installation.
- `exit`: Closes Termux.
## Bonus Tips and Advanced Usage
- **Creating and Managing Aliases**: You can create shortcuts for long commands using aliases.
- `alias <alias_name>='<command>'`: Creates an alias.
- Example: `alias ll='ls -l'` will let you use `ll` instead of `ls -l`.
- **Using Screen or tmux**: These tools allow you to manage multiple terminal sessions within one
window.
- `pkg install tmux`: Installs tmux (terminal multiplexer).
- `tmux`: Starts a new tmux session.
- `tmux attach`: Reattaches to a tmux session.
- **Redirecting Output**: You can save the output of a command to a file.
- Example: `ls -l > files_list.txt` saves the list of files to a text file.
## Practice Exercise
1. **Navigation and File Management**
- Navigate to `/sdcard`: `cd /sdcard`
- Create a folder: `mkdir TermuxTest`
- Go into the folder: `cd TermuxTest`
- Create a file: `touch test.txt`
- Edit the file: `nano test.txt`
- Display the file: `cat test.txt`
- Copy the file to the home directory: `cp test.txt ~/`
- Move the file to `/sdcard`: `mv test.txt /sdcard`
2. **Package Management and Networking**
- Install a package: `pkg install wget`
- Use wget to download a file: `wget http://example.com/sample.txt`
- Ping a website: `ping google.com`
- Check memory usage: `free -h`