Code development on the SoC Linux servers with Visual Studio Code

If you are developing C or C++ code on the School of Computing's CSE server ( and using a Windows PC or Mac, you may benefit from using Visual Studio Code ( (Links to an external site.)) as an editor. While not as full-featured as a true IDE, VS Code does give you syntax and code error highlighting which can be beneficial.

To use Visual Studio Code to edit your files stored on the CSE server, you will need to attach (mount) your CSE home directory as a remote drive. The instructions on the How do I access my home directory on campus? page will tell you how to mount your home directory as the Z: drive on a Windows system. A similar procedure for Mac allows mounting your home directory using Mac OS.

After mounting your CSE home directory, you can open Visual Studio Code to Explore your Z: drive, and open a workspace. Project directories located in your CSE home directory or subdirectories can be selected using the VS Code Explore tool. Selecting the Open Folder link in VS Code also opens the Explorer tool.

VS Code Explore panel showing Z: drive
Figure 1. VS Code - Explorer tool view showing a mounted CSE home directory

You can use Windows Explorer to copy or move source and/or project files and directories from your local laptop hard drive into your Z: drive, and create any directories or sub-directories in your CSE home directory. If you are using Git to store your project, you can clone it directly into your Z: drive by selecting the directory on the Z: drive where you want to clone the project.

To Clone a Git repository project using VS Code, choose the Clone Repository button:

example of a cloning a git repository via the interface
Figure 2. VS Code selecting a Github project repository to clone

Choose a directory on Z: drive to save the git project:

specifying the directory as the remote mount Z: drive
Figure 3. Selecting a directory on the CSE server using the mounted Z: to save the Github project repository into

This example clones a project from Github, and saves the project within the directory ~/git on the CSE server. The tilde character, ~ refers to your home directory on CSE, and the git directory is an arbitrary directory that I have chosen to save all my git projects.

For MacOS, after following the instructions to mount your CSE home directory, you can use the Mac Finder application to navigate into your CSE home directory (remote location) and copy files and directories to and from your MacOS machine. Opening files and projects in VS Code is the same in MacOS using the VS Code Explorer tool, including the cloning repositories by selecting your CSE home directory remote location.

Attaching to your CSE home directory on from an off-campus network may require using a VPN connection. The VPN is a service of UNL Information Technology Services, visit the UNL ITS Global Protect VPN page for instructions on installing and connecting to the UNL network using the VPN client.

Disk Usage Considerations

The prior version of this article instructed users to load the Remote - SSH extension into VS Code and connect to the CSE server via that extension when running VS Code. The instructions above supersede those, and make the need for a .vscode-server directory in your home directory unnecessary.
If you have used VS Code using the old instructions, you may reach or exceed your quota of disk space on CSE. Using the Remote - SSH extension triggers the installation of a 100MB+ image of the VS Code Server into your home directory. With prolonged use of VS Code and Remote - SSH, you may have multiple copies of the VS Code Server application being placed in a subdirectory of your home directory. This is caused by VS Code and the update mechanism, resulting in extra copies of the executable files in ~/.vscode-server/bin. These old/extra copies count against your disk quota on the CSE server, and may result in you receiving disk quota exceeded emails from CSE Systems Support. These old/extra copies can safely be removed, an easy way to tell is if the date reported by ls -lt is the most recent, that is the copy to keep. All older copies can be safely removed.

Below is an example of what you will find in the VS Code Server directory, ~/.vscode-server and how to remove extra copies of VS Code executable files:

wmotycka@cse:~> ls -l ~/.vscode-server/bin/
total 12
drwxr-xr-x 6 wmotycka staff 4096 Oct 26 07:54 d2e414d9e4239a252d1ab117bd7067f125afd80a  # NOTE OLDEST DATE
drwxr-xr-x 6 wmotycka staff 4096 Jan 16 08:55 ea3859d4ba2f3e577a159bc91e3074c5d85c0523
drwxr-xr-x 6 wmotycka staff 4096 Nov  8 09:00 fcac248b077b55bae4ba5bab613fd6e9156c2f0c    # NOTE OLD DATE
wmotycka@cse:~> cd ~/.vscode-server/bin
wmotycka@cse:~/.vscode-server/bin> du -hs
317M    .
wmotycka@cse:~/.vscode-server/bin> du -hd1
112M    ./d2e414d9e4239a252d1ab117bd7067f125afd80a
104M    ./ea3859d4ba2f3e577a159bc91e3074c5d85c0523
103M    ./fcac248b077b55bae4ba5bab613fd6e9156c2f0c
317M    .
wmotycka@cse:~/.vscode-server/bin> cd ../..
wmotycka@cse:~> # Remove the extra/oldest copy/copies of the VS Code Server using 'rm -rf'
wmotycka@cse:~> rm -rf ~/.vscode-server/bin/d2e414d9e4239a252d1ab117bd7067f125afd80a
wmotycka@cse:~> rm -rf ~/.vscode-server/bin/fcac248b077b55bae4ba5bab613fd6e9156c2f0c

