Creating, Copying and Moving Files Print

  • 0

Basic manipulation.

WHAT touch DOES

Creates an empty file, or updates a file's timestamp.

WHAT mkdir DOES

Creates a directory.

WHAT THE PARENTS OPTION ADDS

Creating every directory in a path at once, without error if they exist.

WHAT cp DOES

Copies.

WHAT THE RECURSIVE OPTION IS FOR

Copying directories.

WHAT THE PRESERVE OPTION DOES

Keeps permissions, ownership and timestamps.

WHY THAT MATTERS ON A SERVER

A copy with wrong ownership frequently stops a site working.

WHAT mv DOES

Moves, and also renames.

WHY THEY ARE THE SAME OPERATION

Renaming is moving within the same directory.

WHAT rm DOES

Deletes, permanently and immediately.

WHAT THERE IS NO

Recycle bin.

WHAT THE RECURSIVE AND FORCE OPTIONS TOGETHER DO

Delete a directory and everything in it without asking.

WHY THAT COMBINATION DESERVES RESPECT

It is the command that has destroyed more servers than any other.

WHAT TO DO BEFORE RUNNING IT

Run ls on the same path first, and read what it lists.

WHAT TO NEVER DO

Use it with a variable that might be empty Use it with a wildcard you have not checked

WHAT TO PREFER WHERE POSSIBLE

Moving to a temporary directory instead of deleting.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot