Exploring a Linux server

Understanding the basics of files, disks, processes, and programs on Linux

Starting out

ada is running Ubuntu Linux, and understands all the standard Linux CLI commands. There are additional commands at your disposal, including python and git.

Open a Windows PowerShell, WSL Terminal, or MacOs Terminal and type the following to connect to ada:

ssh <your-uncw-id>@ada.cis.uncw.edu  
# for example, ssh laymanl@ada.cis.uncw.edu

Make sure you are connected to ada using SSH. Type the following commands:

pwd                # where am I?
ls                 # list files
ls -l              # list with permissions and sizes
ls -lah            # human-readable sizes, show hidden
cd /               # root of filesystem
ls
cd ~               # back to their home

The commands above provide the basics of navigating through the file system.

  • Linux commands accept OPTIONS, which are the parts beginning with a hyphen, e.g., -lah
  • Most Linux commands also accept ARGUMENTS that specify the target of the command. For example:
    • cd ~: the ~ is the argument.
    • cd /: the / is the argument.
    • You can also give ls an argument, e.g., ls /usr/bin to list the contents of the usr/bin
  • We covered all this before. Check out the CLI: Navigating the file system lab for a refresher.

Question: What is a hidden file? Why do they exist, do you think? Question: Which option to ls gives you the sizes, owner, and permission?

What’s happening on the system?

Just like working on your computer, you may run out of disk space or a process may be using all your memory or CPU power. How do check these?

Run the following one at a time:

df -h              # disk free — storage usage across mounted filesystems
cd ~
du -h              # list the size of the current directory and all subdirectories
cd /
du -sh             # summarize size of current directory and all subdirectories
du -sh ~           # summarize size of your home directory directory and all subdirectories, but using an argument

The df (disk free) and du (disk used) commands are complimentary, show information about files on disk. You use ls -l to see the size of individual files.

What about processes using CPU or memory? You have a few options for that.

Run the following one at a time:

free -h            # memory: total, used, available
top                # live process viewer (press q to exit)
ps aux             # snapshot of ALL processes
ps u               # more compact, shows %CPU, %MEM of YOUR processes

Curious to know who else is on the server? Run the who command.

Exercise: Use top or ps to find the PID (process id) of the most CPU or memory intensive process. Write the PID down. Then run kill <PID>. What happens?

Downloading files and piping

Linux offers a convenient command-line tool for downloading files. All you need is the URL. Run the following command to download our meteoric dataset from the class website.

Run the following one at a time:

wget https://llayman.github.io/seng-201/labs/remote-server/exploring/meteors.zip
ls -l                # Note that meteors.zip is downloaded
unzip meteors.zip    # decompress the file
ls -l                # You should see both meteors.zip and meteorite_landings.csv

Now suppose you want to view the contents of that file. You can use commands we learned from CLI Lab: Text files:

cat meteorite_landings.csv    # Print an entire file at once
more meteorite_landings.csv   # Paginate. Use SPACE to advance, and `q` to quit

Writing code remotely

When connected to a server like ada, you typically only interface through the CLI. In ada’s case, there is no window-like GUI.

Before creating files, let’s make a directory to work in inside our home directory. Run the following commands:

cd ~               # Go to your home directory
pwd
mkdir dev          # Make a subdirectory named dev/
cd dev             # change into the dev directory within your home
pwd

Linux uses the ~ character as shorthand for your home folder, i.e., /home/<your_id>. So ~/dev is shorthand for /home/<your_id>/dev.

Make sure you are in your ~/dev folder. Do the following:

  • nano hello.py
  • a text editor called Nano will open in the Terminal looking like this:
    the nano text editor
  • type in print("Hello World!")
  • Hit CTRL+X to exit, then Y to save the changes.

You have now created the file. Primitive, huh? Run the following:

ls -al                # You should see your hello.py file.
python3 hello.py      # Python will run an execute the file

Note we use python3 on the server. You may also want to refresh yourself on how to copy, move, and delete files and directory in Lab: File and directory management.

Exercise: Use nano to create another Python file that prints out the numbers from 0 to 9. Run it from the CLI.

Code locally, then upload

The Nano editor is quite handy for editing files on the server quickly. But, we are spoiled by the power of IDEs like Visual Studio Code and PyCharm.

Most of the time, software engineers develop on their own machines and deploy their software programs to servers. One way to accomplish this is to directly transfer files from your computer to a server. To do this requires a program often bundled with ssh called scp – secure copy.

On your local computer: open one of your seng-201/ projects and create a file named process_info.py. Paste in the following:

import os
import sys

def main():
    print(f"Python executable: {sys.executable}")
    print(f"Current working directory: {os.getcwd()}")
    print(f"My PID: {os.getpid()}")
    print(f"My parent PID: {os.getppid()}")
    print(f"USER env var: {os.environ.get('USER')}")
    print(f"SHELL env var: {os.environ.get('SHELL')}")
    print(f"PATH env var (first 60 chars): {os.environ.get('PATH', '')[:60]}...")

if __name__ == "__main__":
    main()

On your local machine, open a new PowerShell or Terminal window. Use the cd command to navigate to the directory you created process_info.py. Once in that directory, enter the following:

scp process_info.py <your_username>@ada.cis.uncw.edu:~/dev/

This will copy the file securely to your ~/dev/ directory. Now, switch back to the Terminal where you are connected via SSH. Use python3 to run the file you just uploaded, which should be in your dev/ directory.

You will see output like the following:

laymanl@ada:~/dev$ python3 process_info.py 
Python executable: /usr/bin/python3
Current working directory: /home/laymanl/dev
My PID: 348335
My parent PID: 347328
USER env var: laymanl
SHELL env var: /bin/bash
PATH env var (first 60 chars): /home/laymanl/.local/bin:/usr/local/sbin:/usr/local/bin:/usr...

The scp command is the key here. You can upload multiple files or entire directories at once with it as well. It is great for infrequent use.

As developer, or a team of developers, a much more convenient way to get your source code on a server for testing or production is to use git. We will do this in the next lab.

Last modified November 17, 2025.