2

then I'm using an ubuntu server with gitlab installed, I need to configure hostname the name ubuntudev, to access it from within the network! I configure the ubuntudev name in /etc/hosts but it does not work with the hostname, how can I fix this error? I put under the contents of the /etc/hosts file

--> /etc/hosts

127.0.0.1       localhost
127.0.1.1       ubuntudev

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
riki
  • 133

1 Answers1

3

you set a new hostname with

sudo hostnamectl set-hostname new_hostname

You can also do so by editing BOTH /etc/hostname and /etc/hosts` . Direct editing is discouraged because if you do not edit both you can break sudo.

panther@Ubuntu:~$hostname Ubuntu panther@Ubuntu:~$sudo hostnamectl set-hostname it_works

panther@Ubuntu:~$hostname

it_works

panther@Ubuntu:~$ping -c1 it_works

PING it_works (10.0.0.8) 56(84) bytes of data. 64 bytes from it_works (10.0.0.8): icmp_seq=1 ttl=64 time=0.020 ms

--- it_works ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.020/0.020/0.020/0.000 ms

panther@Ubuntu:~$sudo hostnamectl set-hostname Ubuntu

panther@Ubuntu:~$hostname

Ubuntu

Panther
  • 104,528