XK0-005 · Question #10170
A user issues the following command: ls -l /var/log | egrep -e '^d[rwx]{3}.[rw-]{3}.' The list of files in the system is shown below: Which of the following results matches the command issued?
The correct answer is A. drwxr-x--- 2 root adm 4096 Apr 25 14:41 unattended-upgrades. The regex '^d[rwx]{3}.[rw-]{3}.' matches lines that: (1) start with 'd' (directory), (2) are followed by exactly 3 characters each being r, w, or x (owner permissions), (3) then any characters, (4) then exactly 3 characters each being r, w, or - (no x). Option A - drwxr-x…
Question
Options
- Adrwxr-x--- 2 root adm 4096 Apr 25 14:41 unattended-upgrades
- Bdrwxr-xr-x 2 root root 4096 Apr 24 08:36 apt
- Cdrwxr-xr-x 2 root root 4096 Apr 24 08:36 apt
- D-rw-r--r-- 1 root root 2877 Apr 24 14:14 alternatives.log
How the community answered
(39 responses)- A82% (32)
- B5% (2)
- C10% (4)
- D3% (1)
Explanation
The regex '^d[rwx]{3}.[rw-]{3}.' matches lines that: (1) start with 'd' (directory), (2) are followed by exactly 3 characters each being r, w, or x (owner permissions), (3) then any characters, (4) then exactly 3 characters each being r, w, or - (no x). Option A - drwxr-x--- - starts with d, has 'rwx' as owner bits, and contains '---' (others field) which satisfies [rw-]{3}. Options B/C - drwxr-xr-x - have 'r-x' in both group and others fields; 'x' is not in [rw-], and no three consecutive [rw-] characters appear. Option D starts with '-' (a file), failing the '^d' anchor immediately.
Topics
Community Discussion
No community discussion yet for this question.