usr/sbin/fix_hostname if it works continue with the above instructions. fix_hostname instead of compiling a C program: #!/bin/shĮcho "hostname_with_underscores" > /proc/sys/kernel/hostnameĭon't forget to make it executable ( chmod +x fix_hostaname) and copy it to e.g. To fix it, simply update /etc/hosts with the new hostname. If your system is not inside a container it should be possible to use the following shellscript named e.g. sudo uses the system resolver, configured by /etc/nf in your case, host lookups were configured to use /etc/hosts, which had the previous hostname identified with the servers IP. See for unit file documentation in general.)Įnable the service: sudo systemctl enable fix_hostnameĭisable anything hostname related (seemed to be needed on my system): systemctl disable rvice systemctl disable (derived from "/etc/rc.local Compatibility" unit file. Write a service to run the program on system startup to e.g. If it does work: copy the program to e.g. If it does not work: Don't continue, this will only break stuff. You should see the newly set hostnames in newly opened terminals or newly executed shells. write a small C program to call the sethostname() system call wrapper:Ĭhar hostname = "hostname_with_underscores" Ĭompile it: gcc -Wall -Wextra fix_hostname.c -o fix_hostname. (see below for a slightly simpler method that only works outside of containers) In case you are fine with potentially breaking stuff at a random point in the future this is how I did it in a container (22.04 guest): Don't try this in production environments or on systems without easy physical access. sudo unable to resolve host localhost.localdomain Im trying to set DefaultRoot to /var/www as per the following screenshots.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |