Transcript for:
Beginner's Guide to Termux Basics

Hello friends, welcome back to another new video. This video is a full tutorial about Termux for beginners. You will learn how to use Termux, its interface, basic commands, zipping and unzipping files and many more.

So let's begin. But before starting this video, don't forget to like and subscribe to my channel, cause it motivates me a lot. First of all, 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. You can also perform various types of attacks with this application.

It can be run in both rooted and non-rooted Android phones. So it's not compulsory to root your phone for just using Termux. Although if you have a rooted phone, it will be good.

Because in unrooted device, there are some limitations. Most of us don't have rooted device. So in this tutorial, I'm going to use unrooted device to show you how it works. Now you know about Termux, then how you can install it.

Termux is available on Play Store and FDroid too. You can use both of them to install it. I would recommend you to install it from FDroid because right now Google Play builds of Termux are no longer updated because of some issues. If you don't have FDroid installed in your device, simply open your browser and in search bar type FDroid and search.

Here click on the first result that is from FDroid.org. You will be redirected to the official FDroid website. Here click on download FDroid button and click on OK. You can see that the downloading has started and we are redirected to donations page. If you want, you can donate FDroid through various options to support them.

After the downloading finishes, open it and install FDroid in your device. After successful installation open FDroid It will take some time to load applications that are available on FDroid cause it downloads the repositories from their server and updates them After it is completed you can see applications that are available Here click on search button and search for FDroid termux you will see applications named like termux api termux styling but right now you have to only install the application named termux only see here it is on sixth number termux terminal emulator with packages click on it after that click on install and now termux is downloading it is of 84.8 mb after the download completes it will be automatically installed But this is our first time installing something from FDroid, we need to allow installing applications from FDroid. For that click on settings and enable allow from this source button. If something like this will pop up, just accept it and click on install.

You can see we have successfully installed termux in our device. To open it just click on open. This is a Termux application and it is running successfully. Now I will tell you about Termux interface.

If you will click on screen, keyboard will appear and you can write any command or anything here and to erase it you can do it by delete button. Press back button to hide keyboard after you are done writing. If you will swipe from left to right, a session tab will appear. Here you can create different sessions by clicking on new session, it will help you to run multiple programs at a time. But it's not unlimited, you can only create 8 sessions at a time.

If you want to create more, then you need to close existing ones. If you will hold anywhere on screen, you will see copy, paste and more option. If you will click on more, you will see more options like autofill, password, kill process etc. If you want to close the session that you are currently active on, you can do it by clicking on kill process. And press enter.

the session you are active on will be closed as you can see there were eight active sessions now there are seven sessions so this is how you can kill session i will tell you another way to kill session later in this video and there are few additional buttons like escape button ctrl and l buttons you can access them from here above your keyboard and if the keyboard will be hidden it will move to the bottom of your screen so this is how you can create more sessions copy paste or access additional options now let's see some basic commands The first command that you need to enter when you install termux for first time is termux setup storage termux dash setup dash storage and hit enter and then click on allow. With the help of this command we have given storage permission to our termux application so that it can access files and folders of our device. After that if you will type apt list apt space list you will see the list of available installed and upgradable packages. But right now you can see that it is only showing the install packages.

It is because the list has not been updated yet. So how you can update the list? Make sure you are connected to internet and type apt update This command will fetch the packages list from internet and will update our local list that we saw just right now After fetching is finished, you can see it's written 16 packages can be upgraded, run apt list upgradable to see them So if you will type apt list space dash dash upgradable You will see the list of upgradable packages only If you don't want to write the command you can simply copy paste it and hit enter. Now you see the list of only upgradable packages.

In the same way if you will type apt list space dash dash installed you will see the list of installed packages only. We saw that there were 16 packages that can be upgraded. So how you can upgrade them? For that type apt upgrade apt upgrade and hit enter. You will see a message like this.

