This question already has an answer here:
The computer name is displayed as "unknown-" at the command prompt. How do I change this?
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
This can be done through
sudo hostname new_name
If new_name contains single quotes, then it should be surrounded with double quotes.
2 years ago