Get display resolution from the command line for Linux Desktop
Use the command xrandr
. Without any argument it displays the available resolutions and the current one (with an asterisk), for instance:
$ xrandr | fgrep '*'
Alternative solution: xdpyinfo | grep dimensions
. xdpyinfo
is older than xrandr
, so might be more portable if you happen to use a very old distribution or some different X server.