Skip to main content

Termux - The android Terminal

Termux

No hesitation, you can certainly call Termux “The Android terminal”. Owing to it’s simplicity and capabilities, Termux stand so close to the original Linux terminal.

Who is it for and who should read this?

This is beginner article which will introduce you to the fundamentals of using Linux terminal on android devices. To understand something here, you should barely understand English and nothing else is a pre-requisite. πŸ€“
Let us figure out the basics.

 Android


If you are using an android device, you know that android is the operating system that run the show on your mobile phone. Android is an operating system with its core based on Linux. In fact, android is based on a modified version of Linux optimized for mobile devices.

Terminal

Terminal is a command line interface which can be used to communicate with or control the Operating system. So, a linux terminal can be used to control a Linux device. Terminal is a tool that comes default with a full fat Unix or Linux oprating system. Terminal helps the users do a lot of things by running the commands. By default, android does not enable the Terminal for the regular users. That means, we cannot get a terminal on android device out of the box.

Termux, the star of the show

Termux is an application that can be downloaded from Play store. Termux is a terminal emulator. Emulator is nothing but a system that does a sort of simulation of something on top of another system. In this context, the Termux will act as a Linux Terminal on top of the Android operating system.

Let us get it.

We can download and install Termux app from Google Play. This is a clean app and there is no shady business here. ✌ For the lazy ones, it is just a click away. πŸ˜‰
The look and feel of the Terminal( rather, Termux)

After installing Termux, upon opening , it shows up with a black screen and white letters. The crowd familiar with the DOS command line or Linux terminal will feel at home for sure.


Some upgrades

The programs and the installed packages will be updated by the corresponding developers from time to time. The updates are nothing but new features, bug fixes or some improvements. We should also try to keep our system upto date by installing the updates. It is easy to run two commands to keep your system updated.

#This is how we add some comments in shell 
apt update


After the above command is executed, you can see any available updates for your installed packages.



Now we have to install the available packages. To install the available packages, just run the command given below. It will prompt you for the confirmation to install. Please input Y or y.

apt upgrade




Good, we are all set. Now we can look for having some fun.
Running some custom programs

We have a working Terminal now, thanks to Termux. We can run custom programs on your android device. The easy way to do something is to run some applications already available on github.

Github

Github is a free public repository available at https://github.com/. You can create a free account, save and share your code or applicatons with other developers. You can access the repostories which are made available to the public by other developers. It is a fantastic collaboration tool and doesn’t cost you a penny.
Getting the public code or applications from Github

Create an github account. This is a no brainer activity. Nobody need any assistance here.
Install git on Termux. To install git on Termux, run the following command on the Termux terminal.

pkg install git



Checkout or clone the code from github to your phone.

I am going to use a Github repo called “ShellScripts” owned by the developer “RapidSailor”. This is by far the simplest shell script repo you can get. It is a one line command to copy the code to your local phone storage.
#The below command will copy the code from the given repo to your phone. 
git clone https://github.com/RapidSailor/ShellScripts

Inspect downloaded code

When you run the above command , the repo is copied to your current woring folder on your phone. To see what all files are there , run the below commands. The below command will list all the repos which you have copied to the phone. right now, it will be only one.

ls 
#Navigate into the downloaded repo 
cd ShellScripts 
#check the contents in the downloaded repo 
ls


You can see that this repo has only one file - ‘echo.sh’ .
Making the file executable

We have only one file that can be executed. To execute any file in Linux, the file should have the ‘Execute’ permission. Running one command will make a file executable.

This command ‘chmod’ is used to change the mode. Tha parameters ‘+x’ indicate the execute permission to the training file names.

chmod +x echo.sh #


Now the file is executable. 😎
Run the application 😁

Running an executable file is another single command. since this program is an shell script, we run the below command.
sh echo.sh


Now the program will execute and display any outcome as needed. The screenshot below with show the sequence of execution and its outcome.



We are done executing a basic shell script program using Termux on your android phone. πŸ˜‡

Doesn’t it feel great and nerdy 😈 ? Now you are ready to explore the possibilities of Termux. Get out and explore.
A word of caution - 😡 Do not clone and run anything you come across.

Not all the code you see will be safe . There may be malicious code as well. Inspect the code once before you execute something. If you are not very sure , do some googling about that repo. If you suspect something, do not execute.

Stay safe and enjoy. 🀩

Comments

Popular posts from this blog

Public private key based login to Unix computer

Public private key based login to Unix computer We know that we can login to a Unix system in several ways. One drawback with username password mode is that there will be requirement to update the password frequently. In such cases, we go for the public key based login.  Required software 1. Putty and puttygen Putty can be downloaded from the download page of  https://www.putty.org/ The downloaded zip contains both putty and puttygen. 2. Winscp This is an optional software which gives a window when dealing with ssh, ftp, sftp connections. This can be downloaded from their official site. https://winscp.net/eng/download.php How it works In the public key based login, we will generate a public key and corresponding private key pair. We can optionally protect the private key using a password so that if someone gets your private key, they wont be able to put it into real use [The secret would be needed for loading your private key to the ssh client]. Process Create the public - private k

PDF files : Merge pdf files into one , extract the pages into new one

 Today, we will take a look into he pdf file management. Many a times we come across situations where  1. We have to extract certain pages of a large pdf file. 2. We have merge several pdf files into a single pdf file. We are covering the basic usage below. We are using Ubuntu Linux for this exercise. Merge several files into a single file 'Pdfunite' is the utility that I will be using today. In my example, I have 3 input files (pdf1.pdf, pdf2.pdf, pdf3.pdf)   Place all the files to be merged in a folder. Use the terminal to navigate to the folder. Execute the command as below: pdfunite is the utility, then we list out all the files in the sequence it has to be added to the resulting file. The last name is the name of the resulting file. The file will be created by the utility. pdfunite pdf1.pdf pdf2.pdf pdf-result.pdf  Now you can see that there is a new large file created using the given input pdf files.  Extract certain pages from a PDF file I am using the 'pdfseparate&#

Linux - How to find all the files that contains a given string

Linux - Find all files that contains a given string. In order to find all the files that contains a given string, we can make use of several commands. One of the simplest option is to use the grep command. grep -R '/path/to/theFiles/' -e 'pattern-to-search' With this execution, grep will go through all the files in the provided location recursively(since we gave -R option) and look for the string-pattern to look for. Then, it will provide a list of files that contains our given string-pattern.