Linux Sysadmin Test Prep
Downloading and Archiving Files
Downloading and Archiving Files
wget
Basics
- Quiet
wget -q <address>
- Not verbose (mostly quite)
wget -nv <address>
- Chagne name
wget -O <filename> <address>
- Download multiple URLs
wget <address> <address>
- create file.txt with links (one per line)
wget -i file.txt
- Throttle download speeds
wget --limit-rate 400k <address>
- Resume download
wget -c <address>
- Download in the background
wget -b <address>
Advanced
- Mirror website
Options | Action |
---|---|
-m | turn on mirroring |
-k | make links suitable for local browsing |
-w <sec> | wait n seconds between each download |
-l | maximum level of recursion |
-r | download recursively |
--spider | spider mode |
- Log output to a file
wget -o file.log -r -l 3 --spider <address>
wget -a file.log <address>
Options | Action |
---|---|
-o | output to a file |
-a | append output to a file |
- Find broken links
grep -B 2 '404' file.log | grep "http" | cut -d " " -f 4 | sort -u
- Change user agent
wget -U '<string>' <address>
- View response headers
wget -S --spider <address>
- Add username and password
wget ‐‐http-user=daniel ‐‐http-password=JZXGAo34mz <address>
- Save cookies
wget ‐‐cookies=on ‐‐save-cookies cookies.txt ‐‐keep-session-cookies ‐‐post-data 'user=daniel&password=JZXGAo34mz' <address>
- Load cookies
wget ‐‐cookies=on ‐‐load-cookies cookies.txt ‐‐keep-session-cookies <address>
Quiz
- Create a directory in
/
calledLinuxTestDrills/downloads
.- The rest of the Quiz should be done in this folder. Remove files that are not part of the instructions if you make a mistake.
- Download
https://en.wikipedia.org/wiki/Penrose_tiling#/media/File:Penrose_Tiling_(Rhombi).svg
and save it asawesome.svg
- Download concatenate
linuxtest.danielc.us/downloads/topSite
andlinuxtest.danielc.us/downloads/secondTopSite
into a single file calledlinks
. - Download the sites in
links
. Openindex.html
with a web browser and click on one of the links. - Mirror
https://dizer.netlify.app/
with one level of recursion with links that you can browse it from your computer. Open it with a browser and click around. - Finish downloading with full recursion, and click around again.
- Download
linuxtest.danielc.us/downloads/quizFiles/quiz
andlinuxtest.danielc.us/downloads/quizFiles/wget
. - Execute the command
quizFiles/quiz wget
tar
tar -cf files.tar files/
(create tar from dir)
tar tvf files.tar
(list files in tar)
tar --delete -f files.tar file
(deletes file from tar)
tar --update -f files.tar file
(adds file to tar)
tar -jcf files.tar.bz2 files.tar
(create bz2 from tar)
tar -Jcf files.tar.xz files/
(create tar.xz from dir)
unzip files.zip -d files/
(unzip to dir)
tar xf files.tar.bz2 -C <DIR> --same-permissions
(extract to dir)
wget file.tar.xz -O - | tar xz
(Download and extract)
Quiz
- Archive
LinuxTestDrills/downloads
into a fileLinuxTestDrills/archives/downloads.tar
. - List the files in
LinuxTestDrills/archives/downloads.tar
to make sure you have only the correct files. - Download the file at
https://danielc.us/lfcs-prep/testFiles.tar.xz
toLinuxTestDrills/downloads
and extract it into/LinuxTestDrills
, in a single command, maintaining original ownership. You can change ownership as needed during the drills. - Add
LinuxTestDrills/downloads/testFiles.tar.xz
intoLinuxTestDrills/archives/downloads.tar
and delete everything in the folderLinuxTestDrills/downloads
. - Compress
LinuxTestDrills/archives/downloads.tar
withbz2
,xz
, andzip
. Look at the resulting files. - Run
quizFiles/checkQuiz1a.sh