If you have a line (or other vector geometry) on top of a terrain layer and you want to get the raster values (from the terrain layer) into the vector layer then have a look at this video to see how.
Here's the terrain layer I use in the video: https://automaticknowledge.co.uk/reso...
See my intro and intermediate QGIS courses for more: https://www.udemy.com/user/alasdair-r...