Copying

In essence, copying a file on Linux is really simple: use the cp command, followed by the filename-to-be-copied to the filename-to-copy-to. It looks something like this:

reader@ubuntu:~$ ls -ltotal 12-rw-rw-r-- 1 reader reader   69 Jul 14 13:18 nanofile.txtdrwxrwxr-x 2 reader reader 4096 Aug  4 16:16 testdir-rwxr-xr-- 1 reader reader    0 Aug  4 13:44 testfiledrwxrwx--- 2 reader reader 4096 Aug  4 16:18 umaskdir-rw-rw---- 1 reader games     0 Aug  4 16:18 umaskfilereader@ubuntu:~$ cp testfile testfilecopyreader@ubuntu:~$ ls -ltotal 12-rw-rw-r-- 1 reader reader   69 Jul 14 13:18 nanofile.txtdrwxrwxr-x 2 reader reader 4096 Aug  4 16:16 testdir-rwxr-xr-- 1 reader reader    0 Aug  4 13:44 testfile-rwxr-xr-- 1 reader reader    0 Aug 18 14:00 testfilecopydrwxrwx--- ...

Get Learn Linux Shell Scripting - Fundamentals of Bash 4.4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.