Install Visual Studio Code on AlmaLinux 8: Free Text Editor

Posted on

Install Visual Studio Code on AlmaLinux 8: Free Text Editor

Install Visual Studio Code on AlmaLinux 8: Free Text Editor

This guide will walk you through the process to Install Visual Studio Code on AlmaLinux 8. Visual Studio Code (commonly known as VS Code) is a free and open-source text editor developed by Microsoft. It’s a cross-platform tool available for Windows, Linux, and macOS. Despite being lightweight, VS Code boasts a rich set of features that have contributed to its widespread adoption as a preferred development environment.

VS Code provides support for a diverse range of programming languages, including Java, C++, Python, CSS, Go, and Dockerfile. Furthermore, its extensibility allows users to add and even create custom extensions for enhanced functionality, such as code linters, debuggers, and cloud and web development support.

Follow the steps outlined below to successfully complete the VS Code setup on your AlmaLinux 8 system.

Before you begin, ensure you are logged into your AlmaLinux 8 server as a non-root user with sudo privileges. If you haven’t already configured this, refer to our guide on Initial Server Setup with AlmaLinux 8.

1. VS Code Setup on AlmaLinux 8

First, update your local package index to ensure you have the latest package information. Execute the following command:

sudo dnf update -y

Install Development Tools

Next, install the necessary development tools. This will provide essential utilities for building and running software. Use the following command:

sudo dnf groupinstall "Development Tools" -y

Visual Studio Code packages are not included in the default AlmaLinux repository. Therefore, you need to add the official Microsoft repository to your system.

Import Visual Studio Code GPG key

To ensure the integrity and authenticity of the packages, import the GPG key used to sign them. Run the following command:

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

Add Visual Studio Code Repository

Now, add the Visual Studio Code repository to your system’s package manager. This will allow you to install VS Code using the dnf package manager. Use the following command:

printf "[vscode]nname=packages.microsoft.comnbaseurl=https://packages.microsoft.com/yumrepos/vscode/nenabled=1ngpgcheck=1nrepo_gpgcheck=1ngpgkey=https://packages.microsoft.com/keys/microsoft.ascnmetadata_expire=1h" | sudo tee -a /etc/yum.repos.d/vscode.repo
Add Visual Studio Code Repository

After adding the repository, it’s recommended to run a system update to refresh the package list.

Run System Update

sudo dnf update -y

Command to Install VS Code

Finally, you can now Install Visual Studio Code on AlmaLinux 8 using the following command:

sudo dnf install code -y

2. Launch Visual Studio Code on AlmaLinux 8

With VS Code successfully installed, you can launch it using several methods. One way is to execute the code command in your terminal:

code

Alternatively, you can run the code & command to launch VS Code in the background, allowing you to continue using the terminal during your VS Code session:

code &

You can also launch VS Code from your desktop environment. Navigate to the following path:

**Applications -> Programming -> Visual Studio Code**

Upon the first launch of VS Code, a welcome window similar to the one below will appear:

visual studio code app

You can now begin installing extensions and configuring VS Code to suit your development preferences.

For further information and advanced configuration options, refer to the Visual Studio Code Documentation.

3. Update Visual Studio Code

To keep your VS Code installation up to date with the latest features and security patches, you can update the package through your desktop’s standard Software Update tool or by executing the following commands:

# sudo dnf update -y
# sudo dnf upgrade -y

4. Uninstall VS Code From AlmaLinux 8

If you wish to remove VS Code from your system, use the following command:

sudo dnf autoremove code -y

To completely remove the VS Code repository and prevent future installations, run the following command:

sudo rm /etc/yum.repos.d/vscode*
**<mark>Output</mark>**
rm: remove regular file '/etc/yum.repos.d/vscode.repo'? y

Conclusion

You have successfully learned how to Install Visual Studio (VS) Code on AlmaLinux 8.

I hope this guide was helpful. You may also find these articles on the AlmaLinux Tutorials Center useful:

How To Install Bitwarden on AlmaLinux 8

How To Install OpenJDK 17 on AlmaLinux 9

Alternative Installation Methods

While the above method using the official Microsoft repository is the recommended approach, here are two alternative methods to Install Visual Studio Code on AlmaLinux 8:

1. Using Flatpak

Flatpak is a universal package manager that allows you to install applications across different Linux distributions. It provides a sandboxed environment for applications, enhancing security and isolating them from the core system.

Installation Steps:

  1. Install Flatpak: If Flatpak is not already installed on your system, install it using the following command:

    sudo dnf install flatpak -y
  2. Add the Flathub repository: Flathub is a popular repository for Flatpak applications. Add it to your system using the following command:

    flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
  3. Install Visual Studio Code: Install VS Code using Flatpak with the following command:

    flatpak install flathub com.visualstudio.code
  4. Run Visual Studio Code: After the installation is complete, you can run VS Code using the following command:

    flatpak run com.visualstudio.code

Explanation:

Flatpak offers a convenient way to install applications without relying on system-specific packages. The flatpak install command downloads and installs VS Code from the Flathub repository. The flatpak run command executes the application within its sandboxed environment. Updating VS Code installed via Flatpak is handled through Flatpak’s update mechanism: flatpak update.

2. Using Snap

Snap is another universal package manager that, similar to Flatpak, allows you to install applications across different Linux distributions and it also offers sandboxing.

Installation Steps:

  1. Install Snapd: If Snapd is not already installed on your system, install it using the following command:

    sudo dnf install snapd -y
    sudo systemctl enable --now snapd.socket
    sudo ln -s /var/lib/snapd/snap /snap

    Log out and log back in to ensure that snap’s paths are updated correctly.

  2. Install Visual Studio Code: Install VS Code using Snap with the following command:

    sudo snap install --classic code
  3. Run Visual Studio Code: After the installation is complete, you can run VS Code using the following command:

    code

Explanation:

The snap install command downloads and installs VS Code from the Snap store. The --classic option is required because VS Code needs full access to the system. Updating VS Code installed via Snap is handled through Snap’s update mechanism: sudo snap refresh code.

Both Flatpak and Snap offer an alternative to using the official Microsoft repository for installing VS Code. They provide sandboxing and simplified installation processes, making them suitable for users who prefer universal package managers. However, keep in mind that these methods may result in slightly larger installation sizes and potentially slower startup times compared to the native package installation.

Leave a Reply

Your email address will not be published. Required fields are marked *