How to Install VS Code-Server on AlmaLinux 8

Code-Server is a Microsoft Visual Studio Code service instance running on a local or remote server accessible through any web browser for yourself or a team. Some other advantages include accessing it from any device such as a tablet or laptop with a consistent, integrated development environment (IDE).

Requirements

  • Code-server has the following requirements:
  • 64-bit host.
  • At least 2GB of RAM.
  • 2 cores or more are recommended

In the following tutorial, you will learn how to install Visual Studio (vscode) Code-Server on AlmaLinux 8 Workstation or Server along with some basic setup and helpful tips.

Update AlmaLinux

Begin by making sure your system is up to date with the latest packages, failure to do this may result in issues further down the line with the installation or your system in general.

sudo dnf upgrade --refresh

Install Dependecies

Before installing, make sure you have installed the following dependencies by running the following command.

sudo dnf install curl nano -y

Now you can proceed to install VS Code-Server.

Install Code-Server

Installing Code-Server is straightforward as there is an automated script to download that executes the installation on your behalf with everything needed, making fewer chances of mistakes occurring.

Use the following command to install Code-Server.

curl -fsSL https://code-server.dev/install.sh | sh

Alternatively, you can preview the install process using the following command instead.

curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run

Enable Code-Server

With the installation complete, you can begin launching your Code-Server service. First, use the following command to enable the service immediately and at system startup.

sudo systemctl enable --now code-server@$USER

Next, confirm the service is active, and no errors have occurred.

systemctl status code-server@$USER

Example output:

How to Install VS Code-Server on AlmaLinux 8

Alternatively, use the following command instead for users who do not wish to run Code-Server in the background.

code-server

Configure Code-Server

Allow Outside Connections

Code-Server is accessed by using the localhost as per default. For users that want to connect remotely, you need to modify the configuration file to allow outside connections.

First, open up your config.yaml configuration file.

sudo nano ~/.config/code-server/config.yaml

Next, change 127.0.0.0:8080 (localhost) to 0.0.0.0:8080 (allow range) as per the following.

While in the terminal screen, you can optionally change the password, which is advised.

Example:

How to Install VS Code-Server on AlmaLinux 8

Save the file Ctrl+O, hit the ENTER BUTTON, and then use Ctrl+X to exit.

Next, proceed to restart the service using the following command.

sudo systemctl restart code-server@$USER

Allow Code-Server Ports on FirewallD

By default, Code-Server uses port 8080 to listen for connections. For users that want to connect remotely, you will need to open the port in FirewallD. Some users would like to also open ports 80 and 443 for using domains.

Below is an all-in-one command, remove the ports you do not require.

sudo firewall-cmd --add-port={8000,80,443}/tcp --permanent

Reload the service once done.

sudo firewall-cmd --reload

Login to Code-Server with Web Browser

With the configurations completed, you can log in to your Code-Server environment for VS (Visual Studio). Most users who are not using a domain will use the server’s IP address followed by port 8080.

{ip-address}:8080

Example:

How to Install VS Code-Server on AlmaLinux 8

Note, if you forgot your password, you could quickly print this from the configuration file using the grep command.

grep password ~/.config/code-server/config.yaml

Example output:

How to Install VS Code-Server on AlmaLinux 8

Once open, you will arrive at your VS Code environment where you can begin work or with your team.

Example (Click Image to Expand):

How to Install VS Code-Server on AlmaLinux 8

Update/Upgrade Code-Server

To update your Code-Server, you just rerun the installation script to check for updates and handle things automatically.

For users that tend to forget, you can set up a cronjob for this as follows.

First, open crontab using the following command.

sudo crontab -e

Next, add the following with a timer set to weekly.

0 0 */1 * * curl -fsSL https://code-server.dev/install.sh | sh >/dev/null 2>&1 | bash >/dev/null 2>&1

Alternatively, if you install Code-Server on a desktop environment that you reboot frequently, you can enable updates on system boot instead.

@reboot curl -fsSL https://code-server.dev/install.sh | sh >/dev/null 2>&1 | bash >/dev/null 2>&1

Save the cronjob press : key and type the wa to save, then repeat and use qa to exit.

Users unsure of setting timers for cron, please check out the Crontab.GURU is one of the best time calculators I have personally seen that is great for beginners.

Remove (Uninstall) Code-Server

For users that want to remove Code-Server on their AlmaLinux system, run the following command.

sudo dnf autoremove code-server

Next, remove the data associated with Code-Server as follows.

sudo rm -rf ~/.local/share/code-server ~/.config/code-server \
sudo rm -rf ~/.local/lib/code-server-*

Comments and Conclusion

In the tutorial, you have installed the Code-Server for VS Code on AlmaLinux 8 along with how to update and if need be remove it.

Consider using code-server if you want to take your development game up a notch. This project can help you write code on all of your devices with a consistent dev environment and speed up your workflow by leveraging large cloud servers. Check it out on GitHub and see how you can integrate it into your next project!



Follow LinuxCapable.com!

Like to get automatic updates? Follow us on one of our social media accounts!