Linux Labs

First steps / Stage 7 of 15

Creating and organising files

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 10 · on a machine · 4 min

A request before the holiday

What you will learn

  • Create directories and empty files without overwriting what already exists.
  • Predict what cp and mv do with the destination — a directory, a new name or a file.
  • Delete only the files you have checked, including by a filename pattern.

A colleague is going on holiday and asks: "Put the drafts into archive." The ~/file-lab directory holds two drafts, draft1.txt and draft2.txt.

Exercise · look

Put the drafts into archive

In ~/file-lab, run the four commands below in order: two moves, a directory listing, and a read of archive.

First, predict

What will ~/file-lab contain after the two mv commands?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in
Check yourself 1 question

Where did the first draft go?

  • mv cannot join files: archive holds a single line, draft 2: server list.

  • archive is not a directory: its line in ls -l starts with -, a directory shows d. You cannot put a file inside a file.

  • The command line has no trash: mv changes a file's name or location at once. ls -a ~ shows no trash folder.

The first mv renamed the draft to archive, and the second replaced that file with the second draft.

Ubuntu 24.04
Loading…