0% found this document useful (0 votes)
223 views

Linux Custom Script Tasks

The document provides instructions for creating a Linux command called "internsctl" that allows users to retrieve system information and perform administrative tasks. It outlines three levels of functionality - easy, intermediate, and advanced. For the easy level, the command should provide CPU and memory info similar to the "lscpu" and "free" commands. The intermediate level involves user management like creation and listing. The advanced level focuses on file properties where specific details can be extracted using options. The command is expected to have a manual page, help output, and version flag for user guidance.

Uploaded by

VAIBHAV TIWARI
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
223 views

Linux Custom Script Tasks

The document provides instructions for creating a Linux command called "internsctl" that allows users to retrieve system information and perform administrative tasks. It outlines three levels of functionality - easy, intermediate, and advanced. For the easy level, the command should provide CPU and memory info similar to the "lscpu" and "free" commands. The intermediate level involves user management like creation and listing. The advanced level focuses on file properties where specific details can be extracted using options. The command is expected to have a manual page, help output, and version flag for user guidance.

Uploaded by

VAIBHAV TIWARI
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

General instructions

1. The approach of solving the Problem solely depends on the Candidate


2. Make sure to have Draw.io diagrams for the workflowns and application architecture
3. Every configuration, code written should be pushed on git (Private Repo)
4. Your are not permitted to share the doc with anyone, even with your colleagues

Scenario There is a customer who came to you with a problem to have a custom linux
command for his operations. Your task is to understand the problem and create a linux
command via bash script as per the instructions.

Command name - internsctl


Command version - v0.1.0

Section A
1. I want a manual page of command so that I can see the full documentation of the command.

For example if you execute the command

man ls

as output we get the doc and usage guidelines. Similarly if I execute man internsctl I want
to see the manual of my command.

2. Each linux command has an option --help which helps the end user to understand the use
cases via examples. Similarly if I execute internsctl --help it should provide me the
necessary help

3. I want to see version of my command by executing

internsctl --version

Section B
I want to execute the following command for -

Part1 | Level Easy

I want to get cpu information of my server through the following command:


$ internsctl cpu getinfo

Expected Output -

I want similar output as we get from lscpu command

---
I want to get memory information of my server through the following command:

$ internsctl memory getinfo

Expected Output

I want similar output as we get from free command

Part2 | Level Intermediate

I want to create a new user on my server through the following command:

$ internsctl user create <username>

Note - above command should create user who can login to linux system and access his home
directory

---
I want to list all the regular users present on my server through the following command:

$ internsctl user list

---
If want to list all the users with sudo permissions on my server through the following command:

$ internsctl user list --sudo-only

Part3 | Advanced Level

By executing below command I want to get some information about a file

$ internsctl file getinfo <file-name>

Expected Output [make sure to have the output in following format only]

xenonstack@xsd-034:~$ internsctl file getinfo hello.txt


File: hellot.txt
Access: -rw-r--r--
Size(B): 5448
Owner: xenonstack
Modify: 2020-10-07 20:34:44.616123431 +0530

In case I want only specific information then I must have a provision to use options

$ internsctl file getinfo [options] <file-name>

--size, -s to print size

--permissions, -p print file permissions

--owner, o print file owner

--last-modified, m

Expected Output with options

If I want to obtain the size of the specified file only, I should be able to use the following
command:

xenonstack@xsd-034:~$ internsctl file getinfo --size hello.txt


5448

If I want to obtain the permissions of the specified file only, I should be able to use the following
command:

xenonstack@xsd-034:~$ internsctl file getinfo --permissions hello.txt


-rw-r--r--

If I want to obtain the owner of the specified file only, I should be able to use the following
command:

xenonstack@xsd-034:~$ internsctl file getinfo --owner hello.txt


xenonstack

If I want to obtain the last modified time of the specified file only, I should be able to use the
following command:

xenonstack@xsd-034:~$ internsctl file getinfo --last-modified hello.txt


2020-10-07 20:34:44.616123431 +0530

You might also like