A script needs to know which devices to connect to.
You keep that list in a file on the server, with one address per line.To create a directory, you use the command
mkdirlike this:netops@automation:~/automation$ mkdir inventoryTo create a file with a text in it, you use
echoand the sign>like this:netops@automation:~/automation$ echo "10.0.0.1" > devices.txt
Figure 1 - > Sends the Text Into the File
Alone,
echoprints the text on the screen. With>, the text goes into the file instead. This is called a redirection.In the lab, you need to:
Create a directory named
backups.Create a file named
devices.txtthat holds10.0.0.1.
Answer the question below
Enter the flag you obtained.
To read a file, you use the command
catlike this:netops@automation:~/automation$ cat devices.txt 10.0.0.1In the lab, read the file
notes.txt.Answer the question below
Which address does notes.txt give for the backup server?
The sign
>replaces everything in the file.
To add a line at the end, you use>>like this:netops@automation:~/automation$ echo "10.0.0.2" >> devices.txt
Figure 2 - > Replaces the File, >> Adds a Line
In the lab, add
10.0.0.2and10.0.0.3todevices.txt, one per line, to get the flag.Answer the question below
Enter the flag you obtained.
To copy a file, you use the command
cpwith the file first, then the destination:
Figure 3 - cp: Source, then Destination
To move a file into another directory, you use
mvthe same way, likemv devices.txt backups/.
With a new name as destination,mvrenames the file:
Figure 4 - mv: Old Name, then New Name
These commands print nothing when they work. Run
lsto check the result.In the lab, you need to:
Copy
devices.txtinto thebackupsdirectory.Move
r1.cfginto thebackupsdirectory.Rename
devices.txttoinventory.txt.
Answer the question below
Enter the flag you obtained.
To delete a file, you use the command
rmlike this:netops@automation:~/automation$ rm notes.old
Figure 5 - rm Deletes a File
There is no recycle bin in Bash: a deleted file is gone.
To delete a directory and everything inside it, you add the option
-r, likerm -r old-backups.In the lab, delete the file
draft.txtand the directoryteststo get the flag.Answer the question below
Enter the flag you obtained.