DEV Community

abbazs
abbazs

Posted on • Edited on

4 1

How to install Visual Studio Code (vscode) in ubuntu using apt-get?

How to install Visual Studio Code (VSCode) from the terminal?

  1. Open the terminal: You can open the terminal by pressing Ctrl+Alt+T or searching for "Terminal" in your system's application launcher.

  2. Download the Microsoft GPG key: Run the following command to download the Microsoft GPG key and save it as microsoft.gpg:

    curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
    
  3. Install the GPG key: Run the following command to install the GPG key into the trusted keyring:

    sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
    
  4. Add the VSCode and Microsoft Edge repositories: Run the following commands to add the VSCode and Microsoft Edge repositories to the system:

    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge.list'
    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
    
  5. Remove the downloaded GPG key: Run the following command to remove the microsoft.gpg file:

    sudo rm microsoft.gpg
    
  6. Update package information: Run the following command to update the package information from the repositories:

    sudo apt update
    
  7. Install VSCode: Run the following command to install Visual Studio Code:

    sudo apt install -y code
    
  8. (Optional) Install with aptitude: If you use aptitude package manager, you can run the following commands instead of step 7 to install VSCode:

    sudo aptitude update
    sudo aptitude install -y code
    

Visual Studio Code should now be installed on your system. You can launch it by searching for "Visual Studio Code" in your system's application launcher or by running the code command in the terminal.

Complete script

# Download the Microsoft GPG key
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg

# Install the GPG key
sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/

# Add the VSCode and Microsoft Edge repositories
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge.list'
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'

# Remove the downloaded GPG key
sudo rm microsoft.gpg

# Update package information
sudo apt update

# Install VSCode
sudo apt install -y code

# (Optional) Install with aptitude
# If you use `aptitude` package manager, uncomment the following lines
# sudo aptitude update
# sudo aptitude install -y code
Enter fullscreen mode Exit fullscreen mode

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay