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. In some operating systems such as Ubuntu 12 or later, that's all you need to do, but for most a hack is required to fix the cedilla, because the apostrophe+C yields an C with an accent instead of a Cedilla!
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 :-)