Termux | Run Linux command and Shell Script on android | Computer Bits Daily

Termux is an Android terminal emulator.

There are lots of questions like  " How do you run a command in Termux? ", and "  How to run Shell Script in Android Smart Phone using Termux" running in our minds.

And answers to all these questions are here.

To run Linux Command and Shell Script using Termux requires the installation of termux packages.

- Nano :
Text Editor to create a file.

- Need to update and upgrade Termux

After Update and Upgrade termux and installing Nano packages on an android phone.  You're ready to run Linux Command and Linux Shell-Script using termux. 

How to get a Linux terminal on Android

    Watch How to run Linux Command on Termux

    Before we learn How to run Linux command and Shell Script on android, let's take a look at Some Important Termux commands we must remember:

    - To clear all screen content run the command.

    $ clear

    - To find the current working directory.

    $ pwd

    - To change our current working directory to another directory. Here I’m moving in /java directory/folder.

    $ cd /java

    - If you want one directory/folder to move

    $ cd..

    - If you want to get back to two directories use.

    $ cd ../../

    - To Create New File: To Create New Directory/Folder use mkdir commad Stands for make a new directory.

    $ mkdir <new-directoy-name>

    - To Delete Directory/Folder in Termux

    $ rmdir <directory-name>

    - To delete File

    $ rm <file-name>

    $ls 
    - List Direcotry 

    Here is How You Can Write and Run Shell Script Programs on Your Android Devices

    Step 1: Installation of  Termux in android smartphone

    Play Store Version of Termux is Deprecated. Due to Android 10 issues, Termux and its plugins are no longer updated on the Google Play Store and have been deprecated. The most recent version for Android >= 7 was v0.101. It is strongly advised not to install Termux apps from the Play Store any longer.

    Download From:

    - F-Droid : F-Droid is a robot with a passion for Free and Open Source Software (FOSS) on the Android platform.

    Click here to dowload F-Droid and get Termux.

    Github :
    Click here to get termux from Github


    - Now open F-Droid, then update repository.

    - After that serach termux in F – Droid and install Termux app as shown in image below.

    GCC / Clang C/C++ Compiler On Android Using Termux

    Step 2: First of all Update and Upgrade Termux

    - Open Termux

    - To Update Termux type command

    $ apt update

    - To Upgrade Termux type command

    $ apt upgrade

    Step 3:  
    Let's Run some Linux Command

    - Type cal and press Enter

    Output:

    root@kali:~# cal 
       September 2022     
    Su Mo Tu We Th Fr Sa  
                 1  2  3  
     4  5  6  7  8  9 10  
    11 12 13 14 15 16 17  
    18 19 20 21 22 23 24  
    25 26 27 28 29 30 

    - Type date and press Enter

    Output:

    root@kali:~# date
    Wed 07 Sep 2022 19:04:16 IST
    root@kali:~# date +%T
    19:04:20
    root@kali:~# date -d "1994-11-06"
    Sun 06 Nov 1994 00:00:00 GMT

    Step 4: Let's create Shell Script 

    - To create Shell Script program file with .sh extension

    Open the Termux app and install nano package.

    $ pkg install nano

    - This command will install nano text editor if not available.

    - Type $ nano Hello.sh

    - This will
    create Hello.sh file and open file in nano text editor.

    - Now write code in nano text editor as given below.

    echo "Computer Bits Dialy"

    - Press Ctrl + s to save file and Ctrl +x to exit nano text editor.

    Step 5: To run Hello.sh Script

    - To Run Hello.sh shell-script file, we need to make this file executable.
    - For that Run $ chmod +x Hello.sh command
    - This will make Hello.sh file executable.
    - To run .sh file  type $ ./Hello.sh  and press enter
    - Output will be "Computer Bits Dialy"

    Step 6: To exit Termux type command

    $ exit

    Learn by Watching Video tutorials on how to create and run Linux Shell Script in Termux. 

    Possible solution for “E: Unable to locate package clang” Error

    • Solution 1: use $ apt update command and then try to install package

    • Solution 2: use $ pkg upgrade command and then try to install package

    • Solution 3: use $ termux-change-repo command and then try to install package

    • Solution 4: use $ pkg install root-repo command and then try to install package

    • Solution 5: use $ termux-setup-storage command and then try to install package

    I hope you like "How to run and learn Linus Command and Shell-Script in Android using Termux". 

    Before you leave, I'd like to invite you to join me on this journey! Follow these to stay up to date on new content.

    Android Free Application:

    Online Computer Courses - Computer Bits Daily

    Facebook Page-

    https://facebook.com/computerbitsdaily/

    Quora Space:

    Quora Space - Computer Bits Daily

    YouTube Channel:

    Computer Bits Daily: Tutorial Tips Tricks

    Telegram:

    https://t.me/computerbits

    👌Keep Learning |💕Keep Sharing | 💪Stay Safe!


    Post a Comment

    0 Comments