Software & AppsOperating SystemLinux

How To Set Terminal Size Permanently in Ubuntu?

Ubuntu 6

In this article, we will be discussing how to permanently set the terminal size in Ubuntu. This can be particularly useful if you often find yourself manually adjusting the terminal window size to suit your preferences every time you open a new session. By following the steps outlined below, you can set a default terminal size that will be applied automatically whenever you open a new terminal window.

Quick Answer

To set the terminal size permanently in Ubuntu, you can use the terminal’s profile preferences. For Ubuntu 16.04 and later versions, open the terminal, go to Edit > Profile Preferences, enable the "Use custom default terminal size" option, and enter your preferred dimensions. For Ubuntu 17.10 and later versions, go to Edit > Preferences, select the Default profile, switch to the Text tab, and set the initial terminal size. Alternatively, you can use a script with the gnome-terminal and the wmctrl tool to resize the terminal automatically.

Method for Ubuntu 16.04 and Later

If you’re using Ubuntu 16.04 or a later version, you can set the terminal size permanently through the terminal’s profile preferences. Here’s how:

  1. Open the Terminal: You can do this by pressing Ctrl + Alt + T or by searching for ‘Terminal’ in your system’s application launcher.
  2. Access Profile Preferences: In the terminal window, navigate to the menu bar at the top, click on Edit, and then select Profile Preferences.
  3. Set Custom Terminal Size: In the ‘Profile Preferences’ window, switch to the ‘General’ tab. Here, you will find an option labeled ‘Use custom default terminal size’. Check this box to enable it.
  4. Enter Preferred Dimensions: You can now specify your preferred terminal size by entering the desired number of columns (width) and rows (height) in the respective fields.
  5. Save Changes: Click ‘Close’ to save your changes. The new default terminal size will now be applied every time you open a new terminal window.

Method for Ubuntu 17.10 and Later

The process to set the terminal size permanently is slightly different for Ubuntu 17.10 and later versions. Here are the steps:

  1. Open the Terminal: Press Ctrl + Alt + T or search for ‘Terminal’ in the application launcher.
  2. Access Terminal Preferences: Go to Edit in the menu bar and select Preferences.
  3. Modify Default Profile: In the ‘Preferences’ window, select the ‘Default profile’ option and then switch to the ‘Text’ tab.
  4. Set Initial Terminal Size: Here, you will find fields for ‘Initial terminal size’. Enter your preferred number of columns and rows.
  5. Save Changes: Click ‘Close’ to save your changes. The new default terminal size will now be applied every time you open a new terminal window.

Alternative Method Using a Script

If you’re using the gnome-terminal, you can also set the terminal size permanently using a script. This method requires the wmctrl tool, which you can install using the command sudo apt-get install wmctrl.

Here’s how to create and use the script:

  1. Create a Script File: Create a new script file (e.g., set_terminal_size.sh) in a location of your choice.
  2. Enter Script Content: Open the script file in a text editor and enter the following content:
#!/bin/bash
APP_CLASS="gnome-terminal.Gnome-terminal"
while [ 1 ]; do
 WIN_ID=$(printf %x $(xdotool getactivewindow))
 WM_CLASS=$(wmctrl -lx | awk -v search=$WIN_ID '{ if($1~search) print $3 }')
 WMCTRL_ID=$( wmctrl -lx | awk -v search2=$WIN_ID '$0~search2 {print $1}' )
 if [ $WM_CLASS = $APP_CLASS ]; then
 wmctrl -i -r $WMCTRL_ID -e 0,0,0,650,650
 fi
 sleep 0.25
done

This script uses wmctrl to check the window class of the active window every 0.25 seconds. If the active window is a gnome-terminal, the script resizes it to the specified dimensions (650×650 in this example).

  1. Make the Script Executable: Save the script file and make it executable by running the command chmod +x set_terminal_size.sh.
  2. Run the Script at Startup: Add the script to your Startup Applications to run it automatically on boot. You can do this by searching for ‘Startup Applications’ in the application launcher, clicking ‘Add’, and then entering the full path to your script file.

Conclusion

Setting the terminal size permanently in Ubuntu can be achieved in several ways, depending on your specific operating system version and terminal emulator. By following the methods outlined in this article, you can customize your terminal window size to suit your personal preferences and improve your productivity.

How can I change the terminal size temporarily in Ubuntu?

To change the terminal size temporarily in Ubuntu, you can manually resize the terminal window by clicking and dragging the edges of the window with your mouse.

Can I set different default terminal sizes for different profiles in Ubuntu?

Yes, you can set different default terminal sizes for different profiles in Ubuntu. In the ‘Profile Preferences’ or ‘Preferences’ window, you can create multiple profiles and customize the terminal size for each profile individually.

Can I set the terminal size using specific dimensions, such as pixels or inches?

No, the terminal size settings in Ubuntu are based on the number of columns and rows, not on specific dimensions like pixels or inches. You can specify the desired number of columns (width) and rows (height) to set the terminal size.

Will changing the default terminal size affect the existing terminal windows?

No, changing the default terminal size will not affect the existing terminal windows. It will only be applied to new terminal windows that are opened after the changes are made.

How can I undo the changes and revert to the default terminal size?

To revert to the default terminal size, you can go back to the ‘Profile Preferences’ or ‘Preferences’ window and uncheck the ‘Use custom default terminal size’ option. This will restore the default terminal size settings.

Leave a Comment

Your email address will not be published. Required fields are marked *