Exercises

  1. Using bash, enter the export command and the set command. Which set of variables is a subset of the other? What is the difference between the variables reported by export and those reported by set? Finally, enter which export. Where is the export command located?

  2. Examine /etc/profile. How is the default umask set? What customizations are done in the file for system users?

  3. Create a simple bash script using the #!/bin/bash syntax, set the executable mode bits, and execute the shell. If it runs correctly, add errors to see the diagnostic messages. Have the script report both exported and nonexported variables. Verify that the nonexported variables do not survive the startup of the new shell.

  4. Create some bash aliases in your current shell. Start a new shell by running the command bash in your current shell. Do your aliases work in this child shell? Why or why not?

  5. Create a MySQL table structure that could be used to store the fields in the file /etc/passwd. Write a shell script to parse this file, one line at a time, and call the mysql command-line program to insert the users defined in /etc/passwd into your table. Once this is complete, write a SQL query to list all usernames that have a shell of /bin/bash.

Get LPI Linux Certification in a Nutshell, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.