Task - Level1 Linux Module
Task - Level1 Linux Module
1. I want a manual page of command so that I can see the full documentation of the
command.
man internctl
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.
internsctl –version
code
echo "v0.1.0"
Out put:
S ection B
Part1 :
Code:
free
Part2
1. I want to create a new user on my server through the following command:
Code
#! /bin/bash
if id "$1" &>/dev/null;
then
echo "User $1 already exists."
echo "please chose another username."
exit
else
read -p "password " pswd
useradd -p "$pswd" -d /home/"$1" -m -g users -s /bin/bash "$1"
echo "$1 added"
fi
2. I want to list all the regular users present on my server through the following
command:
#! /bin/bash
cat /etc/passwd
3. If want to list all the users with sudo permissions on my server through the following
command:
Code
#!/bin/sh
Expected Output
Code:
#! /bin/bash
if [[ "$#" -eq 1 ]];
then
ls -l $1
elif [[ "$#" -eq 2 ]];
then
if [ "$1" == "-s" ] || [ "$1" == "--size" ]
then
wc -c $2
elif [ "$1" == "-p" ] || [ "$1" == "--permissions" ]
then
ls -ld $2 |awk '{ print $1; }'
elif [ "$1" == "o" ] || [ "$1" == "--owner" ]
then
stat -c '%U' $2
elif [ "$1" == "m" ] || [ "$1" == "--last-modified" ]
then
stat -c ‘%y’ $2
fi
fi