# Linux Case Study

**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 &lt;filename&gt;.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?
    
    **&lt;command&gt; &**
    
6. \_\_\_\_\_\_\_\_\_\_\_command is used to keep a process running even after shell logout.
    
    **nohup &lt;command&gt; &lt;arguments&gt;**
    
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**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1694161158655/c0bceea8-68cd-408e-8ef4-96c819df8bc8.png align="center")
    
    **htop**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1694161273863/838737a1-733d-4341-bf53-83360865fc92.png align="center")
    
    **atop**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1694166472749/0c2a40f7-cc4c-42b1-84b3-eeb095ab9504.png align="center")
    
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**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1694166606329/ae318282-4ca0-425c-9745-887e0b09624c.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1694166633028/e0b817c8-bd29-425d-bd3c-4d5ddad9c386.png align="center")
    
11. Use cat to display /etc/hosts and /etc/resolv.conf. What is your idea about the purpose of these files ?
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1694176729710/e227f338-7d2b-4242-82c6-59f8243098b7.png align="center")
    
    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***](https://man7.org/linux/man-pages/man5/resolv.conf.5.html) 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.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1694167051662/b69a7415-e836-445a-a4b0-2c6105dcb801.png align="center")
    
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
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1694167258521/26ccfa38-c39c-4e60-b1c7-692e2aa530b1.png align="center")
    
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.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1694167627146/85505a06-19c3-4719-bf00-24688acaf78a.png align="center")

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](https://lh5.googleusercontent.com/njLkVC2qqKgPq2H4kjwqLf3pyjAJ94HhscSyxBrMfEiFbNu3lWQMp3iAcKTQMZndZgwA7LDbfs5xKiTEzoXgcFH5aKH69L0V5DvhoVN9LPs2e4A5Ru3vTjr-_oau8zY4Vu2-vtHHkcE1gTpw9ywzcA align="left")

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 –

<table><tbody><tr><td colspan="1" rowspan="1"><p><strong>bash </strong><a target="_blank" rel="noopener noreferrer nofollow" href="http://readfile.sh" style="pointer-events: none"><strong>readfile.sh</strong></a><strong> input.txt</strong></p></td></tr></tbody></table>

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1694159251889/905446bf-1271-4f02-a282-001dba6a5578.png align="center")
