Cockpit is a free remote server manager that is lightweight and easy to use for GNU/Linux servers. Cockpit is a web-based graphical interface for servers intended for people new to Linux to the experts such as sysadmins. Cockpit makes Linux discoverable, allowing anyone using the software to perform tasks such as start containers, administer storage, configure networks, and inspect logs.
In the following tutorial, you will learn how to install Cockpit on your Rocky Linux 8 system.
Table of Contents
Prerequisites
- Recommended OS: Rocky Linux 8.+.
- User account: A user account with sudo or root access.
Update Operating System
Update your Rocky Linux operating system to make sure all existing packages are up to date:
sudo dnf upgrade --refresh -y
The tutorial will be using the sudo command and assuming you have sudo status. To verify sudo status on your account:
sudo whoami
Example output showing sudo status:
[joshua@rockylinux ~]$ sudo whoami
root
To set up an existing or new sudo account, visit our tutorial on How to Add a User to Sudoers on Rocky Linux.
To use the root account, use the following command with the root password to log in.
su
Install Cockpit
By default, Cockpit is in the default App stream repository and, depending on the variation of your installation, should be installed by default. However, the tutorial will run through a complete installation if it is missing or you removed it.
To install Cockpit, execute the following command in your terminal.
sudo dnf install cockpit -y
Once installed, by default, the service is not active, so you will need to do a few systemctl commands as follows.
To start Cockpit:
sudo systemctl start cockpit.socket
To enable Cockpit on system startup:
sudo systemctl enable cockpit.socket
Next, verify the status of Cockpit to make sure it is running correctly on your Rocky Linux system:
sudo systemctl status cockpit
Example output if everything is working correctly:
Configure Firewall for Cockpit
The next step is to allow through your firewall Cockpit to have access to listen. By default, Cockpit listens on port 9090.
To set this, execute the following command in your terminal.
sudo firewall-cmd --permanent --zone=public --add-service=cockpit
sudo firewall-cmd --reload
By default, Cockpit should have allowed rules if added installed originally with your Rocky Linux 8 installation. If you see the following error, you are safe to move on.
Warning: ALREADY_ENABLED: cockpit
How to Access Cockpit Web UI
Now that you have confirmed or installed Cockpit, it is time to open it using your favorite Internet Browser.
First, find out your servers IP address:
ip a
Next, in your browser, type the example address with port 9090 at the end.
http://server-ip-address:9090
When you first try to navigate to the Cockpit Web UI, you will come across an alert as follows:
You will be notified that the connections are not private, click on the Advanced button.
Accept the Risk and Continue without an SSL to proceed to the Cockpit login.
Next, you will see the Cockpit login, and this is your same sudo username or root username and password—log in to proceed to the dashboard.
Once logged in, you will see the immediate dashboard. Cockpit’s main options are on the left side, where you can add additional hosts if they have SSH allow connections, view logs, configure network and containers, restart, kill and maintain services and much more.
As mentioned above, in the middle of the screen, you can monitor memory and CPU usage and see detailed history. One of the main benefits of using Cockpit is having a terminal screen in a Web UI. At the bottom of the page, click Terminal.
As above, you have a terminal with the power of using a Web-based GUI to assist you in bringing the best of both worlds together.
Comments and Conclusion
In the tutorial, you have learned how to install or enable Cockpit for Rocky Linux 8. Overall, Cockpit is a fantastic option for users to maintain their systems easily. It is designed for new users with sysadmins in mind and the ability to be operated remotely. If you are getting into Linux, using Cockpit would be a solid option in understanding how the systems work and identifying issues quickly within a few clicks.