Skip to content

File and Directory Management

touch creates an empty file.
If the file already exists, it updates its modification timestamp.

Fenêtre de terminal
touch file.txt

Fenêtre de terminal
mkdir project
mkdir -p folder1/folder2/folder3

  • rm file.txt → delete a file
  • rm -r folder → delete a directory and its contents
  • rm -rf folder → force delete without confirmation ⚠️

Fenêtre de terminal
cp file.txt copy.txt
cp -r folder1 folder2

Fenêtre de terminal
mv file.txt newname.txt
mv file.txt Documents/

CommandDescriptionExample
touchCreate an empty filetouch file.txt
mkdirCreate a directorymkdir project
mkdir -pCreate nested directoriesmkdir -p a/b/c
rmDelete a filerm file.txt
rm -rDelete a directoryrm -r project
cpCopy a filecp file.txt copy.txt
cp -rCopy a directorycp -r folder1 folder2
mvMove or rename a filemv file.txt newname.txt

  • Verify your location with pwd before running rm -r.
  • Use rm -i to prompt for confirmation.
  • Prefer mkdir -p to avoid errors.
  • Check results with ls.