System Security
HomeSCJP | SCWCD | SCEA | SCSA
1.  Identify how to search for regular expressions in the contents of one or more files.
The grep utility is used to parse through existing files in search of matching strings. With its options, it can return output in a variety of ways.
Example: Finding all uses of a word To find all uses of the word "Passing" (in any case) in the  file scores.txt, and write with line numbers in the commands output:
# /usr/bin/grep -i -n Passing scores.txt
Example: Finding all empty lines To find all empty lines in the standard input:
# /usr/bin/grep ^$  or  # /usr/bin/grep -v .
Example: Finding lines containing strings Both of the following commands print all lines containing
strings abc or def or both:
# grep -E 'abc def'
# grep -F 'abc def'

2.  List in sequence the steps to create, modify, and delete access control lists (ACLs)on files.
Access control lists provide a mechanism for finer control over the basic UNIX file permissions. They offer extended protection over and above what is provided by standard UNIX file permissions. A file has an acl set if its output in the ls has a '+' at the end of the permissions mode field.
The setfacl command is used to set a file ACL.
setfacl options acl_entry filename1 [ filename2 filename3 ... ]
For example, to give read access to another user on a file you own:
setfacl -m user:reader1:6 newtext.txt
would assign read only access to the user reader1
To verify that ACLs were set for the file, run
# getfacl
# file: newtext.txt
# owner: reader1
# group: users
user::rw-
user:reader1:r--        #effective:r--
group::r--              #effective:r--
mask:r--
other:r--


To remove an ACL from the file, run:
setfacl -d user:reader1:6 newtext.txt