I have a shell script that installs several programs with sudo apt-get then opens vncserver, then installs more stuff.
#!/bin/sh vncserver >./my_script.sh
But this does not work:
#!/bin/sh sudo apt-get update vncserver >./my_script.sh
Nor does this work:
#!/bin/sh vncserver >sudo ./my_script.sh
When it doesn't work, it returns the error
vncserver: Wrong type or access mode of /home/username/.vnc.
Someone on this question said that this was a known problem. So how can I run vncserver in my_script?