Just so that I remember.
To create a d64 image from a command line (e.g. Linux terminal) with the c1541 tool, part of the VICE package.
c1541 -format floppyname,0 d64 mydisk.d64 -attach mydisk.d64 -write myfile.prg filename
The floppyname is the disk name in the c64 filesystem. mydisk.d64 is the name of the disk image file on your pc filesystem. The myfile.prg is the file you want to write. The last name, filename how the filename will appear in the c64 filesystem. Use lowercase for both diskname and filename or else.
c1541 -format myfloppy,0 d64 diskette.d64
Format a new disk image and write a file inside it:
c1541 -format myfloppy,0 d64 diskette.d64 -attach diskette.d64 -write idiotprog.prg idiotprog
Write a file into an existing d64 image:
c1541 -attach diskette.d64 -write idiotprog.prg idiotprog
Read a file out from an existing d64 image:
c1541 -attach diskette.d64 -read idiotprog