Thursday, April 24, 2025

To open or edit code in Linux server

we can use various terminal-based editors depending on what's installed on your Linux server. Here are a few ways to do it:

For example, the code resides in /var/www/proj_management.

🛠️ View files in the project directory:

bash
ls -la /var/www/proj_management

✏️ Edit a specific file (e.g., index.php):

Using nano (simple editor):

bash
sudo nano /var/www/proj_management/index.php

Using vim (powerful, but has a learning curve):

bash

sudo vim /var/www/proj_management/index.php

Using code (if Visual Studio Code CLI is installed):

bash
sudo code /var/www/proj_management


If you're accessing the server via SSH and want to edit with a GUI-based editor like VS Code on your local machine,
you can use Remote - SSH extension in VS Code.

----------------------------------------------------------

If you want to use Remote - SSH extension in VS Code to open and work with files on a remote Linux server (like your /var/www/proj_management directory), here’s a quick setup guide:


Step 1: Install Remote - SSH Extension in VS Code

  1. Open VS Code.

  2. Go to the Extensions panel (Ctrl+Shift+X).

  3. Search for “Remote - SSH”.

  4. Click Install.


Step 2: Add SSH Configuration

  1. Press Ctrl+Shift+P to open the Command Palette.

  2. Type Remote-SSH: Add New SSH Host and select it.

  3. Enter your SSH command, e.g.:

    bash
    ssh your_username@your_server_ip
  4. Choose the SSH config file to save this entry (usually ~/.ssh/config).


Step 3: Connect to the Server

  1. Open the Command Palette again (Ctrl+Shift+P).

  2. Select Remote-SSH: Connect to Host.

  3. Choose your saved server from the list.

  4. VS Code will open a new window connected to the remote server.


Step 4: Open Your Project Directory

Once connected:

  1. Click File > Open Folder.

  2. Enter:

    bash
    /var/www/proj_management
  3. You now have full access to browse, edit, run, and debug the code remotely as if it's on your local machine.


No comments:

🧹 Clean Up SharePoint Online File Versions: Keep Only the Latest 5 in a Specific Folder Using PnP PowerShell

 Versioning in SharePoint Online is a powerful feature that allows teams to maintain historical copies of documents. However, over time, the...