Nicholas Dodds

CS Servers Reference

CS Servers Quick Reference Guide

1 Managing Email Aliases

  • SSH into 'Ark':
    ssh ndodds@ark
    Navigate to the configuration directory:
    cd /etc/postfix/
    Check out the file for editing:
    co -l aliases_clinic
    Open the file in the vim editor:
    vim aliases_clinic
    Check in the file after editing:
    ci -u aliases_clinic
    Process changes and update alias database:
    newaliases

2 User Password Management

  • SSH into Cortana:
    ssh cortana
    Change a user's password (replace USERNAME with the actual username):
    passwd -i opendirectory -u ndodds USERNAME

3 Service Management

  • SSH into Hopper:
    ssh root@hopper
    Restart the sssd service (OpenRC):
    /etc/init.d/sssd restart
    Restart the sssd service (systemd - for Lovelace or Granville):
    systemctl restart sssd

4 Account Lookup Tools

  • Display user ID and group information:
    id ndodds
    Fetch the password entry for the user:
    getent passwd ndodds
    Display detailed user information with finger:
    finger dodds

5 LDAP Account Management

  • Fetch basic LDAP entries for a user:
    ldapsearch -LLLx uid=ndodds
    Fetch specific LDAP fields (common name and email):
    ldapsearch -LLLx uid=ndodds cn mail

6 Network and DNS Configuration

  • Find the current IP address on the local client:
    ip addr
    SSH into the network server:
    ssh mudd@neutron.cs.hmc.edu
    Locate the DHCP binding for the IP (replace xxx with your IP suffix):
    show ip dhcp bind | incl 134.173.43.xxx
    Clear existing DHCP binding if necessary:
    clear ip dhcp bind 134.173.43.xxx

    Note: This removes the binding from the active table, but the client may still attempt to renew with the old IP. The following method ensures a complete removal.

    Alternative: Clear binding from configuration (more thorough):
    conf term
    ip dhcp pool guest43
    no addr 134.173.43.xxx

    This removes the static binding from the DHCP pool configuration itself, preventing the server from reassigning this binding.

    Enter configuration mode:
    conf term
    Define a DHCP pool:
    ip dhcp pool guest43
    Set static IP with client ID (replace with your specific values):
    addr 134.173.43.xxx client-id 01xx:xx:xx:xx:xx:xx
    Important: The client-id must begin with 01 followed by the MAC address. The 01 prefix indicates the hardware type (Ethernet). DHCP uses this format to distinguish between different types of network interfaces. Without the correct prefix, the binding won't match the client's DHCP request.
    Save the configuration to disk:
    write mem

7 Editing DNS Zone Files

  • SSH into Ark:
    ssh ndodds@ark.cs.hmc.edu
    Navigate to the DNS directory:
    cd /mnt/dns
    Freeze the zone for editing:
    sudo rndc freeze cs.hmc.edu
    Check out the zone file:
    sudo co -l cs.hmc.edu
    Edit the zone file (remember to increment the serial number):
    sudo vim cs.hmc.edu
    Important: Don't forget to increment the serial number at the top of the file.
    Check in the changes:
    sudo ci -u cs.hmc.edu
    Thaw the zone:
    sudo rndc thaw cs.hmc.edu

8 Disk Quota Management

  • Edit quota for a specific user:
    sudo edquota username
    View the quota for a specific user:
    sudo checkquota -v username
    Reset user quota to default:
    sudo edquota -p quotatemplate username

9 APT History Log Processing

  • Process both compressed and uncompressed APT history logs:
    for log in /var/log/apt/history.log /var/log/apt/history.log.*; do
      if [[ "$log" == *.gz ]]; then
        zcat "$log" | perl -00 -lne 'next unless m/\nRequested-By: (\w+) \(\d+\) /; 
          my $user = $1; 
          printf "%s: %s\n", $user, $1 if m/Commandline:\s+(.*)/' | grep install
      else
        cat "$log" | perl -00 -lne 'next unless m/\nRequested-By: (\w+) \(\d+\) /; 
          my $user = $1; 
          printf "%s: %s\n", $user, $1 if m/Commandline:\s+(.*)/' | grep install
      fi
    done

10 NVIDIA Management

  • Unload the NVIDIA kernel module:
    modprobe -r nvidia

    Removes the NVIDIA driver module from the kernel. Useful when troubleshooting driver issues or before updating drivers. All programs using the GPU must be stopped first.

    Load NVIDIA device files:
    nvidia-modprobe

    Creates the NVIDIA device files in /dev if they don't exist. Required for GPU access after driver installation or system boot. Typically runs automatically but can be invoked manually.

    Check which processes are using NVIDIA devices:
    sudo lsof /dev/nvidia*

    Lists all processes with open file handles to NVIDIA devices. Essential for diagnosing "device busy" errors or identifying which programs need to be closed before unloading the driver.

11 NVMe Drive Cloning & Upgrade (Ubuntu Method)

  • 1. Prepare Hardware

    Shut down the system. Move the original NVMe drive to an external USB adapter, then install the new (larger) NVMe drive into the motherboard's M.2 slot.

    2. Boot into Live Environment

    Insert your Ubuntu USB Installer. Boot the machine and select "Try Ubuntu without installing". Once the desktop loads, open a Terminal (Ctrl+Alt+T).

    3. Identify Your Drives

    Run the following to list all connected storage devices:

    lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE

    Identify your two drives based on size:

    • Source (Old Drive): Usually /dev/sda or /dev/sdb (connected via USB).
    • Destination (New Drive): Usually /dev/nvme0n1 (internal M.2 slot).
    4. Clone the Drive
    Critical Warning: Double-check your if (Input File) and of (Output File). Writing to the wrong drive is irreversible.
    sudo dd if=/dev/sdX of=/dev/nvme0n1 bs=64K conv=noerror,sync status=progress

    Replace /dev/sdX with your USB adapter identifier (e.g., /dev/sda). The bs=64K flag speeds up the copy significantly.

    5. Fix GPT Table & Resize Partition

    After cloning, the backup partition table is now "stuck" in the middle of the drive (where the old disk ended). We must move it to the end of the new disk.

    Launch the partition editor:

    sudo parted /dev/nvme0n1

    You will immediately see a warning about the GPT table. Type Fix when prompted:

    Warning: Not all of the space available to /dev/nvme0n1 appears to be used...
    Fix/Ignore? Fix

    Now, find the partition number you want to expand (usually partition 2 or the largest one):

    (parted) print

    Resize the partition to fill the disk:

    (parted) resizepart 2 100%
    (parted) quit
    6. Check & Resize Filesystem

    Now that the partition is larger, we must expand the filesystem inside it to match.

    First, run a safety check on the filesystem:

    sudo e2fsck -f /dev/nvme0n1p2

    Then, resize it (defaults to max available size):

    sudo resize2fs /dev/nvme0n1p2
    7. Finalize

    Shut down the computer, remove the USB boot drive and the external USB adapter. Boot normally from the new internal NVMe.