mkdir, cp, mv, rm in Linux: working with files
Updated July 3, 2026
mkdir, cp, mv and rm create directories and copy, move and delete files.
Common cases
mkdir -p a/b/c # create the whole directory tree
cp file file.bak # copy it next to the original
cp -r src dst # copy a directory with -r
mv old new # move or rename
rm file # delete a file
rm -r dir # delete a directory and its contentsHow it works: mv is a rename
Within one filesystem
mvdoes not move the data: it only changes the name entry in the directory, which is why moving and renaming are the same operation.cpalways makes a fresh copy of the data.rmremoves a name, and when a file's last name is gone and no process holds it open, its inode is freed.rmhas no trash can: what is deleted is gone, so beforerm *.tmpit helps to check the pattern withls *.tmpfirst.
Used in
You need this in the lesson Files and directories. The theory is the chapter Files and directories.
See also
Filename globbing, The ls command.
Try it
Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand - the container is deleted when you leave.