Linux Case Study

·

4 min read

End Course Assignment

  1. Which of the following commands is used to zip and .tar.gz file contents

    tar cvzf file.tar.gz [file or directory to be archived]

    tar: stands for tape archive, which is used to create Archive and extract the Archive files.

    -c: Creates an archive by bundling files and directories together.

    -v: Displays verbose information, providing detailed output during the archiving or extraction process.

    -z: Uses gzip compression when creating a tar file, resulting in a compressed archive with the ‘.tar.gz’ extension.

    -f: Specifies the filename of the archive to be created or extracted.

  2. Which of the following commands is used to view text file contents compressed using gzip?

    zcat <filename>.gz

  3. Find Top 5 files in terms of disk usage in the system.

    df | head -6

  4. Find files bigger than +10M

    find / -size +10M

  5. Which of the following suffixes is used to run a process in the background?

    <command> &

  6. ___________command is used to keep a process running even after shell logout.

    nohup <command> <arguments>

  7. ___________provide command interpreter environment.

    Shell provides a command interpreter environment

  8. In Linux, the default configuration files are stored in ________ directory.

    /etc

  9. List all the processes whose commands don’t have any arguments. Mention the command along with the screenshot.

    ps

    top

    htop

    atop

  10. You are asked to find out the IP address and MAC address of your system, which needs to be added to the whitelist of your company’s network. Mention the steps and provide the screenshot along with their respective command

    ifconfig or ip addr or ip a

  11. Use cat to display /etc/hosts and /etc/resolv.conf. What is your idea about the purpose of these files ?

    The /etc/hosts file in Linux or any other operating system is used to map connections between IP addresses and domain names.

    The /etc/resolv.conf file is known as the configuration file for DNS queries. Specifically, it translates domain names to IP addresses by querying the Domain Name Server (DNS). The /etc/resolv.conf file is the file that configures the domain name resolver.

  12. Create two files (text.txt and text.jpg) under the Documents directory. List all the files under the Documents directory and paste the result in results.txt file. Now display the content of results.txt file. Mention the steps along with their respective screenshots.

  13. List all the files in the home directory and redirect the output to a new text file. Compress the newly generated text file and protect it with a password. Mention the steps along with their respective screenshots

  14. Create a text file with some data in it. Using octal mode, change the permissions of the file such that: •

  • User can read, write, and execute (4+2+1 =7)

  • Group can only execute (0+0+1 =1)

  • Others can only read the file (4+0+0=4)

Mention the command along with the screenshot.

  1. Using symbolic mode, change the permissions of a file such that:
  • User can read, write, and execute

  • Group can read and execute

  • Others can only execute the file

Mention the command along with the screenshot

  1. Execute a Linux Cron Jobs Every Second Using Crontab. Is it possible to schedule jobs every second?

    It's not possible to schedule jobs every second. Cron only supports a time interval of at least 60 seconds (i.e. 1 minute)

  2. Schedule a Background Cron Job For Every 10 Minutes to find files bigger than +10M

    /10 * path/to/find / -size +10M

    Syntax:

    /10 * path/to/command

  3. Schedule a Background Job Every Day using @daily to run a bash script to check disk space.

    00 11 * path/to/script

    Cron job at 11:00 on every day.

  4. Accepting Parameters-

For the inputs given along with the script, read all the inputs and display them as below-

Using command line parameters with a script

  1. Read Data from Files

Have a txt file with content as the below –

Hello how ru

I'm fine

How are you doing

I Am doing good

The output should look like below –

bash readfile.sh input.txt