Basic Commands in Termux

These are Basic linux commands which are easy to learn and can be helpful while executing or playing things around in termux.


Note : The command which contains the green color means it is variable and the code can change according to given conditions.







  • Command:
pkg update && pkg update 


or

  • Command:
apt update && apt upgrade

  • While updating, it will ask permission to update or not, simply press y to update 
  • You can also remove the above work by adding -y at the ending of any commands, it automatically run the command without asking the permission

Example:
  • Command:
pkg update && pkg update -y

or

  • Command:
apt update && apt upgrade -y




Give Storage Permission to Termux:

  • Command:
termux-setup-storage

After entering this command it will ask for the permission, simply click on allow to give permission.



Command to present directory:

  • Command:
pwd

This command to display the present working directory.



Command to display list of all files and directories:

  • Command:
ls 

This command will display the list of all the folders, files and directories in your current working directory.


Command to display list of all hidden files:

  • Command:
ls -a

This command show the  list of all hidden files and directories including hidden content.

Command to go or move forward in directory:

  • Command:
cd "directory-name"

Example: 

  • Command:
cd storage

This command will help you to go or move in a folder or directory in termux, here "storage" is the directory which I am moving to.




Command to go back or move backward in directory:

  • Command:
cd ..

This command will move the present working to previous working directory.

Command to clear the screen:

  • Command:
clear


This command will clear all displayed results or contents in termux.


Command to create a folder or directory:

  • Command:
mkdir Folder-name

or

  • Command:
mkdir Directory-name

This command will help you to create folder or directory in termux, mkdir stands for make directory and to check the created directory just type ls.



Command to remove or delete folder or directory:

  • Command:
rmdir folder-name

or

  • Command:
rmdir directory-name

This command will help you to remove folder or directory in termux, mkdir stands for remove directory



Command to remove or delete the files:

  • Command:
rm -rf file-name

Caution: Dont delete system files.




Command to remove or delete the  folders or Directories:

  • Command:
rm -rf folder-name

Caution: use this command with caution, as it can remove all the files in the folder or directory, so use this command if the folder or directory is not necessary.




Command to copy and paste the file

  • Command:
cp file-name file-path
This command will help you to copy and paste the files from one directory to another directory.


Example: 
  • cp My.txt /storage/downloads
  • here My.txt is file-name 
  • and /storage/downloads is the file-path




Command to move the file:

  • Command:
mv file-name file-path
This command will move the files from one directory to another 

Example: 
  • mv My.txt /storage/downloads
  • here My.txt is file-name 
  • and /storage/downloads is the file-path



Command to search specific package:

  • Command:
pkg search package-name

This command will search the package you want to search.




Command to check the details of a package:

  • Command:
apt show nano


This command will show all the details of a package.



Command to list all the available packages:

  • Command:
 pkg list-all

This command will show all the packages that are available in the APT repository of termux and it can also show you if the packages are installed in termux or not.



Command to install a Package:

  • Command:
pkg install package-name
This command will download and install the given package in termux

Example: 
  • pkg install figlet
  • here figlet is the package-name.




Command to uninstall a package:

  • Command:
pkg uninstall package-name
This command will uninstall the package from the termux, before uninstalling it will ask whether you want to delete the package or not, just type y and the package will be uninstalled from the termux.




Command to check all the running processes in termux:
  • Command:
top
This command will show all the processes or tasks running in the termux.




Command to make an executable file:

  • Command:
chmod +x file-name

This command will give all the permission for the file to make it an executable file.




Command to check content inside of a file:

  • Command:
cat file-name

This command will display all the content of a file in the termux



Command to delete a file:

  • Command:
rm file-name

This command will display all the content of a file in the termux




Command to display the installed packages:

  • Command:
dpkg --list

This command will display all the installed packages in termux.



Command to display all recent used commands:

  • Command:
history

This command will help to find out which command is used to execute a task in termux



Command to check the username:

  • Command:
whoami

This command will show the username in the termux.



Command to check the time spent in termux:

  • Command:
uptime

This command will show the time user has spent while executing a task in termux.



Command to check the kernel information:

  • Command:
uname -a

This command will show the kernel,architecture and date with time of your device in the termux




Command to check the used memory:

  • Command:
free -h -t

This command will show the amount of free and used memory of your system in termux.