Thomas has given the info for exchanging a UK driving licence, as for the validity of driving in Portugal on a UK licence it does depend on whether you are a resident of Portugal or not.
For non-residents it's 185 days.
For residents it's 90 days from becoming resident but whilst the licence ceases to be valid for driving from day 91 it can be exchanged for a PT licence (without taking a PT driving test) for up to 2 years from becoming resident.
NOTE - The time limits usually applicable to residents are currently suspended from being applied to UK issued driving licences by Lei 25-B/2021 until midnight on the 31st December 2021. Non-residents remain subject to the 185 day validity limit.