If you're new to Termux or Linux commands, you might have seen the word "directory" used a lot. In simple terms, a directory is just a folder. It helps you keep your files and scripts organized inside Termux, just like folders on your phone or PC.
Why are directories important in Termux?
Termux is based on Linux, and Linux systems use directories to store files, run programs, and organize data. Without directories, things would be messy and hard to manage.
How to Check Your Current Directory
To see where you are right now inside Termux, type this command:
pwd
pwd stands for "print working directory". It will show something like this:
/data/data/com.termux/files/home
This is your home directory. It’s like your main folder where everything begins.
How to List Files and Directories
To see the files and folders inside your current directory, use:
ls
This will list everything in your current folder. If you want to see hidden files too, use:
ls -a
How to Create a Directory in Termux
To make a new folder (directory), use the mkdir command:
mkdir myfolder
This will create a folder named myfolder in your current location.
How to Go Inside a Directory
If you want to move into a directory, use the cd command:
cd myfolder
Now you're inside that folder. You can check by running
pwd again.
How to Go Back to the Previous Directory
To go back one step, use:
cd ..
This command moves you up one directory level.
How to Remove a Directory
If you want to delete a directory, use:
rmdir myfolder
But this only works if the folder is empty. To remove a folder and all its files, use:
rm -rf myfolder
Warning: Be careful with rm -rf because it
deletes everything in the folder permanently.
Useful Directory Commands Summary
pwd- Show current directoryls- List files and foldersmkdir foldername- Create a new foldercd foldername- Enter a foldercd ..- Go backrmdir foldername- Remove empty folderrm -rf foldername- Delete folder and contents
Final Words
Directories are the backbone of file management in Termux. By learning how to create and manage them, you're one step closer to mastering Termux and Linux commands.
Take time to practice these commands and build your own folders for scripts, tools, or projects. It will help you stay organized and work faster in the future.
Let me know in the comments if you'd like a guide on file management or Termux automation next!