I consider it handy to set a new name for your computer. You can follow this easy steps if you don't have a public DNS domain name.
Check your OS with this command
cat /etc/system-release
Amazon Linux release 2 (Karoo)
For Amazon Linux 2: Use the hostnamectl command
sudo hostnamectl set-hostname "servername.localdomain"
For Amazon Linux AMI: Open /etc/sysconfig/network and set
HOSTNAME=servername.localdomain
Step 2
Open the /etc/hosts file and change the entry beginning with 127.0.0.1 to look like this
127.0.0.1 servername.localdomain servername localhost4 localhost4.localdomain4
Step 3
Reboot the instance
If you do not want to modify the hostname for your instance, but you would like to have a more useful system name when you log into your instance follow the next steps
Step 3
Reboot the instance
If you do not want to modify the hostname for your instance, but you would like to have a more useful system name when you log into your instance follow the next steps
Step 1
Create a file in /etc/profile.d that sets the environment variable called NICKNAME
sudo sh -c 'echo "export NICKNAME=servername" > /etc/profile.d/prompt.sh'
Step 2
Open /etc/bashrc (RedHat/Amazon) or /etc/bash.bashrc (Debian/Ubuntu)
and edit the file with sudo
sudo vi /etc/bashrcand edit the file with sudo
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@$NICKNAME \W]\\$ "
Step 3
Log out and then log back inStep 3
No comments:
Post a Comment