Linuxlab

Chapter 5

Files and directories

Updated July 3, 2026

Creating and moving:

$ mkdir project          # create a directory
$ mkdir -p a/b/c         # create a chain of directories at once
$ touch notes.txt        # create an empty file (or update its timestamp)
$ cp notes.txt copy.txt  # copy
$ cp -r project backup   # copy a directory with everything in it
$ mv copy.txt archive/   # move
$ mv notes.txt todo.txt  # the same command renames

mv does two jobs at once: it moves and it renames. For Linux, renaming is moving to the same place under a new name.

Deletion in Linux is permanent. There is no trash in the terminal.

$ rm todo.txt            # delete a file
$ rm -r backup           # delete a directory with everything inside

The command rm -rf /something

Free with account

Read the rest with a free account

This chapter is free once you sign in. Create an account to keep reading.

Create a free account

Already have an account? Sign in