According to my last question I think we can't use 'cp' to copy file to the tape device or device like '/dev/lp0'.But I still don't understand why.
To make this question simple enough,just tell me if the command 'cp' can only used on block device?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
There are block devices and character devices (and others). Regarding a character device, a stream of characters is going to or coming from. For example a keyboard or a tape drive. Regarding block devices you can seek forward and backward on them, therefore create a file allocation table and manage files. For example a disk.
cp is used for (mounted) block devices: It creates an entry in the filesystem table that has it where the file is stored - then the file is stored to this place. Seeking forward (and maybe backward) included. You cannot do this with a tape device (just as you cannot with a keyboard). That is why you use cat with a tape drive and cp with a disk.
One way to think of it is to think of these things as different device types. 'cp', only knows how to copy files to and from a limited number of device types. The most commonly used device for storing files is the disk drive. 'cp' knows how to copy files to and from the disk drive, as well as a limited set of other devices, such as /dev/tty.
Writing and reading data to and from a tape or CD or printer or across the network to another computer, requires special knowledge about how those devices work.
It is entirely possible that 'cp' could have been enhanced each time a new device type is added, but that would mean that there would be many different command options that would work sometimes, on some computers, and not on others.
The design of UNIX was that a command should do one thing, and do it well. For 'cp' that one thing is to make a copy of a disk file to a disk file.