There are many tools out there. gs is one of such command line tools to achieve this. Suppose there are two pdf files as file1.pdf and file2.pdf and we want to merge them into final.pdf, then the command will be -
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=final.pdf file1.pdf file2.pdf
More than two pdf can also be merged by providing their names in the command line argument.