Chapter 3: Linux Basic Commands
Practice Questions and Lab Exercises
- Explain the purpose of
/etc,/var/log,/homeand/usr/share. - What is the difference between absolute and relative paths? Give two examples.
- Convert to numeric:
rwxr-x---,rw-r--r--,r--------. Convert750and640to symbolic. - Why must a
.pemkey have permission400or600? - Write the commands to install
gitandtreeon Ubuntu and on Amazon Linux 2023. - Lab: Create
~/labs/demo/{html,css,js}, createindex.htmlinsidehtml, copy it to/tmp, rename it, then delete it. - Lab: Create user
student1, add it to the admin group of your distribution, switch to it and runsudo whoami. - Lab: Run
sleep 300 &, find its PID withpgrep, and kill it. - 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 755dirs,644files,400pem. Ownershipchown user:group. - Users:
useradd -m,passwd,usermod -aG. Admin group:wheel(RHEL/AL) vssudo(Ubuntu). - Packages:
apt(Ubuntu),yum(Amazon Linux / CentOS; runsdnfon newer releases). - Processes:
ps aux,top,kill. Help:man,--help. Editors: nano (easy), vim (i,Esc,:wq).