Need to get 5981 KB of archives? Do you want to continue? Enter Y for Yes and if you don't want to continue, enter N for No.

If you will enter Y, it will start connecting to server and then it will download and install all upgradable packages. It can take few minutes to complete it and in the middle of the installation process, you will get a message to keep the current installed version of your bash or to update it to newer version. I will recommend you to update it by entering Y or I.

So this is how you can update packages in termux. The next command that I am going to tell you is double and command. What we did earlier is first we saw the list by apt list command, then updated the list by apt update command and then upgraded the packages with apt upgrade command. So with the help of double and command you can execute multiple commands at once. Like if I will type apt list double and apt update double and apt upgrade.

Don't forget to add space. and we'll hit enter it will execute all three commands one by one as you can see first it showed the list then updated it but there were no new upgradable packages available so there was nothing to upgrade so if you want to execute multiple commands you can use double and to type them all at once and termux will execute it one by one the next command is help command like if you will type apt space dash dash help You will see the information about apt commands and also the most commonly used apt commands and what they do. As you can see here if I will type apt list it will list packages.

And if we have to search some package we need to use apt search and package name that we have to search. and for installing apt install the next command is clear command this will clear the screen of your termux as we saw just now that for installing package we need to use apt install command and package name for example let's install zip package so for that we have to type apt install zip this will install zip in our termux and for removing or uninstalling the package you can use apt remove and package name for example let's remove the package that we just installed type apt remove zip and hit enter it will ask for confirmation enter y for yes this will remove zip package from termux the another way to install and uninstall packages is by using pkg command for example if you have to install zip package using pkg command you have to type pkg install zip and hit enter You can see zip is successfully installed again. And now to uninstall it. In apt we used apt remove. But in pkg we need to use pkguninstall command to uninstall packages.

Like here we will type pkguninstall zip. and it will remove zip package from our termux so this is how you can install and uninstall packages in termux now let's clear the screen by clear command if you want to see the commands that you have typed earlier like browsing history in browsers you can see your command history by typing history command in terminal Earlier I told you you can kill the ongoing session by holding anywhere on screen clicking on more and then kill process and hit enter But this takes time you have to go through so many steps to kill one freaking session Another alternate method is to type exit and hit enter it will automatically kill the session. There was only one session running so the termux application is also closed.

If there are multiple sessions and you kill the session you are currently active on it will switch to another session instead of closing the entire application. So with exit command you can kill sessions easily let me open termux again and now i will tell you how you can navigate through files and folders in termux if you will type pwd that means print working directory it will show you currently in which folder or directory you are like here we are in home directory and if you want to go one directory up like here if i want to go in files directory i will type cd that means change directory and space followed by two full stop and hit enter now we have moved to file files directory if i will do pwd again you can see that now we are in files directory to see the files and folders of your current working directory you can do it by typing ls like here it shows two folders home and user folder or you can say them directories directories and folders are same and their names are written in blue color as you can see here now to change your working directory to sub directory of your parent directory you can do it by typing cd and directory name for example if i want to change my directory to user directory here i need to type type cd user, cd means change directory and then the directory name. Now my current working directory is user directory.

You can confirm it by pwd command. By typing ls again here you can view files and folders of user directory. To change your directory to home directory you must be thinking I need to go back to files directory and then change my directory to home directory. Yes you can do like that too.

But there is a very simple command that will change your working directory to your home directory. no matter where are you and that command is cd command Just type cd and enter. Your current working directory will be changed to home directory. You can confirm it by pwd command.

Earlier I told you that you can go one directory up by cd space and followed by two full stop. And what about going two directory up? Like here how can I directly go to com.termux directory?

For that you can type cd space followed by two full stop then backward slash again two full stop. Now we are directly in com.termux directory. Let's type cd to move back to our home directory. And if I will do ls here, you can only see one storage directory that is our internal storage of phone. How you can create your own directories?

