Lab09 Setup - jacob-dinapoli/tech-journal GitHub Wiki
Step One: Bash Scripting
Login to user on web01
Type in the following commands
touch script.sh
ls -la script.sh
chmod 774 script.sh
ls -ls script.sh
./script.sh
This creates a file and messes around with the permissions(warmup)
ssh into jacob@web01-jacob from ad01
The Path environment variable is very important. It tells your bash interpreter, which directories to scan for applications that match your command.
Type the following command:
echo $PATH
To show all the Environment variables type the following command:
env
Go back to normal user with exit and check out your path.
Your profile information comes from several files in /etc, as well as your home directory. If you want to modify the path for all users, then you would do so in a file in /etc. If you are just changing the user's specific environment, then you would do it in configurations located in their home directory.
Step Two: Shortcuts
From your home directory, navigate to /usr/share/firewalld/tests/ just using the minimal number of characters and the tab key to complete. Once there type cd - to go back to the last directory you were in.
Up and Down Arrows
Hit the up arrow until you get back to your original cd statement
History
Type history to see what has gone on before. If you echo the $HISTSIZE environment variable, it shows how many entries are saved.
To create a simple bash script, type the following command:
vi info.sh
Type the following code
#!/bin/bash
echo "Welcome to SYS255"
echo "Kernel Version"
uname -a
echo "Linux Version"
cat /etc/redhat-release
echo "Currently Logged in Users"
w
Save the following code and run the command:
bash info.sh
Step Three: A Parsing Script
We are going to work with the /etc/group and /etc/passwd files. We will run through the example using /etc/group, and you will extend the example to do similar things with the /etc/passwd file.
The following one line command will parse the /etc/group file and pluck out the first, third and fourth fields:
In many cases we wish to filter the results of a script or command down using grep. In this case, we only want to show entries with the group "wheel", this should show your sudo users.
Your job is to create a similar script to the one that parsed /etc/group. We are interested in the name, uid, gid, directory and shell fields. Your command should look similiar t this: