How to Install Visual Studio Code on Ubuntu: A Complete Step by Step Guide
Visual Studio Code (VS Code) is a popular and versatile code editor used by many developers. If you’re using Ubuntu and want to set up VS Code, follow this guide for a clear, step-by-step installation process.
Step 1: Update Your System
Keeping your system up-to-date ensures all your software packages are current and secure.
-
Open a terminal by pressing
Ctrl + Alt + T. -
Run the following command to update your package list:
sudo apt update- What this does: Updates your package list with the latest information about available packages and their versions from the repositories.
-
Next, upgrade your installed packages to their latest versions:
sudo apt upgrade- What this does: Upgrades all installed packages to their latest versions based on the updated package list.
Step 2: Install Required Tools
Before adding the VS Code repository, you need to install a few essential tools.
-
Run the following command:
sudo apt install software-properties-common apt-transport-https wgetsoftware-properties-common: Provides theadd-apt-repositorycommand to add new repositories.apt-transport-https: Allowsaptto use repositories accessed over HTTPS, ensuring a secure connection.wget: A utility for downloading files from the web, used to get Microsoft’s GPG key.
Step 3: Add Microsoft’s Repository
To get VS Code, you need to add Microsoft’s official repository.
-
Import the Microsoft GPG key with:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -- What this does:
wget -qO-downloads the key from Microsoft’s servers and| sudo apt-key add -adds it to your system’s list of trusted keys.
- What this does:
-
Add the VS Code repository with:
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"- What this does: Adds the VS Code repository to your list of package sources, allowing you to install VS Code using
apt.
- What this does: Adds the VS Code repository to your list of package sources, allowing you to install VS Code using
Step 4: Install Visual Studio Code
With the repository added, you can now install VS Code.
-
Update your package list to include packages from the new repository:
sudo apt update- What this does: Updates your package list to include the packages available in the newly added VS Code repository.
-
Install VS Code with:
sudo apt install code- What this does: Installs Visual Studio Code from the repository.
Step 5: Open Visual Studio Code
To start VS Code:
-
Type
codein the terminal:code- What this does: Launches the Visual Studio Code application.
- Alternatively, you can find VS Code in your application menu.
Optional: Install Extensions
VS Code’s functionality can be extended with various extensions.
- Open VS Code, then:
- Click on the Extensions view icon on the Sidebar or press
Ctrl + Shift + X. - Search for and install extensions like:
- Python: For Python development.
- Prettier: For code formatting.
- GitLens: For enhanced Git capabilities.
Troubleshooting Tips
If you encounter issues, here are some troubleshooting steps:
-
Missing Dependencies: Fix them with:
sudo apt install -f- What this does: Attempts to fix any broken dependencies by installing missing packages.
-
Broken Packages: Resolve them with:
sudo apt --fix-broken install- What this does: Fixes broken packages and dependencies that might be preventing the installation of new software.
Conclusion
You’ve successfully installed Visual Studio Code on Ubuntu! With VS Code, you have a powerful tool to enhance your coding experience. If you have any questions or run into problems, don’t hesitate to seek help.
Happy coding!
Comments
Post a Comment