You can do it by mkdir command followed by directory name. mk means make and dir means directory. Now here, if I want to create haha directory, I will type mkdir and haha that is ha ha. And our haha directory will be created. You can say it by ls.

Now we see storage and haha directory. Let's change our working directory to Haha by typing cd Haha. Now our current working directory is Haha.

You just saw how to create a directory. Now how you can create a file? You can create files using touch command.

Type touch and then file name. And I recommend you to enter files extension too. Like if you create a text file named APB, you should type touch apb.txt.

Txt is a text file extension. so it will be easier to identify which type of file it is and there will be less confusion. Now see files are written in normal text color unlike directories that are in blue color.

This is how you can create files by using touch command. Now to create a hidden file just type full stop In the beginning of the file name for example touch.hiddenfile.txt Here I added full stop before the file name hidden file. And that hidden file doesn't show up by ls command. To view both hidden and visible files you can type ls dash. It will also show other information along with file name.

And now see that there is a file named hidden file.txt. If you don't want to see this additional info and only want to see files and folders, you can do this by typing ls space dash a. This command will only show you visible and hidden files and folders name. To delete a file, you can type rm and then file name.

For example, let's delete that hidden file. We will type rm space dot hidden file dot txt. And now let's do ls-a There is no file named hiddenfile.txt, it is successfully deleted Not only hidden files, you can delete visible files too by rm command Let's delete apb.txt rm apb.txt And if I will do ls, it doesn't show anything Because now it's an empty directory We can also create multiple files at once by touch command Type touch and write all the file names you want to create and don't forget to add space after each file name.

Like here I created two visible and one hidden file at once. If I will do ls it will only show two files because one is hidden. And if I will do ls-a it will show all three files.

You can delete multiple files too at once by using same method just type rm and all file names. And if you are feeling lazy. and don't want to write file names you can copy paste them too and hit enter all files are deleted now same way you can create multiple directories too and if you want to create hidden directory you can add full stop before writing the directory name Like here I created three directories, third one is hidden.

We can see that directory by ls-a command. To delete a directory you cannot do it by rm command. You have to type rmdir, rm for remove and dir for directory and then directory name.

Here I removed hidden directory. And if I will do ls-a you can see it's deleted. Same way we can delete these remaining directories too. And again our haha directory is empty. Let's create one text file in this haha directory.

I will name it 1.txt And then let's go one directory up by cd.. command. This will change our working directory to home because haha directory was in home directory. Now I told you, you can delete directories with RMDIR command but that only applies for non-empty directory. If I will try to delete Haha directory by RMDIR command that is not empty directory because we created a file there.

It will fail and you will see. see message fail to delete directory it is not empty so how you can delete non empty directories to delete a non empty directory you need to type RM space dash RF and directory name here I will type RM dash RF haha and we'll hit enter the non-empty directory will be deleted if i will do ls i can't see haha directory same goes for ls dash a i can't see higher directory because it is now deleted now let's create our haha directory again by mkdir command and let's see if we will create the directory we deleted can we get the files back So the answer is no it is empty. Now let's clear the screen by clear command. Now I will show you how you can move or copy files and folders in termux. Let's create two directories named 1 and 2. Change your working directory to 1. And now if you want to move directory 2 here inside one directory.

So for that first type pwd. You can see the path, copy it and then get outside of this directory 1. Here we have to move directory 2 inside directory 1. So for that type mv and directory name. Here it is 2. And then path where you have to move it.

We already copied the path. So we will just paste it and hit enter. Now if I will do ls you can see that the directory 2 is not here. And if I will change my working directory to directory 1 and will do ls.

Directory 2 is here inside directory 1. So this is how you can move an empty directory. Now let's see can we do the same for non-empty directory. Let's change our working directory to directory 2. We will do ls here and you can see it's empty.

Let's create more directories 3, 4 and 5. And more files 1.txt, 3.py, 8.apk. By ls you can see all the files and directories that we created in directory 2. Let's move back to directory 1 by cd... Here there is directory 2 and now it's not empty.

I will try to move it outside the directory 1 that means inside haha directory mv2 and we will paste the same path that we copied last time but I will erase slash 1 so the path will be for haha directory and we will hit enter. now directory 1 is empty let's move back to haha directory and here we can see directory 2 and if i will change my working directory to directory 2 to make sure the files and folders are also moved with the directory so yes they are also moved too so with mv command you can move both empty and not empty directories same goes for files you can move single or multiple files at once using mv command the same way we move directories like here i moved two files and one directory to directory one let's change our working directory to directory one to see if they are moved or not So yes the files and directories are moved here successfully. Now what about copying? You can also copy files and directories by cp command, then file name and path but if you are copying directory you need to type cp dash r and then file your directory name and path.

Here I was also copying directory 3 and did not specify dash r so I got error. Now I will write again with dash r specified and I will copy them to directory 2. It's done. You can see the files and directories are still here because we have copied them not moved. Now let's check in directory 2. Are these files and directories are really copied?

So yes both one file and one directory is successfully copied. Same way you can copy single files too like I will copy 3.py to directory 1. It's still here and it is also in directory 1. Let's create directory named 5 and remember for copying directory you need to specify dash r after cp or else you will see error like this. Again to change directory you have to type cd and directory name to list files ls To move one directory back cd..

and to move two directories back cd.. Now I am in home directory. Let's move to our directory one that is in haha directory.

Now to view the contents of a file you can use cat command. It will show you what's written in that file. Like here we created 1.txt. If I will do cat 1.txt I will see nothing. Because there is nothing in that file we created an empty text file.

How to write in that text file? For that we need a text editor. There are so many available but mostly people use nano text editor.

It is pre-installed but in some cases if it is not you can install it by typing apt install nano. it is already installed in my termux to edit a file using nano text editor type nano and the file name here i will type nano 1.txt see it's empty you can write anything you want to be written in this file for example i will write this is termux tutorial If you will press CTRL and G, you can see the help section. From here you can read about various nano button combinations for navigating in nano text editor, saving and deleting files and many more. To close this press CTRL plus C or X. You can press C or X to close it.

To save it we need to write out and for that press CTRL and O. then it will ask for file name if you want you can change it else press enter you will see the message like this wrote one line that means it is successfully saved now close nano text editor by pressing ctrl and x button we did touch 1.txt earlier but we saw nothing if i will do again touch 1.txt i will see the sentence that i wrote in this file same like apt if you want to know more about cat command you can type cat space dash dash help to see it Now let's clear the screen. Now I will tell you about Termux API. With the help of Termux API, one can access many features of Android device directly from the terminal. For example, you can access your camera and many more.

So how to install Termux API? Open FDroid. After opening, search for Termux. and you will see termux api at the top of the list click on it and then click on install after downloading finishes a message will pop up whether you want to install this application or not click on install and then it will be successfully installed now open termux again and type cd command to move to home directory and then type apt install termux dash api This will install termux api package in termux After successful installation, you can access your device camera, battery information and many more directly from terminal Like if I will type termux-battery-status See this time I have not added any space It will show information about my device battery Like its health, percentage left, plugged or unplugged, its temperature You can also reduce or increase your screen brightness for that type termux-brightness and then you can type value from 0 to 255 in which 0 means the lowest and the 255 means highest brightness of your screen.

For example if I will type 255 Here we got error because I have not given permission to termux api to change my screen brightness level To solve this search for termux api long press on its icon and then click on app info then app permission and allow access to the things you want here I will allow everything and then switch back to termux my termux was closed so I started again and by default we are in home directory let's try again to change brightness of a screen using terminal type termux brightness and the value you want for example 255 we got error again oh I forgot to allow termux api to modify system settings I apologize for that again go to app info of termux api and in other permissions find modify system settings and allow it maybe in your phone it will be in another section sometimes it differs now again let's switch back to termux and type termux dash brightness 255 and my screen brightness is at the highest level I know you can't see any difference because I am screen recording it but try this in your termux and then you will see change in brightness level of your screen. In the middle of recording my recorder stopped due to low space so I deleted some files and started recording it again. Before this I told you about termux brightness with the help of this command you can increase or decrease brightness level of your screen.

