Homework #1#
Completing this assignment
For this assignment, create a single text file in nano called
homework1.txt and provide the sequence of commands needed for
each problem.
You will then upload homework1.txt to Brightspace.
Important
All work must be your own.
You may not use generative AI / large-language models for any part of this assignment.
Starting in your home directory:
Create the directory structure:
~/homework/1/files/
solution
Starting in your home directory:
mkdir homework cd homework mkdir 1 cd 1 mkdir files
or
mkdir homework mkdir homework/1 mkdir homework/1/files
or if you looked at
man mkdirmkdir -p homework/1/filesNow move into the
files/sub-directory you created, and create a file calledproblem.txtusing thetouchcommand.solution
cd ~/homework/1/files touch problem.txt
For this problem we will use the same directory-structure/files from the shell lessons (see Some Sample Data to remember how to get this).
Change to the directory:
~/shell-lesson-data/exercise-data/alkanes
solution
cd ~/shell-lesson-data/exercise-data/alkanesNow make a subdirectory under that called
tests/and change directory intotests/.solution
mkdir tests cd tests
From within
tests/copy the filescubane.pdb,ethane.pdb, andoctane.pdbfrom the directory above into your current directory. You should use a single command for it.solution
cp ../cubane.pdb ../ethane.pdb ../octane.pdb .
Let’s consider two ways to do the same task—moving a file to a new location. We want to move a file
~/answer.txtto~/homeworks/answer.txtMethod 1: copy + delete
In your home directory, create a file called
answer.txtusingtouchCreate a directory called
homeworks/Copy the file
answer.txtintohomeworks/Delete the version of
answer.txtin your home-directory (only the versionhomeworks/answer.txt) should remain.
solution
touch answer.txt mkdir homeworks cp answer.txt homeworks/ rm answer.txt
Method 2: moving
Back in your home directory, create a file named
answer2.txt(again usingtouch).Move this file, using a single command, into the
homeworks/directory you created previously.
solution
touch answer2.txt mv answer2.txt homeworks
Using
man ls, find the option/flag that sorts files by size (largest file first). In addition to this new option, also use the-loption to get a long listing.Give the
lscommand that will do this sorting + long listingsolution
ls -lSor
ls -l -sor
ls -l --sizeIn
~/shell-lesson-data/exercise-data/alkanes/, show the (long-listing) output when you sort by sizesolution
-rw-rw----. 1 zingale zingale 1828 Apr 23 2025 octane.pdb -rw-rw----. 1 zingale zingale 1226 Apr 23 2025 pentane.pdb -rw-rw----. 1 zingale zingale 1158 Apr 23 2025 cubane.pdb -rw-rw----. 1 zingale zingale 825 Apr 23 2025 propane.pdb -rw-rw----. 1 zingale zingale 622 Apr 23 2025 ethane.pdb -rw-rw----. 1 zingale zingale 422 Apr 23 2025 methane.pdb