How To Change Hostname on Fedora 43

Configuring your system’s hostname is a fundamental task in Linux administration that affects network identification, system management, and server communication. Whether you’re setting up a new Fedora 43 workstation, managing multiple servers, or simply personalizing your Linux environment, understanding how to properly change your hostname is essential for effective system administration.
Fedora 43, released in October 2024, continues to use systemd as its initialization system, making hostname management streamlined through the hostnamectl command. This guide covers multiple proven methods to change your hostname on Fedora 43, from command-line tools to graphical interfaces, ensuring you can choose the approach that best fits your workflow and expertise level. Each method has been tested on Fedora 43 to provide accurate, actionable instructions that work reliably across different installation types, including Workstation, Server, and various Spins.
By the end of this tutorial, you’ll understand the different types of hostnames, master multiple modification techniques, and know how to troubleshoot common issues that arise during hostname configuration.
Understanding Hostnames in Fedora 43
Before diving into the modification process, it’s important to grasp what a hostname represents and how Fedora 43 manages these identifiers within its systemd architecture.
What Is a Hostname?
A hostname serves as your computer’s unique identifier on a network. Think of it as your system’s name that distinguishes it from other machines when communicating across local networks or the internet. When you open a terminal, you’ll typically see your username followed by your hostname in the command prompt.
Types of Hostnames in Linux
Fedora 43’s systemd-based architecture recognizes three distinct hostname types, each serving specific purposes:
Static Hostname: This is the permanent, traditional hostname stored in /etc/hostname and used to initialize the system’s name during boot. It persists across reboots and serves as your system’s primary identifier.
Transient Hostname: A dynamic, temporary hostname that can be modified at runtime by programs or network services. The kernel maintains this hostname, and it defaults to the static hostname if not specifically set.
Pretty Hostname: A free-form, UTF-8 hostname designed for presentation to users. Unlike static hostnames, pretty hostnames can include spaces, special characters, and mixed case letters, making them more human-readable. An example might be “John’s Fedora 43 Development Workstation.”
Hostname Naming Conventions and Best Practices
Following proper naming conventions prevents configuration errors and ensures compatibility across network services:
- Use only lowercase letters, numbers, hyphens, and periods
- Keep hostname length between 2 and 64 characters
- Never start or end hostnames with hyphens
- Avoid using underscores, spaces, or special characters in static hostnames
- Choose descriptive names that indicate the system’s purpose without revealing sensitive information
Valid examples include: fedora43-workstation, dev-server-01, webhost.example.com
Prerequisites and Requirements
Before modifying your system’s hostname, ensure you have the following in place:
- A running Fedora 43 system (Workstation, Server, or any official Spin)
- Root access or a user account with sudo privileges
- Basic terminal familiarity for command-line methods
- Active terminal emulator or GNOME desktop access (Fedora Workstation 43 includes GNOME 49)
While hostname changes are generally safe, documenting your current configuration before making modifications represents good system administration practice. This documentation becomes particularly valuable in enterprise environments where multiple administrators manage systems.
Method 1: Checking Your Current Hostname
Understanding your existing hostname configuration provides context before making changes and helps verify modifications afterward.
Using the hostname Command
The simplest way to view your current hostname involves the basic hostname command:
hostname
This displays your system’s current hostname without additional details. Short and direct.
To view your Fully Qualified Domain Name (FQDN), which includes your hostname and domain name, use:
hostname --fqdn
You can also use the shorter option -f to achieve the same result.
Using hostnamectl Command
The hostnamectl command provides comprehensive hostname information integrated with systemd:
hostnamectl
Or explicitly:
hostnamectl status
This command displays detailed system information including all three hostname types (static, transient, and pretty), along with additional data such as chassis type, machine ID, boot ID, operating system details, kernel version, and system architecture. This comprehensive output makes hostnamectl the preferred method for system administrators who need complete hostname context.
Alternative Verification Methods
Additional commands provide quick hostname checks from different system perspectives:
The uname -n command shows the network node hostname:
uname -n
Direct file inspection reveals the static hostname stored during boot:
cat /etc/hostname
Each method serves different purposes. Use hostname for quick checks, hostnamectl for comprehensive information, and file inspection for verification that configuration files contain correct values.
Method 2: Changing Hostname Using hostnamectl Command (Recommended)
The hostnamectl command represents the standard, recommended approach for hostname modification on Fedora 43 and other modern Linux distributions using systemd.
Why hostnamectl Is the Recommended Method
Several technical advantages make hostnamectl superior to alternative approaches:
- Native systemd integration: Designed specifically for systemd-based distributions like Fedora 43
- Automatic propagation: Changes apply to all hostname types simultaneously
- Configuration file management: Automatically updates
/etc/hostnamewithout manual editing - Persistence: Changes survive reboots without additional configuration
- Simplicity: Single command accomplishes what previously required editing multiple files
These benefits make hostnamectl the go-to tool for both novice users and experienced system administrators.
Step-by-Step Instructions
Follow these detailed steps to change your Fedora 43 hostname using hostnamectl:
Step 1: Open your terminal application. On Fedora Workstation 43 with GNOME 49, press the Super key (Windows key) and type “Terminal,” then press Enter.
Step 2: Check your current hostname configuration to document the existing setup:
hostnamectl
Review the output, noting your current static, transient, and pretty hostnames.
Step 3: Change your hostname using the following syntax:
sudo hostnamectl set-hostname new-hostname
Replace new-hostname with your desired hostname. For example:
sudo hostnamectl set-hostname fedora43-workstation
Step 4: Enter your sudo password when prompted. The system won’t display characters as you type for security purposes—this is normal behavior.
Step 5: Verify the hostname change took effect:
hostnamectl
Examine the output to confirm all hostname types now reflect your new hostname.
Step 6: Apply the change to your current terminal session:
exec bash
This command restarts your shell without closing the terminal window, allowing the new hostname to appear in your command prompt immediately.
Step 7: Open a new terminal window or tab to see the updated hostname displayed in the shell prompt. The prompt typically shows your username, hostname, and current directory.
The entire process takes less than a minute and provides immediate results without requiring a system reboot.
Setting Different Hostname Types Individually
Advanced scenarios sometimes require setting individual hostname types separately. The hostnamectl command supports this through specific options:
Set only the static hostname:
sudo hostnamectl set-hostname fedora43-dev --static
Configure a transient hostname for temporary use:
sudo hostnamectl set-hostname temp-hostname --transient
Define a pretty hostname with spaces and special characters:
sudo hostnamectl set-hostname "Development Workstation - Fedora 43" --pretty
Setting a pretty hostname separately proves useful when you want a technical, network-compatible static hostname but a more descriptive display name for system settings and user interfaces. Network services use the static hostname, while GNOME settings display the pretty hostname for better user experience.
Method 3: Changing Hostname Temporarily (Without Reboot Persistence)
Temporary hostname changes serve specific use cases where persistence isn’t required or desired.
When to Use Temporary Hostnames
Consider temporary hostname modification for these scenarios:
- Testing new hostname configurations before making them permanent
- Troubleshooting network connectivity issues where hostname conflicts might exist
- Running automated scripts that require specific hostnames during execution
- Development environments where you switch between different project configurations
Understanding that temporary changes revert after reboot prevents confusion when your modifications don’t persist.
Step-by-Step Process
Implementing a temporary hostname change requires fewer steps than permanent modification:
Step 1: Open your terminal with standard user access. Sudo privileges are still required for the actual modification.
Step 2: Execute the hostname command with sudo and your desired temporary name:
sudo hostname fedora-test
Step 3: Verify the change immediately:
hostname
The output should display your new temporary hostname.
Step 4: Update your current shell session to reflect the change:
exec bash
Step 5: Confirm that /etc/hostname remains unchanged:
cat /etc/hostname
The file still contains your original hostname, demonstrating that this change exists only in memory.
After rebooting your system, Fedora 43 reads the static hostname from /etc/hostname and reverts to that value, discarding your temporary modification. This behavior makes temporary changes safe for experimentation without affecting your production configuration.
Limitations and Considerations
Temporary hostname changes carry several important limitations:
Some network services may not recognize the modified hostname until they restart. Services that cached the original hostname at startup continue using the old value. Additionally, any systemd service that explicitly reads /etc/hostname uses the permanent hostname rather than your temporary change, potentially creating inconsistent behavior across different system components.
Production servers and permanent workstation configurations should always use persistent hostname modification methods to ensure consistent network identification and service behavior.
Method 4: Changing Hostname via GNOME Settings (GUI Method)
Fedora Workstation 43 users benefit from graphical hostname management through the GNOME Settings application, providing an intuitive alternative to command-line methods.
Accessing GNOME Settings in Fedora 43
Fedora Workstation 43 ships with GNOME 49, featuring a refined interface and Wayland-only sessions. The Settings application integrates seamlessly with this desktop environment.
Launch GNOME Settings using any of these methods:
- Press the
Superkey, type “Settings,” and press Enter - Click the system menu in the top-right corner and select “Settings”
- Open the application grid (Super + A) and click the Settings icon
The Settings application provides centralized system configuration, including hostname management.
Step-by-Step GUI Instructions
Modifying your hostname through GNOME Settings requires no terminal commands:
Step 1: Open the Settings application using your preferred method from above.
Step 2: Navigate to the “About” section in the left sidebar. This section contains system information including hardware specifications, operating system version, and hostname configuration.
Step 3: Locate the “Device Name” field near the top of the About panel. This field displays your current hostname.
Step 4: Click directly on the Device Name field. The field becomes editable when clicked.
Step 5: Delete the existing hostname and type your new desired hostname. GNOME automatically validates your input against naming conventions.
Step 6: Click outside the field or press Enter to apply the change. GNOME Settings automatically calls hostnamectl in the background to implement your modification.
Step 7: Close the Settings application. Your change takes effect immediately.
Step 8: Open a terminal window to verify the new hostname appears in your shell prompt and can be confirmed with hostnamectl.
No authentication dialog appears if you’re logged in as the primary administrator user, as GNOME handles permission management seamlessly. Secondary users may need to enter an administrator password.
Advantages of GUI Method
The graphical approach offers several benefits for desktop users:
User-friendly interface removes the intimidation factor for Linux newcomers who haven’t mastered terminal commands. Visual confirmation provides immediate feedback that your change was accepted. Integration with GNOME 49’s system settings creates a cohesive user experience consistent with other system configurations. The method automatically handles systemd integration, ensuring proper communication with all system components that track hostname information.
Desktop-focused Fedora Workstation 43 users typically find this method most convenient for occasional hostname modifications, while system administrators managing multiple servers prefer command-line approaches for scripting and remote management capabilities.
Method 5: Manually Editing Configuration Files
Direct configuration file editing provides maximum control and proves essential for automated provisioning scripts and advanced customization scenarios.
Understanding the Configuration Files
Two primary files govern hostname configuration in Fedora 43:
The /etc/hostname File: This simple text file contains your static hostname on a single line. The systemd initialization system reads this file during boot to establish your system’s network identity.
The /etc/hosts File: This file maps hostnames to IP addresses for local name resolution. While not strictly required for hostname changes, updating this file ensures proper local hostname resolution and prevents certain network services from experiencing delays or errors.
Manual editing suits automation scripts, configuration management tools like Ansible, and situations where hostnamectl isn’t available. Exercise caution when editing system configuration files—syntax errors can cause boot issues or network problems.
Editing /etc/hostname File
Modify the primary hostname configuration file using these steps:
Step 1: Open the file with your preferred text editor using sudo privileges:
sudo nano /etc/hostname
Alternative editors include vi, vim, or gedit for GNOME desktop users who prefer graphical editors.
Step 2: The file typically contains a single line with your current hostname. Delete the existing content and replace it with your new hostname:
fedora43-server
Ensure no extra spaces, blank lines, or special characters appear in the file. The file should contain only your new hostname.
Step 3: Save the file. In nano, press Ctrl+O (write out), then Enter to confirm, followed by Ctrl+X to exit.
Step 4: Verify the file was saved correctly:
cat /etc/hostname
The output should show only your new hostname.
Updating /etc/hosts File
Synchronizing the hosts file with your new hostname prevents local resolution issues:
Step 1: Open the hosts file with elevated privileges:
sudo nano /etc/hosts
Step 2: Locate lines containing your old hostname. The file typically includes entries mapping localhost and your hostname to IP addresses:
127.0.0.1 localhost
127.0.1.1 old-hostname
Step 3: Replace all instances of the old hostname with your new hostname:
127.0.0.1 localhost localhost.localdomain
127.0.1.1 fedora43-server
The 127.0.1.1 address specifically handles hostname-to-IP mapping for your local system.
Step 4: Save and exit the editor using the same process as before.
Step 5: Verify your changes:
cat /etc/hosts
Properly formatted entries ensure network services resolve your hostname correctly for local communications.
Applying the Changes
Manual configuration file edits require additional steps to activate:
The most reliable method involves rebooting your system:
sudo reboot
Alternatively, restart the systemd-hostnamed service to apply changes without a full reboot:
sudo systemctl restart systemd-hostnamed
After restarting or rebooting, verify your hostname using hostnamectl or hostname commands. If changes don’t persist, review your configuration files for syntax errors or permission issues.
Verifying Your Hostname Changes
Thorough verification ensures your hostname modification succeeded and persists across different system components.
Multiple Verification Methods
Use several complementary approaches to confirm successful hostname changes:
Run the comprehensive hostnamectl command for complete hostname status:
hostnamectl
Check that static, transient, and pretty hostnames all reflect your intended changes.
Use the quick hostname command for simple verification:
hostname
Open a new terminal window and observe the shell prompt. Most shell configurations display your username and hostname, providing immediate visual confirmation.
Inspect the configuration file directly:
cat /etc/hostname
Test FQDN resolution:
hostname -f
Verify local network resolution using ping:
ping -c 4 $(hostname)
Successful ping responses confirm that your system can resolve its own hostname to an IP address.
Understanding Verification Output
Successful hostname changes produce consistent results across all verification methods. The hostnamectl output displays your new hostname in the “Static hostname” field, and matching values should appear for transient and pretty hostnames unless you’ve specifically set them differently.
Your terminal prompt updates to show the new hostname (typically displayed as username@newhostname). The /etc/hostname file contains your new hostname as its only content. Network resolution commands return without errors or timeouts.
Inconsistent results across different verification methods indicate incomplete configuration. Certain system services cache hostname information and may require restarts or a full system reboot to recognize changes. Services particularly sensitive to hostname changes include SSH servers, mail transfer agents, and web servers configured with hostname-based virtual hosts.
Troubleshooting Common Issues
Even straightforward hostname changes occasionally encounter problems. These solutions address the most frequent issues.
Hostname Not Persisting After Reboot
When your hostname reverts to the original value after restarting, several causes might be responsible:
First, verify that /etc/hostname contains your new hostname:
cat /etc/hostname
If the file still shows the old hostname, your modification method didn’t update the file properly. Use hostnamectl set-hostname instead of temporary methods.
Check the systemd-hostnamed service status:
sudo systemctl status systemd-hostnamed
The service should show as active. If inactive or failed, restart it:
sudo systemctl restart systemd-hostnamed
sudo systemctl enable systemd-hostnamed
Examine file permissions on /etc/hostname. The file should be readable by all users but writable only by root:
ls -l /etc/hostname
Correct permissions if necessary:
sudo chmod 644 /etc/hostname
Some network management tools or cloud initialization scripts automatically set hostnames during boot, overwriting your configuration. Cloud instances particularly may have initialization scripts that reset hostnames. Consult your hosting provider’s documentation for cloud-based systems.
Permission Denied Errors
“Permission denied” messages when attempting hostname changes indicate insufficient privileges:
Confirm you’re using sudo with hostname modification commands:
sudo hostnamectl set-hostname newhostname
Verify your account has sudo privileges:
sudo -l
This command lists your sudo permissions. If you see “not allowed to run sudo” messages, contact your system administrator to grant appropriate access.
Ensure you’re typing the sudo password correctly. The system provides no visual feedback when entering passwords—no asterisks or dots appear—which can cause confusion for new users.
Network Services Not Recognizing New Hostname
Applications and services sometimes continue using the old hostname even after successful modification:
Restart NetworkManager to propagate the hostname change to network-dependent services:
sudo systemctl restart NetworkManager
Verify your /etc/hosts file includes correct hostname-to-IP mappings:
cat /etc/hosts
Update the file if it still references your old hostname.
Restart specific services that depend on hostname configuration. For SSH servers:
sudo systemctl restart sshd
For web servers like Apache:
sudo systemctl restart httpd
Some applications cache hostname information in their own configuration files. Check service-specific configuration directories (typically under /etc/) for hardcoded hostname references.
A complete system reboot resolves most service recognition issues, as all processes start fresh with the new hostname from /etc/hostname. Schedule reboots during maintenance windows for production systems.
Invalid Hostname Error Messages
Hostname validation failures occur when attempting to use non-compliant names:
Review hostname naming conventions:
- Use only lowercase letters, numbers, hyphens, and periods
- Stay within 2-64 character length
- Never start or end with hyphens
- Avoid underscores, spaces, and special characters
Invalid examples: my_server, Server-, -webhost, my server (space)
Valid examples: my-server, webhost01, dev.example.com
Choose a compliant hostname format and retry the modification. For pretty hostnames, remember that the --pretty option allows spaces and special characters, but the static hostname must still follow strict conventions.
Congratulations! You have successfully changed the Hostname. Thanks for using this tutorial to change the Hostname on your Fedora 43 Linux system. For additional or useful information, we recommend you check the official Fedora website.