How to View the Content of .tgz and .gz Files on Ubuntu

On Ubuntu if you have a file compressed as .tgz you can check its contents with this command

tar -tf filename.tgz

Or if you have a .gz file and you want to check its contents, you can do so with this command

gzip -cd <filename> | more

I have not tested these commands on other Linux distributions but I guess they would also work.