Most software that you use is a combination of a client software system and a server software system. “The cloud” is a generic term for a group of servers that do the same thing.
For example:
You use the TikTok app on your phone, which performs searches and recommends videos in the cloud.
You play a multiplayer game on your XBox, but a server controls people entering and leaving, tracking scores, and managing lag.
You have used pip to install Python libraries, but pip talks to a remote server to find the package and retrieve the bytes.
In the final weeks of SENG 201, we will connect to a remote server to host a network application. You will edit and deploy the application.
1 - Connecting to ada
Instructions for connecting to ada and installing a VPN for offsite work
We will use an on-premises (on-prem) server called Ada, named after Ada Lovelace, who wrote the first algorithm for the precursor to modern computers, Babbage’s Analytical Engine.
WHEN OFFSITE - use the VPN client
The ada server is accessible only from the UNCW network.
You will need to use UNCW’s Virtual Private Network (VPN) client software to reach the server while offsite.
Install the VPN client software. You can only install the VPN client while offsite.
Native Linux: Point your web browser at https://vpn.uncw.edu and follow the prompts.
Open the Cisco AnyConnect VPN program and connect to the pre-configured UNCW VPN.
I recommend that you disconnect from the VPN when you don’t need it because it can slow your connection.
Connecting to ada via SSH
We will use the Secure Shell (SSH) program to connect to ada. SSH is a program for creating client-server connections. SSH will connect you to ada’s Linux CLI, which will function like a WSL or MacOS Terminal.
SSH is pre-installed on Windows, MacOS, Ubuntu, and WSL. Open a Terminal and enter the following:
ssh <your-uncw-id>@ada.cis.uncw.edu
# for example, ssh laymanl@ada.cis.uncw.edu
Enter your UNCW login password when prompted. Choose “yes” when prompted to trust the connected machine. The initial login may take several seconds as your account is loaded from UNCW systems.
You should see something like the following after successfully signing in:
You are now logged into the ada server. ada is running Ubuntu Linux, and understands all the standard Linux CLI commands.
There are many commands at your disposal, including python and git.
Type pwd to see your home directory location.
Rules for using ada
ada is a shared server. As such:
Do not read, write, or edit files outside your home directory.
Do not change the permissions on your home directory using chmod or any other command.
Do not intentionally do anything to harm the server, such as fill up the hard disk or overload the CPU.
Activity on the server is logged. Any intentional or negligent violation of these rules will result in a grade of 0 for the course and a violation of the Student Code of Conduct reported to the Dean of Students.
When in doubt if you are allowed to do something, ask the instructor first.
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
Navigating the file system
Make sure you are connected to ada using SSH. Type the following commands:
pwd# where am I?ls # list filesls -l # list with permissions and sizesls -lah # human-readable sizes, show hiddencd / # root of filesystemls
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
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 filesystemscd ~
du -h # list the size of the current directory and all subdirectoriescd /
du -sh # summarize size of current directory and all subdirectoriesdu -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, availabletop # live process viewer (press q to exit)ps aux # snapshot of ALL processesps 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 downloadedunzip meteors.zip # decompress the filels -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 oncemore 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 directorypwdmkdir dev # Make a subdirectory named dev/cd dev # change into the dev directory within your homepwd
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:
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:
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:
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: 348335My parent PID: 347328USER 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.