Ravindra BagaleCourses & study guides

Chapter 3: Linux Basic Commands

Practice Questions and Lab Exercises

  1. Explain the purpose of /etc, /var/log, /home and /usr/share.
  2. What is the difference between absolute and relative paths? Give two examples.
  3. Convert to numeric: rwxr-x---, rw-r--r--, r--------. Convert 750 and 640 to symbolic.
  4. Why must a .pem key have permission 400 or 600?
  5. Write the commands to install git and tree on Ubuntu and on Amazon Linux 2023.
  6. Lab: Create ~/labs/demo/{html,css,js}, create index.html inside html, copy it to /tmp, rename it, then delete it.
  7. Lab: Create user student1, add it to the admin group of your distribution, switch to it and run sudo whoami.
  8. Lab: Run sleep 300 &, find its PID with pgrep, and kill it.
  9. Lab: Open a file in vim, add three lines, save and quit. Then do the same in nano.

Quick Revision

  • Navigate: pwd, ls -la, cd. Files: mkdir -p, touch, cp -r, mv, rm -r (permanent!).
  • View: cat, less, head, tail -f.
  • Permissions r=4, w=2, x=1 → chmod 755 dirs, 644 files, 400 pem. Ownership chown user:group.
  • Users: useradd -m, passwd, usermod -aG. Admin group: wheel (RHEL/AL) vs sudo (Ubuntu).
  • Packages: apt (Ubuntu), yum (Amazon Linux / CentOS; runs dnf on newer releases).
  • Processes: ps aux, top, kill. Help: man, --help. Editors: nano (easy), vim (i, Esc, :wq).