
List of Essential Bash Commands
Here are the most frequently used commands that will become second nature to you:
Command Purpose
pwd Print Working Directory (Where you are now)
ls List files and directories
cd Change directory
mkdir Make a new directory
touch Create an empty file
rm Remove (delete) files or directories
mv Move or rename files
cp Copy files or directories
Let’s explore them one by one:
1. pwd - print working directory
pwd
This shows the absolute path of the current working directory.
Example:
/home/yourname/Desktop
2. ls – List Directory Contents
ls
Lists all files and folders in the current directory.
Options:
ls -l → Long listing format (permissions, owners, timestamps)
ls -a → Show hidden files (those starting with .)
ls -la → Combine both
Example:
ls -la
3. cd – Change Directory
cd foldername
Moves you into a different directory.
Examples:
cd Documents # Go to Documents
cd .. # Move one level up
cd ~ # Go to home directory
cd /etc # Absolute path
4. mkdir – Make Directories
mkdir foldername
Creates a new directory.
Example:
mkdir Projects
You can also create nested folders:
mkdir -p Projects/Python/Scripts
5. touch – Create Empty Files
touch filename
Creates a new empty file.
Example:
touch hello.txt
You can also create multiple files at once:
touch file1.txt file2.txt file3.txt
6. rm – Remove Files and Folders
rm filename
Deletes a file.
To remove a folder recursively:
rm -r foldername
To avoid accidental deletions, use:
rm -ri foldername
The -i option will prompt you for confirmation before deleting.
Warning: There is no recycle bin. Files deleted with rm are gone unless you have backups.
7. mv – Move or Rename
mv source destination
Examples:
mv file1.txt folder/ # Move to folder
mv file1.txt file2.txt # Rename file1 to file2
8. cp – Copy Files and Folders
cp source destination
Examples:
cp file1.txt backup.txt # Copy file
cp -r folder1 folder2 # Copy folder recursively
File Navigation and Manipulation – Real Scenario
Let’s try this:
mkdir mytest
cd mytest
touch test1.txt test2.txt
mkdir data
mv test1.txt data/
cp test2.txt data/
rm test2.txt
cd ..
rm -r mytest
What this does:
- Creates a folder mytest
- Goes inside and creates two files
- Moves one file into a subfolder
- Copies the other file
- Cleans everything up
Hidden Files and File Permissions
Hidden Files
Files starting with a . are hidden by default.
ls -a
Example: .bashrc, .git, .ssh
To create a hidden file:
touch .hiddenfile
File Permissions
ls -l
Output:
-rw-r–r– 1 user user 0 Jul 29 10:22 file1.txt
Breakdown:
r = Read
w = Write
x = Execute
Format:
[Owner][Group][Others]
Example:
rw- means read/write
r– means read-only
To change permissions:
chmod +x script.sh # Make executable
chmod 755 script.sh # rwxr-xr-x
Summary
Navigation pwd, cd, ls
File Management mkdir, touch, rm, mv, cp
Hidden Files ls -a, . prefix
Permissions chmod, ls -l