Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to run a command like get-screen-resolution during a X session to get a '800x480' output. ( or whatever the actual screen size is ).

Is there something available for this? Currently I take a screenshot and measure the resulting *.jpg's width & height attributes.

Also, how do I set the screensize during a X session from the command-line?

share|improve this question
up vote 9 down vote accepted

You can use xrandr to do both

Get resolution

$ xrandr
Screen 0: minimum 320 x 240, current 1920 x 1080, maximum 1920 x 1080
default connected 1920x1080+0+0 0mm x 0mm

Set resolution

$ xrandr --output default --mode 1280x1024
share|improve this answer

From my personal shell library:

    xdpyinfo | awk '/dimensions:/ { print $2; exit }'
share|improve this answer

Clean xrandr output for imagemagick use

xrandr |grep \* |awk '{print $1}'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.