75 lines
2.3 KiB
EmacsLisp
75 lines
2.3 KiB
EmacsLisp
;;; 60-file-permissions-lesson.el --- file-permissions-lesson
|
|
|
|
(defun file-permissions-lesson ()
|
|
"Linux+ lesson for file permissions and ownership."
|
|
(interactive)
|
|
(delete-other-windows)
|
|
(let ((buf (get-buffer-create "*File Permissions Lesson*"))
|
|
(shell (or shell-file-name (getenv "SHELL") "/bin/sh")))
|
|
(switch-to-buffer buf)
|
|
(read-only-mode -1)
|
|
(erase-buffer)
|
|
(insert
|
|
"Linux+ Lesson: File Permissions and Ownership\n"
|
|
"============================================\n\n"
|
|
"Concepts:\n"
|
|
"- chmod changes permissions\n"
|
|
"- chown changes ownership\n"
|
|
"- rwx permissions apply to:\n"
|
|
" user / group / others\n\n"
|
|
"Permission values:\n"
|
|
" r = 4\n"
|
|
" w = 2\n"
|
|
" x = 1\n\n"
|
|
"Common octal permissions:\n"
|
|
" 644 = rw-r--r--\n"
|
|
" 755 = rwxr-xr-x\n"
|
|
" 600 = rw-------\n"
|
|
" 700 = rwx------\n\n"
|
|
"Hands-on tasks:\n\n"
|
|
"1. Create a practice directory:\n"
|
|
" mkdir ~/linuxplus-permissions\n\n"
|
|
"2. Enter it:\n"
|
|
" cd ~/linuxplus-permissions\n\n"
|
|
"3. Create a file:\n"
|
|
" touch testfile\n\n"
|
|
"4. View permissions:\n"
|
|
" ls -l\n\n"
|
|
"5. Change permissions to 644:\n"
|
|
" chmod 644 testfile\n"
|
|
" ls -l\n\n"
|
|
"6. Change permissions to 755:\n"
|
|
" chmod 755 testfile\n"
|
|
" ls -l\n\n"
|
|
"7. Use symbolic mode:\n"
|
|
" chmod u+x testfile\n"
|
|
" chmod g-w testfile\n"
|
|
" ls -l\n\n"
|
|
"8. View ownership:\n"
|
|
" ls -l\n\n"
|
|
"9. Change ownership (requires sudo):\n"
|
|
" sudo chown root:root testfile\n"
|
|
" ls -l\n\n"
|
|
"10. Return ownership to yourself:\n"
|
|
" sudo chown $USER:$USER testfile\n"
|
|
" ls -l\n\n"
|
|
"Linux+ exam traps:\n"
|
|
"- chmod changes permissions, NOT ownership\n"
|
|
"- chown changes ownership\n"
|
|
"- x on directories means traversal\n"
|
|
"- 755 is common for executable files/directories\n"
|
|
"- 644 is common for regular files\n\n"
|
|
"When finished, run:\n"
|
|
" M-x file-permissions-quiz\n")
|
|
(goto-char (point-min))
|
|
(view-mode 1)
|
|
(split-window-below)
|
|
(other-window 1)
|
|
(let ((term (get-buffer "*term*")))
|
|
(if (buffer-live-p term)
|
|
(switch-to-buffer term)
|
|
(ansi-term shell "term")))
|
|
(other-window -1)))
|
|
|
|
;;; 60-file-permissions-lesson.el ends here
|