28 August 2026
Linux CLIWelcome to this series called Most Used Linux Commands.
In today's post, I will going through my most used file manipulation commands and what they're used for...
Creates a blank file...
| Command | Description |
|---|---|
touch file.txt |
in the current directory |
touch ../file.txt |
in the directory below the current |
touch /path/to/file.txt |
specifying full path to file |
Tip - You can do multiple at a time i.e. touch file1.txt file2.txt
Outputs the content of a file...
| Command | Description |
|---|---|
cat file.txt |
in the current directory |
cat ../file.txt |
in the directory below the current |
cat /path/to/file.txt |
specifying full path to file |
Creates an empty directory...
| Command | Description |
|---|---|
mkdir stuff |
in the current directory |
mkdir ../stuff |
in the directory below the current |
mkdir /path/to/stuff |
specifying full path |
Change directory...
| Command | Description |
|---|---|
cd stuff |
in the current directory |
cd ../stuff |
in the directory below the current |
cd /path/to/stuff |
specifying full path to directory |
cd .. |
to the parent directory |
Every file/directory has a group associated.
More on Linux Permissions here.
| Command | Description |
|---|---|
chgrp mygroup file.txt |
for files |
chgrp mygroup dir |
for direectories |
Every file/directory can be read/writen/executed for user/group/owner (or all)...
| Command | Description |
|---|---|
chmod +r file.txt / chmod -r file.txt |
add / remove read (for all) |
chmod +w file.txt / chmod -w file.txt |
add / remove write (for all) |
chmod +x file.txt / chmod -x file.txt |
add / remove execute (for all) |
chmod u+x file.txt / chmod u-x file.txt |
add / remove execute for user |
chmod g+x file.txt / chmod g-x file.txt |
add / remove execute for group |
chmod o+x file.txt / chmod o-x file.txt |
add / remove execute for owner |
Set the ownership of a file/directory...
| Command | Description |
|---|---|
chown user:group file.txt |
for files |
chown user:group dir |
for directories |
chown -R user:group dir |
recursively for sub-directories |
Shows utilisation of directories...
| Command | Description |
|---|---|
du |
current directory |
du dir |
another directory |
du .. |
the parent directory |
du /path/to/dir |
specifying full path to directory |
du -s /path/to/dir |
summarises everything in the directory to total value |
du -h /path/to/dir |
gives values in human-friendly format i.e MB |
Tip - You can chain multiple options together i.e. du -sh
Lists files and directories...
| Command | Description |
|---|---|
ls |
in the current directory |
ls dir |
in another directory |
ls .. |
the parent directory |
ls /path/to/dir |
specifying full path to directory |
ls -l /path/to/dir |
results appear in long-form (lists permissions, sizes etc...) |
ls -h /path/to/dir |
human-friendly sizes i.e. MB |
ls -a /path/to/dir |
includes dotfiles / hidden files |
Removes an empty directory...
| Command | Description |
|---|---|
rmdir stuff |
in the current directory |
rmdir ../stuff |
in the directory below the current |
rmdir /path/to/stuff |
specifying full path |
Remove files or directories full of files...
| Command | Description |
|---|---|
rm file.txt |
in the current directory |
rm ../file.txt |
in the directory below the current |
rm /path/to/file.txt |
specifying full path to file |
rm -r dir |
in the current directory |
rm -r ../dir |
in another directory |
rm -r /path/to/dir |
the parent directory |