LFCS study materials
LFCS study resources

LFCS: Essential Commands

LFCS · Work through your exam, one topic at a time.

All guide sections

Essential Commands

Files, text, permissions, and pipelines

Essential command questions reward precision with paths, globs, options, and redirection. Know file operations (cp, mv, rm, mkdir -p, touch, ln), text search (grep -r, -i, -n, -v), and file search (find). find tests are explicit: -name, -type, -size, -mtime, and actions such as -exec or -delete. Remember that shell globs are expanded by the shell, while find -name patterns are interpreted by find.

Permissions use octal and symbolic modes. chmod 640 file gives owner read/write and group read. Directories need execute permission to be traversed. chown user:group file changes ownership; chgrp changes group. Hard links share an inode and cannot cross filesystems or point to directories; symbolic links store a path and can point anywhere.

Pipelines and redirection are frequent traps. cmd > out 2> err redirects stdout and stderr separately; cmd > out 2>&1 sends both to the same place, but order matters. >> appends. Use tee when you need output on screen and in a file. tar archives and extracts: creating with tar -czf archive.tar.gz dir, listing with -tzf, extracting with -xzf.

Worked rule of thumb: for a safe search, state the start path, a test, and an action: find /var/log -type f -name '*.log' -mtime +7 -print. For deletion, run the same command with -print first, then replace it with -delete only after confirming the matches. Quote patterns so the shell does not expand them prematurely.