To access the man page for a specific linux command or application, you would enter the following command in the terminal. In the example below I am requesting the manual page for the ls command
man ls
The manual page is then displayed in the terminal window.
On Ubuntu and Ubuntu based distributions, man pages (Manual pages) are located in the following directory.
/usr/share/man/man1/
You might like a permanent copy of a man page for reference at later stage. You can copy and paste the information directly to a text file from the terminal, but it will be unformatted.
Another alternative is to install the mandoc package, which has a function to export the man page in .html or .pdf format.
To install mandoc enter the following command in the terminal
sudo apt-get install mandoc
Once installed issue the following command to export the ls man page in .html format
Or issue the following command to export the ls man page .pdf format
mandoc -Tpdf /usr/share/man/man1/ls.1.gz > ls.pdf
Instead of entering the command each time, I put together a small bash script that searches the man doc directory and then exports the man page in .html and .pdf formats.
Create a folder and file on your desktop using the following commands.
Replace username with your own username
Copy and paste the code below, and save in the manhtmlpdf.sh file you created above.
#!/usr/bin/bash
echo "*** Create HTML/PDF copy of man document ***"
echo "What man page are you looking for?"
read manpage
if [ -f "/usr/share/man/man1/$manpage.1.gz" ]
then
echo "Creating $manpage.html and $manpage.pdf files"
mandoc -Thtml /usr/share/man/man1/$manpage.1.gz > $manpage.html
mandoc -Tpdf /usr/share/man/man1/$manpage.1.gz > $manpage.pdf
else
echo "The man page for $manpage was not found"
fi
Make the file executable by entering the following command in the terminal