Lab 5 - Managing Files and directories
Question 1.1: Creating Files and Directories - Part 1
- Create the following directory structure. Here are the rules:
- YOU ARE NOT ALLOWED TO USE CD!
- You can create more than 1 directory at the same time
- You can only use relative path for all the directory and file names
- All the commands must be run from your home directory ($HOME)
lab5/
└── q1.1
└── games
├── action
│ └── action_games.txt
├── fps
│ └── fps_list.txt
└── rpg
└── mods.py
5 directories, 3 files
- To complete this question, follow these instructions:
- Create a Directory in YOUR home directory ($HOME) labeled:
lab5
. - Inside
lab5
create the directoryq1.1
and the subdirectorygames
. Insidegames
, create the subdirectoryaction
. You must use the-p
option of themkdir
command. Then, insidegames
, create the remaining 2 subdirectories.-p
is not necessary here anymore because the parents directory already exist. - Inside each respective directory, create the text files:
action_games.txt
,fps_list.txt
, andmods.py
- Use the
tree
command to list thelab5
directory. Alternatively, you can usels -R
for a recursive list of thelab5
directory.
Take a screenshot of the terminal only. Your screenshot must show all the commands that you used to answer this question. Multiple screenshots are allowed
Question 1.2: Creating Files and Directories - Part 2
To the previous directory structure, add the missing directories and files. Here are the rules:
- YOU ARE NOT ALLOWED TO USE CD aside from step 1
- You can create more than 1 directory at the same time
- You can only use absolute path for all the directory and file names
- All the commands must be run from your home directory (/etc)
/home/adrian/lab5/
├── q1
│ └── games
│ ├── action
│ │ └── action_games.txt
│ ├── fps
│ │ └── fps_list.txt
│ └── rpg
│ └── mods.py
└── q1.2
├── hmw
│ └── linux.txt
└── notes
└── math.pdf
8 directories, 5 files
- To complete this question, follow these instructions:
- Change your current working directory to
/etc
. The remaining of this questions will be completed from this directory. - Create the directories and subdirectories:
q1.2
,hmw
andnotes
. Remember to use-p
when necessary. - Create the files
linux.txt
andmath.pdf
in their respective directories. - Use the
tree
command to list thelab5
directory. Alternatively, you can usels -R
for a recursive list of thelab5
directory.
Take a screenshot of the terminal only. Your screenshot must show all the commands that you used to answer this question. Multiple screenshots are allowed
Question 2: Removing Files and Directories
- Change your current working directory to:
/srv/
- Remove the files:
math.pdf
andlinux.txt
located in theq1.2
directory. - Change your current working directory to
$HOME
- Remove the directories
q1.1
andq1.2
. Use relative path. Remember the-r
option of therm
command
Take a screenshot of the terminal only. Your screenshot must show all the commands that you used to answer questions 1-4. Multiple screenshots are allowed
Question 3: Moving Files and Directories
- Change the current working directory to
$HOME
and remove thelab5
directory. - Run the following command:
wget https://cis106.com/assets/lab5/lab5.zip && unzip lab5.zip && rm lab5.zip
You will notice that you have a newlab5
directory in$HOME
. Split your terminal in 2 or open a new terminal window. List thelab5
directory sorted by file extensions and in a single column. This will make it easy to work. - In
$HOME
, create the following directories:lab5-img
,lab5-audio
,lab5-video
,lab5-doc
- Move all the files inside the
lab5
directory to their respective new directories in$HOME
. - Inside the
lab5
directory, you will find a directory calledwallpapersLab5
. Move this directory to yourPictures
directory and rename it toNewWallpapers
. You must achieve this in a single command. - List the directories:
lab5-img
,lab5-audio
,lab5-video
,lab5-doc
andNewWallpapers
in a single command using absolute path for each directory path. - Remove
lab5
,lab5-img
,lab5-audio
,lab5-video
,lab5-doc
andNewWallpapers
- List
$HOME
. Use this command to list directories only:ls -d1 ~/*/
Take a screenshot of the terminal only. Your screenshot must show all the commands that you used to answer questions 1-8. Multiple screenshots are allowed
Question 4: Copying Files and Directories
- Rules for this question:
- You are not allowed to use CD
- You have to use absolute path
- Go to Pexels.com. Filter the results by Horizontal images. Download at least 3 wallpapers.
- Split your terminal in 2. In one side, list the wallpapers you downloaded.
- In your
~/Pictures
directory, create a new directory calledlab5wallpapers
- Copy the newly downloaded wallpapers to the directory
lab5wallpapers
- Copy the
lab5wallpapers
directory to theDownloads
directory
Take a screenshot of the terminal only. Your screenshot must show all the commands that you used to answer questions 1-5. Multiple screenshots are allowed
Challenge Question:
Problem Description:
Joe is working on a web development assignment. The goal is to create a slide show that can show different images when the user clicks the next and previous button. He has sent you the code that makes the website. Your job is to test it to make sure it works. To download the site use this command:
cd $HOME && wget https://cis106.com/assets/lab5/website-lab5.zip && unzip website-lab5.zip && rm website-lab5.zip
This will create the following directory: ~/website-lab5
. That contains index.html
. There is no need to edit this file.
If you open the site, you will notice that the site is just a black screen. That is because the directory website-lab5
is missing 3 image files that you need to test it. Here are the steps to complete this challenge:
- Use the given command in the problem description to download the directory and file. (
website-lab5/index.html
) - Download 3 images from Pexels.com. Make sure the images are horizontal and the file format is jpg
- Rename and move the images using the following naming convention. You have to rename and move using 1 command. This part should take 3 commands because there are only 3 files.
- old_name1.jpg -> img1.jpg
- old_name2.jpg -> img2.jpg
- old_name3.jpg -> img3.jpg
-
List the
website-lab5
directory. It should look like this: - Open the
index.html
file in firefox and take a screenshot. Test the slideshow by clicking the next and previous buttons. The images you downloaded should be shown there.
Take a screenshot of the commands you used to answer this question and of firefox showing the index.html file open.
What will you Submit:
- Place all the screenshots and answers to your questions in a the
lab5.md
file. Label each question submission correctly using headings. - Convert your markdown file to pdf
- Push the changes to Github:
git pull; git add .; git commit -m "lab5 complete; git push"
- Submit the URL of
Lab5.md
and the pdf file - If you are using virtualbox, this will be a good time to take a snapshot.
How will you be graded:
- You will lose points if you do not include the full screenshot of firefox. I need to see the complete firefox window showing the URL.
- You will lose points if you use more than 3 mv commands to get the job done.
- The value of each question is: 20pts
Special Note
You are going to be using the git commands a lot. Here is a quick reference:
git clone repository/url/here
: is the command to clone a repository where cloning means downloading a repository to your computergit pull
: to pull/synchronize your repository from github to your local machine. Always run this command BEFORE you start working VS Codegit add .
: to track all the changes made to your file.git commit -m "label for your changes here"
: this command will label all the changes you added with theadd
commandgit push
: will send all your changes to your github repository
Always run the commands in this order:
pull
=>add
=>commit
=>push
Never use the github website to make changes to your repository unless you know what you are doing and can remember to pull the changes before working on your local repository!