Stop Ubuntu going into suspended mode
$ sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target Created symlink /etc/systemd/system/sleep.target → /dev/null. Created symlink /etc/systemd/system/suspend.target → /dev/null. Created symlink /etc/systemd/system/hibernate.target → /dev/null. Created symlink /etc/systemd/system/hybrid-sleep.target → /dev/null.
sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
Clone SD card
sda 8:0 0 465.8G 0 disk ├─sda1 8:1 0 512M 0 part /boot/efi └─sda2 8:2 0 465.3G 0 part / sdb 8:16 1 29.7G 0 disk ├─sdb1 8:17 1 256M 0 part /media/vbhadra/boot └─sdb2 8:18 1 14.6G 0 part /media/vbhadra/rootfs sr0 11:0 1 1024M 0 rom
As can be seen above in my Ubuntu the SD card (which is attached to the PC using a SD card reader) has been detected in /dev/sdb which has two partitions /dev/sdb1 and /dev/sdb2. If you do not see the above your SD card might need some preparation, particularly it would require a formatting in FAT32 format. You can format your SD card following the instruction here. Remember there is no need to create the partitions yourself. Once you clone the whole Raspbian image into the SD card you would have these partitions already and use the SD card straight into a Pi. All you need is to format the SD card and create a big FAT32 partition occupying the whole card space.
$ sudo dd if=/dev/sdb of=raspbian.img bs=4M
7609+1 records in 7609+1 records out 31914983424 bytes (32 GB, 30 GiB) copied, 2414.63 s, 13.2 MB/s
To enable progress of dd command use status=progress along with the above command:
$ sudo dd if=/dev/sdb of=raspbian.img bs=4M status=progress
Copy disk image to SD card
Now, to do the opposite i.e. copying an image (e.g. raspbian) to SD card do the below:
$ sudo dd if=raspbian.img of=/dev/sdb bs=4M status=progress
Where raspbian.img is the name of the image you want to copy to the SD card, and in this case the image is in the current directory, otherwise you have to provide the absolute path of the image in the above command.