From 57f0d3ad644f572d4388ada35b172484d69d6797 Mon Sep 17 00:00:00 2001 From: tk5im Date: Wed, 18 May 2022 16:36:37 +0200 Subject: [PATCH 1/2] typo correction at if conditions --- Days/day19.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Days/day19.md b/Days/day19.md index c9a7c30..2727f20 100644 --- a/Days/day19.md +++ b/Days/day19.md @@ -152,7 +152,7 @@ We might also use bash scripting to determine information about files and folder - `-d file` True if the file is a directory - `-e file` True if the file exists - `-f file` True if the provided string is a file -- `g file` True if the group id is set on a file +- `-g file` True if the group id is set on a file - `-r file` True if the file is readable - `-s file` True if the file has a non-zero size From 586cc5676d712808c363ea16b217efe832ef277d Mon Sep 17 00:00:00 2001 From: Codehunter-py Date: Wed, 18 May 2022 17:19:56 +0200 Subject: [PATCH 2/2] added userdel command in create-user script --- Days/Linux/create-user.sh | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) mode change 100644 => 100755 Days/Linux/create-user.sh diff --git a/Days/Linux/create-user.sh b/Days/Linux/create-user.sh old mode 100644 new mode 100755 index 554d6ae..30465cc --- a/Days/Linux/create-user.sh +++ b/Days/Linux/create-user.sh @@ -1,15 +1,27 @@ #! /usr/bin/bash +if [ -z "${1}" ] +then + echo "What is your intended username?" + read username + echo "What is your password" + read password -echo "What is your intended username?" -read username -echo "What is your password" -read password + #A user can be passed in as a command line argument + echo "$username user account being created." -#A user can be passed in as a command line argument -echo "$username user account being created." + #A user is created with the name of command line argument + sudo useradd -m $username -#A user is created with the name of command line argument -sudo useradd -m $username + #A password can be parsed in as a command line argument. + sudo chpasswd <<< $username:$password + + sleep 2 + echo "If you want to delete the user then pass 'del' and username in command line argument. e.g: ./create-user.sh del username" + +else + sudo userdel -rf "${2}" + sleep 2 + echo "${2} user account successfully deleted." + exit 0 +fi -#A password can be parsed in as a command line argument. -sudo chpasswd <<< $username:$password \ No newline at end of file