Full Termux Tutorial | Basic Commands In Termux

    - Advertisement -

    Hello friends, this is the Termux tutorial. In this article, you’ll learn about how to use Termux? Its interface, basic commands, zipping and unzipping files, and many more. Upon completing this tutorial you’ll be able to use Termux hassle-free. This article is basically a full Termux Tutorial and at the end of this article, there will be a downloadable Termux tutorial basic commands PDF file. So make sure to download it.

    full termux tutorial

    What Is Termux?

    Termux is an Android terminal emulator that creates a Linux environment in your device in which you can install so many packages that are available for operating systems like Kali Linux. So it’s like a lightweight Linux system on your device and you can install almost every Linux packages in Termux. Also, the packages that can perform various types of attacks.

    Do You Need To Root Your Phone To Use Termux ?

    You can run the Termux application on both rooted and non-rooted android devices. So it is not compulsory to root your phone for just using Termux. Although, if you have a rooted phone, it’ll be beneficial for you because, in an unrooted device, there are some limitations.

    How To Install Termux ?

    Termux is available on PlayStore and F-droid too. You can download and install it from both sources. But, I would recommend you to install it from F-Droid because Google play builds of Termux are no longer updated.

    Click here to download Termux from F-Droid

    After you click the link above, you’ll be redirected to the F-droid site. From there download the latest version of Termux. I would recommend you to download the F-droid application from that site to manage Termux and all its add-ons conveniently.

    Termux Interface

    - Advertisement -

    When you’ll open Termux for the first time, you’ll see your Termux as shown in the image below.


    With the help of your keyboard, you can write commands or anything that you want. To erase what you’ve written use your keyboard’s delete button. To hide the keyboard, press the back button of your phone.

    If you’ll swipe from left to right, a session tab will appear. From there you can create different sessions by clicking on a new session, it will help you to run multiple programs at a time. But you can only create up to 8 sessions at a time.

    By holding anywhere on the screen, you’ll see options like Copy, Paste, and More options. In More options, there are options like Autofill, Password, Kill process, etc. You can close the session that you are currently active on by selecting Kill process and then press enter.

    There are few additional buttons like the escape button, Ctrl, and Alt buttons above your keyboard and if the keyboard will be hidden it will move to the bottom of your screen.

    Basic Commands of Termux Tutorial

    Below are some basic commands that you can use in your Termux application.

    Give Termux internal storage access

    After you enter this command, a message will pop up. Whether to allow storage access to the Termux application or not. Click on allow to give storage permission to our Termux application. So that you can access files and folders of your internal storage within Termux.

    - Advertisement -

    Update packages list in Termux

    As I told you earlier that Termux just creates a Linux environment. So you can use almost all commands that we use in Linux distros.

    apt list
    apt list

    By typing apt list , you’ll see the list of available, installed, and upgradable packages. This list is stored locally in your Termux and you need to update it. If there is a new package or a new version of the package available on the internet. It won’t show you until you update the list. While installing some package that is not in your local list, will give you unable to locate package error.

    How to update the list?

    apt update

    To update list type apt update . After you run apt update command, the apt package manager will fetch the latest list from the internet, and then it will update the local list. It requires internet so make sure you are connected to the internet.

    After it is done, you’ll see a message like “16 packages can be upgraded run apt list --upgradable to see them”. That means the newer version of 16 packages is available. To see those 16 packages that can be upgraded to the latest version type apt list --upgradable . In the same way, type apt list --installed to see the list of installed packages only.

    How to update those packages?

    - Advertisement -
    apt upgrade

    Type apt upgrade and hit enter, to upgrade upgradable packages. This apt upgrade command will download all the upgradable package’s latest version and then install it in your Termux. It can take some time to complete. It usually depends on your internet speed.

    Installing and Uninstalling Packages

    To install a package, you can use apt install command. Let’s say, I want to install python in my Termux, so I’ll type apt install python . This will install python package in my Termux.

    apt install <package-name>
    apt install python

    To uninstall a package use apt remove and package name. For example to remove python package from Termux type apt remove python.

    apt remove <package-name>
    apt remove python

    Alternatively, you can use pkg install and package name to install package and to uninstall pkg uninstall and package name.

    pkg install <package-name>
    pkg uninstall <package-name>

    Manual of all commands

    You can know more about any command by referring to its manual. For example, If I want to know more about apt commands. I can refer to the manual of apt. But first, we need to install manual in our Termux using the apt package manager.

    apt install man

    The above command will install man package. In this man package, you’ll find the manual of almost every command. To open manual of command just type man and then command. Like to open manual of apt command. I need to type man apt

    man apt
    result of man apt command
    man apt

    After you are done reading, press q to close the manual.

    Execute multiple commands at once

    Let’s say we want to execute apt update and apt upgrade command at once. We don’t want to wait for apt update to complete and then type apt upgrade. We want to type them at once and then after apt update finishes apt upgrade will be automatically executed. For that we can use two ampersands (&&). With the help of && , we can write multiple commands at once. Just use && after every command and they will be executed in the order you write them.

    <first-command> && <second-command>
    apt update && apt upgrade

    The above command is an example of the usage of && command. Not only two, but you can also execute as many commands you want at once with the help of && .

    Navigating through folders/directories in Termux

    Let’s see how we can navigate through files and folders in the Termux application. By typing pwd command in your terminal. You will see the path of the directory/folder you are in. As shown in the image below, I’m in home directory and the path for home directory is printed in the terminal. pwd means print working directory.

    pwd    #prints working directory
    pwd command in termux - Termux tutorial

    To go one directory up, like if I want to get inside files directory that is above home directory (as shown in the image above). I need to type cd .. cd means change directory and .. for going one directory up. In the same way, you can use cd ../.. to go two levels up. No matter where are you, to directly get to home directory type cd in the terminal. By typing just cd command in terminal you can get inside home directory.

    cd        #change working directory to home directory
    cd ..     #change directory to one level up
    cd ../..  #change directory to two levels up
    cd command in termux tutorial
    cd command in Termux

    Lisitng files/directories in Termux

    To list all files and directories of the current working directory type ls in terminal and hit enter. All visible files and directories will be displayed in terminal. (As shown in the image below)

    ls    #lists files and directories
    ls command in termux

    ls command only displays visible files and directories in the terminal. To display hidden files and directories type ls -a in the terminal.

    ls -a   #displays hidden files and directories
    ls -a command in termux
    ls -a

    To display more info about files and directories, you can use ls -l command. We can write multiple options of ls command at once. Like to display hidden files we use ls -a , to know more info about files we use ls -l command. So to display hidden files too and also more info about both hidden and visible files we can type ls -la command.

    ls -la   #displays hidden files and more info about files
    ls -la command in termux
    ls -la
    Change working directory to subdirectory

    To change the working directory to any subdirectory use cd command. Type cd and then the name of directory you want to get in. For example if I want to get in usr directory, I need to type cd usr in terminal.

    cd <directory name> #changes working directory
    cd usr
    change directory in termux
    changing directory
    Creating Directories

    To create your own directory, you can use mkdir command. mkdir stands for make directory. Type mkdir and then the directory name to create a directory. For example, if I want to create a directory named ‘project’, I need to type mkdir project command in terminal.

    mkdir <directory_name>   # creates a directory
    mkdir project

    To create a hidden directory just add a full stop ( . ) before writing the name of the directory. For example, to create a hidden directory named hidden_porjects I need to type mkdir .hidden_projects command in the terminal.

    mkdir .<directory_name>   # creates a hidden directory
    mkdir .hidden_projects

    You can also create multiple directories at once using mkdir command, just type the name of directories that you want to create after mkdir command. For example, if I want to create 4 directories named test1, test2, test3, and test4 at once. I need to type mkdir test1 test2 test3 test4 command in the terminal.

    mkdir <directory_name> <directory_name>
    mkdir test1 test2 test3 test4 
    mkdir command in termux

    Creating Files

    Using touch command you can create files in Termux. Type touch and then the file name to create a file. For example, If I want to create a file named code.txt I can do it by typing touch code.txt command in the terminal.

    touch <file_name>  #creates a file
    touch code.txt

    As I told you guys earlier to create a hidden directory just add full stop at the beginning of the directory name, same goes of creating hidden files. Just add full stop before the file name. For example if I want to create a hidden file named secret.txt, I can do that by typing touch .secret.txt in the terminal.

    touch .<file_name>  #creates hidden file
    touch .secret.txt

    You can also create multiple files at once. Type touch and then the name of the files that you want to create. For example, if I want to create multiple files named code1.txt, code2.txt, and code3.txt. I can do that by typing touch code1.txt code2.txt code3.txt command in the terminal.

    touch <file_name> <file_name> #creates multiple files
    touch code1.txt code2.txt code3.txt
    termux tutorial creating files
    Note : Name of files are written in white colour in the terminal and the name of directories/folders are written in blue colour. 
    Deleting files and directories

    To delete a file you can type rm (stands for remove) and then the file name. As I told you earlier you can also delete multiple files at once by specifying file names after rm command.

    rm <file_name> <file_name> #deletes specified files
    rm code.txt code1.txt code2.txt
    rm command in temrux tutorial

    To delete empty directories you can use rmdir (stands for remove directory) and then the directory names that you want to delete.

    rmdir <directory_name> <directory_name> #deletes directories
    rmdir dir1 dir2

    If you will use just rmdir command to delete a non-empty directory, you’ll get an error. So the simplest way to delete a non-empty directory is to use rm -rf command and then the directory name.

    rm -rf <directory_name>  #deletes no empty directories
    rm -rf dir3
    rmdir and rm -rf command in termux
    rmdir & rm -rf
    Moving and copying files and directories

    To move files or directories in Termux you can use mv command that stands for move and to copy files and directories you can use cp command that stands for copy.

    To move a directory type mv and then the directory name that you want to move and then the path of the place where you want to move the directory. For example if I want to move termux directory in scripts directory I need to type mv termux scripts in the Termux terminal.

    mv termux scripts
    mv <directory-name> <path>
    mv termux scripts

    The same goes for files, to move a file type mv then file name, and then the path of the place you want to move the file.

    mv <file-name> <path>
    mv scripts/termux

    Now to copy a directory, you need to type cp -r and then the directory name after that type the path.

    cp -r <directory-name> <path>

    And to copying file is same as moving a file, Just replace mv with cv, so to copy a file type cp then file name and after that the path of the place where you want to copy the file.

    cp <file-name> <path>

    View contents of a file

    You can view the content of a file using cat command just type cat and then the file name. For example, to view what’s written in a text file named learn.txt, I need to type cat learn.txt command in terminal.

    cat learn.txt
    cat <file-name>
    cat learn.txt

    Edit files

    There are so many text editors available for Linux that you can use in Termux to edit files. The most popular one is the nano text editor, so first, install the nano text editor in your Termux using the apt package manager.

    apt install nano -y

    After the nano text editor has been installed type nano and then the file name that you want to edit, after that the editor will launch. For example, if I need to edit learn.txt, I need to type nano learn.txt in the termux terminal.

    nano learn.txt
    nano <file-name>
    nano text editor in termux
    nano learn.txt

    In the editor after you are done making changes, press Ctrl + O to save the changes and then Ctrl + X to exit the nano text editor.

    Termux API

    With the help of Termux API, one can access many features of an Android device directly from the Termux terminal. For example, one can access the camera of an android device directly from the Termux terminal.

    Click here or the link given below to visit the Termux tutorial for Termux API, in that you’ll know about how to install Termux API and all the Termux API commands.

    What Is Termux-API ? Termux-API Commands

    Zipping and Unzipping files in Termux

    To zip files or to unzip a file you can use zip & unzip packages. Install zip package using the apt package manager. Type apt install zip unzip -y to install zip and unzip packages.

    apt install zip unzip -y  #installs zip and unzip

    After both zip and unzip package is installed you can now zip files or unzip a file using zip and unzip packages in your Termux application.

    Zipping files and directories

    To zip a directory type zip -r and then the zip file name and then the name of the directory that you want to zip. For example to zip a directory named projects to a zip file name type zip -r projects command in your Termux terminal.

    zip -r projects
    zip -r <zip-file-name> <directory-name>
    zip a directory in termux

    To zip a file just type zip then zip file name and then the file name that you want to zip. For example to zip a file named in a zip file named type zip in your termux terminal.

    zip <zip-file-name> <file-name>
    zip a file in termux

    Unzipping a zip file in Termux

    To unzip a zip file just type unzip and then the zip file name that you want to unzip. For example to unzip a file named file type unzip in your Termux.

    unzip <zip-file-name>
    unzip zip file in termux

    So this is how you can zip and unzip files and directories in your Termux application. To know more about zip commands type zip --help in your Termux terminal.

    Last words about termux tutorial

    In this Termux tutorial, we learned some basic commands that you can use to perform various tasks in your Termux application. Keep using Termux and you’ll learn more as you use the Termux application. I’ve also created a youtube video about the Termux tutorial that is given below, watch it if you have any doubts.

    - Advertisement -

    Recent Articles

    1 Comment

    Leave A Reply

    Please enter your comment!
    Please enter your name here