Bash Scripting
Create another script that asks a user to enter a search term from the console & then uses that term with grep to search all log files in the dev/logs directory for matching lines.
#!/bin/bashecho "Enter search term or REGEX"read searchTermegrep -r $searchTerm dev/logs/*
Create a BASH script that performs file system cleanup by finding and removing all files in and below your home directory that have a (.core) or (.tmp) extension.
#!/bin/bashfind ~ -type f -name '*.core' | while read fname; do rm $fname; donefind ~ -type f -name '*.tmp' | while read fname; do rm $fname; done OR #!/bin/bashfind / -type f -name '*.core' -deletefind / -type f -name '*.tmp' -delete
In the file permission listing drwxr-xr-x, what is the file type?
(d) directory
List 4 shortcomings of root accounts.
1. single point of failure if compromised 2. setuid is the only way to delegate priviledges 3. the security model is not strong enough for a network 4. high security environments enforce rules that cannot be implemented in traditional UNIX/Linux 5. modification of rules written in command code requires rewrite and recompilation 6. minimal support for auditing
Show the crontab file entry that would run the script from the last question, every Monday, Wednesday, and Friday at 5:30 AM. Assume the name of the script is fileCleanup.sh and that it is located in the ~/script directory.
30 05 * * 1,3,5 ~/scripts/fileCleanup.sh
The only way to have more than 1 root account on a UNIX/Linux system is to set the UID of two user accounts to zero. T/F
False
What is the effect of the command: $ killall root (Where root is the root account of the system)
If the command comes from an unprivledged shell, it will be denied. If it comes from the root shell, the machine will be forced into a shutdown
Which of the following files systems are supported by both Windows and UNIX/Linux?
NFS
When a parent process dies, what happens to any child processes that are still running?
The init process becomes their parent
A Preboot Execution Environment includes hardware and firmware that allows a virgin computer to perform initial loading of an operating system from a network location. T/F
True
Write a regular expression that would find date fields of the form: mm-dd-yyyy and where the field is delineated with either tabs or spaces.
\s[0-9]{2}-[0-9]{2}-[0-9]{4}\s
What is the default hash algorithm for passwords in UNIX/Linux?
crypt
In the file permission listing -rwsr--r--, what does 's' signify?
elevated privileges
What file and file-field are read by the finger command?
etc/psswd GECOS field
What file in the etc/ directory contains user's hashed password?
etc/shadow
Explain when it would be necessary to use the non-rewinding interface file of any backup device.
if multiple dumps were being made to the same drive. Without the non-rewinding interface, successive dumps would overwrite each other.
What regular expression would you type into the script from the last question if you were looking for kernel errors in the category or kern.alert, kern.crit, or kern.emerg ?
kern\.(alert|crit|emerg)
What BASH shell command can send any signal level to a running process?
kill
Which two inter-process signals cannot be caught or blocked?
kill 9 and stop
What BASH shell utility allows you to monitor CPU and memory usage?
ps (process status) or top (dynamic monitor)
Write a BASH command that would force the OS into single-user mode.
telinit 1