Running the .sql script in Linux to get the postgresql database table and functions
You are trying to run the psql as the OS user 'root'.  Your pg_hba.conf file doesn't let OS user 'root' log in as database user 'postgres'.

You could instead use sudo to run as OS user 'postgres', not 'root':

sudo -u postgres psql -U postgres -d tsdb -f /.sqlscript/location


(Although perhaps OS user 'postgres' won't have access to the sqlscript)

You could also make use of a mapping file pg_ident.conf to say that root is allowed to log in as postgres, although I don't see much point in that.

Or you could change the "local" line of your pg_hba.conf so that it uses "md5" rather than "peer".  At that point, there is no reason to use "sudo" at all as it doesn't care who you are, just that you know the password.

Or you could make use of the existing 'host ... md5' line of your pg_hba.conf, by specifying a host rather than defaulting to using a unix socket:

psql -h 127.0.0.1 -U postgres -d tsdb -W -f /.sqlscript/location