An assignment designed to challenge students to move files and clone repositories on the command line. The WATS1030 course uses Digital Ocean as the chosen hosting service. The challenge and instructions here are written according to how Digital Ocean works, but you can accomplish the same goals using any server running Unix or Linux. Be aware that different distributions of Linux are not identical, so some details (such as the package management tool) may vary accordingly.
The base requirements for this assignment are to complete the following list of tasks and then commit your repository back up to the server. Your completion of these tasks provides evidence of your success. You will create, delete, move and rename files and folders in several ways.
To begin working on this project, you will need to set up a new server:
- Create an account on Digital Ocean.
- Create a new Droplet with the following configuration:
- Ubuntu (the latest version)
- You do not need to select any particular App.
- Be sure to add your SSH key by clicking the "Add SSH Key" link (or selecting your previously added SSH Key) near the bottom of the Droplet creation form.
- Connect to your Droplet via SSH. (Consult this guide for more detailed help with SSH Keys and access.)
Once you have created your Droplet and successfully connected to it, you will need to install and configure Git:
- Install Git on your Droplet using
apt-get
, which is a package management tool used by Ubuntu.
- Run the command
sudo apt-get install git
to begin the install process - Pay attention:
apt-get
will ask you to confirm that you want to install the application once it determines how much disk space it will take up. You will have to pressY
to continue the installation. - You will know the installation is finished when you see:
'git help -a' and 'git help -g' lists available subcommands and some concept guides. See 'git help <command>' or 'git help <concept>' to read about a specific subcommand or concept.
- Configure the basic global variables in Git:
- Run the command:
git config --global user.name "Your Name"
- Run the command:
git config --global user.email "[email protected]"
- Run the command
git config --list
to see that these values have been successfully set. You should see a list that indicates your name and email address correctly.
Now that you have Git installed on your Droplet, you must configure Github to allow this Droplet to access your repositories. That means you must add the Droplet's SSH key to your Github profile so Github knows you are using this machine. But since your Droplet is brand new, you must first generate an SSH key for this Droplet.
- Follow the Github Guide to Generating SSH Keys (Linux) to generate an SSH key for your Droplet and add it to your Github profile.
- Now that you have added the SSH Key to your Github profile, fork the WATS1030 Moving Files source repository into your personal Github account.
- Verify that you have been successful by copying the SSH Clone URL from your repository homepage and cloning the repository using command-line Git:
git clone <SSH ClONE URL>
- Please note: You should be in your home directory (
cd ~
) when you do this.
- Change directory into the repository root directory.
Congratulations! You have successfully provisioned a brand new virtual server (aka "Droplet") and cloned a Git repository so you can work with those files on your Droplet. This is a great accomplishment! But we have more to explore.
Now that you have this repository on your Droplet, we will perform some file management exercises to explore how to create, copy, move, delete, upload and download files on your server. These steps all use the files and directory structure contained beneath the challenge_files
directory.
- Change directory into the
challenge_files
directory. - Use the
cp
command to copyindex.html
toindex.html.bak
(Note: This is a common naming convention when you wish to back up a file.) - Use the
mkdir
command to make the directorytmp/
inside ofchallenge_files
. - Use the
cp
command to copyindex.html
totmp/keepme.html
. - Use the
rm
command to remove (or "delete") the filedeleteme.html
. - Use the
rmdir
command to remove (or "delete") the directorydelete_this_directory/
. - Use the
scp
(SSH secure copy) command to upload an image to theimg/
directory. (scp <your_filename.jpg> root@<YOUR DROPLET IP ADDRESS>:~/wats1030-moving-files/challenge_files/img/
)
- Make your life a little easier by uploading a file that isn't too huge in filesize.
- You may upload any file you choose; please keep it appropriate for the classroom/workplace.
- You may use an application such as WinSCP or Cyberduck if you choose.
- Use the
mv
(move) command to sort thechallenge_files/logs/
directory.
- Use
mkdir
to create new directories to store the files. - Organize the new directories into year and month.
- Use
mv
to move the log files into their appropriate directory. - Hint: Use wildcards to move several files at a time so the work goes much more quickly.
Once you have completed this work, you should commit
your changes and push
them back up to Github. To do that, use the command-line Git application:
- Change directory to the repository root directory (probably
~/wats1030-moving-files/
). - Run
git status
to see the current status of your repository. - Run
git add -A
to add all of your changes to the repository. - Run
git rm <filename>
to tell Git that you have removed a file or directory (you should see prompts about doing this if you rungit status
again). - Run
git status
and notice how all of your altered files show up highlighted green in the "staging" area, and there should be no more files highlighted red in the "unstaged" area. - Once you've staged all your changes, you must make a
commit
:git commit -m "Completed moving files assignment"
- After you have made your commit, you should push your changes to Github, which is the
origin
for your repository:git push origin
- Review the response and make sure your
push
was successful.
Congratulations! You have now committed and pushed your changes to Github, all from the command line. This whole process may have seemed difficult or arduous at first, but with practice it becomes much faster to manage these files and commits via the command-line rather than most graphical tools.
The following goals are meant to provide more of a challenge for individuals who like that sort of thing.
- Create a Droplet using a different kind of Linux and repeat all of the above (altering your process according to the difference of tools/environment).
- Figure out how to connect to your Droplet using SFTP or a different file management/upload tool. (Or, if you used a GUI application before, then try it using only the command line.)