Lab Challenge

By Muhammad Aditiya Rakhman


Lab Challenge 1: Working with file content

Instructions

  1. Extact all line from the file /var/log/sample1.log that contain the string INFO and write them to the file /home/student/challenge01/output1.log

  2. Extact all line from the file /var/log/sample2.log that contain the string illegal at the very start of the line only, and write them to the file /home/student/challenge01/output2.log

  3. Extact all line from the file /var/log/sample1.log that contain router_forward_getOI with TRACE level and write them to the file /home/student/challenge01/output3.log

Answer

$ grep "INFO" /var/log/sample1.log >> /home/student/challenge01/output1.log
$ cat challenge01/output1.log

$ grep "^illegal" /var/log/sample2.log >> challenge01/output2.log
$ cat challenge01/output2.log

Disini saya melakukan 2x kerja
$ grep "router_forward_getOI" /var/log/sample1.log >> hahay
$ grep "TRACE" hahay >> challenge01/output3.log
$ cat challenge01/output3.log


Lab Challenge 2: Finding files

Instructions

  1. Find all files in the directory /home/student/challenge02/spesials/ with their SUID + SGID bits set. Write a list of matching filenames, one per line, to the file /home/student/challenge02/suid.txt. Esure that you specify the absolute path to each file.

  2. Find all files in the directory /home/student/challenge02/spesials/ with mode 0600 . Copy those files to the directory /home/student/challenge02/backup/. Ensure that you preserve the original permissions of the spesials files.

  3. Find all files in the directory /home/student/challenge02/spesials/ with a size that is around of 8-10K. Copy those files to the directory /home/student/challenge02/size/.

  4. Find all files in the directory /home/student/challenge02/spesials/ with a file extension of .txt which are not owned by the user student. Write a list of matching filenames, one per line to the file /home/student/challenge02/extension.txt. Esure that you specify the absolute path to each file

Answer

$ find /home/student/challenge02/spesials/ -perm /6000 -exec ls -ldb {} \; >> /home/student/challenge02/suid.txt

$ cd challenge02/spesials
$ find . -type f -perm u=rw -exec cp {} /home/student/challenge02/backup/ \;

$ cd challenge02/spesials
$ find . -size +7k -size -11k -exec cp {} ../size/ \;

$ cd challenge02/spesials
$ find . -iname '*.txt' -user root -exec ls -l {} \; >> ../extension.txt


Lab Challenge 3: Working with partition

Instructions

  1. Adding a disk to a virtual machine with a size of 2GB

  2. Create a new partition on device /dev/sdc that is 1GiB in size. This should be the first partition on the device

  3. Create an ext4 filesystem on the newly created partition /dev/sdc1. And configure the filesystem's label to be appcache

  4. Mount the new filesystem to the mountpoint /app

  5. Ensure that new filesystem will be mounted automatically upon system startup using LABEL

Answer

Create partition use cfdick tools
# mkfs.ext4 /dev/sdc1
# e2label /dev/sdc1 appcache
# mkdir /app
# mount -L appcache /app

# vim /etc/fstab
Tambahkan
LABEL=appcache    /app    ext4    defaults    0 0

# mount -a
# findmnt --verify

# reboot


Lab Challenge 4 : Comparing Files

Instructions

  1. Compare the content of the files /home/student/challenge04/fileA.txt and /home/student/challenge04/fileB.txt, ignoring case in your comparison. Redirect the output from your comparison on the file /home/student/challenge04/results01.txt.

  2. Compare all file in directory (included subdirectory) /home/student/challenge04/compare01 and /home/student/challenge04/compare02, one file will be different. Write the absolute path of the different file to the output file /home/student/challenge04/results02.txt.

  3. Two directories of the files are present /home/student/challenge04/comdir01 and /home/student/challenge04/comdir02, write a list of filenames only (do not include the path) of files which are only present in /home/student/challenge04/comdir02 to /home/student/challenge04/results03.txt.

Answer

$ diff -i challenge04/fileA.txt challenge04/fileB.txt >> challenge04/results01.txt

$ diff -r /home/student/challenge04/compare01 /home/student/challenge04/compare02 >> /home/student/challenge04/results02.txt

$ cd challenge04/
$ diff -r comdir02 comdir01 | grep comdir02 >> results03.txt

Last updated