I have been struggling for a few days getting a vnc server to work in my new Debian server with xfce desktop. Doing google searches returns a wealth of “try this and see if it sticks to the wall” type approach. Well, not satisfied with that I am attempting to explain here every line in a common /home/username/.vnc/xstartup file, so when you go for troubleshooting you can fix things yourself more intelligently. Feel free to comment if you can add more to this thread.
Common xstartup file lines and their meaning:
First line of any executable script. The file needs execute permissions to run (obviously). That’s “chmod 755 xstartup” if you have issues there. Don’t let the leading # comment tag fool you, as this is not really a comment, this is necessary to invoke the /bin/sh shell to run the rest of the lines of the script. This is explained in wikipedia under “shebang (unix)”
# Uncomment the following two lines for normal desktop: unset SESSION_MANAGER exec /etc/X11/xinit/xinitrc
This is where you start your window manager. I am using xfce4. You can also use gnome, kde, cinnamon, etc.
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
The [ -x /something ] construct means “if /something file eXists then”. && is the logical and operator (if 1 and if 2). The way it is implemented here is an if then. Basically this is saying if the /etc/vnc/xstartup file exists then execute it. Otherwise continue on. The /etc/vnc/xstartup file is a system wide kind of file, where the user based xstartup is specific to that user.
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
Same as above. FWIW, I don’t have an /etc/vnc/ directory or a $HOME/.Xresources file, so I could remove / comment these.
xrdb sets the contents of the RESOURCE_MANAGER property on the root window of screen 0. This is where apps get user preferences on color and fonts.
xsetroot -solid grey
Tailors the background of the window, if the widow manager (xfce4) goes away. So, not that important because a vncserver without a xfce4 (or similar) desktop — what’s the point?
vncconfig -iconic &
A helper application for vnc. The option forces it to be iconized
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
This one is odd. You would think the -geometry refers to the geometry of the vnc session, but it does not. This is saying start a console (xterm, or x-terminal-emulator, all programs found in /usr/bin) that is 80 columns wide, 24 columns tall and spaced 10 pixels (both the x and y axis) from the top left corner of the screen. What’s odd? This terminal is behind the vnc x session, so you only see it when you log out of your vnc desktop. Because you don’t go back to a login window manager, only then you see this command prompt. Really, you don’t need this line.
You will set the geometry of the screen elsewhere, in your user profile at computer startup time in the file
- or -
or could be x-windows-manager &. This says start the window manager and is the last line in the file.
2 thoughts on “every line in a linux .vnc xstartup explained”
This terminal is behind the vnc x session, so you only see it when you log out of your vnc desktop. Because you don’t go back to a login window manager, only then you see this command prompt.
This is not even close to correct.
I think that was correct, at least for me. The main point I was making there is that this “80×24+10+10” has nothing to do with the geometry of the vnc session. At least that’s how it worked for me.