stottj / Command-Line

0 stars 0 forks source link

Copy, move, and delete files using `cp`, `mv`, and `rm` #9

Closed stottj closed 1 year ago

stottj commented 1 year ago

Ticket: Copy, Move, and Delete Files Using cp, mv, and rm.


Summary

Learn how to copy, move, and delete files and directories using the cp, mv, and rm commands in a Unix-like operating system.


Description


Learning Tasks

  1. Copy Files with cp:

    • Study the basic syntax and everyday use cases of the cp command.
  2. Move Files with mv:

    • Learn how the mv command moves files and directories.
  3. Delete Files with rm:

    • Understand how to safely use the rm command for file and directory removal.
  4. Explore Options and Flags:

    • Familiarize yourself with commonly used options like -r for recursive operations or -f for forcing actions.
  5. Best Practices and Warnings:

    • Be aware of the potential risks and learn how to use these commands responsibly.
  6. Troubleshooting:

    • Identify common issues you might encounter and learn how to resolve them.

Learning Goals


Priority

stottj commented 1 year ago

cp allows for a user to copy a file/groups of files/directories. Standard command goes: cd [option] source destination/directory.

ex cp a.txt b.txt

mv allows for a user to move and renaming files/directories. Standard command goes: mv [option] source destination/directory

ex mv filre.txt destination

Note: cp is like copy and past and mv is like cut and paste

rm allows a user to remove files,directories. Standard command goes: rm [option] file

ex rm a.txt

common options -i system warns user before overwriting destination -b creates backup of the destination file -f forces operation if user doesnt have permission -r recursive, for example cp -r will copy entire directory structure

becareful with options, such as -f -r as these can be used to delete/overwrite directories which shouldnt be touched.

common troubleshooting is not having rights to perform actions, destinations not existing, using wrong options or commands. Ensure spelling is correct and destination/source are correct.

tupleHunden commented 1 year ago

👍🏻