How do I maximize an already open gnome-terminal window from command line?

You can use wmctrl:

wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz

or xdotool:

xdotool windowsize $(xdotool getactivewindow) 100% 100%

For more info, see man wmctrl and man xdotool.

If you don't have these packages installed, you can install them using the following comand:

sudo apt-get install wmctrl xdotool

You can send keystroke combinations directly to a window using the xdotool command-line X11 automation tool e.g.

xdotool key ctrl+super+Up

In general it is necessary to specify the target window to receive the keystrokes, but the default is to send them to the active window so in this case no additional window target is required

The xdotool package is not installed by default but you can add it from your favourite package manager / software center or using apt-get

sudo apt-get install xdotool

Then edit your ~/.bash_aliases file and add the following line

alias wmax='xdotool key ctrl+super+Up'

This will enable you to max any future screen with wmax


On Ubuntu 14.04 while in the terminal window, just pressing F11 does the thing.


For Ubuntu 18.04 this works (e.g. added those lines to the end of .bashrc; g might stand for gui, just to avoid conflicts with other similar names):

alias gmax='xdotool key super+Up'
alias gwin='xdotool key super+Down'
alias gmin='xdotool key super+h'

Please not that after calling 'gmin' on the shell your focus will go to somewhere else. If using a script then you dont have to care. At the keyboard you have to use e.g. your pointing device for returning to your console.

Evidently the installation of the used 'xdotool' needs to be performed one time for the machine:

sudo apt-get install xdotool