This tutorial will show you how to get your screen or monitor resolution using command in linux , 4 command will be include, xrandr , xdpyinfo, xwininfo , xprop , all of them are X11 commands .

Use xrandr command

xrandr which stands X11 Resize and Rotate which is used to set the size, orientation and/or reflection of the outputs for a screen. It can also set the screen size.

And if we run it without any option, it will dump the state of the outputs, showing the existing modes for each of them.

j@ubuntu2004:~$ xrandr
Screen 0: minimum 1 x 1, current 1914 x 884, maximum 16384 x 16384
Virtual1 connected primary 1914x884+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1914x884      60.00*+
   2560x1600     59.99  
   1920x1440     60.00  
   1856x1392     60.00  
   1792x1344     60.00  
   1920x1200     59.88  
   1600x1200     60.00  
   1680x1050     59.95  
   1400x1050     59.98  
   1280x1024     60.02  
   1440x900      59.89  
   1280x960      60.00  
   1360x768      60.02  
   1280x800      59.81  
   1152x864      75.00  
   1280x768      59.87  
   1024x768      60.00  
   800x600       60.32  
   640x480       59.94  
j@ubuntu2004:~$

If there are multiple monitors ,each one will be displayed individually , like screen 0 , screen 1 etc.

too many outputs, try below command to grep out only required information.

j@ubuntu2004:~$ xrandr | fgrep '*'
   1914x884      60.00*+
j@ubuntu2004:~$

use xdpyinfo command

Xdpyinfo is a utility for displaying information about an X server. It is used to examine the capabilities of a server, the predefined values for various parameters used in communicating between clients and the server, and the different types of screens and visuals that are available.

By default, numeric information (opcode, base event, base error) about protocol extensions is not displayed.

$ xdpyinfo

Similarly to list resolution only ,try below command

j@ubuntu2004:~$ xdpyinfo | grep dimensions
  dimensions:    1914x884 pixels (506x234 millimeters)
j@ubuntu2004:~$

Same as xrandr if there are multiple monitors , each one’s resolution will be displayed individually .

use command xwininfo

Xwininfo stands X11 windows information which is a utility for displaying information about windows. In the X Window System, every window is contained within another window, called its parent. This makes the windows form a hierarchy. The root window is the root of this hierarchy. It is as large as the screen, and all other windows are either children or descendants of it.

$ xwininfo -root

The output of this command looks like below:

j@ubuntu2004:~$ xwininfo -root

xwininfo: Window id: 0x405 (the root window) (has no name)

  Absolute upper-left X:  0
  Absolute upper-left Y:  0
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 1914
  Height: 884
  Depth: 24
  Visual: 0x21
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x20 (installed)
  Bit Gravity State: ForgetGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +0+0  -0+0  -0-0  +0-0
  -geometry 1914x884+0+0

j@ubuntu2004:~$

Compare to xrandr and xdpyinfo , xwininfo just shows the window information of root window , so if you have more than one monitors it can’t show every monitor’s resolution.

Use command xprop

The xprop utility is for displaying window and font properties in an X server. One window or font is selected using the command line arguments or possibly in the case of a window, by clicking on the desired window. A list of properties is then given, possibly with formatting information.

$ xprop

The outputs of this command maybe very long you can use pipe and more command to find required information

$ xprop | more

Or just use below command to show your screen size only

j@ubuntu2004:~$ xprop -root _NET_DESKTOP_GEOMETRY
_NET_DESKTOP_GEOMETRY(CARDINAL) = 1914, 884
j@ubuntu2004:~$

Conclusion

Now we have showed to how to find your screen or display resolution using command in linux , above examples already tested in Ubuntu/Gnome and Redhat Linux/KDE . If you still have queries ,feel free to leave a comment.