I am an international student in the Czech Republic studying electrical engineering as undergraduate.I am from Ghana (no)and I want to visit a friend in Denmark for 2 days by train, what are the documents I need? How should I do it?
You need a valid passport and your valid long-term visa. If you have a residence permit as a separate document, then you do not need the visa, but you still need your passport.
(Schengen long-stay visas are type D. These visas show only the country that issued the visa in the "valid for" field, but they implicitly allow the bearer to visit other Schengen countries for up to 90 days in any 180-day period unless there is an explicit restriction noted on the visa. A residence permit also allows its bearer to visit other Schengen countries subject to the 90/180 restriction. There is no systematic enforcement of the 90/180 restriction for travelers with type D visas or residence permits.)
You will not normally leave or re-enter the Schengen area on this trip, since you would normally travel only through Germany and possibly Poland. There are normally no systematic controls on these internal borders. You could encounter random passport checks, or perhaps temporary controls such as those imposed during the migrant crisis, but if you do your passport will not be stamped. As long as your documents are in order, there is virtually no chance of your being prevented from continuing on your way.
So just buy your ticket, board the train, and enjoy your visit to Denmark.