Copying and Moving Files
Introduction
You can now build files and folders exactly where you want them, but a real workspace never stays neatly arranged for long. Files need duplicates for backups, drafts need to move into final folders, and messy names need fixing. Two commands handle nearly all of this: cp, which copies a file or folder, and mv, which moves or renames one.
Both commands share a single rule that decides everything they do: what happens is controlled entirely by the destination argument you give them. Learn that one rule, and both commands make sense right away. There's a catch worth taking seriously from the start, though — cp and mv can silently overwrite an existing file with no warning at all, so this lesson also builds the habit of checking before you act.
Confirming a Command Exists with command -v
Before using an unfamiliar command, you can confirm that the shell resolves its name to the program you expect. command -v does exactly that: it looks up a name and tells you what it resolves to, without running it. Think of it as asking the shell, "If I type this, what exactly will happen?"
Both names resolve to programs sitting in /bin, the standard location for core system commands on macOS. cp and mv are built into the operating system itself, so there's nothing to install — unlike some tools you might add later, these are already present the moment you open a terminal. In the CodeSignal environment specifically, you never have to worry about this setup step at all; cp and mv are already there and ready to use. Still, it's a good habit to know how to check for yourself on your own Mac, since not every command you'll eventually use is guaranteed to be pre-installed. This is a one-time discovery step, though — once you know a command exists, there's no reason to re-check it before every copy or move.
Reading a Usage Message
A second one-off way to get your bearings with a new command is to run it with no operands and read what it tells you. Both cp and mv require at least two operands: a source and a destination. If you run either command with no operands at all, nothing gets copied or moved. Instead, the command refuses to guess and prints a short usage message describing its expected form.
Treat this as a quick reference exercise rather than a safety check — it tells you the shape of the command, but it says nothing about your actual files, so it can't protect you from a bad copy or move. The real safety workflow, which you'll build later in this lesson, is inspecting the source and destination paths before and after you act.
Still, it's worth learning to read this kind of output the same way you'd read any diagnostic: identify the command first, then check whether a specific path is named, and finally read the last part as the reason the operation didn't happen. Here, there's no path to name, and the reason is simple — you didn't give one. Nothing changed on disk; this is purely informational. That "reason at the end" habit is one you'll reuse constantly, including a few sections from now when cp refuses to copy a directory the plain way.
