4

I know in the man pages it puts it as -x, --one-file-system stay on this file system but can someone explain it to me like I'm five.

jkris
  • 159

4 Answers4

12

cp -ax ,rsync -xor tar -one-file-system, all are the same.

It means not to cross file system boundaries.

A boundary between file systems is a mount point.

If you run df -a, you will see all files and mount points.

To help you understand with an example:

If you run df on your filesystem: df /, or on /usr directory: df /usr, you will see that they are mounted on /, your installation partition. But if you run it on /proc df /proc you will see that the mount point is different.

So if you issue a recursive copy on your filesystem cp -ax /, it won't copy /proc directory.

You could add -v option if you want to see exactly what is discarded and what is being copied.

As others pointed out, it's used with recursive and people generally use it for backup.

And you should see "Meaning of crossing filesystem boundaries" for more on mount points.

1

That makes a difference if you use cp with recursion i.e. with -r or -a and the source is above a mount point.

E.g.: /data/job/encrypt is an active mount point.

cp -a  /data/job /path/to/target # includes /data/job/encrypt
cp -ax /data/job /path/to/target # excludes /data/job/encrypt
Hauke Laging
  • 90,279
1

From my understanding it means it will only copy things on the currently running filesytem, and not from another one that may be present

Example. If you mounted another filesystem (another physical disk, usb or remote filesystem) under /home/jkris/mnt/otherfs and then proceeded to

cp -ax /home/jkris/ /mybackup/dir/

It would not copy anything from ~/mnt/otherfs

Similar question and answer here: https://superuser.com/questions/307541/copy-entire-file-system-hierarchy-from-one-drive-to-another

mrwhale
  • 164
0

To specify that the data to be copied is an executable, we use this command cp -X on the USS mainframe part.

I hope this helps.