Next one is termux call log termux dash call dash log this will list your call log history directly in your terminal. To know about your camera you can type termux dash camera dash info this will show you information about your both front and back cameras. like its physical size, capabilities the first one's ID was 0 and the second one's is 1 and the second one is front facing camera let's change our directory to haha here as you can see there are only two directories and nothing else to take a photo directly from your terminal you need to type termux-camera-photo-c and then the camera ID so for front it is 1 and for back it is 0 I want to take photo from back camera I will type 0 and then the file name you want to give to that pic Here for example I will type back.jpeg.

You can name anything you want and hit enter. This will click a picture from back camera and save it with the name back.jpeg. It's done.

Now if I will do ls again you will see a file name back.jpeg. That means it did actually click the pic from my back camera. So this is how you can click pictures directly from your terminal.

Next one is termux-clipboard-git. This will show you the last text you copied. Like here it shows black dot jpeg.

Because I copied that text to copy paste it to delete that file. To get the text saved in clipboard we use termux dash clipboard dash get. Now to save any text in clipboard you can use termux dash clipboard dash set. And then the text you want to save for example I will save haha.

Oh I accidentally missed to type a in clipboard. This time let's copy paste it and then I will type text haha. because this is the text I want to save in clipboard.

We got no error that means it has been saved. Now it shows in my Gboard Haha because it is saved in Clipboard. If I will click on it, it will be pasted here. So this is how you can get or set text in Clipboard directly from Terminal. See this time I did get and I got Haha because I saved it last time using termux-clipboard-set.

Here also if I will click on paste, Haha will be pasted because it is saved in Clipboard. Now to get your contact list directory in your terminal you can do it by termux-contact-list This will list all of your contacts in alphabetical order in terminal Like this name and their phone numbers Let's clear the screen by clear command To access your location information based on your device location you can type termux-location for it It will show your latitude, longitude, altitude, accuracy See with the help of of api you can do so many things and you don't have to leave your terminal you can also access your phone's microphone with the help of termux api and can record things for that type termux dash microphone dash record space dash d it will start recording after you enter Enter this command and the recording file will be saved as termux audio recording file in your internal storage. As you can see the max duration of recording is 15 minutes. Now to know about current recording session type termux-microphone-record-i This will show you details about current recording. Like it shows is recording and then true.

That means the recording is active now. If you want to stop it before 15 minutes you can type termux-microphone-record-q Q means Quit. This will stop ongoing recording and save it as Termux audio recording in your internal storage.

To know more about mic recording commands, type termux-microphone-record i. This time you don't have to add dash before i. If you will type dash i, it will show you details about current recording. See it shows you all the commands and their uses. If I will type termux-microphone-record i, This time it will say is recording false because we are not recording anything now.

Let's see where the recording file is saved. It is in internal storage. Change your working directory to home directory by cd command. And then copy paste the path from above if you don't want to type it and hit enter. And don't forget to erase the file name because we are changing directory so the path should be some directory not file.

and here we are in our internal storage directory this is the audio we recorded it is in m4a format you can follow these steps to record audio within terminal anytime no need to close terminal and use some third-party app to record something from microphone you can also access your phone sensors within termux for that type termux dash sensor and this will show the arguments that you have to give with termux sensor like here if i will type termux dash sensor space dash l it will show me the list of all sensors that are in my device same way you can give different arguments with termux sensor for various things. Now to access your message directly in termux, type termux-sms-list. This will list your messages directly in termux. I told you way to access your messages, call logs and contacts directly in terminal. Now how to call someone directly from terminal?

