International keyboard settings
To make your keyboard have the accents working for Brazilian Portuguese on Debian-like operating systems in the proper way that Brazilians are used to, you need to add a second Keyboard Layout which uses the English (US, alternative international) language.
The dead keys are single quote, double quote, back-tick and tilde, typing any of these characters while using the international keyboard will result in an accent being applied to the next typed character - unless the next character is a space in which case the dead-key itself will be typed. For example single quote, double quote, back-tick and tilde respectively followed by the letter A results in á, ä, à and ã.
In Spanish, upside down question marks (¿) and exclamation marks (¡) are also required as they work like quotes that wrap around a sentence in Spanish. These characters are available on the international keyboard using right-alt + 1 and right-alt + /.
An annoying hack is required to fix the cedilla, because the apostrophe+C yields a C with an accent instead of a Cedilla!. But note that if the hack is not installed, or it doesn't work on your distro, the cedilla is also available using right-alt + comma.
I had included some solutions for various Debian-based OS's here, but they were sub-optimal because they were always failing edge cases. But fortunately I recently found this cool fix-cedilla script by Marco Paganini that seems to work across most versions and flavours of Linux and in most programs whether they're shell, Gnome, Cinnamon, QT or whatever! Thanks Marco :-)
Note: This script stops dead keys from working in Telegram, but this can be fixed by commenting out the line that says QT_IM_MODULE=cedilla in the /etc/environment file.