월요일, 7월 22, 2024
HomeLinuxubuntu hostname 변경하기

ubuntu hostname 변경하기

호스트명 확인

root@localhost:~# hostname
localhost

root@localhost:~# cat /etc/hostname
localhost

명령어로 변경

root@localhost:~# hostname ip-10-2-2-10.computer-1.com
root@localhost:~# hostname
ip-10-2-2-10.computer-1.com
root@localhost:~# su -
root@ip-10-2-2-10:~#

hosts 수정

root@ip-10-2-2-10:~# vi /etc/hosts
127.0.0.1        localhost        localhost        localhost
10.2.2.10        ip-10-2-2-10.computer-1.com        chef-server        ip-10-2-2-10

한방스크립트
참조URL:http://zetawiki.com/wiki/리녹스_호스트_변경

NEW_HOSTNAME=ip-10-2-2-10.computer-1.com
OLD_HOSTNAME=$HOSTNAME
HOSTNAME=$NEW_HOSTNAME
hostname $HOSTNAME
sed -i "s/$OLD_HOSTNAME/$HOSTNAME/" /etc/hostname 2> /dev/null
echo "\$HOSTNAME=$HOSTNAME"
grep -Hn '' /proc/sys/kernel/hostname grep -Hn '' /etc/hostname 2> /dev/null
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular