Skip to main content

Creating and Deleting Files and Directories

Commands for making and removing files or directories.


Create an Empty File​

Command:

touch newfile.txt

Create a File with Text​

Command:

echo "Hello Linux" > hello.txt

Create a New Directory​

Command:

mkdir project

Create Nested Directories​

Command:

mkdir -p /data/logs/backup

Remove a File​

Command:

rm file.txt

Remove Directory and Its Contents​

Command:

rm -r oldfolder

Remove an Empty Directory​

Command:

rmdir emptydir