dd input/output error. No information in error string I am using a MacBook macOS Mojave 10.14.5. I can list the device with diskutil list, but it isn't mounted. I perform the dd command below. The output states input/output error, which doesn't give a lot of information.

sudo dd if=~/Downloads/ubuntu-18.04.2-desktop-amd64.dmg of=/dev/rdisk2s2 
Password:
dd: /dev/rdisk2s2: Input/output error
1+0 records in
0+0 records out
0 bytes transferred in 80.936791 secs (0 bytes/sec)


Anyone know how I can resolve this issue?
For a bootable flash drive, follow the Ubuntu help:


This will be easier since there is the Etcher app you download to avoid the direct use of the dd command.


https://tutorials.ubuntu.com/tutorial/tutorial-create-a-usb-stick-on-macos#0

While I recommend using the Ubuntu ISO image with Etcher, my comments on the use of the dd command follow. You seem to be following the instructions from the link below. You got the wrong device name, /dev/rdisk2s2. You need the disk name not the partition name. You should remove all external drives except your flash drive.  This will make it easier to identify the flash drive and reduce the risk from using the dd command. Try the instructions again from the beginning. 

https://itsfoss.com/create-bootable-ubuntu-usb-drive-mac-os/