For that type termux-telephony-call and enter the number you want to call for example 12345 and hit enter. Select your application if you have more than one calling application in your device. And here we successfully called 12345 from terminal with the help of termux api. To know more about sim cards in your device type termux-telephony-cellinfo don't add dash between cell and info or else you will get an error. This will show information about the sim cards that are in your phone And if you will change cell info to device info like termux-telephony-deviceinfo This will show you telephony information about your device Like if your data is enabled or not, phone type, network operator and many more You can also turn on and turn off your phone's torch without leaving terminal Type termux torch and then type on or off Typing on will turn it on and off will turn it off Next one is to see which text to speech engine is installed in your device Type termux-tts-engines This will show you information about all the text to speech engines that are in your phone I got only one and it is google text to speech engine Now if you will type termux-tts-speak And then add any sentence or word that you want text to speech engine to talk Like I will type hello I am google this is termux tutorial And if I will hit enter Google TTS engine will start speaking the sentence that I wrote.

Hello im google this is tamux tutorial. Same way if you want to do it in real time. Just type tamux dash tts dash speak hit enter and now write anything. After hitting enter TTS engine will start speaking it. Like I am doing here.

U O U I I Y A T A Hello I'm Google. Nice to meet you. Hi, bye.

After you are done you can stop it by pressing ctrl and Z button These were some examples of what you can do with the help of termux API if you are interested in more commands of termux API I have given the link to all termux API commands in description. You can check them out Now I will show you how you can style your termux application hold anywhere on screen click more and here if I will click on Style you will be redirected to Play Store for installing termux styling application, but it is paid application on Play Store Wanna know something? I made you install FDroid because of this cause termux styling and other termux applications like termux tasker and widgets are paid on play store but they are free to install from FDroid so lets open FDroid application and search for termux styling and then install it it is of 18mb after downloading completes click on install and after installation switch back to automax Again hold on screen, click on more and then click on style.

You got two options, you want to change color or font. If you will click on color, you will see a huge list of colors. You can select any of them according to your choice.

Same goes for fonts, a huge list of fonts and you can select any style you want. I will go with Roboto font. This is how you can style your termux without paying anything for any application.

If you want to change again you can change it later. It's up to you how you want your terminal to look. Now I'm going to tell you how you can zip and unzip files in Termux. For that you need to have zip and unzip packages installed in Termux.

If they are not installed type apt install zip unzip and hit enter. This will install both packages. It is already installed in my Termux.

To zip some directory like here I will try to zip directory 1. First write zip after that name you want to give to the zip and then directory name you want to zip and hit enter. It says stored 0%. You can see that there is a zip file named 13.zip.

Let's move this zip file to directory 2 by mv command. Now to unzip it, type unzip and then zip file name. Here it is unzip 13.zip. This is our directory one but you can see that it is empty. Let's delete it by rmdir command and then this zip file.

You saw that vzip directory 1 it only stored the directory name not its files. So to zip a non-empty directory you need to give an argument with zip command and that argument is dash r. So in our case it will be zip-r then the zip file name 13.zip and then directory name that is 1. This time it added directory files also and it says stored 0% because those files are empty.

I just created them earlier to show you how touch command works. With mv command you can rename directories too. Like here I did mv 1 3. This command rename directory 1 to directory 3. It's unzip 1 3.zip now. and if i will do ls you can see all the files that were in this directory before unzipping we rename directory 1 to directory 3 that means the same files will be in directory 3 too and yes they are same this is how you can zip and unzip files and directives for non-empty directory using argument dash r and for file you can zip without an argument to know more about zip command type zip space dash dash help this will show you more arguments that you can use for various things. So these were some basic commands to get you started with termux.

Keep using termux and you will learn more as you use and if you get stuck somewhere you can dm me on insta I will try to reply you as soon as possible. That's it for this video I will see you in next one.