The last two commands above remove the oldest copies of VS Code Server images while retaining the most recently dated copy present.

Latest Notes

Unless you have a particular need, we recommend completely removing the ~/.vscode-server directory and instead access files on CSE using the method above. The ~/.vscode-server directory is necessary for operation using the Remote - SSH extension but is unnecessary when using VS Code on remote-mounting files to your personal Windows or Mac machine. There is also a performance improvement to VS Code by using remote-mounted files instead of the Remote - SSH method since all of the editing work is done on your local system. Disk usage reduction and performance improvement together justify changing to the method described above. If you want, remove all the contents of the ~/.vscode-server/bin/* and then use the instructions above to connect to your project. The only change you should see may be the need to install extensions locally that you originally had installed on the CSE server.

The Remote - SSH extension can also cause performance issues on the CSE server. Features of the extension like file search spawn processes that can linger in the CSE process table, becoming "zombie" processes that can only be removed by manual intervention (reboot or using 'kill' on each.) These lingering processes reduce available processing time, which you experience as slow compiles and program execution.

VS Code on a Linux client

Running VS Code on a Linux client (for example running Ubuntu on your own laptop) the way you mount the drive is important. You will need to use the fuse filesystem and the base SAMBA client packages samba-client and samba-common. For more specifics follow (or search) the instructions for your Linux distribution regarding installing SAMBA client. For my installation (Kubuntu 22.04), I also installed samba-common-bin, samba-libs, samba-vfs-libs, smbclient, cifs-utils, and winbind packages.
The Gnome Virtual Filesystem gvfs facility, if properly configured, will mount your CSE home directory to one of the two the default locations, ~/.gvfs or /run/user/<user-number>/gvfs. This gvfs facility is easy to use from the Gnome Files application, but doesn't work properly with all file managers like Dolphin, where the mounted CSE filesystem is not being exposed into the ~/.gvfs or /run/user/<user-number>/gvfs directory, as the gvfsd-fuse documentation describes. Using the Gnome Files application, the /run/user/<user-number>/gvfs directory contains the mount point directory that allows access to your CSE home directory. Later instructions provide the Linux shell command-line necessary to mount your home directory without the use of a file manager application.
After installing the appropriate packages, the following steps will mount your CSE home directory:

  • Launch the Files application, and select Other Locations from the left-side menu:
    Gnome Files application view of other locations
    Figure 4. Gnome Files application Other Locations page
    In the Connect to Server field enter the URL for connecting to the the Samba server, smb://;cse-login%gt; where cse-login is your username on the CSE server. Finish this step by pressing the Connect button.
  • You will next be prompted to enter your CSE username (login id), network domain, and password. Enter for the Domain, and your CSE username and password:
    CSE credentials prompt
    Figure 5. Network connection prompt for CSE login credentials
  • Your CSE home directory is now mounted and can be accessed from within VS Code using the Explore Open Folder action:
    CSE home folder in Explorer view
    Figure 6. VS Code Explore panel offering your CSE home directory under the Networks heading

You can also mount your CSE home directory using the Linux command-line shell. The following outlines the basic steps:

  • Open a terminal window and execute the command: gio mount smb:// replacing cse-login with your login id on the CSE server
  • You will be prompted for you CSE login id and credentials:
    CSE credentials prompt
    Figure 7. Mounting my CSE home directory from command-line
    If your login credentials on your Linux client (laptop) are not the same as your CSE credentials, enter your CSE login username to the User prompt. The Domain is as shown in figure 4. Enter your CSE password to the Password prompt. If successful, the shell command prompt is returned.
  • You can then create symbolic links from the mount-point directory under /run/user/<user-number>/gvfs/ into a place in your home directory that will help navigate to it:
    ln -s /run/user/1000/gvfs/smb-share\:server\\,share\=wmotycka ~/Documents/CSE
    creates a symbolic-link (directory path), /home/wmotycka/Documents/CSE, to the CSE home directory of the user wmotycka that can be accessed from within the VS Code Explorer, Open Folder action.
    CSE home directory mount point navigation using symbolic link
    Figure 8. Navigating to the ~/public_html/homepage_jekyll project path on the CSE server using the symbolic-linked CSE path
  • Projects and source files that require compilers like C and C++ source will still need to be compiled from a shell command-line on CSE, since the compiler and libraries on your local Linux client system may not be compatible with the libraries installed on CSE. This does not preclude compiling and running your code on your local Linux client system, which you can do for testing and development.
  • Project management tools like git have extensions in VS Code that allow managing shared code projects and cloud-based source repositories through the VS Code application. The CSE server supports git and maven (mvn) source management as well as svn source version control. Code-base management can be performed from both within the VS Code application and using CSE server shell commands.
FAQ Priority: 
FAQ Category: