adds better code tags for the lpi essentials lessons 1 and 2

This commit is contained in:
waldek 2021-04-10 17:53:03 +02:00
parent a57b1a2775
commit e897a54d29
3 changed files with 82 additions and 78 deletions

View File

@ -19,11 +19,11 @@
## Guided Exercises ## Guided Exercises
1. For each of the following commands, identify whether it is associated with the Debian packaging system or the Red Hat packaging system: 1. For each of the following commands, identify whether it is associated with the Debian packaging system or the Red Hat packaging system:
* dpkg * `dpkg`
* rpm * `rpm`
* apt-get * `apt-get`
* yum * `yum`
* dnf * `dnf`
1. Which command could be used to install Blender on Ubuntu? After installation, how can the program be executed? 1. Which command could be used to install Blender on Ubuntu? After installation, how can the program be executed?
1. Which application from the LibreOffice suite can be used to work with electronic spreadsheets? 1. Which application from the LibreOffice suite can be used to work with electronic spreadsheets?
1. Which open-source web browser is used as the basis for the development of Google Chrome? 1. Which open-source web browser is used as the basis for the development of Google Chrome?
@ -47,7 +47,7 @@
## Guided Exercises ## Guided Exercises
1. What arein a nutshellthe “four freedoms” as defined by Richard Stallman and the Free Software Foundation? 1. What are*in a nutshell*the “four freedoms” as defined by Richard Stallman and the Free Software Foundation?
* freedom 0 * freedom 0
* freedom 1 * freedom 1
* freedom 2 * freedom 2

View File

@ -3,20 +3,20 @@
## Guided Exercises ## Guided Exercises
1. Split the lines below into the components of command, option(s)/parameter(s) and argument(s): 1. Split the lines below into the components of command, option(s)/parameter(s) and argument(s):
* cat -n /etc/passwd * `cat -n /etc/passwd`
* ls -l /etc * `ls -l /etc`
* ls -l -a * `ls -l -a`
* cd /home/user * `cd /home/user`
1. Find what type the following commands are: (extenal commands or builtin) 1. Find what type the following commands are: (extenal commands or builtin)
* pwd * `pwd`
* mv * `mv`
* cd * `cd`
* cat * `cat`
* exit * `exit`
1. Resolve the following commands that use quotes: 1. Resolve the following commands that use quotes:
* echo "$HOME is my home directory" * `echo "$HOME is my home directory"`
* touch "$USER" * `touch "$USER"`
* touch 'touch' * `touch 'touch'`
## Explorational Exercises ## Explorational Exercises
@ -28,52 +28,52 @@
## Guided Exercises ## Guided Exercises
1. Create a local variable **number**. 1. Create a local variable `number`.
1. Create an environment variable **ORDER**, using one of the two above methods. 1. Create an environment variable `ORDER`, using one of the two above methods.
1. Display both the variable names and their contents. 1. Display both the variable names and their contents.
1. What are the scopes of the previously created variables? 1. What are the scopes of the previously created variables?
## Explorational Exercises ## Explorational Exercises
1. Create a local variable **nr_files** and assign the number of lines found in the /etc/passwd file. Hint: Look into the command wc and command substitution and dont forget about quotation marks. 1. Create a local variable `nr_files` and assign the number of lines found in the `/etc/passwd` file. Hint: Look into the command `wc` and command substitution and dont forget about quotation marks.
1. Create an environment variable **ME**. Assign the **USERNAME** variables value to it. 1. Create an environment variable `ME`. Assign the `USERNAME` variables value to it.
1. Append the **HOME** variables value to **ME**, having the : delimiter. Display the contents of the **ME** variable. 1. Append the `HOME` variables value to `ME`, having the : delimiter. Display the contents of the `ME` variable.
1. Using the date example above, create a variable called **today** and assign the date for one of the time zones. 1. Using the date example above, create a variable called `today` and assign the date for one of the time zones.
1. Create another variable called **today1** and assign the systems date to it. 1. Create another variable called `today1` and assign the systems date to it.
# Lesson 2.2 # Lesson 2.2
## Guided Exercises ## Guided Exercises
1. Use the man command to find out what each command does: 1. Use the `man` command to find out what each command does:
* ls * `ls`
* cat * `cat`
* cut * `cut`
* cd * `cd`
* cp * `cp`
* mv * `mv`
* mkdir * `mkdir`
* touch * `touch`
* wc * `wc`
* passwd * `passwd`
* rm * `rm`
* rmdir * `rmdir`
* more * `more`
* less * `less`
* whereis * `whereis`
* head * `head`
* tail * `tail`
* sort * `sort`
* tr * `tr`
* chmod * `chmod`
* grep * `grep`
1. Open the ls info page and identify the MENU. 1. Open the `ls` info page and identify the MENU.
* What options do you have? * What options do you have?
* Find the option that allows you to sort the output by modification time. * Find the option that allows you to sort the output by modification time.
1. Display the path to the first 3 README files. Use the man command to identify the correct option for locate. 1. Display the path to the first 3 README files. Use the `man` command to identify the correct option for locate.
1. Create a file called test in your home directory. Find its absolute path with the locate command. 1. Create a file called test in your home directory. Find its absolute path with the `locate` command.
1. Did you find it immediately? What did you have to do in order for locate to find it? 1. Did you find it immediately? What did you have to do in order for locate to find it?
1. Search for the test file that you previously created, using the find command. What syntax did you use and what is the absolute path ? 1. Search for the test file that you previously created, using the `find` command. What syntax did you use and what is the absolute path ?
## Explorational Exercises ## Explorational Exercises
@ -98,6 +98,7 @@
| └── passa | └── passa
└── test └── test
``` ```
1. Display on the screen the present working directory, including the subfolders. 1. Display on the screen the present working directory, including the subfolders.
1. Search within the tree for all files that end with a number. 1. Search within the tree for all files that end with a number.
1. Remove the entire directory tree with a single command. 1. Remove the entire directory tree with a single command.
@ -137,14 +138,15 @@
12 directories, 5 files 12 directories, 5 files
``` ```
* A user enters the following commands: * A user enters the following commands:
``` ```
$ cd /etc/udev $ cd /etc/udev
$ ls -a $ ls -a
``` ```
* What will be the output of the ls -a command?
* What will be the output of the `ls -a` command?
1. Enter the shortest possible command for each of the following: 1. Enter the shortest possible command for each of the following:
* Your current location is root (/). Enter the command to navigate to lost+found within the home directory (example): * Your current location is root (/). Enter the command to navigate to lost+found within the home directory (example):
* Your current location is root (/). Enter the command to navigate to the directory named /etc/network/. * Your current location is root (/). Enter the command to navigate to the directory named /etc/network/.
@ -159,7 +161,7 @@
$ cd .. $ cd ..
$ pwd $ pwd
``` ```
* What is the output of the final pwd command? * What is the output of the final `pwd` command?
## Explorational Exercises ## Explorational Exercises
@ -170,10 +172,11 @@
$ ls $ ls
this is a test this is a test
``` ```
* What cd command would allow you to enter this directory? * What cd command would allow you to enter this directory?
1. Try this again, but after typing in cd this, press the TAB key. What is now displayed on the prompt? 1. Try this again, but after typing in cd this, press the TAB key. What is now displayed on the prompt?
* This is an example of autocompletion, which is an invaluable tool not only for saving time, but for preventing spelling errors. * This is an example of autocompletion, which is an invaluable tool not only for saving time, but for preventing spelling errors.
1. Try to create a directory whose name contains a \ character. Display the directorys name with ls and delete the directory. 1. Try to create a directory whose name contains a `\` character. Display the directorys name with ls and delete the directory.
# Lesson 2.3.2 # Lesson 2.3.2
@ -202,10 +205,11 @@
└── michael/ └── michael/
└── Music/ └── Music/
``` ```
* What command will navigate into the network directory regardless of your current location? * What command will navigate into the network directory regardless of your current location?
* What command can user enter to navigate into their Documents directory from /etc/udev? Use the shortest possible path. * What command can user enter to navigate into their Documents directory from `/etc/udev`? Use the shortest possible path.
* What command can user enter to navigate into michael 's Music directory? Use the shortest possible path. * What command can user enter to navigate into michael 's Music directory? Use the shortest possible path.
1. Consider the following output of ls -lh to answer the next two questions. Note that directories are indicated with a d at the beginning of the line. 1. Consider the following output of `ls -lh` to answer the next two questions. Note that directories are indicated with a `d` at the beginning of the line.
``` ```
drwxrwxrwx 5 eric eric 4.0K Apr 26 2011 China/ drwxrwxrwx 5 eric eric 4.0K Apr 26 2011 China/
@ -225,20 +229,21 @@
-rwxrwxrwx 1 eric eric 728K Jul 18 2011 Toronto 173.jpg -rwxrwxrwx 1 eric eric 728K Jul 18 2011 Toronto 173.jpg
drwxrwxrwx 2 eric eric 4.0K Jun 5 2016 Wallpapers/ drwxrwxrwx 2 eric eric 4.0K Jun 5 2016 Wallpapers/
``` ```
* When you run the command ls -lrS, what file will be at the beginning?
* Please describe what you expect to see as the output for ls -ad \*/. * When you run the command `ls -lrS`, what file will be at the beginning?
* Please describe what you expect to see as the output for `ls -ad */`.
## Explorational Exercises ## Explorational Exercises
1. Run the ls -lh command in a directory that contains subdirectories. Note the listed size of these directories. Do these file sizes seem correct to you? Do they accurately represent the contents of all files inside that directory? 1. Run the `ls -lh` command in a directory that contains subdirectories. Note the listed size of these directories. Do these file sizes seem correct to you? Do they accurately represent the contents of all files inside that directory?
1. Here is a new command to try: du -h. Run this command and describe the output that it gives you. 1. Here is a new command to try: `du -h`. Run this command and describe the output that it gives you.
1. On many Linux systems, you can type in ll and get the same output as you would if you typed ls -l. Please note however that ll is not a command. For example, man ll will give you the message that no manual entry exists for it. This is an example of an alias. Why might aliases be useful to a user? 1. On many Linux systems, you can type in `ll` and get the same output as you would if you typed `ls -l`. Please note however that `ll` is not a command. For example, `man ll` will give you the message that no manual entry exists for it. This is an example of an `alias`. Why might aliases be useful to a user?
# Lesson 2.4 # Lesson 2.4
## Guided Exercises ## Guided Exercises
1. Given the following, select the directories that would be created by the command mkdir -p /tmp/outfiles/text/today /tmp/infiles/text/today 1. Given the following, select the directories that would be created by the command `mkdir -p /tmp/outfiles/text/today /tmp/infiles/text/today`.
``` ```
$ pwd $ pwd
@ -248,6 +253,7 @@
./outfiles ./outfiles
./outfiles/text ./outfiles/text
``` ```
* /tmp * /tmp
* /tmp/outfiles * /tmp/outfiles
* /tmp/outfiles/text * /tmp/outfiles/text
@ -255,18 +261,15 @@
* /tmp/infiles * /tmp/infiles
* /tmp/infiles/text * /tmp/infiles/text
* /tmp/infiles/text/today * /tmp/infiles/text/today
1. What does -v do for mkdir, rm, and cp? 1. What does `-v` do for `mkdir`, `rm`, and `cp`?
1. What happens if you accidentally attempt to copy three files on the same command line to a file that already exists instead of a directory? 1. What happens if you accidentally attempt to copy three files on the same command line to a file that already exists instead of a directory?
1. What happens when you use mv to move a directory into itself? 1. What happens when you use `mv` to move a directory into itself?
1. How would you delete all files in your current directory that start with old? 1. How would you delete all files in your current directory that start with old?
1. Which of the following files would log_[a-z]\_201?\_\*\_01.txt match? 1. Which of the following files would `log_[a-z]_201?_*_01.txt` match?
* `log\_3\_2017_Jan_01.txt`
``` * `log_+_2017_Feb_01.txt`
log\_3\_2017_Jan_01.txt * `log_b_2007_Mar_01.txt`
log_+_2017_Feb_01.txt * `log_f_201A_Wednesday_01.txt`
log_b_2007_Mar_01.txt
log_f_201A_Wednesday_01.txt
```
1. Create a few globs to match the following list of file names: 1. Create a few globs to match the following list of file names:
* doc100 * doc100
* doc200 * doc200
@ -275,8 +278,8 @@
## Explorational Exercises ## Explorational Exercises
1. Use the cp man page to find out how to make a copy of a file and have the permissions and modification time match the original. 1. Use the `cp` man page to find out how to make a copy of a file and have the permissions and modification time match the original.
1. What does the rmdir -p command do? Experiment with it and explain how it differs from rm -r. 1. What does the `rmdir -p` command do? Experiment with it and explain how it differs from `rm -r`.
1. **DO NOT ACTUALLY EXECUTE THIS COMMAND:** What do you think rm -ri /\* will do? **(HONESTLY, DO NOT ATTEMPT TO DO THIS!)** 1. **DO NOT ACTUALLY EXECUTE THIS COMMAND:** What do you think `rm -ri /*` will do? **(HONESTLY, DO NOT ATTEMPT TO DO THIS!)**
1. Other than using -i, is it possible to prevent mv from overwriting destination files? 1. Other than using `-i`, is it possible to prevent `mv` from overwriting destination files?
1. Explain the command cp -u. 1. Explain the command `cp -u`.

View File

@ -50,3 +50,4 @@ roger
* put all of the new users $HOME directory in a distinct folder so that their home would be `/home/students/$HOME` * put all of the new users $HOME directory in a distinct folder so that their home would be `/home/students/$HOME`
* write a **second** script that removes these users from the system **and** also removes all traces of their existance * write a **second** script that removes these users from the system **and** also removes all traces of their existance
* how could you combine both scripts into one big script? * how could you combine both scripts into one big script?
* how would you force the new users to change their password upon first login? (might require an additional script)