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

Linux Foundation Certified System Administrator

The document provides an overview of module 1 of the Linux Foundation Certified System Administrator certification, which covers advanced Bash shell scripting. It discusses the benefits of shell scripts, including being easy to learn and always available without needing to load additional modules. It also covers essential shell script components like shebang lines, variables, and conditional statements. The document concludes with a lab example of a shell script that extracts usernames from an LDAP export file and demonstrates how it could be used to create local user accounts, though it avoids actually creating accounts during testing.

Uploaded by

gilefx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
232 views

Linux Foundation Certified System Administrator

The document provides an overview of module 1 of the Linux Foundation Certified System Administrator certification, which covers advanced Bash shell scripting. It discusses the benefits of shell scripts, including being easy to learn and always available without needing to load additional modules. It also covers essential shell script components like shebang lines, variables, and conditional statements. The document concludes with a lab example of a shell script that extracts usernames from an LDAP export file and demonstrates how it could be used to create local user accounts, though it avoids actually creating accounts during testing.

Uploaded by

gilefx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Linux Foundation Certified System Administrator (LFCS) [2019]

Module 1 - Advanced System Administration


01 An Introduction to Bash Shell Scripting
- Shell scripts are common as they are easy to learn and implement
- Will always be available to interpret code from shell script
- If the script use internal commands only, they’re very fast as nothing needs to be loaded
- There is no need to compile nothing
- Thete no modules to be used in the Bash script, wich makes them rather static
- Bash shell scripts are not idempotent
01-02 Essential Shell Script Components
- Create a simple Bash shell script file
Use vim ou nano Editor:
#!/bin/bash
#
#some explanation
Echo what directory do you want to go to ?
Read DIR
cd $DIR
pwd
ls

exit 0
- We check the script properties and make him executable using these commands:
ls –ls script2
chmod +x script
./script2
cat script – verify the conteud of the script without run it
01-03 Using Loops in Shell Scripts
- Different conditiuonal statements are available in Bash
- If…then..fi
- While..do..done
- Until…do…done
- Case…in…esac
- For…in…do…done
We using script3 and script10
Script3 make an argument and script 10 make an account down to warn you time is up for
something you forget or need to do
01-04 Lab. Writing Shell Scripts
- A customer exported a long list of LDAP user names.These usernames are stored in the
file ldapusers.In this file, ever user has a aname in the format
cn=lisa,dc=example,dc=com. Write a scipt that extract the username only (lisa) from all
of these lines and write those to a new file
- Based on this new file, create local user account on your Linux box
- Note:while testing, it is not a smart idea to create the user accounts direftly. Find a
solution that proves that the script works wthout polluting your system with many user
names.
01-05 Lab Solution. Writing Shell Scripts
Create and execute script lessons1.sh

#!/bin/bash
#extract the user names
for i in $(cat ldapusers)
do
USER=${i%%,*}
USER=${USER#*=}
echo $USER >> users
done
# show that user creation will work
for j in $(cat users)
do
echo useradd $j
done
~
~
Create ldapuser file
Ldapusers: cn=lisa,dc=example,dc=com
Cn=amy,dc=example,dc=com
02 Managing Local Security

You might also like