Beginner · 9 min read · Updated 2026-11

Files and folders on the command line

List, create, move and delete files without a mouse — the handful of commands you'll use every single day.

Everything in Linux is a file, and you spend most of your time moving between folders and looking at what's inside them. Six commands cover almost all of it: ls, cd, mkdir, touch, cp, mv and rm. Let's build a small workspace and use each one.

Looking: ls

ls lists what's in the current folder. Add -l for a detailed list (permissions, owner, size, date) and you see the real shape of each item — a dash means a file, a d means a directory.

bash — real output
$ ls -l
total 4
-rw-r--r-- 1 root root    0 Nov  2 11:56 notes.txt
drwxr-xr-x 2 root root 4096 Nov  2 11:56 projects
-rw-r--r-- 1 root root    0 Nov  2 11:56 report.pdf
Two files and one folder (projects, marked with d).

Making things: mkdir and touch

mkdir makes a new directory; touch creates an empty file (or updates its timestamp). cd moves you into a folder, and cd .. moves you back up one level.

bash
mkdir projects
cd projects
touch app.py readme.md
cd ..
Make a folder, go in, create two files, come back out.

Copy, move, rename, delete

  • cp a.txt b.txt — copy a file
  • mv a.txt docs/ — move it into another folder
  • mv old.txt new.txt — rename (move onto a new name)
  • rm file.txt — delete a file
  • rm -r folder — delete a folder and everything in it
rm deletes permanently — there is no Recycle Bin on the command line. Read the line twice before you press Enter, especially with rm -r.

A trick that saves your fingers

Start typing a file or folder name and press Tab. The shell completes it for you. Press Tab twice to see all the matching options. You'll use this thousands of times.

All articles