Launching VS Code from Terminal

Getting Visual Studio Code (VS Code) up and running from the command line in Ubuntu 24.04 is a huge productivity booster. Once you have it configured, you can jump straight into your workspace without hunting through menus.

Here is how you do it, ranging from the basic command to some helpful power-user shortcuts.


1. The Basic Command

To open a specific directory in VS Code, open your terminal and type:

code /path/to/your/project

If you are already inside the project folder in your terminal, simply use a period (.), which represents the current directory:

code .

2. Useful Flags for Starting Projects

Sometimes you want more than just opening the folder. Here are the most common flags:

CommandResult
code .Opens the current folder in the current window.
code -n .Opens the current folder in a new window.
code -r .Replaces the folder in the last active window with the current one.
code -g file.txt:15Opens a specific file and jumps directly to line 15.
code --diff file1.js file2.jsOpens the two files in a side-by-side diff editor.

3. Troubleshooting: „command ‚code‘ not found“

If the terminal doesn’t recognize the code command, it usually depends on how you installed it.

If you installed via Snap (Ubuntu Software Center): The binary should be at /snap/bin/code. You can add this to your path, but usually, a simple restart of the terminal fixes it.

If you installed via .deb package:

  1. Open VS Code manually from your applications menu.
  2. Open the Command Palette (Ctrl + Shift + P).
  3. Type „shell command“ and look for: Shell Command: Install 'code' command in PATH.
  4. Select it and restart your terminal.

4. Pro Tip: Opening Multiple Folders (Multi-Root Workspace)

If you are working on a frontend and a backend simultaneously, you can open them both in one sidebar:

code folder-a folder-b