Tuesday, December 9, 2014

Practice test!

EDIT: I MADE SUBSTANTIAL CHANGES TO THIS EXAM.

I created a practice test for LFCS that I think is serious overkill. I tried to create questions that hit on every core competency listed on linuxfoundation.org's website. Assume you have a CentOS 6.5 box with primary drive of 20gb and two supplemental drives of 5gb each.
 
  1. You do not know the root password. Interrupt the startup and reset the root password to “centos”
  2. Upon reboot, manually configure grub to boot into runlevel 3
  3. Upon booting, set the machine to permanently boot into runlevel 3
  4. Change the hostname to CENT6
  5. Statically assign viable network settings for your machine:
    1. IP - DNS - FQDN - Gateway
  6. Install the Apache Package
    1. Change the default directory to /web/html
    2. Create a file named index.html and place it in /web/html
    3. Make sure that anyone on your local subnet can access index.html but no one else.
  7. Create the following users with the following details - If the supplemental groups listed do not exist, create them.
    1. Bob - Supplemental Group Engineering - PW: cent6
    2. Tim - Supplemental Group WebDev - PW: cent6
    3. Ben - Supplemental Group Chemical - PW: cent6
    4. All accounts created must expire one year from today.
    5. Set Bob's default shell to zsh
    6. Set Tim's default home directory to /websites - if this directory does not exist, create it.
      1. Apply the same SELinux contexts and permissions to /websites that would be found on a user's /home directory such that Tim and only Tim will have access to /websites
  8. Give Ben complete Sudo access to the machine.
  9. Give Tim Sudo access to the following tool:
    1. iptables
  10. Create a directory named /Homework
    1. Allow all users to read this directory. But nothing else.
    2. Create three folders inside /Homework
      1. Bob_homework
      2. Tim_homework
      3. Ben_homework
    3. Give Bob (and only Bob) read and write access to /Homework/Bob_homework
    4. Give Tim (and only Tim) read and write access to /Homework/Tim_homework
    5. Give Ben (and only Ben) read and write access to /Homework/Ben_homework
  11. Create a RAID 0 array using the two spare drives on (5GB) on this machine.
    1. Size=2048MB
    2. Label=RAID_0
    3. Mount it persistently by Label at /storage
  12. Create a RAID 1 array using LVM using the two spare drives (5GB) on this machine
    1. size 1024MB
    2. Label=RAID_1
    3. Mount it persistently by UUID at /storage2
  13. Using the left over space on those one of those two drives, create a 1GB SWAP partition and add it to the existing SWAP pool - This SWAP space should mount at boot.
  14. Assume that there is an NFS share somewhere on your network. Write the command you would use to mount the NFS share on /NFS_mount. Append your terminal code to a file named “network_mount.txt” and place it in the /root folder.
    1. The IP or DNS name for the share do not matter - Use whatever you would like.
  15. Assume that there is an CIFS share somewhere on your network. Write the command you would use to mount the CIFS share on /CIFS_mount. Append your terminal code to a file named “network_mount.txt” and place it in the /root folder.
    1. The IP or DNS name for the share do not matter - Use whatever you would like.
  16. Create a bash script named “Infinite_loop” that does the following:
    1. Continually writes the string "Linux is fun" to the folder /dev/null
    2. Has no exit loop (that is, it will continue to run until told to stop
    3. Place the script in /root
    4. Give bob permissions to run infinite_loop
    5. Switch user to Bob and have him run infinite_loop
    6. Switch back to root
    7. As root, locate the now running infinite_loop and forcefully kill it by PID
  17. Create a backup of the /etc/yum.repos.d folder using tar or rsync; place your backup in /root
  18. Create a local repo using a live dvd iso of Centos
  19. Using your local repo, install the appropriate packages needed for virtualization.
  20. Download the following text file from Project Gutenberg
    1. Within that document, find and replace every instance of the word "Ernest" with "Earnest"
    2. Find line 3123 and put it at the bottom of the document.
    3. Find line 2134 and put it at the top of the document.
    4. Find line 2351 and put it at line 1532.

 
Post your solutions below if you want (if anyone is reading).  

16 comments:

  1. Hi Brandan, how did you do on your LFCS test? I'm trying to prepare fro the same test in the future.

    ReplyDelete
    Replies
    1. I failed the first time due to a technical error on my part but I passed the second time with flying colors - The only thing I will tell you is that any change that you make to a system that could result in a KP or Emergency Mode will immediately end your exam. When I appealed to the Linux Foundation over my first failure, they informed me that "you should be taking the test as if you are working in a COLO with no physical access to the machine; ssh only" so yeah - If you make changes to something that could break the connection (fstab or sudoers etc...) make sure you know what you are doing...

      Other than that, I will say that if you can do RHCSA, LFCS is on the same level. Just prepare by doing everything you can in terminal (no GUI) and follow certdepot.net - That site was insanely valuable.

      Delete
  2. Hello Brendan. Could you please provide some inside information about the LFSC exam. I will be taking it in about 2 weeks and want to be fully prepared.

    ReplyDelete
  3. Great job posting these Practice Test questions, Brendan. They are of the same nature with the LFCS exam questions. If somebody answers all of the questions above, he/she should have no problem passing LFCS exam.

    ReplyDelete
  4. Thank you very much for the Practice Test.
    I give the exam in 3 weeks!
    I have i question. What do you min in 6 question in 3 part??
    To give access only in local subnet? How to do what???
    Thank you in advance.

    ReplyDelete
  5. Thanks man...appreciate the time you took to make this.

    ReplyDelete
  6. How can you reset root password without rebooting and effectively breaking the ssh connection and as a result fail the test?

    ReplyDelete
  7. are there any solutions for this

    ReplyDelete
  8. Hello Brendan. Could you please help me to provide some inside information about the LFSC exam. I will be taking it in about 2 weeks and want to be fully prepared as I have to give exam in our office premises

    ReplyDelete
  9. Passing the LFCS exam is not a big deal now! You can get most reliable LFCS study material from dumpsdownlaod at very reasonable price. Our study material covers all the pionts of LFCS exam. For more information visit us. Dumpsdownload.com

    ReplyDelete
  10. Thank you so much Brendan - I have my first attempt of this on Sunday and have found your prep material challenging and really good thank you again!

    ReplyDelete
  11. 1.

    At boot OS selection, press ‘e’ and edit ‘linux16’ line:

    Replace ro with rw init=/sysroot/bin/sh
    ctrl-x

    In single user mode:
    chroot /sysroot

    Set new password for root:
    passwd root

    touch /.autorelabel



    2.

    Press “e” at GRUB OS selection, scroll down to “Linux16” and append “3” to the line. ctrl-x to exit and boot into RL 3.



    3.

    vi /etc/default/grub = append “3” to GRUB_CMDLINE_Linux line. update-grub = apply changes to GRUB.
    Or systemctl set-default multi-user.target = permanently change runlevel to 3 aka multi-user.target

    systemctl get-default to verify.



    4.

    hostnamectl set-hostname OR vi /etc/hostname = change hostname
    vi /etc/hosts = add new hostname to local address.

    hostname = to verify name change



    5.

    ip a = find connected interface name
    vi /etc/sysconfig/network-scripts/ifcfg- = add dynamic or static network details.

    • dynamic

    BOOTPROTO=dhcp

    • static

    BOOTPROTO=static
    IPADDR=192.168.1.200
    NETMASK=255.255.255.0
    GATEWAY=192.168.1.1
    DNS1=1.0.0.1
    DNS2=8.8.4.4

    systemctl restart network = restart network service to apply changes



    6.

    yum install httpd = install Apache HTTP

    systemctl start httpd = start HTTP svc

    mkdir /web/html = make a dir

    vi /web/html/index.html = create index.html file


    chmod -R 755 /web/html = set permissions of web dir
    chown -R apache:apache /web/html/ = give ownership of web dir to apache user


    vi /etc/httpd/yourdomain.com.conf = create virtual host config file and add lines below to configure it.

    ServerName www.yourdomain.com
    ServerAlias yourdomain.com
    DocumentRoot /web/html <----- default dir (usually /var/www//)
    ErrorLog /web/html/error.log
    CustomLog /web/html/requests.log combined
    <----- path relative to document root, here it is web root /
    Require 192.168.1.0/24 <----- Allow only this IP range



    systemctl restart httpd = restart service to apply changes



    7.

    Create groups:

    groupadd Engineering
    groupadd WebDev
    groupadd Chemical

    vi /etc/group = verify groups created.


    Create Users with expiry date, password and add to group:

    useradd Bob -e YYYY-MM-DD -p cent6 -G Engineering
    useradd Tim -e YYYY-MM-DD -p cent6 -G WebDev
    useradd Ben -e YYYY-MM-DD -p cent6 -G Chemical

    vi /etc/passwd = shows list of all users created
    ls -l /home/ = shows user home dirs


    yum install zsh = install zsh shell
    usermod -s /bin/zsh Bob = change Bob’s shell to zsh


    mkdir /websites
    usermod -d /websites Tim = change Tim’s home dir


    chcon -Rt user_home_t /websites = change context type of dir and files to user home

    ls -lZ /websites/ = verify change of context type



    8.

    sudo visudo = edit file /etc/sudoers to add entry for Ben
    Ben ALL=(ALL) ALL
    or
    usermod Ben -aG wheel = add Ben to “wheel” group, -a appends with other groups



    9.

    which iptables = find location of iptables

    Edit file /etc/sudoers using visudo to add entry for Tim:

    sudo visudo
    =[(as_user)] [NOPASSWD:]
    Tim ALL=(ALL) NOPASSWD: /sbin/iptables



    10.

    Create dirs:
    sudo mkdir /homework = create as root.

    chmod 754 /homework = allow non-owners to read only. r=4, w=2, x=1.

    sudo mkdir /homework/bob_homework = make more dirs for each user.


    Give only Bob rw access, make him owner and make perms 600:
    chown bob.bob /homework/bob_homework
    chmod 600 -R /homework/bob_homework/*


    stat -c ‘%A %a %n’ /hw/* = to verify perms

    ReplyDelete

  12. 11.

    Partition disk for size:
    fdisk /dev/sdb = make 2 partitions sdb1 and sdc1 in each disk of 512MB
    fdisk /dev/sdc
    n, p, 1, +512M


    Create RAID 0 using 2 disks:
    mdadm --verbose --create /dev/raid_0 --level=0 --raid-devices=2 /dev/sdb1 /dev/sdc1

    mkfs.ext4 /dev/raid_0
    mkdir /storage/raid0
    mount /dev/raid_0 /storage/raid0
    mdadm --verbose --detail --scan > /etc/mdadm.conf


    Mount persistently:
    vi /etc/fstab
    /dev/raid_0 /storage/raid0 ext4 defaults 0 0



    12.

    Create 2 partitions in disks:
    fdisk /dev/sdb
    fdisk /dev/sdc

    Create LVM:

    pvcreate /dev/sdb2
    pvcreate /dev/sdc2

    vgcreate vg_grp1 /dev/sdb2 /dev/sdc2

    lvcreate --type raid1 -m 1 -L 1G -n raid1 vg_grp1

    mkfs.ext4 /dev/mapper/vg_grp1-raid1
    mkdir /storage2/raid1
    mount /dev/mapper/vg_grp1-raid1 /storage2/raid1

    Persistently moiunt:
    vi /etc/fstab
    /dev/mapper/vg_grp1-raid1 /storage2.raid1 ext4 defaults 0 0



    13.

    Create a file of 200MB:
    dd if=/dev/zero of=/storage/swap1 bs=1M count=200
    chmod 600 /storage/swap1

    Assign file as swap file and mount it:
    mkswap /storage/swap1
    swapon /storage/swap1

    vi /etc/fstab
    /storage/swap1 swap swap defaults 0 0



    14.

    mkdir /storage/nfs

    mount -t nfs server:/nfs_share /storage/nfs


    For persistance:

    vi /etc/fstab
    server:/nfs_share /storage/nfs nfs defaults 0 0


    For auto-mount:

    vi /etc/auto.master
    /storage /etc/auto.nfs

    vi /etc/auto.nfs
    nfs server:/nfs_share



    15.

    CIFs Share



    16.

    Make script and make it executable:

    vi /infinite_loop

    #!/bin/bash
    while [ 1 ]; do echo “linux is fun” > /dev/null; done

    chmod 755 /infinite_loop


    Switch user to Bob and run script in bg:
    su bob

    /infinite_loop &


    Switch back to root, see process of script and kill it:
    sudo -i

    ps -au

    kill or pkill .*infinite.*


    17.

    Compress and archive folder:
    tar -zcvf /root/yum.repos.d.tar.gz /etc/yum.repos.d



    18 & 19 – skipped, not in LFCS syllabus July 2019



    20.

    Download file from URL into a file:
    curl -o 844.txt

    vi 844.txt

    Replace pattern with string from line 1 to last line for all accurances:
    :1,$s/pattern/string/g

    :3123
    dd
    G
    p


    :2134
    dd
    1G
    P

    :2351
    dd
    :1532
    p


    ReplyDelete
  13. Thanks for the lab. I have posted the solutions to my best knowledge.

    ReplyDelete
  14. Great points there, Translating the thank you, But i Say you if you want Linux Foundation Certification Exams Questions preparation materials you can catch from Pass4future in the procedure of PDF question & answers, and also avail practice test in form of Desktop & Web-based Application for Success. You can also download a free demo of Linux Foundation Exams Questions

    ReplyDelete
  15. TINY TIPS - TINY TIPS - TOITANIAN ART
    TINY TIPS. TINY TIPS. microtouch titanium TINY TIPS. titanium trim as seen on tv TINY TIPS. TINY TIPS. TINY TIPS. TINY TIPS. TINY TIPS. titanium nipple rings TINY TIPS. TINY TIPS. TINY TIPS. TINY titanium grades TIPS. TINY aftershokz trekz titanium TIPS. TINY TIPS.

    ReplyDelete