{"id":260953,"date":"2024-05-28T07:40:10","date_gmt":"2024-05-28T07:40:10","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=260953"},"modified":"2024-05-28T07:40:10","modified_gmt":"2024-05-28T07:40:10","slug":"linux-hostname-management-skript","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/de\/script-hub\/linux-hostname-management-skript\/","title":{"rendered":"Umfassendes Skripting-Handbuch: \u00c4ndern des Hostnamens auf einer Linux-Maschine"},"content":{"rendered":"<h2>Die wichtigsten Erkenntnisse<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Automatisiert die \u00c4nderung von Hostnamen<\/strong>: Das Skript rationalisiert den Prozess der \u00c4nderung von Hostnamen auf Linux-Systemen und erh\u00f6ht die Effizienz.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Unterst\u00fctzt mehrere Funktionen<\/strong>: Bietet Optionen zum Aktualisieren des Hostnamens, der Hostdatei, des Anzeigennamens und zum Neustarten des Systems.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Validierung und Fehlerpr\u00fcfung<\/strong>: Integriert \u00dcberpr\u00fcfungen auf vorhandene Befehle und validiert \u00c4nderungen, um Fehlkonfigurationen zu verhindern.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"1\"><strong>Benutzerfreundliche Argumentenanalyse<\/strong>: Vereinfacht die Verwendung mit klaren Argumenten f\u00fcr verschiedene Funktionen.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"1\"><strong>Verringert menschliche Fehler<\/strong>: Durch die Automatisierung wird das Risiko manueller Fehler bei der \u00c4nderung von Hostnamen minimiert.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"6\" data-aria-level=\"1\"><strong>Verbessert die IT-Verwaltung<\/strong>: Ein wertvolles Tool f\u00fcr IT-Experten und MSPs zur Verwaltung mehrerer Linux-Ger\u00e4te.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"1\"><strong>Skript vs. traditionelle Methoden<\/strong>: Bietet im Vergleich zur manuellen Bearbeitung von Systemdateien einen effizienteren Ansatz.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"8\" data-aria-level=\"1\"><strong>Sicherheit und Schutz<\/strong>: Empfiehlt Backups und Tests in kontrollierter Umgebung, um die Stabilit\u00e4t des Netzwerks zu gew\u00e4hrleisten.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"9\" data-aria-level=\"1\"><strong>Integration mit Verwaltungstools<\/strong>: Hebt die Vorteile der Integration solcher Skripte in Plattformen wie NinjaOne hervor, um die Abl\u00e4ufe zu optimieren.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"10\" data-aria-level=\"1\"><strong>Unverzichtbar f\u00fcr die Netzverwaltung<\/strong>: Betont die Rolle des Skripts bei der Aufrechterhaltung von Einheitlichkeit und Sicherheit in der Netzverwaltung.<\/li>\n<\/ul>\n<p>Die Verwaltung eines Netzwerks von Linux-Rechnern umfasst verschiedene Aufgaben, von denen eine die \u00c4nderung des Hostnamens eines Ger\u00e4ts ist. Dieser scheinbar einfache Vorgang spielt eine entscheidende Rolle bei der Netzverwaltung und der Ger\u00e4teidentifizierung.<\/p>\n<h2>Hintergrund<\/h2>\n<p>Das betreffende Skript dient dazu, den Hostnamen eines Linux-Ger\u00e4ts zu \u00e4ndern. Sie ist besonders f\u00fcr IT-Experten und <a href=\"https:\/\/www.ninjaone.com\/what-is-an-msp\/\" target=\"_blank\" rel=\"noopener\">Managed Service Provider (MSPs<\/a> ) relevant, die mehrere Linux-Ger\u00e4te verwalten. Ein solches Skript gew\u00e4hrleistet Einheitlichkeit, erleichtert die Verwaltung und tr\u00e4gt zu besseren Sicherheitspraktiken bei.<\/p>\n<h2>Das Skript:<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">#!\/bin\/bash\r\n\r\n# Description: Change the hostname for a linux device (require's hostnamectl\/systemd). Host file update expects the hostname to not be fully qualified.\r\n#\r\n# Release Notes: Initial Release\r\n# By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n#Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n# Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n# Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n# Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n# Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n# Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n# EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n#\r\n# Below are all the (case sensitive) valid parameters for this script.\r\n# Only the new computer name \/ pretty name is required!\r\n# Preset Parameter: \"ReplaceWithNewComputerName\"\r\n# Preset Parameter: \"ReplaceWithNewComputerName\" --update-hostfile\r\n#   --update-hostfile: Will replace the non-fqdn in \/etc\/hosts with the name given in the script (will not un-fullyqualify it)\r\n# Preset Parameter: \"ReplaceWithNewPrettyName\" --prettyname-only\r\n#   --prettyname-only: Set's the 'Pretty' name used by some applications.\r\n# Preset Parameter: \"ReplaceWithNewComputerName\" --restart\r\n#   --restart: Restart's the machine after updating the hostname. This is required for the new name to take immediate effect.\r\n\r\nprint_help() {\r\n  printf '\\n### Below are all the (case sensitive) valid parameters for this script. ###\\n'\r\n  printf '### Only the new computer name \/ pretty name is required! ###\\n'\r\n  printf 'Preset Parameter: \"ReplaceWithNewComputerName\" \\n'\r\n  printf 'Preset Parameter: \"ReplaceWithNewComputerName\" --update-hostfile \\n'\r\n  printf '\\t%s\\n' \"--update-hostfile: Will replace the non-fqdn in \/etc\/hosts with the name given in the script (will not un-fullyqualify it)\"\r\n  printf 'Preset Parameter: \"ReplaceWithNewPrettyName\" --prettyname-only \\n'\r\n  printf '\\t%s\\n' \"--prettyname-only: Set's the 'Pretty' name used by some applications.\"\r\n  printf 'Preset Parameter: \"ReplaceWithNewComputerName\" --restart \\n'\r\n  printf '\\t%s\\n' \"--restart: Restart's the machine after updating the hostname. This is required for the new name to take immediate effect.\"\r\n}\r\n\r\n# Determines whether or not help text is necessary and routes the output to stderr\r\ndie() {\r\n  local _ret=\"${2:-1}\"\r\n  echo \"$1\" &gt;&amp;2\r\n  test \"${_PRINT_HELP:-no}\" = yes &amp;&amp; print_help &gt;&amp;2\r\n  exit \"${_ret}\"\r\n}\r\n\r\n# Commands required for this script\r\nrequired_cmds=\"hostnamectl sed sleep echo\"\r\nfor i in $required_cmds; do\r\n  check=$(type -P \"$i\" 2&gt;\/dev\/null)\r\n  if [[ -z $check ]]; then\r\n    _PRINT_HELP=yes die \"FATAL ERROR: The command $i was not found and is required!\" 1\r\n  fi\r\ndone\r\n\r\n# THE DEFAULTS INITIALIZATION - OPTIONALS\r\n_arg_prettyname_only=\"off\"\r\n_arg_update_hostfile=\"off\"\r\n_arg_restart=\"off\"\r\ntypical=\"on\"\r\n\r\n# Grabbing the parameters and parsing through them.\r\nparse_commandline() {\r\n  while test $# -gt 0; do\r\n    _key=\"$1\"\r\n    case \"$_key\" in\r\n    --prettyname-only)\r\n      typical=\"off\"\r\n      _arg_prettyname_only=\"on\"\r\n      ;;\r\n    --update-hostfile)\r\n      _arg_update_hostfile=\"on\"\r\n      ;;\r\n    --restart)\r\n      _arg_restart=\"on\"\r\n      ;;\r\n    --*)\r\n      _PRINT_HELP=yes die \"FATAL ERROR: Got an unexpected argument '$1'\" 1\r\n      ;;\r\n    *)\r\n      if [[ -z $_arg_name ]]; then\r\n        _arg_name=$1\r\n      else\r\n        _PRINT_HELP=yes die \"FATAL ERROR: Got an unexpected argument '$1' but the new computername '$_arg_name' was already specified\" 1\r\n      fi\r\n      ;;\r\n    esac\r\n    shift\r\n  done\r\n}\r\n\r\n# Initializes parameter processing\r\nparse_commandline \"$@\"\r\n\r\nif [[ -n $setHostnameTo ]]; then\r\n  _arg_name=$setHostnameTo\r\nfi\r\n\r\nif [[ -n $forceRestart &amp;&amp; $forceRestart == \"true\" ]]; then\r\n  _arg_restart=\"on\"\r\nfi\r\n\r\nif [[ -n $action ]]; then\r\n  if [[ $action == \"Set Pretty Name\" ]]; then\r\n    _arg_prettyname_only=\"on\"\r\n    typical=\"off\"\r\n  fi\r\n\r\n  if [[ $action == \"Set Hostname and Update Host File\" ]]; then\r\n    _arg_update_hostfile=\"on\"\r\n  fi\r\nfi\r\n\r\n# Old hostname to use when updating the hosts file or checking success\r\nold_name=$(hostname)\r\n\r\n# Error out on invalid combo\r\nif [[ $typical == \"off\" &amp;&amp; $_arg_update_hostfile == \"on\" ]]; then\r\n  _PRINT_HELP=yes die 'FATAL ERROR: --update-hostfile and --prettyname-only cannot be used together.' 1\r\nfi\r\n\r\n# If the new computer name isn't given error out\r\nif [[ -z $_arg_name ]]; then\r\n  _PRINT_HELP=yes die 'FATAL ERROR: No Computer Name was given! Please enter in the new name in the \"Preset Parameter\" box in Ninja! For Example \"MyNewName\".' 1\r\nfi\r\n\r\n# If the typical use case is given proceed with changing the hostname\r\nif [[ $typical == \"on\" ]]; then\r\n\r\n  pattern='^[a-zA-Z0-9]([a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?$'\r\n  if [[ $_arg_name =~ [^a-zA-Z0-9-] ]] || [[ ! $_arg_name =~ $pattern ]]; then\r\n    _PRINT_HELP=yes die 'FATAL ERROR: Hostname has invalid characters or spaces. Hostname can only contain A-Z characters, Digits or Hyphens.' 1\r\n  fi\r\n\r\n  # Converts the variables to lowercase prior to comparing them\r\n  if [[ \"${old_name,,}\" == \"${_arg_name,,}\" ]]; then\r\n    _PRINT_HELP=yes die \"FATAL ERROR: The name $old_name is already set. Please enter a new name in the 'Preset Parameter' box in Ninja! For Example 'MyNewName'.\" 1\r\n  fi\r\n\r\n  # Sets the hostname\r\n  hostnamectl set-hostname \"$_arg_name\"\r\n\r\n  # Sleep for a few seconds prior to checking that the change worked\r\n  sleep 7\r\n\r\n  current_hostname=$(hostnamectl --static)\r\n\r\n  # Checking if the hostname got set correctly\r\n  if ! [[ \"${current_hostname,,}\" == \"${_arg_name,,}\" ]]; then\r\n    _PRINT_HELP=no die \"FATAL ERROR: Failed to set the hostname from $current_hostname to $_arg_name using hostnamectl is this a systemd system?\" 1\r\n  else\r\n    echo \"Successfully updated the hostname to '$current_hostname'!\"\r\n    printf \"\\nWARNING: The displayname in Ninja will need to be manually updated however the 'Device Name' section will update itself.\\n\\n\"\r\n  fi\r\n\r\n  # If requested to update the hosts file update it\r\n  if [[ $_arg_update_hostfile == \"on\" ]]; then\r\n    echo \"Replacing $old_name in \/etc\/hosts with $_arg_name (if $old_name is in \/etc\/hosts at all)\"\r\n    sed -i \"s\/$old_name\/$_arg_name\/\" \/etc\/hosts\r\n  fi\r\nfi\r\n\r\n# If requested to update the pretty name update it\r\nif [[ $_arg_prettyname_only == \"on\" ]]; then\r\n  current_hostname=$(hostnamectl --pretty)\r\n\r\n  if [[ \"${current_hostname,,}\" == \"${_arg_name,,}\" ]]; then\r\n    _PRINT_HELP=no die \"FATAL ERROR: The pretty name $current_hostname is already set. Please enter a new name in the 'Preset Parameter' box in Ninja! For Example 'MyNewName'.\" 1\r\n  fi\r\n\r\n  hostnamectl set-hostname --pretty \"$_arg_name\"\r\n\r\n  sleep 7\r\n\r\n  current_hostname=$(hostnamectl --pretty)\r\n  if ! [[ \"${current_hostname,,}\" == \"${_arg_name,,}\" ]]; then\r\n    _PRINT_HELP=no die \"FATAL ERROR: Failed to set the pretty name from $current_hostname to $_arg_name using hostnamectl is this a systemd system?\" 1\r\n  else\r\n    echo \"Successfully updated the pretty name to '$current_hostname'!\"\r\n  fi\r\nfi\r\n\r\nif [[ $_arg_restart == \"on\"  ]]; then\r\n  echo \"A restart was requested, restarting...\"\r\n  shutdown -r\r\nelse\r\n  echo \"Please restart this computer at your earliest convenience.\"\r\nfi<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p style=\"text-align: center;\">Zugriff auf \u00fcber 300 Skripte im NinjaOne Dojo<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.ninjaone.com\/freetrialform\/\">Zugang erhalten<\/a><\/p>\n<\/div>\n<h2>Detaillierte Aufschl\u00fcsselung<\/h2>\n<p>Das Skript funktioniert auf folgende Weise:<\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Erste Kontrollen und Parameter<\/strong>: Zun\u00e4chst wird gepr\u00fcft, ob die notwendigen Befehle wie <strong>hostnamectl<\/strong>, <strong>sed<\/strong>, <strong>sleep<\/strong> und <strong>echo<\/strong>vorhanden sind. Wenn welche fehlen, gibt das Skript einen Fehler aus.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Parsing von Argumenten<\/strong>: Das Skript akzeptiert verschiedene Argumente, um den neuen Hostnamen zu setzen, die Hostdatei zu aktualisieren, den h\u00fcbschen Namen zu setzen oder den Rechner neu zu starten. Jedes Argument l\u00f6st bestimmte Aktionen innerhalb des Skripts aus.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Einstellung und Validierung von Hostnamen<\/strong>: Wenn das typische Szenario gew\u00e4hlt wird, setzt das Skript den neuen Hostnamen mit <strong>hostnamectl<\/strong> und \u00fcberpr\u00fcft die \u00c4nderung.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"1\"><strong>Aktualisierung der Hosts-Datei<\/strong>: Falls gew\u00fcnscht, aktualisiert das Skript die Datei <strong>\/etc\/hosts<\/strong> mit dem neuen Hostnamen.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"1\"><strong>Aktualisierung des Anzeigenamens<\/strong>: Zur Aktualisierung des Anzeigenamens verwendet das <strong>Skript erneut &#8222;hostnamectl&#8220; und stellt sicher, dass die \u00c4nderung validiert wird,<\/strong> bevor sie angewendet wird.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"6\" data-aria-level=\"1\"><strong>Option Neustart<\/strong>: Schlie\u00dflich bietet das Skript die M\u00f6glichkeit, den Rechner neu zu starten, um die \u00c4nderungen sofort anzuwenden.<\/li>\n<\/ul>\n<h2>M\u00f6gliche Anwendungsf\u00e4lle<\/h2>\n<p>Stellen Sie sich einen IT-Administrator in einem gro\u00dfen Unternehmen vor, der nach einer Rebranding-Initiative mehrere Linux-basierte Server umbenennen soll. Mit Hilfe dieses Skripts kann der Administrator den Prozess automatisieren und so f\u00fcr Konsistenz sorgen und viel Zeit sparen.<\/p>\n<h2>Vergleiche<\/h2>\n<p>Traditionell erfordert das \u00c4ndern eines Hostnamens die manuelle Bearbeitung von Dateien wie <strong>\/etc\/hostname<\/strong> und <strong>\/etc\/hosts<\/strong>, gefolgt von einem Neustart des Systems. Dieses Skript automatisiert diese Schritte, verringert das Risiko menschlicher Fehler und optimiert den Prozess.<\/p>\n<h2>FAQs<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"1\"><strong>Ist das Skript mit allen Linux-Distributionen kompatibel?<\/strong>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"1\">Es wurde f\u00fcr Systeme entwickelt, die <strong>hostnamectl<\/strong> verwenden, wie es in modernen Distributionen wie Ubuntu, Fedora und CentOS \u00fcblich ist.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"8\" data-aria-level=\"1\"><strong>Wie w\u00e4re es, wenn ich ausschlie\u00dflich den Anzeigenamen \u00e4ndern m\u00f6chte?<\/strong>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"8\" data-aria-level=\"1\">Verwenden Sie das Argument <strong>&#8211;prettyname-only<\/strong>. Es f\u00fchrt keine anderen Aktionen aus und aktualisiert ausschlie\u00dflich den &#8218;Anzeigenamen.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"9\" data-aria-level=\"1\"><strong>Ist ein Neustart des Systems immer notwendig?<\/strong>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"9\" data-aria-level=\"1\">Nicht immer, aber ein Neustart stellt sicher, dass die \u00c4nderungen vollst\u00e4ndig \u00fcbernommen werden.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>Auswirkungen<\/h2>\n<p>Das Skript erleichtert zwar die \u00c4nderung von Hostnamen, aber eine falsche Verwendung kann zu Fehlkonfigurationen des Netzwerks f\u00fchren. Um eine Unterbrechung der Netzdienste zu vermeiden, ist ein geeigneter Sicherungs- und Validierungsmechanismus unerl\u00e4sslich.<\/p>\n<h2>Empfehlungen<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Testen Sie das Skript zun\u00e4chst in einer kontrollierten Umgebung.<\/strong><\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Vergewissern Sie sich, dass Sie \u00fcber die entsprechenden Rechte verf\u00fcgen, bevor Sie das Skript ausf\u00fchren.<\/strong><\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Sichern Sie wichtige Systemdateien wie <\/strong><strong>\/etc\/hosts<\/strong><strong> bevor Sie \u00c4nderungen vornehmen.<\/strong><\/li>\n<\/ul>\n<h2>Abschlie\u00dfende \u00dcberlegungen<\/h2>\n<p>Im Bereich des Ger\u00e4temanagements bieten Tools wie NinjaOne eine umfassende Plattform f\u00fcr die <a href=\"https:\/\/www.ninjaone.com\/de\/effizienz\/\">effiziente Verwaltung solcher Vorg\u00e4nge<\/a>. Die Integration von <a href=\"https:\/\/www.ninjaone.com\/script-hub\/\" target=\"_blank\" rel=\"noopener\">Skripten<\/a> in solche Systeme kann die IT-Verwaltungsprozesse weiter rationalisieren und Aufgaben wie die \u00c4nderung von Hostnamen zu einem Kinderspiel machen, w\u00e4hrend gleichzeitig die Konsistenz gew\u00e4hrleistet und<a href=\"https:\/\/www.ninjaone.com\/blog\/how-human-error-relates-to-cybersecurity-risks\/\"> menschliche Fehler reduziert werden.<\/a><\/p>\n","protected":false},"author":35,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4211],"use_cases":[4307],"class_list":["post-260953","script_hub","type-script_hub","status-publish","hentry","script_hub_category-linux","use_cases-allgemeine-konfiguration"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub\/260953","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/comments?post=260953"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/media?parent=260953"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/operating_system?post=260953"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/use_cases?post=260953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}