├── images ├── Readme.md ├── BIOS.PNG ├── Link.PNG ├── VIM.PNG ├── apt.PNG ├── auth.PNG ├── copy.PNG ├── disk.PNG ├── dns.PNG ├── dpkg.PNG ├── edit.PNG ├── egp.PNG ├── fs.PNG ├── grep.PNG ├── io.PNG ├── jlog.PNG ├── key.PNG ├── list.PNG ├── lvm.PNG ├── lvm2.PNG ├── net.PNG ├── pci.PNG ├── perm.PNG ├── pipe.PNG ├── root.PNG ├── rpm.PNG ├── scp.PNG ├── site.PNG ├── stop.PNG ├── sudo.PNG ├── tee.PNG ├── type.PNG ├── unit.PNG ├── user.PNG ├── vi.PNG ├── who.PNG ├── yum.PNG ├── Shell.PNG ├── active.PNG ├── enable.PNG ├── filep.PNG ├── fstab.PNG ├── grep1.PNG ├── grep2.PNG ├── group.PNG ├── insert.PNG ├── iplink.PNG ├── linux.PNG ├── manage.PNG ├── passwd.PNG ├── pless.PNG ├── record.PNG ├── reload.PNG ├── shadow.PNG ├── start.PNG ├── status.png ├── switch.PNG ├── Install.PNG ├── Service.PNG ├── bash-auto.PNG ├── command1.PNG ├── command2.PNG ├── command3.PNG ├── croncmd.png ├── deb-rpm.PNG ├── default.PNG ├── disable.PNG ├── dpkg-fail.PNG ├── lastline.PNG ├── library.PNG ├── package.PNG ├── partition.PNG ├── pkg-mgr.PNG ├── reloadsvc.PNG ├── restart.PNG ├── routing.PNG ├── rpm-modes.PNG ├── runlevel.PNG ├── systemctl.png ├── useradd.PNG ├── yum-cmd.PNG ├── yum-cmd1.PNG ├── yum-repo.PNG ├── bash-auto1.PNG ├── bash-prompt.PNG ├── boot-loader.PNG ├── cronformat.png ├── cronspchar.png ├── dpkg-modes.PNG ├── file-types.PNG ├── file-types1.PNG ├── file-types2.PNG ├── filesystem.PNG ├── journalctl.png ├── locate-find.PNG ├── otherstate.PNG ├── pushd_popd.PNG ├── rhel-centos.PNG ├── run-levels.PNG ├── run-levels1.PNG ├── run-levels2.PNG ├── user-space.PNG ├── user-space1.PNG ├── yum-update.PNG ├── Command-Types.PNG ├── apt-vs-apt-get.PNG ├── bash-prompt1.PNG ├── bash-prompt2.PNG ├── bash-prompt3.PNG ├── block-device.PNG ├── boot-sequence.PNG ├── compress-cat.PNG ├── cronspclstring.png ├── linux-kernel.PNG ├── package-errors.PNG ├── types-of-pkg.PNG ├── apt-vs-apt-get1.PNG ├── functions-of-pkg.PNG ├── kernel-versions.PNG ├── package-managers.PNG ├── The_Home_Directory.JPG ├── compress-uncompress.PNG ├── kernel-initialize.PNG ├── memory-management.PNG ├── Command-and-Arguments.PNG ├── before_after_commands.PNG ├── working-with-hardware.PNG ├── mkdir_cd_working_with_shell_I.PNG └── Absolute_and_relative_path_working_with_shell_I.PNG ├── docs ├── 10-The-Client-Demonstration │ ├── 03-Finale(story).md │ ├── 01-Client-Demonstration-in-Jeopardy!(story).md │ └── 02-Troubleshoot-the-Development-Environment.md ├── 08-Storage-in-Linux │ ├── 01-Where's-my-Storage.md │ ├── 06-Project-Status-Meeting.md │ ├── 04-DAS-NAS-and-SAN.md │ ├── 03-File-System-in-Linux.md │ ├── 02-Storage-Basics.md │ └── 05-LVM.md ├── 03-Linux-Core-Concepts │ ├── 01-Bobs-first-team-meeting.md │ ├── 04-Lab-Linux-Kernel.md │ ├── 08-Filesystem-Hierarchy.md │ ├── 09-Lab-Linux-RunLevels-Filesystem-Hierarchy.md │ ├── 07-File-Types.md │ ├── 06-Run-Levels.md │ ├── 02-The-Linux-Kernel.md │ ├── 03-Working-with-hardware.md │ └── 05-Linux-Boot-Sequence.md ├── 07-Networking │ ├── 01-The-Network-Issue(story).md │ ├── 03-Networking-Basics.md │ ├── 04-Troubleshooting.md │ └── 02-DNS.md ├── 05-Working-With-Shell-Part-II │ ├── 01-Behind-Schedule(story).md │ ├── 07-Lab-VI-Editor.md │ ├── 05-Lab-Working-With-Shell-Part-II.md │ ├── 06-Vi-Editor.md │ ├── 04-IO-Redirection.md │ ├── 03-Searching-for-files-and-patterns.md │ └── 02-File-Compression-and-Archival.md ├── 06-Security-and-File-Permissions │ ├── 01-The-Security-Incident(story).md │ ├── 08-Cronjob.md │ ├── 04-Access-Control-Files.md │ ├── 03-User-Management.md │ ├── 06-SSH-and-SCP.md │ ├── 05-File-Permissions.md │ ├── 02-Linux-Accounts.md │ └── 07-IPtables.md ├── 09-Service-management-with-SYSTEMD │ ├── 01-Working-Overtime-Story.md │ ├── 02-Creating-a-SYSTEMD-Service.md │ └── 03-SYSTEMD-Tools.md ├── 01-Introduction │ └── 01-Introduction.md ├── 04-Package-Mangement │ ├── 06-Lab-DPKG-AND-APT.md │ ├── 03-Lab-RPM-and-YUM.md │ ├── 05-APT-vs-APT-GET.md │ ├── 04-DPKG-AND-APT.md │ ├── 01-Package-Management-Distribution.md │ └── 02-RPM-and-YUM.md └── 02-Working-With-Shell-Part-I │ ├── 03-Command-Line-Help.md │ ├── 06-Lab-Linux-Bash-Shell.md │ ├── 04-lab-working-with-shell.md │ ├── 05-Bash-Shell.md │ ├── 01-Introduction-to-Shell.md │ └── 02-Basic-Commands.md └── README.md /images/Readme.md: -------------------------------------------------------------------------------- 1 | Images 2 | -------------------------------------------------------------------------------- /images/BIOS.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/BIOS.PNG -------------------------------------------------------------------------------- /images/Link.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/Link.PNG -------------------------------------------------------------------------------- /images/VIM.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/VIM.PNG -------------------------------------------------------------------------------- /images/apt.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/apt.PNG -------------------------------------------------------------------------------- /images/auth.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/auth.PNG -------------------------------------------------------------------------------- /images/copy.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/copy.PNG -------------------------------------------------------------------------------- /images/disk.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/disk.PNG -------------------------------------------------------------------------------- /images/dns.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/dns.PNG -------------------------------------------------------------------------------- /images/dpkg.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/dpkg.PNG -------------------------------------------------------------------------------- /images/edit.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/edit.PNG -------------------------------------------------------------------------------- /images/egp.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/egp.PNG -------------------------------------------------------------------------------- /images/fs.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/fs.PNG -------------------------------------------------------------------------------- /images/grep.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/grep.PNG -------------------------------------------------------------------------------- /images/io.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/io.PNG -------------------------------------------------------------------------------- /images/jlog.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/jlog.PNG -------------------------------------------------------------------------------- /images/key.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/key.PNG -------------------------------------------------------------------------------- /images/list.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/list.PNG -------------------------------------------------------------------------------- /images/lvm.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/lvm.PNG -------------------------------------------------------------------------------- /images/lvm2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/lvm2.PNG -------------------------------------------------------------------------------- /images/net.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/net.PNG -------------------------------------------------------------------------------- /images/pci.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/pci.PNG -------------------------------------------------------------------------------- /images/perm.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/perm.PNG -------------------------------------------------------------------------------- /images/pipe.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/pipe.PNG -------------------------------------------------------------------------------- /images/root.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/root.PNG -------------------------------------------------------------------------------- /images/rpm.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/rpm.PNG -------------------------------------------------------------------------------- /images/scp.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/scp.PNG -------------------------------------------------------------------------------- /images/site.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/site.PNG -------------------------------------------------------------------------------- /images/stop.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/stop.PNG -------------------------------------------------------------------------------- /images/sudo.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/sudo.PNG -------------------------------------------------------------------------------- /images/tee.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/tee.PNG -------------------------------------------------------------------------------- /images/type.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/type.PNG -------------------------------------------------------------------------------- /images/unit.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/unit.PNG -------------------------------------------------------------------------------- /images/user.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/user.PNG -------------------------------------------------------------------------------- /images/vi.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/vi.PNG -------------------------------------------------------------------------------- /images/who.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/who.PNG -------------------------------------------------------------------------------- /images/yum.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/yum.PNG -------------------------------------------------------------------------------- /images/Shell.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/Shell.PNG -------------------------------------------------------------------------------- /images/active.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/active.PNG -------------------------------------------------------------------------------- /images/enable.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/enable.PNG -------------------------------------------------------------------------------- /images/filep.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/filep.PNG -------------------------------------------------------------------------------- /images/fstab.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/fstab.PNG -------------------------------------------------------------------------------- /images/grep1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/grep1.PNG -------------------------------------------------------------------------------- /images/grep2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/grep2.PNG -------------------------------------------------------------------------------- /images/group.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/group.PNG -------------------------------------------------------------------------------- /images/insert.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/insert.PNG -------------------------------------------------------------------------------- /images/iplink.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/iplink.PNG -------------------------------------------------------------------------------- /images/linux.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/linux.PNG -------------------------------------------------------------------------------- /images/manage.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/manage.PNG -------------------------------------------------------------------------------- /images/passwd.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/passwd.PNG -------------------------------------------------------------------------------- /images/pless.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/pless.PNG -------------------------------------------------------------------------------- /images/record.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/record.PNG -------------------------------------------------------------------------------- /images/reload.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/reload.PNG -------------------------------------------------------------------------------- /images/shadow.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/shadow.PNG -------------------------------------------------------------------------------- /images/start.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/start.PNG -------------------------------------------------------------------------------- /images/status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/status.png -------------------------------------------------------------------------------- /images/switch.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/switch.PNG -------------------------------------------------------------------------------- /images/Install.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/Install.PNG -------------------------------------------------------------------------------- /images/Service.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/Service.PNG -------------------------------------------------------------------------------- /images/bash-auto.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/bash-auto.PNG -------------------------------------------------------------------------------- /images/command1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/command1.PNG -------------------------------------------------------------------------------- /images/command2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/command2.PNG -------------------------------------------------------------------------------- /images/command3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/command3.PNG -------------------------------------------------------------------------------- /images/croncmd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/croncmd.png -------------------------------------------------------------------------------- /images/deb-rpm.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/deb-rpm.PNG -------------------------------------------------------------------------------- /images/default.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/default.PNG -------------------------------------------------------------------------------- /images/disable.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/disable.PNG -------------------------------------------------------------------------------- /images/dpkg-fail.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/dpkg-fail.PNG -------------------------------------------------------------------------------- /images/lastline.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/lastline.PNG -------------------------------------------------------------------------------- /images/library.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/library.PNG -------------------------------------------------------------------------------- /images/package.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/package.PNG -------------------------------------------------------------------------------- /images/partition.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/partition.PNG -------------------------------------------------------------------------------- /images/pkg-mgr.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/pkg-mgr.PNG -------------------------------------------------------------------------------- /images/reloadsvc.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/reloadsvc.PNG -------------------------------------------------------------------------------- /images/restart.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/restart.PNG -------------------------------------------------------------------------------- /images/routing.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/routing.PNG -------------------------------------------------------------------------------- /images/rpm-modes.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/rpm-modes.PNG -------------------------------------------------------------------------------- /images/runlevel.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/runlevel.PNG -------------------------------------------------------------------------------- /images/systemctl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/systemctl.png -------------------------------------------------------------------------------- /images/useradd.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/useradd.PNG -------------------------------------------------------------------------------- /images/yum-cmd.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/yum-cmd.PNG -------------------------------------------------------------------------------- /images/yum-cmd1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/yum-cmd1.PNG -------------------------------------------------------------------------------- /images/yum-repo.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/yum-repo.PNG -------------------------------------------------------------------------------- /images/bash-auto1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/bash-auto1.PNG -------------------------------------------------------------------------------- /images/bash-prompt.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/bash-prompt.PNG -------------------------------------------------------------------------------- /images/boot-loader.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/boot-loader.PNG -------------------------------------------------------------------------------- /images/cronformat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/cronformat.png -------------------------------------------------------------------------------- /images/cronspchar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/cronspchar.png -------------------------------------------------------------------------------- /images/dpkg-modes.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/dpkg-modes.PNG -------------------------------------------------------------------------------- /images/file-types.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/file-types.PNG -------------------------------------------------------------------------------- /images/file-types1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/file-types1.PNG -------------------------------------------------------------------------------- /images/file-types2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/file-types2.PNG -------------------------------------------------------------------------------- /images/filesystem.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/filesystem.PNG -------------------------------------------------------------------------------- /images/journalctl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/journalctl.png -------------------------------------------------------------------------------- /images/locate-find.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/locate-find.PNG -------------------------------------------------------------------------------- /images/otherstate.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/otherstate.PNG -------------------------------------------------------------------------------- /images/pushd_popd.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/pushd_popd.PNG -------------------------------------------------------------------------------- /images/rhel-centos.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/rhel-centos.PNG -------------------------------------------------------------------------------- /images/run-levels.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/run-levels.PNG -------------------------------------------------------------------------------- /images/run-levels1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/run-levels1.PNG -------------------------------------------------------------------------------- /images/run-levels2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/run-levels2.PNG -------------------------------------------------------------------------------- /images/user-space.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/user-space.PNG -------------------------------------------------------------------------------- /images/user-space1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/user-space1.PNG -------------------------------------------------------------------------------- /images/yum-update.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/yum-update.PNG -------------------------------------------------------------------------------- /images/Command-Types.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/Command-Types.PNG -------------------------------------------------------------------------------- /images/apt-vs-apt-get.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/apt-vs-apt-get.PNG -------------------------------------------------------------------------------- /images/bash-prompt1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/bash-prompt1.PNG -------------------------------------------------------------------------------- /images/bash-prompt2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/bash-prompt2.PNG -------------------------------------------------------------------------------- /images/bash-prompt3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/bash-prompt3.PNG -------------------------------------------------------------------------------- /images/block-device.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/block-device.PNG -------------------------------------------------------------------------------- /images/boot-sequence.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/boot-sequence.PNG -------------------------------------------------------------------------------- /images/compress-cat.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/compress-cat.PNG -------------------------------------------------------------------------------- /images/cronspclstring.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/cronspclstring.png -------------------------------------------------------------------------------- /images/linux-kernel.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/linux-kernel.PNG -------------------------------------------------------------------------------- /images/package-errors.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/package-errors.PNG -------------------------------------------------------------------------------- /images/types-of-pkg.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/types-of-pkg.PNG -------------------------------------------------------------------------------- /images/apt-vs-apt-get1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/apt-vs-apt-get1.PNG -------------------------------------------------------------------------------- /images/functions-of-pkg.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/functions-of-pkg.PNG -------------------------------------------------------------------------------- /images/kernel-versions.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/kernel-versions.PNG -------------------------------------------------------------------------------- /images/package-managers.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/package-managers.PNG -------------------------------------------------------------------------------- /images/The_Home_Directory.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/The_Home_Directory.JPG -------------------------------------------------------------------------------- /images/compress-uncompress.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/compress-uncompress.PNG -------------------------------------------------------------------------------- /images/kernel-initialize.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/kernel-initialize.PNG -------------------------------------------------------------------------------- /images/memory-management.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/memory-management.PNG -------------------------------------------------------------------------------- /images/Command-and-Arguments.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/Command-and-Arguments.PNG -------------------------------------------------------------------------------- /images/before_after_commands.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/before_after_commands.PNG -------------------------------------------------------------------------------- /images/working-with-hardware.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/working-with-hardware.PNG -------------------------------------------------------------------------------- /docs/10-The-Client-Demonstration/03-Finale(story).md: -------------------------------------------------------------------------------- 1 | # Finale (story) 2 | 3 | - Lets Hear the Finale [Story](https://kodekloud.com/topic/finale/) -------------------------------------------------------------------------------- /images/mkdir_cd_working_with_shell_I.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/mkdir_cd_working_with_shell_I.PNG -------------------------------------------------------------------------------- /docs/08-Storage-in-Linux/01-Where's-my-Storage.md: -------------------------------------------------------------------------------- 1 | # Where's my Storage 2 | 3 | - Lets hear the [Story](https://kodekloud.com/topic/where-is-my-storage/) 4 | -------------------------------------------------------------------------------- /docs/08-Storage-in-Linux/06-Project-Status-Meeting.md: -------------------------------------------------------------------------------- 1 | # Project Status Meeting 2 | 3 | - Join the [Meeting](https://kodekloud.com/topic/project-status-meeting-story/) -------------------------------------------------------------------------------- /docs/03-Linux-Core-Concepts/01-Bobs-first-team-meeting.md: -------------------------------------------------------------------------------- 1 | Welcome Bob. 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/bobs-first-team-meeting/) 4 | -------------------------------------------------------------------------------- /docs/07-Networking/01-The-Network-Issue(story).md: -------------------------------------------------------------------------------- 1 | # The Networking Story 2 | 3 | - Click [here](https://kodekloud.com/topic/the-network-issue/) to know The Networking Story. -------------------------------------------------------------------------------- /docs/05-Working-With-Shell-Part-II/01-Behind-Schedule(story).md: -------------------------------------------------------------------------------- 1 | # Behind Schedule (Story) 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/behind-schedule/) 4 | -------------------------------------------------------------------------------- /docs/06-Security-and-File-Permissions/01-The-Security-Incident(story).md: -------------------------------------------------------------------------------- 1 | # Security Incident (story) 2 | 3 | - Take me to the[Story](https://kodekloud.com/topic/security-incident/) -------------------------------------------------------------------------------- /docs/09-Service-management-with-SYSTEMD/01-Working-Overtime-Story.md: -------------------------------------------------------------------------------- 1 | # Working Overtime 2 | 3 | - Lets hear the [Story](https://kodekloud.com/topic/working-overtime/) 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /images/Absolute_and_relative_path_working_with_shell_I.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/linux-basics-course/HEAD/images/Absolute_and_relative_path_working_with_shell_I.PNG -------------------------------------------------------------------------------- /docs/10-The-Client-Demonstration/01-Client-Demonstration-in-Jeopardy!(story).md: -------------------------------------------------------------------------------- 1 | # Client Demonstration in Jeopardy! 2 | 3 | - Let's hear the [Story](https://kodekloud.com/topic/client-demonstration-in-jeopardy-story/) -------------------------------------------------------------------------------- /docs/01-Introduction/01-Introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | ### Course Introduction 4 | 5 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/course-introduction-3/) 6 | 7 | ### WAR (Story) 8 | 9 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/war-story/) 10 | 11 | ### Bob's First Day at Work 12 | 13 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/bobs-first-day-at-work/) 14 | 15 | ### Lab Introduction 16 | 17 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/lab-introduction-2/) 18 | -------------------------------------------------------------------------------- /docs/04-Package-Mangement/06-Lab-DPKG-AND-APT.md: -------------------------------------------------------------------------------- 1 | # Lab - DPKG and APT 2 | 3 | - Access Hands-On Labs here [Hands-On Labs](https://kodekloud.com/topic/lab-dpkg-and-apt-2/) 4 | 5 | Package managers that you use on a debian based distro 6 | ``` 7 | Debain distros use dpkg. 8 | ``` 9 | 10 | To install a package for **`firefox`** browser which has been downloaded at /root/firefox.deb. The dependencies might fail. 11 | ``` 12 | $ sudo dpkg -i /root/firefox.deb 13 | ``` 14 | 15 | To install a package using **`APT`** 16 | ``` 17 | $ sudo apt install firefox 18 | ``` 19 | 20 | Lets now locate the package to install Chromium browser in the system. Use **`apt search`** functionality to locate the correct package name. The browser has the description of: Chromium web browser, open-source version of Chrome 21 | ``` 22 | $ sudo apt search chromium-browser 23 | ``` 24 | 25 | To install the **`chromium-browser`** 26 | ``` 27 | sudo apt install -y chromium-browser 28 | ``` 29 | 30 | To remove the **`firefox`** browser from the system. 31 | ``` 32 | $ sudo apt remove firefox 33 | ``` 34 | -------------------------------------------------------------------------------- /docs/04-Package-Mangement/03-Lab-RPM-and-YUM.md: -------------------------------------------------------------------------------- 1 | # Lab - RPM and YUM 2 | 3 | - Access Hands-On Labs here [Hands-On Labs](https://kodekloud.com/topic/lab-yum-and-rpm/) 4 | 5 | Which package managers would you use on centos machine 6 | ``` 7 | Centos makes use of RPM and YUM 8 | ``` 9 | 10 | Use an **`rpm`** command and find out the exact package name for **`wget`** installed in this server 11 | ``` 12 | $ rpm -qa |grep wget 13 | ``` 14 | 15 | To install a package for **`firefox`** browser that has been downloaded under **`/home/bob`** in the system. Caution: It might fail due to failed dependencies 16 | ``` 17 | $ sudo rpm -ivh /home/bob/firefox-68.6.0-1.el7.centos.x86_64.rpm 18 | ``` 19 | 20 | To install a package for **`firefox`** browser along with its dependencies 21 | ``` 22 | $ sudo yum install firefox -y 23 | ``` 24 | 25 | To check how many software repositories are configured for YUM in the system 26 | ``` 27 | $ sudo yum repolist 28 | ``` 29 | 30 | To check which package provides **`tcpdump`** command 31 | ``` 32 | $ sudo yum provides tcpdump 33 | ``` 34 | 35 | 36 | -------------------------------------------------------------------------------- /docs/05-Working-With-Shell-Part-II/07-Lab-VI-Editor.md: -------------------------------------------------------------------------------- 1 | # Lab - VI Editor 2 | 3 | - Access Hands-On Labs here [Hands-On Labs](https://kodekloud.com/topic/lab-vi-editor-3/) 4 | 5 | Go to **`insert mode`** 6 | ``` 7 | Press i 8 | ``` 9 | 10 | Exit from **`insert mode`** and go to **`command mode`** 11 | ``` 12 | Press ESC 13 | ``` 14 | 15 | To **`remove`** a character 16 | ``` 17 | Move Cursor to the characters to be removed and press x to remove them 18 | ``` 19 | 20 | Change the file contents to **`Welcome to KodeKloud`** and **`save`** file. 21 | ``` 22 | Go to insert mode by pressing i and delete all content and type in new content. Once done press ESC key and go to command mode. Then type in command :w! 23 | ``` 24 | 25 | Update the port it listens on from **`80`** to **`5000`** in apache webserver. 26 | ``` 27 | Go to insert mode by pressing i and replace 80 with 5000 in line 10 28 | ``` 29 | 30 | Remove the line that starts with **`LogFormat`**. 31 | ``` 32 | Go to the line 33 and press dd (d twice) to remove the entire line. 33 | ``` 34 | 35 | To undo the previous change 36 | ``` 37 | Press u to undo previous change 38 | ``` 39 | 40 | There's a 6 hiding in the file. Find it. 41 | ``` 42 | find command /6 43 | ``` 44 | 45 | -------------------------------------------------------------------------------- /docs/03-Linux-Core-Concepts/04-Lab-Linux-Kernel.md: -------------------------------------------------------------------------------- 1 | # Lab - Linux Kernel 2 | 3 | - Access Hands-On Labs here [Hands-On Labs](https://kodekloud.com/topic/lab-linux-kernel-lsmod-insmod-modprobe-uname/) 4 | 5 | To check the exact kernel version that is running in this system. 6 | ``` 7 | $ uname -r 8 | ``` 9 | 10 | what is the kernel version in 4.15.0-88-generic? 11 | ``` 12 | Look for the first digit. In this case, it is 4 13 | ``` 14 | 15 | What is the major version number of the kernel 4.15.0-88-generic 16 | ``` 17 | Look for the second digit after the kernel version separated by a . In this case, it is 15 18 | ``` 19 | 20 | Which command would you run to print the messages generated by the kernel? 21 | ``` 22 | Type the command dmesg to see the messages. 23 | $ dmesg 24 | ``` 25 | 26 | To list/count all block devices of type disk that are present in the system 27 | ``` 28 | Run: lsblk and count the number of disk devices. 29 | $ lsblk 30 | ``` 31 | 32 | To check total number of **`physical cores`** in the system. 33 | ``` 34 | Run lscpu and multiply the Core(s) per socket with the number of Socket(s): 35 | $ lscpu 36 | ``` 37 | 38 | To check total online memory 39 | ``` 40 | Run the lsmem command and look for the value of online memory 41 | $ lsmem 42 | ``` 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /docs/06-Security-and-File-Permissions/08-Cronjob.md: -------------------------------------------------------------------------------- 1 | # Cronjob in Linux 2 | 3 | - Take me to the [Tutorial](https://kodekloud.com/courses/873064/lectures/24032686) 4 | - In this lecture we will learn about **Cronjobs** in Linux . 5 | 6 | 7 | The basic usage of **cron** is to execute a job in a specific time. The **`crontab`** is a list of commands that you want to run on a regular schedule, and also the name of the command used to manage that list. **Crontab** stands for **`cron table`** because it uses the job scheduler cron to execute tasks. The schedule is called the crontab, which is also the name of the program used to edit that schedule. 8 | 9 | ## Linux Crontab Format 10 | 11 | ![format](../../images//cronformat.png) 12 | 13 | ### Expressions used and Description 14 | 15 | ![specialstring](../../images//cronspclstring.png) 16 | 17 | ![specialcharacter](../../images//cronspchar.png) 18 | 19 | #### Crontab commands 20 | 21 | 22 | ![command](../../images//croncmd.png) 23 | 24 | 25 | ##### Crontab Examples 26 | 27 | */30 * * * * Every 30 mins 28 | 29 | 0 * * * * Every hour 30 | 31 | 0 0 * * 0 At midnight of every Sunday 32 | 33 | 0 0 0 15 * * Every 15th of month (monthly) 34 | 35 | 0 0 0 1 1 * Every 1st of january (yearly) 36 | 37 | @reboot Every reboot 38 | -------------------------------------------------------------------------------- /docs/04-Package-Mangement/05-APT-vs-APT-GET.md: -------------------------------------------------------------------------------- 1 | # APT vs APT-GET 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/apt-vs-apt-get/) 4 | 5 | #### Difference between APT vs APT-GET 6 | - APT is a more user friendly tool when compared to APT-GET 7 | - In all the latest debian based distros APT is already installed by default. 8 | 9 | #### Lets take a look why **`APT`** is better when compare to **`APT-GET`** 10 | 11 | Lets try to install **`firefox`** package using both APT and APT-GET 12 | - You will notice APT does easy on the eyes, you get just enough information and also a nice little progress bar 13 | - APT-GET is just effective and doesn't provide the output in user-friendly format. 14 | 15 | ![apt-vs-apt-get](../../images/apt-vs-apt-get.PNG) 16 | 17 | Lets try another comparision by search a **`telent`** package. 18 | - You will notice with apt, all its options are located in one place. You can search with **`apt search telnet`** command. 19 | - On the other hand, you cannot use search command with **`apt-get`** command. Instead, you have to use another tool called **`apt-cache search telnet`**. 20 | - If you compare the results of the two commands, you will also see the **`apt-cache`** throws in a lot of extra information in the search result, which may not be really useful for the end user. 21 | 22 | ![apt-vs-apt-get1](../../images/apt-vs-apt-get1.PNG) 23 | 24 | -------------------------------------------------------------------------------- /docs/02-Working-With-Shell-Part-I/03-Command-Line-Help.md: -------------------------------------------------------------------------------- 1 | # Using command line to get help 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/command-line-help-3/) 4 | 5 | In this section we will learn how to use **`help`** command to get help in command line 6 | - If you are new to using `linux` or `bash shell` or if you are not sure which command does what, there are few commands in bash that can help get started. 7 | - Lets take a look of those 8 | 9 | First command is **`whatis`** , this command will displays a one line description of a command does. 10 | 11 | **`Syntax: whatis `** 12 | 13 | ``` 14 | $ whatis date 15 | ``` 16 | 17 | Most of the commands internal or external come bundled with **`man pages`** which provides information about the command in detail (with examples, usecases and with command options) 18 | 19 | **`Syntax: man `** 20 | 21 | ``` 22 | $ man date 23 | ``` 24 | 25 | Several commands will provide **`-h`** or **`--help`** to provide users with the options and usecases available in a command 26 | 27 | ``` 28 | $ date -h 29 | $ date --help 30 | ``` 31 | 32 | To search through the man page names and descriptions for instances of the keyword use **`apropos`**. This is useful if you want to look for all commands within the system that contains the specifc keyword. 33 | 34 | **`Syntax: apropos `** 35 | ``` 36 | $ apropos modpr 37 | ``` 38 | -------------------------------------------------------------------------------- /docs/02-Working-With-Shell-Part-I/06-Lab-Linux-Bash-Shell.md: -------------------------------------------------------------------------------- 1 | # Lab - Linux Bash Shell 2 | 3 | - Access Hands-On Labs here [Hands-On Labs](https://kodekloud.com/topic/lab-linux-bash-prompt/) 4 | 5 | 1. To check the default shell for the current user. Display the shell for the current user but not necessarily the shell that is running at the movement. 6 | ``` 7 | $ echo $SHELL 8 | ``` 9 | 2. To change the shell for bob from **`Bash`** to **`Bourne Shell`** 10 | ``` 11 | $ chsh -s /bin/sh bob 12 | ``` 13 | 3. What is the value of the environment variable **`TERM`** 14 | ``` 15 | echo $TERM 16 | ``` 17 | 4. Create a new environment variable called **`PROJECT=MERCURY`** and make it persistent by adding the variable to the **`~/.profile`** file. 18 | ``` 19 | echo export PROJECT=MERCURY >> ~/.profile 20 | ``` 21 | 5. Which of the following directories is not part of the PATH variable? 22 | ``` 23 | /opt/caleston-code 24 | ``` 25 | 6. Set an alias called **`up`** for the command **`uptime`** and make it persistent by adding to **`~/.profile`** file. 26 | ``` 27 | echo alias up=uptime >> ~/.profile 28 | ``` 29 | 7. Update Bob's prompt so that it displays the date as per the format below: 30 | Example: **`[Wed Apr 22]bob@caleston-lp10:~$`** 31 | Make sure the change is made persistent. 32 | ``` 33 | PS1='[\d]\u@\h:\w\$' 34 | or 35 | echo 'PS1=[\d]\u@\h:\w$' >> ~/.profile 36 | ``` -------------------------------------------------------------------------------- /docs/08-Storage-in-Linux/04-DAS-NAS-and-SAN.md: -------------------------------------------------------------------------------- 1 | # DAS NAS AND SAN 2 | 3 | - Take me to the [Tutorial](https://kodekloud.com/topic/das-nas-and-san/) 4 | 5 | - Now that you are familiar with basic of storage in Linux lets learn about external storage. 6 | 7 | - DAS - Direct Attached Storage, external storage is attached directly to the host system tha requires the space. 8 | - NAS - Network Attached Storage quite similar to NFS server. 9 | - SAN - Storage Aread Network, this technology uses a fiber channel for providing high-speed storage. 10 | 11 | #### NFS 12 | 13 | - NFS - Does not store data in blocks. Instead, it saves data in form of files. It works on service-client model. 14 | 15 | - NFS server maintains an export configuration file at **`/etc/exports`** that defines the clients which should be able to 16 | access the directories on the server. **`/etc/exports`** looks like this 17 | 18 | ``` 19 | [~]$ /etc/exports 20 | /software/repos 10.61.35.201 10.61.35.202 10.61.35.203 21 | ``` 22 | 23 | - To exports all the mounts defined in **`/etc/exports`** use 24 | 25 | ``` 26 | [~]$ exportfs -a 27 | ``` 28 | 29 | - To manually export a directory use below command 30 | 31 | ``` 32 | [~]$ exportfs -o 10.61.35.201:/software/repos 33 | ``` 34 | 35 | # HANDS-ON LABS 36 | 37 | - Lets had over to the [NFS LABS](https://kodekloud.com/courses/873064/lectures/17311763) 38 | -------------------------------------------------------------------------------- /docs/06-Security-and-File-Permissions/04-Access-Control-Files.md: -------------------------------------------------------------------------------- 1 | # ACCESS CONTROL FILES 2 | 3 | - Take me to the [Tutorial](https://kodekloud.com/topic/access-control-files/) 4 | 5 | - Access Ccontrol files are stored under **`/etc`**. 6 | - Can be read by anyone and can be only edited by **`root`** user. 7 | 8 | 9 | ### Control files 10 | 11 | - To get more details about one's account for example **`bob`** account, home director, uid, and shell check **`/etc/passwd`** 12 | 13 | ``` 14 | [~]$ grep -i ^bob /etc/passwd 15 | bob:x:1002:1002::/home/bob:/bin/sh 16 | USERNAME:PASSWORD:UID:GID:GECOS:HOMEDIR:SHELL 17 | ``` 18 | 19 | ![passwd](../../images//passwd.PNG) 20 | 21 | - Password are stored under **`/etc/shadow`** 22 | 23 | ``` 24 | [~]$ grep -i ^bob /etc/shadow 25 | bob:$6$0h0utOtO$5JcuRxR7y72LLQk4Kdog7u09LsNFS0yZPkIC8pV9tgD0wXCHutY 26 | cWF/7.eJ3TfGfG0lj4JF63PyuPwKC18tJS.:18188:0:99999:7::: 27 | 28 | USERNAME:PASSWORD:LASTCHANGE:MINAGE:MAXAGE:WARN:INACTIVE:EXPDATE 29 | ``` 30 | 31 | ![shadow](../../images//shadow.PNG) 32 | 33 | - Check the groups **`bob`** belongs too 34 | 35 | ``` 36 | [~]$ grep -i ^bob /etc/group 37 | NAME:PASSWORD:GID:MEMBERS 38 | ``` 39 | 40 | ![egp](../../images//egp.PNG) 41 | 42 | # HANDS-ON LABS 43 | 44 | - Lets start with Managing and User Accounts [here](https://kodekloud.com/courses/the-linux-basics-course/lectures/17074503) -------------------------------------------------------------------------------- /docs/02-Working-With-Shell-Part-I/04-lab-working-with-shell.md: -------------------------------------------------------------------------------- 1 | # Lab - Working with shell 2 | 3 | - Access Hands-On Labs here [Hands-On-Labs](https://kodekloud.com/topic/lab-working-with-the-shell/) 4 | 5 | 1. To check the home directory for a particular user say **`bob`** 6 | ``` 7 | $ grep bob /etc/passwd | cut -d ":" -f6 8 | ``` 9 | 1. To check the home directory for a particular user using built in shell variables 10 | ``` 11 | $ echo $HOME 12 | ``` 13 | 1. In the command **`echo Welcome`**, what does the word Welcome represent with respect to the command? 14 | ``` 15 | $ echo Welcome 16 | - Where Welcome is an argument 17 | ``` 18 | 19 | 1. To check **`git`** command type 20 | ``` 21 | $ type git 22 | ``` 23 | 1. To create a directory 24 | ``` 25 | $ mkdir /home/bob/birds 26 | ``` 27 | 1. To create directories recursively 28 | ``` 29 | $ mkdir -p /home/bob/fish/salmon 30 | ``` 31 | 1. Create few more directories 32 | ``` 33 | $ mkdir -p /home/bob/mammals/elephant 34 | $ mkdir -p /home/bob/mammals/monkey 35 | $ mkdir /home/bob/birds/eagle 36 | $ mkdir -p /home/bob/reptile/snake 37 | $ mkdir -p /home/bob/reptile/frog 38 | $ mkdir -p /home/bob/amphibian/salamander 39 | ``` 40 | 1. To move a directory 41 | ``` 42 | $ mv /home/bob/reptile/frog /home/bob/amphibian 43 | ``` 44 | 1. To rename a directory 45 | ``` 46 | $ mv /home/bob/reptile/snake /home/bob/reptile/crocodile 47 | ``` 48 | 1. To delete a directory 49 | ``` 50 | $ rm -r /home/bob/reptile 51 | ``` 52 | -------------------------------------------------------------------------------- /docs/08-Storage-in-Linux/03-File-System-in-Linux.md: -------------------------------------------------------------------------------- 1 | # File System in Linux 2 | 3 | - Take me to the [Tutorial](https://kodekloud.com/topic/file-systems-in-linux/) 4 | 5 | - In this lecture we will cover the most commonly used file systems from EXT2 to EXT4. 6 | 7 | ![fs](../../images/fs.PNG) 8 | 9 | #### Working with Ext4 10 | 11 | - To create a file system we will make use of **`/dev/sdb`** disk, run below command 12 | 13 | ``` 14 | [~]$ mkfs.ext4 /dev/sdb1 15 | ``` 16 | 17 | - Now create a directory to mount the filesystem use below commands 18 | 19 | ``` 20 | [~]$ mkdir /mnt/ext4; 21 | 22 | [~]$ mount /dev/sdb1 /mnt/ext4 23 | ``` 24 | - To verify if the filesystem is mounted use 25 | 26 | ``` 27 | [~]$ mount | grep /dev/sdb1 28 | 29 | [~]$ df -hP | grep /dev/sdb1 30 | ``` 31 | - Add an entry into **`/etc/fstab`** for the filesystem to be available after reboot. 32 | 33 | ``` 34 | # /etc/fstab: static file system information. 35 | # 36 | # Use 'blkid' to print the universally unique identifier for a 37 | # device; this may be used with UUID= as a more robust way to name devices 38 | # that works even if disks are added and removed. See fstab(5). 39 | # 40 | # 41 | /dev/sda1 / ext4 defaults,relatime,errors=panic 0 1 ~ 42 | ``` 43 | 44 | ``` 45 | echo "/dev/sdb1 /mnt/ext4 ext4 rw 0 0" >> /etc/fstab 46 | ``` 47 | - **`fstab`** file attributes 48 | 49 | ![fstab](../../images/fstab.PNG) 50 | 51 | # HANDS-ON LABS 52 | 53 | - Lets Play around with [FileSystems](https://kodekloud.com/courses/873064/lectures/17074604) -------------------------------------------------------------------------------- /docs/03-Linux-Core-Concepts/08-Filesystem-Hierarchy.md: -------------------------------------------------------------------------------- 1 | # Filesystem Hierarchy 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/filesystem-hierarchy/) 4 | 5 | In this section, lets take a look at the **`filesystem hierarchy`** 6 | - Linux uses single rooted, inverted tree like file system 7 | - **`/home`** : It is the location that contains the home directories for all users, except the **`root`** user (root user home directory is located at **`/root`**) 8 | - **`/opt`** : If you want to install any third party programs put them in the **`/opt`** filesystem. 9 | - **`/mnt`** : It is the default mount point for any partition and it is empty by default. It is used to mount filesystems temporarly in the system 10 | - **`/tmp`** : It is used to store temporary data 11 | - **`/media`** : All external media is mounted on **`/media`** 12 | - **`/dev`** : Contains the special block and character device files 13 | - **`/bin`** : The basic programs such as binaries **`cp`**, **`mv`**, **`mkdir`** are located in the **`/bin`** directory 14 | - **`/etc`** : It stores most of the configuration files in Linux. 15 | - **`/lib`** : The directory **`/lib`** and **`/lib64`** is the place to look for shared libraries to be imported into your program 16 | - **`/usr`** : In older systems, **`/usr`** directory is used for **`User Home Directories`**, however in the modern linux operating systems it is the location where all user land applciations in their data reside 17 | - **`/var`** : It contains variable data like mails, log files 18 | 19 | ![filesystem](../../images/filesystem.PNG) 20 | 21 | To print all the mounted filesystems, run **`df`** (disk filesystem) command 22 | ``` 23 | $ df -hP 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /docs/03-Linux-Core-Concepts/09-Lab-Linux-RunLevels-Filesystem-Hierarchy.md: -------------------------------------------------------------------------------- 1 | # Lab - Linux Runlevels and Filesystem Hierarchy 2 | 3 | - Access Hands-On Labs here [Hands-On Labs](https://kodekloud.com/topic/lab-linux-kernel-modules-boot-and-filetypes/) 4 | 5 | To run commands that need **`sudo`**(super-user) privilages. Run **`sudo`** 6 | ``` 7 | $ sudo ls /root 8 | ``` 9 | 10 | To check the **`init process`** (systemd or sysV) used by the system 11 | ``` 12 | $ sudo ls -l /sbin/init 13 | ``` 14 | 15 | To check **`default systemd target`** (eg. graphical.target or multi-user.target) set in the system 16 | ``` 17 | $ sudo systemctl get-default 18 | ``` 19 | 20 | To change the systemd target to **`multi-user.target`** 21 | ``` 22 | $ sudo systemctl set-default multi-user.target 23 | ``` 24 | 25 | To check what type of file is **`firefox.deb`** which is located at /root 26 | ``` 27 | $ sudo file /root/firefox.deb 28 | ``` 29 | 30 | To check what type of file is **`sample_script.sh`** which is located at /root 31 | ``` 32 | $ sudo file /root/sample_script.sh 33 | ``` 34 | 35 | You were asked to install a new **`third-party IDE`** in the system. Which directory is the recommended choice for the installation? 36 | ``` 37 | Third-party software is usually installed under **`/opt`** 38 | ``` 39 | 40 | Which directory contains the files related to the block devices that can be seen when running the **`lsblk`** command? 41 | ``` 42 | Block Device or Device Node files are located under **`/dev`** directory 43 | ``` 44 | 45 | What is the name of the **`vendor`** for the **`Ethernet Controller`** used in this system? 46 | ``` 47 | Use: sudo lshw and lookup the vendor for Ethernet Controller under the network section. 48 | $ sudo lshw 49 | ``` 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /docs/07-Networking/03-Networking-Basics.md: -------------------------------------------------------------------------------- 1 | # Switching & Routing 2 | 3 | - Take me to the [Tutorial](https://kodekloud.com/topic/networking-basics/) 4 | 5 | #### Switching 6 | 7 | - Switching helps to connect the interface within same network. 8 | 9 | ![switch](../../images//switch.PNG) 10 | 11 | - To see the interfaces on the hosts use **`ip link`** command 12 | 13 | ``` 14 | [~]$ ip link 15 | eth0: mtu 1500 qdisc fq_codel state UP mode 16 | DEFAULT group default qlen 1000 17 | ``` 18 | 19 | - To connect to the switch we use **`ip addr add`** command 20 | 21 | ``` 22 | [~]$ ip addr add 192.168.1.10/24 dev eth0 23 | ``` 24 | 25 | #### Routing 26 | 27 | - Router helps to connect to two seprate networks together. 28 | 29 | ![route](../../images//routing.PNG) 30 | 31 | - To see the existing routing table configuration run the **`route`** command. 32 | 33 | ``` 34 | [~]$ route 35 | Kernel IP routing table 36 | Destination Gateway Genmask Flags Metric Ref Use Iface 37 | ``` 38 | 39 | - To configure a gateway on system B to reach the system on other network run 40 | 41 | ``` 42 | [~]$ ip route add 192.168.2.0/24 via 192.168.1.1 43 | ``` 44 | 45 | ``` 46 | [~]$ route 47 | 48 | Kernel IP routing table 49 | Destination Gateway Genmask Flags Metric Ref Use Iface 50 | 192.168.2.0 192.168.1.1 255.255.255.0 UG 0 0 0 eth0 51 | ``` 52 | 53 | - To see the ip addresses assign to interfaces use 54 | 55 | ``` 56 | [~]$ ip addr 57 | ``` 58 | 59 | - 60 | 61 | ``` 62 | [~]$ ip route 63 | ``` 64 | 65 | - To make this changes permanent you must set them in **`/etc/network/interfaces`** file. 66 | 67 | # HANDS-ON LAB 68 | 69 | - Lets get our hands on [LABS](https://kodekloud.com/courses/873064/lectures/17074533) -------------------------------------------------------------------------------- /docs/03-Linux-Core-Concepts/07-File-Types.md: -------------------------------------------------------------------------------- 1 | # File Types in Linux 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/file-types/) 4 | 5 | In this section, we will take a look at different types of files in linux. 6 | - Everything is a file in Linux. 7 | - Every object in linux can be considered to be a type of file, even a directory for example is a special type of file. 8 | 9 | There are three types of files. 10 | 1. Regular File 11 | 1. Directory 12 | 1. Special Files 13 | 14 | ![file-types](../../images/file-types.PNG) 15 | 16 | **`Special files`** are again catagorized into five other file types. 17 | 1. Character Files 18 | - These files represent devices under the **`/dev`** file system. 19 | - Examples include the devices such as the **`keyboard`** and **`mouse`**. 20 | 1. Block Files 21 | - These files represent block devices also located under **`/dev/`** file system. 22 | - Examples include the **`harddisks`** and **`RAM`** 23 | 1. Links 24 | - Links in linux is a way to associate two or more file names to the same set of file data. 25 | - There are two types of links 26 | - The Hard Link 27 | - The Soft Link 28 | 1. Sockets 29 | - A sockets is a special file that enables the communication between two processes. 30 | 1. Named Pipes 31 | - The Named Pipes is a special type of file that allows connecting one process as an input to another 32 | 33 | ![file-types1](../../images/file-types1.PNG) 34 | 35 | #### Let us now see how to identify different file types in Linux. 36 | 37 | One way to identify a file type is by making use of the **`file`** command. 38 | ``` 39 | $ file /home/michael 40 | $ flle bash-script.sh 41 | $ file insync1000.sock 42 | $ file /home/michael/bash-script 43 | ``` 44 | 45 | Another way to identify a file type is by making use of the **`ls -ld`** command 46 | ``` 47 | ls -ld /home/michael 48 | ls -l basg-script.sh 49 | ``` 50 | ![file-types2](../../images/file-types2.PNG) 51 | 52 | -------------------------------------------------------------------------------- /docs/06-Security-and-File-Permissions/03-User-Management.md: -------------------------------------------------------------------------------- 1 | # USER MANAGEMENT 2 | 3 | - Take me to the [Tutorial](https://kodekloud.com/topic/user-management/) 4 | - In this lecture we will learn how to create and manage user accounts in Linux. 5 | 6 | #### User Add 7 | 8 | - To create a new local user **`bob`** in the system use **`useradd`** command. 9 | 10 | ``` 11 | [~]$ useradd bob 12 | ``` 13 | 14 | - To get more details about **`bob`** account like, home director, uid, and shell use **`/etc/passwd`** 15 | 16 | ``` 17 | [~]$ grep -i bob /etc/passwd 18 | bob:x:1002:1002::/home/bob:/bin/sh 19 | ``` 20 | 21 | ![useradd](../../images//useradd.PNG) 22 | 23 | - To check the uid or username of the user logged in user **`whoami`** command. 24 | 25 | ``` 26 | [~]$ whoami 27 | bob 28 | ``` 29 | 30 | - All user's password are store under **`/etc/shadow`** 31 | 32 | ``` 33 | [~]$ grep -i bob /etc/shadow 34 | bob:!:18341:0:99999:7::: 35 | ``` 36 | 37 | - To change the password of current user use **`passwd`** or for any specific user use **`passwd `** 38 | 39 | ``` 40 | [~]$ passwd bob 41 | Changing password for user bob. 42 | New UNIX password: 43 | Retype new UNIX password: 44 | passwd: all authentication tokens updated 45 | successfully. 46 | ``` 47 | 48 | # Managing Users 49 | 50 | - **`useradd`** command be used along with many attributes as show below. 51 | 52 | ``` 53 | [~]$ useradd -u 1009 -g 1009 -d /home/robert -s /bin/bash -c ”Mercury Project member" bob 54 | ``` 55 | 56 | ![manage](../../images//manage.PNG) 57 | 58 | - To delete a user use **`userdel`** command 59 | 60 | ``` 61 | [~]$ userdel bob 62 | ``` 63 | 64 | - To add a group use **`groupadd`** command 65 | 66 | ``` 67 | [~]$ groupadd –g 1011 developer 68 | ``` 69 | 70 | - To delete a group user **`groupdel`** command 71 | 72 | ``` 73 | [~]$ groupdel developer 74 | ``` -------------------------------------------------------------------------------- /docs/03-Linux-Core-Concepts/06-Run-Levels.md: -------------------------------------------------------------------------------- 1 | # Run Levels 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/runlevels/) 4 | 5 | ## Systemd Targets (Run Levels) 6 | 7 | We can setup the server to boot either into graphical mode or non-graphical mode. Linux can run in multiple modes and these modes are set by something called **`runlevel`** 8 | - The operation mode which provide a graphical interface is called **`runlevel 5`** 9 | - The operation mode which provide a non-graphical mode is called **`runlevel 3`** 10 | 11 | ![run-levels](../../images/run-levels.PNG) 12 | 13 | To see the operation mode run in the system. Run the command **`runlevel`** from the terminal 14 | ``` 15 | $ runlevel 16 | ``` 17 | 18 | During boot, the **`init`** process checks the **`runlevel`**, it make sure that all programs need to get the system operation in that mode are started. 19 | - For example: The **`Graphical User`** mode requires a **`display manager`** service to run for the GUI to work, however this service is not required for the **`non-graphical mode`** 20 | 21 | ![run-levels1](../../images/run-levels1.PNG) 22 | 23 | In the boot process section, we saw that the **`systemd`** is used as the **`init`** process in most new linux distributions suchs as **`Ubuntu 18.04`**. 24 | - In **`systemd`**, runlevels are called as **`targets`**. 25 | - The RunLevel 5 is called as the **`graphical target`** 26 | - The Runlevel 3 is called as the **`multiuser target`** 27 | 28 | ![run-levels2](../../images/run-levels2.PNG) 29 | 30 | #### Now that we are familiar with runlevels in systemd target unit. Lets now take a look at how we change these values from a shell. 31 | 32 | To see the default target, run the command **`systemctl get-default`**. This command looks at the file located at **`/etc/systemd/system/default.target`** 33 | ``` 34 | $ systemctl get-default 35 | ``` 36 | 37 | To change the default target, we can make use of **`systemctl set-target `** 38 | ``` 39 | $ systemctl set-default multi-user.target 40 | ``` 41 | 42 | 43 | -------------------------------------------------------------------------------- /docs/05-Working-With-Shell-Part-II/05-Lab-Working-With-Shell-Part-II.md: -------------------------------------------------------------------------------- 1 | # Lab - Working With Shell Part - II 2 | 3 | - Access Hands-On Labs here [Hands-On Labs](https://kodekloud.com/topic/lab-working-with-shell-ii/) 4 | 5 | Create a tarball of the directory called **`python`** and compress it using **`gzip`**. The compressed tar file should be available at **`/home/bob/python.tar.gz`** 6 | ``` 7 | $ tar -cf /home/bob/python.tar /home/bob/reptile/snake/python 8 | $ gzip /home/bob/python.tar 9 | ``` 10 | 11 | There is a compressed file called eaglet.dat.gz located under the eagle directory. Extract it in the same location 12 | ``` 13 | $ gunzip /home/bob/birds/eagle/eaglet.dat.gz 14 | ``` 15 | 16 | A file has been copied to the laptop by the name of caleston-code. But he does not remember which directory he saved it in.Can you find it? 17 | ``` 18 | $ sudo find / -name caleston-code 19 | ``` 20 | 21 | Find the location of the file called **`dummy.service`** and redirect its absolute path to the file **`/home/bob/dummy-service`**. You can use the redirect operator with the echo command to save the answer to the file. 22 | ``` 23 | $ sudo find / -name dummy.service 24 | $ echo /etc/systemd/system/dummy.service > /home/bob/dummy-service 25 | ``` 26 | 27 | Find the file under **`/etc`** directory that contains the string **`172.16.238.197`**. Save the answer using the absolute path in the file **`/home/bob/ip**` 28 | ``` 29 | $ sudo grep -ir 172.16.238.197 /etc/ > /home/bob/ip 30 | ``` 31 | 32 | Create a new file called **`/home/bob/file_wth_data.txt`**. This file should have one line of text that says **`a file in my home directory`**. Make use of the redirect operator. 33 | ``` 34 | $ echo "a file in my home directory" > /home/bob/file_wth_data.txt 35 | ``` 36 | 37 | Run the command python3 **`/home/bob/my_python_test.py`** and redirect the **`standard error`** to the file **`/home/bob/py_error.txt`**. 38 | ``` 39 | $ python3 /home/bob/my_python_test.py 2>/home/bob/py_error.txt 40 | ``` 41 | 42 | Read the file **`/usr/share/man/man1/tail.1.gz`** and without extracting it copy the first line of this file to **`/home/bob/pipes`** 43 | ``` 44 | $ zcat /usr/share/man/man1/tail.1.gz | head -1 > /home/bob/pipes 45 | ``` 46 | 47 | -------------------------------------------------------------------------------- /docs/05-Working-With-Shell-Part-II/06-Vi-Editor.md: -------------------------------------------------------------------------------- 1 | # Vi Editor 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/vi-editor/) 4 | 5 | In this section, we will take a look at console based text editors in linux. 6 | - It is not feasible using **`cat`** when dealing with large amounts of text or for writing code. This is why we use text editors 7 | 8 | ## Text Editor 9 | 10 | There are several options available, we will be focusing on the **`VI Editor`**. 11 | - Most popular text editor in linux is the **`VI`** Editor. 12 | - The VI EDITOR is available in all most all of the linux distribution out of the box. 13 | - The command to open the vi editor is **`vi`** followed by the filename that you want to create or append. 14 | ``` 15 | $ vi /home/michael/sample.txt 16 | ``` 17 | - The VI EDITOR has three operation modes. 18 | 1. Command Mode 19 | - When the vi editor opens a file, it always goes to the **`COMMAND MODE`** first. 20 | - In this mode, the editor only understands the commands 21 | 1. Insert Mode 22 | - To switch from command mode to **`INSERT MODE`** type lower case **`i`** 23 | - This mode allows you to write text into the file. 24 | - Once you are done with editing the file, to go back to command mode hit the **`ESC`** button. 25 | - While going into insert mode from command mode you may use other options such as **`I`**, **`o`**, **`O`**, **`a`**, or **`A`** 26 | 1. Last Line Mode 27 | - Pressing the **`:`** key will take you to the **`LAST LINE MODE`** 28 | - In this mode you can choose to save changes to the file, discard changes, or save and edit. 29 | - From the last line mode hit the **`ESC`** key to go back to the command mode. 30 | 31 | ![vi](../../images/vi.PNG) 32 | 33 | ## Command Mode 34 | 35 | ![command1](../../images/command1.PNG) 36 | 37 | ![command2](../../images/command2.PNG) 38 | 39 | ![command3](../../images/command3.PNG) 40 | 41 | 42 | ## Insert Mode 43 | 44 | ![insert](../../images/insert.PNG) 45 | 46 | ## Last Line Mode 47 | 48 | ![lastline](../../images/lastline.PNG) 49 | 50 | 51 | #### There is another popular editor called **`VIM`** which is an improved version of **`VI`** with added features but very similar in appereance to VI. 52 | 53 | - In the most distros today, the VI is the symblic to the VIM editor 54 | 55 | ![VIM](../../images/VIM.PNG) 56 | 57 | -------------------------------------------------------------------------------- /docs/07-Networking/04-Troubleshooting.md: -------------------------------------------------------------------------------- 1 | # TROUBLESHOOTING 2 | 3 | - Take me to the [Tutorial](https://kodekloud.com/topic/troubleshooting/) 4 | 5 | - In this lecture we will be going to troubleshooting the issue that **`Bob`** is facing. 6 | - Bob is not able to reach to the repository server and he get the error as show below. 7 | 8 | ![site](../../images/site.PNG) 9 | 10 | #### Check Interfaces 11 | 12 | - Use the **`ip link`** to ensure the primary interface is up. 13 | - In this case, the network interface named **`enp1s0f1`** state is up. 14 | 15 | ``` 16 | [~]$ ip link 17 | 1: lo: mtu 65536 qdisc 18 | noqueue state UNKNOWN mode DEFAULT group default qlen 1000 19 | link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 20 | 2: enp1s0f1: mtu 1500 qdisc 21 | fq_codel state UP mode DEFAULT group default qlen 1000 22 | link/ether 08:97:98:6e:55:4d brd ff:ff:ff:ff:ff:ff 23 | ``` 24 | 25 | - Check if we can resolve the hostname to IP address via **`nslookup`** 26 | 27 | ``` 28 | [~]$ nslookup caleston-repo-01 29 | Server: 192.168.1.100 30 | Address: 192.168.1.100 #53 31 | 32 | Non-authoritative answer: 33 | Name: caleston-repo-01 34 | Address: 192.168.2.5 35 | ``` 36 | 37 | - **`ping`** to check the connectivity. 38 | 39 | ``` 40 | [~]$ ping caleston-repo-01 41 | PING caleston-repo-01 (192.168.2.5) 56(84) bytes of data. 42 | 43 | --- localhost ping statistics --- 44 | 3 packets transmitted, 0 received, 100% packet loss, time 2034ms 45 | ``` 46 | 47 | - **`traceroute`** to check the number of hops between the source. 48 | 49 | ``` 50 | [~]$ traceroute 192.168.2.5 51 | 52 | Tracing route to example.com [192.168.2.5] 53 | over a maximum of 30 hops: 54 | 1 <1 ms <1 ms <1 ms 192.168.1.1 55 | 2 <2 ms <1 ms <1 ms 192.168.2.1 56 | 3 * * * Request timed out. 57 | ``` 58 | 59 | - To check the port status use **`netstat`** command and to use it along with port number use below command. 60 | 61 | ``` 62 | [caleston-repo-01: ~]$ netstat -an | grep 80 | grep -i LISTEN 63 | ``` 64 | 65 | ![net](../../images/net.PNG) 66 | 67 | - To bring up the interface up use below command. 68 | 69 | ``` 70 | [caleston-repo-01: ~]$ ip link set dev enp1s0f1 up 71 | ``` 72 | 73 | ![iplink](../../images/iplink.PNG) -------------------------------------------------------------------------------- /docs/06-Security-and-File-Permissions/06-SSH-and-SCP.md: -------------------------------------------------------------------------------- 1 | # SSH and SCP 2 | 3 | - Take me to the [Tutorial](https://kodekloud.com/topic/ssh-and-scp/) 4 | - In this lecture we will learn about SSH and SCP commands. 5 | - SSH is used to login to the remote computer. 6 | - SCP is used to copy of files/directories within the file system also can copy data to remote computer. 7 | 8 | #### SSH 9 | 10 | - To login to the remote server use **`ssh`** command with hostname or IP address. 11 | 12 | ``` 13 | ssh 14 | ``` 15 | 16 | - To login to the remote server with specific username and password. 17 | 18 | ``` 19 | ssh @ 20 | ``` 21 | 22 | **`-l`** attribute can also be used as 23 | 24 | ``` 25 | ssh –l 26 | ``` 27 | 28 | #### Password-Less Authentication 29 | 30 | - Passwordless authentication can be setup via key-pair authentication in order to login to the remote server with password. 31 | 32 | - Public and Private key are stored at below location. 33 | 34 | ``` 35 | Public Key: /home/bob/.ssh/id_rsa.pub 36 | ``` 37 | 38 | ``` 39 | Private Key: /home/bob/.ssh/id_rsa 40 | ``` 41 | 42 | - To generate a keypair on the **`Client`** run this command 43 | 44 | ``` 45 | bob@caleston-lp10 ~]$ ssh-keygen –t rsa 46 | ``` 47 | 48 | ![key](../../images//key.PNG) 49 | 50 | - To copy the Public key from the client to the remote server 51 | 52 | ``` 53 | bob@caleston-lp10 ~]$ ssh-copy-id bob@devapp01 54 | ``` 55 | 56 | ![copy](../../images//copy.PNG) 57 | 58 | 59 | - Now **`Bob`** can login to remote server without password 60 | 61 | ``` 62 | [bob@caleston-lp10 ~]$ ssh devapp01 63 | ``` 64 | 65 | ![pless](../../images//pless.PNG) 66 | 67 | - Public Key is copied to the remote server at : 68 | 69 | ``` 70 | [bob@caleston-lp10 ~]$ cat /home/bob/.ssh/authorized_keys 71 | ``` 72 | 73 | ![auth](../../images//auth.PNG) 74 | 75 | #### SCP 76 | 77 | - To copy a compresses file to a remote server 78 | 79 | ``` 80 | bob@caleston-lp10 ~]$ scp /home/bob/caleston-code.tar.gz devapp01:/home/bob 81 | ``` 82 | 83 | - To copy a directory to a remote server 84 | 85 | ``` 86 | [bob@caleston-lp10 ~]$ scp –pr /home/bob/media/ devapp01:/home/bob 87 | ``` 88 | 89 | ![scp](../../images//scp.PNG) -------------------------------------------------------------------------------- /docs/05-Working-With-Shell-Part-II/04-IO-Redirection.md: -------------------------------------------------------------------------------- 1 | # IO Redirection 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/io-redirection/) 4 | 5 | In this section, we will take a look at IO **`Redirection`**. 6 | - IO Redirection 7 | - Standard Streams in Linux 8 | 9 | There are three data streams created when you launch a linux commnad. 10 | - Standard Input (STDIN) 11 | - STDIN is the standard input stream which accepts text as an input. 12 | - Standard Output (STDOUT) 13 | - Text output is delivered as STDOUT or the standard out stream 14 | - Standard ERROR (STDERR) 15 | - Error messages of the command are sent through the standard ERROR stream (STDERR) 16 | 17 | ![io](../../images/io.PNG) 18 | 19 | With IO Redirection, the STDIN, STDOUT and STDERR can be redirected to a text file. 20 | 21 | ## REDIRECT STDOUT 22 | 23 | To redirect STDOUT to a file instead of printing it on the screen. 24 | ``` 25 | $ echo $SHELL > shell.txt 26 | ``` 27 | 28 | To append STDOUT to an exisiting file 29 | ``` 30 | $ echo $SHELL >> shell.txt 31 | ``` 32 | 33 | ## REDIRECT STDERR 34 | 35 | To redirect just the ERROR message we need to use **`2`** followed by forward arrow **`>`** symbol and then the name of the filename in which the errors are written. 36 | ``` 37 | $ cat missing_file 2> error.txt 38 | ``` 39 | 40 | To append the STDERR to the exisiting file 41 | ``` 42 | $ cat missing_file 2>> error.txt 43 | ``` 44 | 45 | If you want to execute and not print ERROR messages on the screen even if it generates a standard ERROR. You can redirect to **`/dev/null`** 46 | ``` 47 | $ cat missing_file 2> /dev/null 48 | ``` 49 | 50 | ## Command Line Pipes 51 | 52 | Command Line Pipes allow the linking of multiple commands. 53 | - In simple terms, pipes allows the first commands standard output to be used as the standard input for the second command. 54 | - The pipes are defined using vertical bar symbol (|). 55 | 56 | ``` 57 | $ grep Hello sample.txt | less 58 | ``` 59 | ![pipe](../../images/pipe.PNG) 60 | 61 | Another command to work with STDIN and STDOUT is the **`tee`** command. 62 | - Instead of the redirect operator, we can use the command line pipe **`(|)`** followed by **`tee`** command. 63 | ``` 64 | $ echo $SHELL | tee shell.txt 65 | ``` 66 | 67 | - Use **`tee`** with -a option, to append instead of overwritting it 68 | ``` 69 | $ echo "This is the bash shell" | tee -a 70 | ``` 71 | 72 | ![tee](../../images/tee.PNG) 73 | 74 | -------------------------------------------------------------------------------- /docs/04-Package-Mangement/04-DPKG-AND-APT.md: -------------------------------------------------------------------------------- 1 | # DPKG and APT Package Managers 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/dpkg-and-apt/) 4 | 5 | In this section, we will look at debian package managers for distributions like **`Ubuntu`**, **`Debian`** and **`PureOS`**. 6 | - DPKG 7 | - APT 8 | 9 | ## DPKG Utility 10 | 11 | - DPKG stands for Debian Package Manager 12 | - It is a low level package manager 13 | 14 | ![dpkg](../../images/dpkg.PNG) 15 | 16 | #### Working with DPKG 17 | 18 | Similar to RPM, DPKG can be used for the below. The package extension is .deb. 19 | 1. Installing 20 | 1. Uninstalling 21 | 1. Upgrade 22 | 1. List 23 | 1. Status 24 | 1. Verfiying 25 | 26 | ![dpkg-modes](../../images/dpkg-modes.PNG) 27 | 28 | ## APT and APT-GET 29 | 30 | Similar to RPM, DPKG doesnt resolve the dependencies when it comes to package management. 31 | - Install may fail due to dependencies issues. This is the reason why we use higher level debian package managers such as **`APT`** and **`APT-GET`**. 32 | 33 | ![dpkg-fail](../../images/dpkg-fail.PNG) 34 | 35 | - Instead of relying on DPKG, you can install software along with its dependencies using **`APT`** or **`APT-GET`**. 36 | - **`APT`** or **`APT-GET`** although sounds similar, but they do not depend on each other. 37 | - **`APT`** stands for advanced package managers, it is more user friendly and overall better tool compared to **`APT-GET`**. 38 | ``` 39 | $sudo apt install gimp 40 | $sudo apt-get install gimp 41 | ``` 42 | 43 | - APT act as a frontend package manager that relies on DPKG utility. In similar to YUM, APT relies on software repository that contains packages that would eventually be installed on a system. 44 | - The software repository for APT is defined in **`/etc/apt/sources.list`** file. 45 | 46 | ![apt](../../images/apt.PNG) 47 | 48 | #### Let us know see some common commands 49 | 50 | To refresh a repository. Run **`apt update`** command. 51 | ``` 52 | $ sudo apt update 53 | ``` 54 | 55 | To install available upgrades of all packages currently installed on the system from the sources configured. 56 | ``` 57 | $ sudo apt upgrade 58 | ``` 59 | 60 | Another way to update the repository is to use **`apt edit-sources`** command. This opens up the **`/etc/apt/sources.list`** file in the text editor of your choice. 61 | ``` 62 | $ sudo apt edit-sources 63 | ``` 64 | 65 | To install the package 66 | ``` 67 | $ sudo apt install telnet 68 | ``` 69 | 70 | To remove the package 71 | ``` 72 | $ sudo apt remove telnet 73 | ``` 74 | 75 | To search or look for a package in the repository. 76 | ``` 77 | $ sudo apt search telnet 78 | ``` 79 | 80 | To list all the available packages 81 | ``` 82 | $ sudo apt list |grep telnet 83 | ``` 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /docs/03-Linux-Core-Concepts/02-The-Linux-Kernel.md: -------------------------------------------------------------------------------- 1 | # Linux Core Concepts 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/linux-kernel/) 4 | 5 | In this section, we will take a look at the core concepts of a linux operating system. 6 | - We will start with introduction to the linux kernel. 7 | - We will then learn about the kernel space and user space. 8 | 9 | ## Linux Kernel 10 | 11 | #### If you have worked with any operating system, you have run into the term kernel. 12 | 13 | - The Linux kernel is monolithic, this means that the kernel carrries out CPU scheduling, memory management and several operations by itselfs. 14 | - The Linux Kernel is also modular, which means it can extends its capabilities through the use of dynamically loaded kernel modules 15 | 16 | ![linux-kernel](../../images/linux-kernel.PNG) 17 | 18 | #### To understand a kernel in simple terms, let us use an analogy of a **`College Library`**. Here the librarian is equal to Linux Kernel. 19 | 20 | ![library](../../images/library.PNG) 21 | 22 | #### The Kernel is responsible for 4 major tasks 23 | 24 | 1. Memory Management 25 | 1. Process Management 26 | 1. Device Drivers 27 | 1. System calls and Security 28 | 29 | ## Linux Kernel Versions 30 | 31 | #### let us know identify the ways to identify linux kernel versions 32 | 33 | Use **`uname`** command to get the information about the kernel (by itself it doesn't provide much information except that the system uses the **`Linux`** Kernel. 34 | ``` 35 | $ uname 36 | ``` 37 | 38 | Use the **`uname -r`** or **`uname`** comamnd and option to print the kernel version 39 | ``` 40 | $ uname -r 41 | $ uname -a 42 | ``` 43 | ![kernel-versions](../../images/kernel-versions.PNG) 44 | 45 | ## Kernel and User Space 46 | 47 | #### One of the important functions of the linux kernel is the **`Memory Management`** . We will now see how memory is seperated within the linux kernel 48 | 49 | Memory is divded into two areas. 50 | 1. Kernel Space 51 | 1. Kernel Code 52 | 1. kernel Extensions 53 | 1. Device Drivers 54 | 1. User Space 55 | 1. C 56 | 1. Java 57 | 1. Python 58 | 1. Ruby e.t.c 59 | 1. Docker Containers 60 | 61 | ![memory-management](../../images/memory-management.PNG) 62 | 63 | #### Let us know see how programs running in the `User Space` work 64 | 65 | All user programs function by manipulating data that is stored in memory and on disk. User programs get access to data by making special request to the kernel called **`System Calls`** 66 | - Examples include, allocating memory by using variables or opening a file. 67 | 68 | ![user-space](../../images/user-space.PNG) 69 | 70 | - For example, opening a file such as the **`/etc/os-release`** to see the operating system installed, results in a **`system call`** 71 | 72 | ![user-space1](../../images/user-space1.PNG) 73 | 74 | 75 | -------------------------------------------------------------------------------- /docs/09-Service-management-with-SYSTEMD/02-Creating-a-SYSTEMD-Service.md: -------------------------------------------------------------------------------- 1 | # Creating your own SYSTEMD Service 2 | 3 | - Take me to the [Tutorial](https://kodekloud.com/topic/creating-a-systemd-service/) 4 | 5 | In this lecture we will learn how to create a SYSTEMD Service. 6 | - All the major distributions, such as Rhel, CentOS, Fedora, Ubuntu, Debian and Archlinux, adopted systemd as their init system. 7 | - Systemd is a Linux initialization system and service manager that includes features like on-demand starting of daemons, mount and automount point maintenance etc. 8 | - Systemd also provides a logging daemon and other tools and utilities to help with common system administration tasks. 9 | 10 | #### What is a service unit? 11 | 12 | - A file with the .service suffix contains information about a process which is managed by systemd. It is composed by three main sections: 13 | 14 | #### 1.Unit 15 | 16 | - The **`Unit`** section of a .service file contains the description of the unit itself, and information about its behavior and its dependencies: (to work correctly a service can depend on another one). Here we discuss some of the most relevant options which can be used in this section 17 | - First of all we have the **`Description`** option. By using this option we can provide a description of the unit. The description will then appear, for example, when calling the systemctl command, which returns an overview of the status of systemd. 18 | - Secondly, we have **`Documentation`** option. By using this option we can get the details of the service and documentation related to it. 19 | - By using the **`After`** option, we can state that our unit should be started after the units we provide in the form of a space-separated list. 20 | 21 | ``` 22 | [~]$ cat /etc/systemd/system/project-mercury.service 23 | [Unit] 24 | Description=Python Django for Project Mercury 25 | Documentation=http://wiki.caleston-dev.ca/mercury 26 | After=postgresql.service 27 | ``` 28 | 29 | 30 | #### 2.Service 31 | 32 | - In the **`Service`** section of a service unit, we can specify things as the command to be executed when the service is started, or the type of the service itself. 33 | 34 | ``` 35 | [Service] 36 | ExecStart=/usr/bin/project-mercury.sh 37 | User=project_mercury 38 | Restart=on-failure 39 | RestartSec=10 40 | ``` 41 | 42 | #### 3.Install 43 | 44 | - This **`Install`** section contains information about the installation of the unit 45 | 46 | ``` 47 | [Install] 48 | WantedBy=graphical.target 49 | ``` 50 | 51 | #### How to Start the Service now ? 52 | 53 | - The system to detect the changes you have done in the file, we need to reload the daemon and start the service. 54 | 55 | ``` 56 | [~]$ systemctl daemon-reload 57 | 58 | [~]$ systemctl start project-mercury.service 59 | ``` -------------------------------------------------------------------------------- /docs/06-Security-and-File-Permissions/05-File-Permissions.md: -------------------------------------------------------------------------------- 1 | # LINUX FILE PERMISSIONS 2 | 3 | - Take me to the [Tutorial](https://kodekloud.com/topic/file-permissions-and-ownership/) 4 | 5 | - In this lecture we will learn about various file type identifiers. 6 | - We will also learn about various Linux file permissions that can be applied on the file or the directory. 7 | 8 | ![perm](../../images//perm.PNG) 9 | 10 | 11 | ![type](../../images//type.PNG) 12 | 13 | 14 | #### Directory Permission 15 | 16 | - To list the directory permission use 17 | 18 | ``` 19 | [~]$ ls -ld /home/bob/random_dir 20 | ``` 21 | 22 | - To know the current user 23 | 24 | ``` 25 | [~]$ whoami 26 | ``` 27 | 28 | - To change the change the directory 29 | 30 | ``` 31 | [~]$ cd /home/bob/random_dir 32 | ``` 33 | 34 | #### File Permissions 35 | 36 | - Linux file permissions are defined as 37 | 38 | ![filep](../../images//filep.PNG) 39 | 40 | #### Modifying file permissions 41 | 42 | - Use **`chmod`** command to modify the file permissions. 43 | 44 | - Provide full access to owners 45 | 46 | ``` 47 | [~]$ chmod u+rwx test-file 48 | ``` 49 | 50 | - Provide Read access to Owners, groups and others, Remove execute access 51 | 52 | ``` 53 | [~]$ chmod ugo+r-x test-file 54 | ``` 55 | 56 | - Remove all access for others 57 | 58 | ``` 59 | [~]$ chmod o-rwx test-file 60 | ``` 61 | 62 | - Full access for Owner, add read , remove execute for group and no access for others 63 | 64 | ``` 65 | [~]$ chmod u+rwx,g+r-x,o-rwx test-file 66 | ``` 67 | 68 | - Provide full access to Owners, group and others 69 | 70 | ``` 71 | [~]$ chmod 777 test-file 72 | ``` 73 | 74 | - Provide Read and execute access to Owners,groups and others 75 | 76 | ``` 77 | [~]$ chmod 777 test-file 78 | ``` 79 | 80 | - Read and Write access for Owner and Group, No access for others. 81 | 82 | ``` 83 | [~]$ chmod 660 test-file 84 | ``` 85 | 86 | - Full access for Owner, read and execute for group and no access for others. 87 | 88 | ``` 89 | [~]$ chmod 750 test-file 90 | ``` 91 | 92 | #### Change Ownership 93 | 94 | - Changes owner to bob and group to developer 95 | 96 | ``` 97 | [~]$ chown bob:developer test-file 98 | ``` 99 | 100 | - Changes just the owner of the file to bob. Group unchanged. 101 | 102 | ``` 103 | [~]$ chown bob andoid.apk 104 | ``` 105 | 106 | - Change the group for the test-file to the group called android. 107 | 108 | ``` 109 | [~]$ chgrp android test-file 110 | ``` 111 | 112 | # HANDS-ON LABS 113 | 114 | - Lets do some hands on labs to understand File Permission better. [Take me to Labs](https://kodekloud.com/courses/873064/lectures/17074516) -------------------------------------------------------------------------------- /docs/06-Security-and-File-Permissions/02-Linux-Accounts.md: -------------------------------------------------------------------------------- 1 | # LINUX ACCOUNTS 2 | 3 | - Take me to the [Tutorial](https://kodekloud.com/topic/linux-accounts/) 4 | - In this section we will take a look at basic access control in Linux. 5 | - We will also learn about about the file permissions. Lets Get Started! 6 | 7 | ![linux](../../images/linux.PNG) 8 | 9 | 10 | #### User Accounts 11 | 12 | - User's informations are stored under **`/etc/passwd`** file. 13 | 14 | ``` 15 | [~]$ cat /etc/passwd 16 | ``` 17 | 18 | - Information about groups is stored into **`/etc/group`** file. 19 | 20 | ``` 21 | [~]$ cat /etc/group 22 | ``` 23 | 24 | ![user](../../images/user.PNG) 25 | 26 | - Each user has a username and a unique ID assigned to them known as user ID or UID. 27 | - The user also has a GID, the group id they are part of, **`id`** command can be use to check these details. for eg: 28 | 29 | ``` 30 | [~]$ id michael 31 | uid=1001(michael) gid=1001(michael)groups=1001(michael),1003(developers) 32 | ``` 33 | 34 | - More details about the user account can be found eg. default shell, home directory using. 35 | 36 | ``` 37 | [~]$ grep -i michael /etc/passwd 38 | michael:x:1001:1001::/home/michael:/bin/sh 39 | ``` 40 | 41 | ![group](../../images/group.PNG) 42 | 43 | - To see the list of users currently logged use **`who`** command. 44 | 45 | ``` 46 | [~]$ who 47 | bob pts/2 Apr 28 06:48 (172.16.238.187) 48 | ``` 49 | 50 | - The **`last`** command displays the record of all logged-in users along with the date and time when the system was rebooted. 51 | 52 | ``` 53 | [~]$ last 54 | michael :1 :1 Tue May 12 20:00 still logged in 55 | sarah :1 :1 Tue May 12 12:00 still running 56 | reboot system boot 5.3.0-758-gen Mon May 11 13:00 - 19:00 (06:00) 57 | ``` 58 | 59 | #### Switching users 60 | 61 | - To switch to any user use **`su`** command. 62 | 63 | ``` 64 | [~]$ su – 65 | Password: 66 | 67 | root ~# 68 | ``` 69 | 70 | - To run a specific command you can use **`su -c "whoami"`** (This is not recommended way) 71 | 72 | ``` 73 | [michael@ubuntu-server ~]$ su -c "whoami" 74 | Password: 75 | root 76 | ``` 77 | 78 | - To run a command as a root user **`sudo`** command is recommended. 79 | 80 | ``` 81 | [michael@ubuntu-server ~]$ sudo apt-get install nginx 82 | [sudo] password for michael: 83 | ``` 84 | 85 | ![who](../../images/who.PNG) 86 | 87 | - Users listed in /etc/sudoers file can make use of sudo command for privledge escalation. 88 | 89 | ``` 90 | [~]$ cat /etc/sudoers 91 | ``` 92 | ![sudo](../../images/sudo.PNG) 93 | 94 | - To restrict anyone from directly login as root login, this can be done by setting **`nologin`** shell. 95 | 96 | ``` 97 | [~]$ grep -i ^root /etc/passwd 98 | /root:x:0:0:root:/root:/usr/sbin/nologin 99 | ``` 100 | -------------------------------------------------------------------------------- /docs/05-Working-With-Shell-Part-II/03-Searching-for-files-and-patterns.md: -------------------------------------------------------------------------------- 1 | # Searching for files and Patterns 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/searching-for-files-and-patterns/) 4 | 5 | In this section, we will take a look at how to locate a file or directory in the filesystem. 6 | - locate 7 | - find 8 | - grep 9 | 10 | ## locate 11 | Lets say you want to find the files with the name **`City.txt`**. Easiest way to do this is to make use of **`locate`** command. 12 | - Run **`locate`** command followed by the filename you are searching as an argument. This should return all paths matching the pattern. 13 | ``` 14 | $ locate City.txt 15 | ``` 16 | 17 | - The downside of the locate command is it depends on a database called **`mlocate.db`** for querying the filename. 18 | - If you have just installed linux or if the file you are trying to locate was created recently. The locate command may not give you useful results. This is because it is possible that the DB is not been updated yet. 19 | - To manually update the DB, run the command **`updatedb`** and then run the locate command again 20 | ``` 21 | $ sudo updatedb 22 | ``` 23 | - Please note that the **`updatedb`** command needs to be run as root user to work. 24 | 25 | ## find 26 | 27 | Another way to do this is make use of the **`find`** command. Use the find command followed by the directory under which you want to search. To search file by a name use the **`-name`** option followed by the name of the file. 28 | ``` 29 | $ find /home/michael -name City.txt 30 | ``` 31 | ![locate-find](../../images/locate-find.PNG) 32 | 33 | ## Grep 34 | 35 | To search within files, the most popular command in linux is grep. 36 | - Grep is commonly used to print lines of a file matching a pattern but it also offers a variety of other options as well. 37 | - The grep command is case-sensitive 38 | 39 | To search for the word **`second`** from the **`sample.txt`** 40 | ``` 41 | $ grep second sample.txt 42 | ``` 43 | 44 | To search for the word **`capital`** with **`case-insensitive`** use **`-i`** flag. 45 | ``` 46 | $ grep -i capital sample.txt 47 | ``` 48 | 49 | To search for a pattern recursively. 50 | ``` 51 | $ grep -r "thrid Line" /home/michael 52 | ``` 53 | 54 | To print the lines that don't matches the pattern 55 | ``` 56 | $ grep -v "printed" sample.txt 57 | ``` 58 | 59 | ![grep](../../images/grep.PNG) 60 | 61 | #### What if you want to match a pattern that form a whole word? 62 | 63 | To search for the whole word called **`exam`**. Use **`grep`** followed by **`-w`** flag 64 | ``` 65 | $ grep -w exam examples.txt 66 | ``` 67 | 68 | You can also combine multiple options together. For example, to reverse the search and print all lines of the same file that doesn't match the whole word exam. Use **`grep -vw`** 69 | ``` 70 | $ grep -vw exam examples.txt 71 | ``` 72 | 73 | To print the number of lines after and before matching a pattern. Use **`grep`** command with **`-A`** and **`-B`** flags respectively. 74 | ``` 75 | $ grep -A1 Arsenal premier-league-table.txt 76 | $ grep -B1 4 premier-league-table.txt 77 | ``` 78 | 79 | ![grep1](../../images/grep1.PNG) 80 | 81 | 82 | Finally, the **`-A`** and **`-B`** can be combined into one single search. 83 | ``` 84 | $ grep -A1 -B1 Chelsea premier-league-table.txt 85 | ``` 86 | ![grep2](../../images/grep2.PNG) 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /docs/03-Linux-Core-Concepts/03-Working-with-hardware.md: -------------------------------------------------------------------------------- 1 | # Working with Hardware 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/working-with-hardware/) 4 | 5 | In this section, we will look at how linux works with the hardware resources available to the system and how to make use of kernel modules 6 | - We will look at how linux identifies and manages hardware devices attached to the system 7 | - We will then see ways to list and get detailed information about these devices from the command line. 8 | 9 | Lets take an example of **`USB Disk`** be used in the system. 10 | - As soon as the **`USB device`** is attached to the system a corresponding device driver which is part of the kernel space detects the stage change and generates an event. 11 | - This event which is called **`uevents`** is then sent to the **`User Space`** device manager daemon called **`udev`**. 12 | - The **`udev`** service is then responsible for dynamically creating a device node associated with the newly attached USB drive in the **`/dev/`** filesystem. 13 | - Once the process is complete, the newly attached disk should be visible under **`/dev/`** filesystem. 14 | 15 | ![working-with-hardware](../../images/working-with-hardware.PNG) 16 | 17 | Use **`dmesg`** display messages from the area of kernel called **`Ring Buffer`** . When a linux operating system boots up there were numerous messages generated by the kernel that appear on the display screen. These messages also contain logs from the hardware devices that the kernel detects and provide good indication wheather it is able to configure 18 | ``` 19 | $ dmesg 20 | $ dmesg | grep -i usb 21 | ``` 22 | 23 | The **`udevadm`** is the management utility for udev which queries the database for device information. 24 | ``` 25 | $ udevadm info --query=path --name=/dev/sda5 26 | ``` 27 | 28 | The **`udevadm monitor`** listens to the kernel new **`uevents`** upon detecting an event, it prints the details such as the **`device path`** and the **`device name`** on the screen. This command is handy to determine the details of the newly attached or removed device. 29 | ``` 30 | $ udevadm monitor 31 | ``` 32 | 33 | To list all PCI (Peripheral Component Interconnect) devices that are configured in the system. Examples of PCI devices are **`Ethernet Cards`**, **`RAID Controllers`**, **`Video Cards`** and **`wireless Adaptors`** that directly attached to PCI slots in the motherboard of the computer 34 | ``` 35 | $ lspci 36 | ``` 37 | ![pci](../../images/pci.PNG) 38 | 39 | 40 | To list information about **`Block Devices`** 41 | ``` 42 | $ lsblk 43 | ``` 44 | ![block-device](../../images/block-device.PNG) 45 | 46 | 47 | To display detail information about the **`CPU`** such as CPU architecture, cpu op-modes (32 bit, 64 bit) etc. 48 | ``` 49 | $ lscpu 50 | ``` 51 | 52 | To list available memory in the system. 53 | ``` 54 | $ lsmem --summary 55 | ``` 56 | 57 | Another alternate command to see the information about the memory. This command will list total used and free memory. 58 | ``` 59 | $ free -m 60 | ``` 61 | 62 | To extract detail information about the entire hardware information of the machine 63 | ``` 64 | $ lshw 65 | ``` 66 | 67 | #### To run commands with root privileges. Not every user can run all the commands in the linux system some commands need to be run as the `root` or the `super-user`. Use **`sudo`** followed by ( input the sudo password ). 68 | 69 | ``` 70 | $ sudo lshw 71 | ``` 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /docs/05-Working-With-Shell-Part-II/02-File-Compression-and-Archival.md: -------------------------------------------------------------------------------- 1 | # File Compression and Archival 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/file-compression-and-archival/) 4 | 5 | In this section, we will take a look to compress and archive files 6 | - File Compression and Archival 7 | 8 | ## Viewing file sizes 9 | 10 | The **`du`** command, which stands for **`disk usage`** is a popular command to inspect the size of the file. 11 | - **`du`** with **`-sk`** shows the size of a file or directory in **`Kilobytes`** 12 | ``` 13 | $ du -sk test.img 14 | ``` 15 | 16 | - **`du`** with **`-sh`** shows the size of a file or directory in **`human readable format`** 17 | ``` 18 | $ du -sh test.img 19 | ``` 20 | 21 | - we can also use **`long list`** , **`ls -lh`** to print the size of the file. 22 | ``` 23 | $ ls -lh test.img 24 | ``` 25 | 26 | ## Archiving Files 27 | 28 | Let us know take a look at widely used utility called **`tar`** 29 | - **`tar`** is used to group multiple files and directories into a single file. Hence it is specially used for archiving data. 30 | - tar is an abrevation for **`tape archive`**. 31 | - Files created with tar are often called **`tarballs`**. 32 | 33 | To archive a file or directory. Use **`tar`** command followed by **`-c`** to create an archive and the **`-f`** is used to specify the name of the tar file to be created. These is followed by files or directories to be archive. 34 | ``` 35 | $ tar -cf test.tar file1 file2 file3 36 | $ ls -ltr test.tar 37 | ``` 38 | 39 | The **`tar`** command followed by **`-tf`** option followed by the tar filename is used to see the contents of the tarball. 40 | ``` 41 | $ tar -tf test.tar 42 | ``` 43 | 44 | The **`tar`** command followed by **`-xf`** option followed by the tar filename is used to extract the contents from the tarball. 45 | ``` 46 | $ tar -xf test.tar 47 | ``` 48 | 49 | The **`tar`** command followed by **`-zcf`** option is used to compress the tarball to reduce its size. 50 | ``` 51 | $ tar -zcf test.tar 52 | ``` 53 | 54 | ## Compression 55 | 56 | Compression is the technique used to reduce the size consumed by a file or a dataset. 57 | - To reduce the size of a file or directory in the linux file system, there are commands specificly used for compression. 58 | - Let us now look at the three popular ones 59 | - bzip2 (.bz2 extension) 60 | - gzip (.gz extension) 61 | - xz (.xz extension) 62 | 63 | ``` 64 | $ bzip2 test.img 65 | $ gzip test1.img 66 | $ xz test2.img 67 | ``` 68 | 69 | #### The space of the compressed files created by these three commands depends on a few factors, such as the type of data being compressed, the other factors that effect the size are the compression algorithm used by these commands and the compression level used. 70 | 71 | - The compressed files can be uncompressed by using the below commands 72 | - bunzip2 73 | - gunzip 74 | - unxz 75 | ``` 76 | $ bunzip2 test.img 77 | $ gunzip test1.img 78 | $ unxz test2.img 79 | ``` 80 | 81 | ![compress-uncompress](../../images/compress-uncompress.PNG) 82 | 83 | #### Compressed files need not to be uncompressed everytime 84 | - Tools such as **`zcat`** , **`bzcat`** and **`xzcat`** allow the compressed files to be read without an uncompress 85 | ``` 86 | $ zcat hostfile.txt.bz2 87 | $ zcat hostfile.txt.gz 88 | $ zcat hostfile.txt.xz 89 | ``` 90 | ![compress-cat](../../images/compress-cat.PNG) 91 | 92 | 93 | -------------------------------------------------------------------------------- /docs/04-Package-Mangement/01-Package-Management-Distribution.md: -------------------------------------------------------------------------------- 1 | # Package Management Distribution 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/package-management-introduction/) 4 | 5 | In this section, we will take a look at the Linux Package Management tools used in different linux distribution 6 | - Will start with introduction to the package management. 7 | 8 | ## Introduction to Package Managers 9 | 10 | For **`Debain/Ubuntu`**, it is **`apt/dpkg`** and for CentOs/Redhat, it is **`RPM`** 11 | 12 | ![package-managers](../../images/package-managers.PNG) 13 | 14 | **Question** : What is the difference between **`CentOS`**, **`RHEL`** and **`Ubuntu`***? 15 | - There are hundreds of Linux distributions in use today 16 | 17 | One of the common ways to catagorize linux distribution is by the package manager it uses. 18 | - For example: Distributions such as **`RHEL`**, **`Fedora`** and **`CentOS`**. are based on RPM. Hence they are known as **`RPM`** based distribution. The **`Debian`** family including **`Ubuntu`**, **`Debian`** and **`Linux Mint`** e.t.c. make use of **`Debian`** based package managers such as the **`DPKG`**. 19 | 20 | ![deb-rpm](../../images/deb-rpm.PNG) 21 | 22 | #### Now, Lets compare **`RHEL`** and **`CentOS`** Operating Systems. 23 | 24 | ![rhel-centos](../../images/rhel-centos.PNG) 25 | 26 | #### What is a package? 27 | - A package in its simplest defination is a compressed archieve that contains all the files that are required by a particular software to run. 28 | - For example: Lets consider an Ubuntu System, we want to install a simple editing system such as **`gimp`** which stands for **` GNU Image Manipulation System`**. To do this, we can make use of the **`gimp.deb`** package which contains all the software binaries and files needed to for the image editor to run along with the metadata which provides the information about the software itself. 29 | 30 | ![package](../../images/package.PNG) 31 | 32 | #### Thats seems to be a quite easy process, why don't we do all the time? download a package and install it on a linux servers. Wondering the need of package managers? 33 | - There are hundreds of linux distributions are there, these distributions runs different sets of tools and libraries, software and possibly even different linux kernels as a result of this a linux program may not run the same way from one system to another. To fix this problem packages include a manifest of dependencies or list of programs in versions that must be satified for the package software to run correctly on a given computer. 34 | - Take a look at the errors in the installation while attempting to install **`gimp.deb`** on this ubuntu 18.04 system, the dependencies failed as a result the installations failed. Bare in mind that each of these dependent packages may have dependencies of their own which makes package installation management a very tedious process. This is where a **`Package Manager`** comes into save the day. 35 | 36 | ![package-errors](../../images/package-errors.PNG) 37 | 38 | #### A package manager is a software in a linux system that provides the consistent and automated process in installing, upgrading, configuring and removing packages from the operating system. 39 | 40 | ![pkg-mgr](../../images/pkg-mgr.PNG) 41 | 42 | ## Functions of Package Manager 43 | 44 | ![functions-of-pkg](../../images/functions-of-pkg.PNG) 45 | 46 | ## Types of Package Managers 47 | 48 | A Linux distribution supports different types of package managers, some of the common ones are below 49 | 50 | ![types-of-pkg](../../images/types-of-pkg.PNG) 51 | 52 | 53 | -------------------------------------------------------------------------------- /docs/03-Linux-Core-Concepts/05-Linux-Boot-Sequence.md: -------------------------------------------------------------------------------- 1 | # Linux Boot Sequence 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/linux-boot-sequence/) 4 | 5 | In this section, we look at the boot process in a simplied manner by dividing it into four broader steps. 6 | - The boot process can be broken down into four stages 7 | 1. BIOS POST 8 | 1. Boot Loader (GRUB2) 9 | 1. Kernel Initialization 10 | 1. INIT Process 11 | 12 | ![boot-sequence](../../images/boot-sequence.PNG) 13 | 14 | #### How to initiate a linux boot process? 15 | - This can be achieved in one of the two ways. 16 | - The first method is to start a linux device which is in a halted or stopped state 17 | - Second method is to reboot or reset a running system 18 | 19 | #### BIOS POST 20 | 21 | - The first stage, called **`BIOS POST`** has very little to do with linux itself. 22 | - **`POST`** Stands for **`Power On Self Test`**. 23 | - In this stage, BIOS runs a POST test, to ensure the hardware components that are attached to the device are functioning correctly, if POST fails the computer may not be operable and the system will not be proceed to next stage of the boot process 24 | 25 | ![BIOS](../../images/BIOS.PNG) 26 | 27 | #### Boot Loader 28 | - The next stage after BIOS POST is **`Boot Loader`** after successful of POST test. 29 | - BIOS loads and executes the boot code from the boot device, which is located in the first sector of the harddisk. In Linux this is located in the **`/boot`** file system. 30 | - The boot loader will provide the user with the boot screen, often with multiple options to boot into. Such as Microsoft windows O.S or Ubuntu 18.04 O.S in an example of a dual boot system. 31 | - Once the selection is made at the boot screen, boot laoder loads the kernel into the memory supplies it with some parameters and handsover the control to kernel 32 | - A popular example of the boot loader is **`GRUB2`** (GRand Unified Bootloader Version 2). Its a primary boot loader now for most of the operating system. 33 | 34 | ![boot-loader](../../images/boot-loader.PNG) 35 | 36 | #### Kernel Initialization 37 | - After the selected kerenl is selected and loads into the memory, it usually decompress and then loads kernel into the memory. 38 | - At this stage, kernel carries out tasks such as initializing hardware and memory management tasks among other things. 39 | - Once it is completely operational , kernel looks for **`INIT Process`** to run. Which sets up the **`User Space`** and the process is needed for the environment. 40 | 41 | ![kernel-initialize](../../images/kernel-initialize.PNG) 42 | 43 | #### INIT Process 44 | 45 | - In most of the current day linux distribution, the **`INIT`** function then calls the **`systemd`** daemon. 46 | - The **`systemd`** is responsible for bringing the linux host to usable state. 47 | - **`systemd`** is responsible for mounting the file systems, starting and managing system services. 48 | - **`systemd`** is the universal standard these days, but not too long ago another initialization process called **`system V (five) init`** was used. It is also called **`Sys5` 49 | - For example these were used in **`RHEL 6`** or **`CentOS 6`** distribution 50 | - Once of the key advantages of using **`systemd`** over **`system V(five) init`** is that it reduces the system startup time by parallelizing the startup of services. 51 | 52 | To check the **`init`** system used run **`ls -l /sbin/init`**, if it is systemd then you will see a pointer to **`/lib/systemd/systemd`** 53 | ``` 54 | $ ls -l /sbin/init 55 | ``` 56 | 57 | -------------------------------------------------------------------------------- /docs/04-Package-Mangement/02-RPM-and-YUM.md: -------------------------------------------------------------------------------- 1 | # RPM and YUM Package Managers 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/rpm-and-yum/) 4 | 5 | In this section, we will take a look at **`RPM`** and **`YUM`** package managers in detail. 6 | - RPM 7 | - YUM 8 | 9 | ## RPM (Redhat Package Manager) 10 | 11 | This package manager is used in RHEL as well as other linux distributions but these are the most common ones. The File extensions for packages manage by RPM is **`.RPM`** 12 | 13 | ![rpm](../../images/rpm.PNG) 14 | 15 | #### Working with RPM 16 | 17 | RPM has five basic modes of operations. Each of these modes can be run using **`rpm`** command followed by a specific command **`options`**. Despite of this, RPM doesn't resolve dependencies on its own. This is why we make use of a higher level of package manager called **`YUM`**. 18 | 1. Installing 19 | 1. Uninstalling 20 | 1. Upgrade 21 | 1. Query 22 | 1. Verfiying 23 | 24 | ![rpm-modes](../../images/rpm-modes.PNG) 25 | 26 | ## YUM (Yellowdog Updater Modifier) 27 | 28 | YUM is a free and opensource package manager. 29 | - Works on RPM based Linux systems 30 | - Works with Software repositories which are essentially a collection of packages and provides package independency management on RPM based distro. The repository information is stored in **`/etc/yum.repos.d/`** and repository files will have the **`.repo`** extension. 31 | - Acts as a high level package manager but under the hood it still depeneds on **`RPM`** to manage packages on the linux systems. 32 | - Unlike RPM, YUM handles package dependencies very well (Automatic Dependency Resolution). It is able to install any dependencies packages to get the base package install on the linux system. 33 | 34 | ![yum](../../images/yum.PNG) 35 | 36 | #### Let us see how YUM installs a package. 37 | 38 | ![yum-repo](../../images/yum-repo.PNG) 39 | 40 | #### Now, lets take a look at sequence of steps envolve while installing the package. 41 | - Once yum runs **`yum install`** command is issued YUM first runs transaction check, if the package is not installed in the system yum checks the configured repositories under **`/etc/yum.repos.d/`** for the availability of the requested package. 42 | - It also checks if there are any dependent packages are already installed in the system or if it needs to be upgrade. 43 | 44 | ![yum-cmd](../../images/yum-cmd.PNG) 45 | 46 | - After this step, transaction summary is displayed on the screen for the user to review, if we wish to proceed with the install enter the **`y`** button (this step can be skipped by providing the **`-y`** flag with the **`yum install`** command). 47 | - Yum will download and install necessary RPMs to linux system 48 | 49 | ![yum-cmd1](../../images/yum-cmd1.PNG) 50 | 51 | 52 | If you want to update a single package, use **`yum update`** command. If the package is already in the latest version in the repository and hence no action will be taken 53 | 54 | ![yum-update](../../images/yum-update.PNG) 55 | 56 | 57 | #### Common Commands 58 | 59 | To list all the repos added to your system. Run **`yum repolist`** 60 | ``` 61 | $ yum repolist 62 | ``` 63 | 64 | To check which package should be installed for specific command to work. Use **`yum provides`** command followed by name. 65 | ``` 66 | $ yum provides scp 67 | ``` 68 | 69 | To Install a package 70 | ``` 71 | $ yum install httpd 72 | ``` 73 | 74 | To Install a package to automatically answer "yes" to any question prompt during the operation. Use **`-y`** flag with the **`yum install`** command. 75 | ``` 76 | $ yum install httpd -y 77 | ``` 78 | 79 | To remove a package 80 | ``` 81 | $ yum remove httpd 82 | ``` 83 | 84 | To update a package 85 | ``` 86 | $ yum update telnet 87 | ``` 88 | 89 | To update all packages in the system, use the **`yum update`** command without any arguments. 90 | ``` 91 | $ yum update 92 | ``` 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /docs/08-Storage-in-Linux/02-Storage-Basics.md: -------------------------------------------------------------------------------- 1 | # DISK'S & PARTITIONS 2 | 3 | - Take me to the [Tutorial](https://kodekloud.com/topic/disk-partitions/) 4 | 5 | - In this lecture we will learn about Disk Partitions. 6 | - We will look at the File Systems such as EXT series and NFS. 7 | - External Storage Devices such as DAS,NAS, and SAN. 8 | - LVM in Action. 9 | 10 | ![Disk](../../images//disk.PNG) 11 | 12 | #### List all Block devices 13 | 14 | - Block devices are special files that refer to or represent a device (which could be anything from a hard drive to a USB drive). So naturally, there are command line tools that help you with your block devices-related work. 15 | - Major Number is used to identigy the type of block device, value 8 represent a SCSI device starts with SD. 16 | - Minor Number is uset to distuinguish individual, physical or logical devices. 17 | 18 | ``` 19 | [~]$ lsblk 20 | ``` 21 | 22 | ``` 23 | [~]$ ls -l /dev/ | grep "^b" 24 | ``` 25 | 26 | - To Print,Create and Delete the parition table use **`fdisk -l`** command 27 | 28 | ``` 29 | [~]$ sudo fdisk -l /dev/sda 30 | ``` 31 | 32 | #### Partition Types - 33 | 34 | ![Part](../../images//partition.PNG) 35 | 36 | - PRIMARY - Use to Boot an Operating System. 37 | - EXTENDED - Can host logical partitions but cannot be used on its own. 38 | - LOGICAL - Created within an extended partition. 39 | 40 | #### Creating Partitions - 41 | 42 | - **`Gdisk`** is an improved version of the **`fdisk`** that works with the GTP partition table. 43 | - To create a partition on **`sdb`** use 44 | 45 | ``` 46 | [~]$ gdisk /dev/sdb 47 | GPT fdisk (gdisk) version 1.0.1 48 | 49 | Partition table scan: 50 | MBR: protective 51 | BSD: not present 52 | APM: not present 53 | GPT: present 54 | Found valid GPT with protective MBR; using GPT. 55 | 56 | Command (? for help): ? 57 | b back up GPT data to a file 58 | c change a partition's name 59 | d delete a partition 60 | i show detailed information on a partition 61 | l list known partition types 62 | n add a new partition 63 | o create a new empty GUID partition table (GPT) 64 | p print the partition table 65 | q quit without saving changes 66 | r recovery and transformation options (experts only) 67 | s sort partitions 68 | t change a partition's type code 69 | v verify disk 70 | w write table to disk and exit 71 | x extra functionality (experts only) 72 | ? print this menu 73 | 74 | Command (? for help): n 75 | Partition number (1-128, default 1): 1 76 | First sector (34-41943006, default = 2048) or {+-}size{KMGTP}: 2048 77 | Information: Moved requested sector from 34 to 2048 in 78 | order to align on 2048-sector boundaries. 79 | Use 'l' on the experts' menu to adjust alignment 80 | Last sector (2048-41943006, default = 41943006) or {+-}size{KMGTP}: 41943006 81 | Current type is 'Linux filesystem' 82 | Hex code or GUID (L to show codes, Enter = 8300): 83 | Changed type of partition to 'Linux filesystem' 84 | Command (? for help): w 85 | Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING 86 | PARTITIONS!! 87 | Do you want to proceed? (Y/N): Y 88 | OK; writing new GUID partition table (GPT) to /dev/vdb. 89 | The operation has completed successfully. 90 | ``` 91 | 92 | ``` 93 | [~]$ sudo fdisk -l /dev/sdb 94 | Disk /dev/sdb: 20 GiB, 128035676160 bytes, 250069680 sectors 95 | Units: sectors of 1 * 512 = 512 bytes 96 | Sector size (logical/physical): 512 bytes / 512 bytes 97 | I/O size (minimum/optimal): 512 bytes / 512 bytes 98 | Disklabel type: gpt 99 | Disk identifier: 7CABF26E-9723-4406-ZEA1-C2B9B6270A23 100 | Device Start End Sectors Size Type 101 | /dev/sdb1 2048 41943006 204800 20GB Linux filesystem 102 | ``` 103 | 104 | # HANDS-ON LABS 105 | 106 | - [Troubleshoot](https://kodekloud.com/courses/873064/lectures/17074602) why **`Bob's`** System is not displaying the entire size of the physical disk -------------------------------------------------------------------------------- /docs/02-Working-With-Shell-Part-I/05-Bash-Shell.md: -------------------------------------------------------------------------------- 1 | # Bash Shell 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/bash-shell/) 4 | 5 | ## Different types of Shells 6 | 7 | In this section, we will take a look at different types of shells. 8 | - There are different types of shells in linux, some of the popular ones are below 9 | - Bourne Shell (sh) 10 | - C Shell (csh or tsh) 11 | - Korn Shell (ksh) 12 | - Z Shell (zsh) 13 | - Bourne again shell (Bash) 14 | 15 | To check the shell being used. Use the command **`echo $SHELL`** 16 | ``` 17 | $ echo $SHELL 18 | ``` 19 | 20 | To change the default shell. Use the command chsh, you will be prompted for the password and following that input the name of the new shell. You have to login into new terminal session to see this change though. 21 | ``` 22 | $ chsh 23 | ``` 24 | 25 | ## Bash Shell Features 26 | 27 | 1. Bash supports command auto-completion. What this means is bash means to auto-complete commands for you if you type part of it and press the **`tab`** key 28 | 29 | ![bash-auto](../../images/bash-auto.PNG) 30 | 31 | ![bash-auto1](../../images/bash-auto1.PNG) 32 | 33 | 1. In Bash we can set custom aliases for the actual commands 34 | ``` 35 | $ date 36 | $ alias dt=date 37 | $ dt 38 | ``` 39 | 1. Use the **`history`** command to list the previous run commands that you ran earlier 40 | ``` 41 | $ history 42 | ``` 43 | 44 | ## Bash environment variables 45 | 46 | To print **`SHELL`** environment variable 47 | ``` 48 | $ echo $SHELL 49 | ``` 50 | 51 | To see a list of all environment variables. Run **`env`** from the terminal 52 | ``` 53 | $ env 54 | ``` 55 | 56 | To set an environment variable with in the shell. The value is not carry forward to any other process. 57 | ``` 58 | $ OFFICE=caleston 59 | ``` 60 | 61 | To set an environment variable we can use the **`export`** command. To make the value carry forward to any other process. 62 | ``` 63 | $ export OFFICE=caleston 64 | ``` 65 | 66 | To persistently set an environment variable over subsequent login or a reboot add them to the **`~/.profile`** or **`~/.pam_environment`** in the users home directory. 67 | 68 | ``` 69 | $ echo "export OFFICE=caleston" >> ~/.profile (or) 70 | $ echo "export OFFICE=caleston" >> ~/.pam_environment 71 | ``` 72 | 73 | To check the value of a environment variable called **`LOGNAME`** 74 | ``` 75 | $ echo $LOGNAME 76 | ``` 77 | 78 | ## Path Variable 79 | 80 | #### Speaking about the environment variables, when a user issues an external command into the shell, the shell uses path variable to search for these external commands 81 | 82 | To see the directories defined in path variable. Use the command **`echo $PATH`**. 83 | ``` 84 | $ echo $PATH 85 | ``` 86 | 87 | To check if the location of the command can be identified. Use the **`which`** command 88 | 89 | **`Syntax: which `** 90 | 91 | ``` 92 | $ which obs-studio 93 | ``` 94 | 95 | To define a command in the **`PATH`** variable. To add we can use the **`export`** command. 96 | ``` 97 | $ export PATH=$PATH:/opt/obs/bin 98 | $ which obs-studio 99 | ``` 100 | 101 | ## Customize Bash Prompt 102 | 103 | Once you login into the shell, the line you see is the bash prompt. 104 | 105 | ![bash-prompt](../../images/bash-prompt.PNG) 106 | 107 | It can be customized to see the **`username`** and the **`hostname`** 108 | 109 | ![bash-prompt1](../../images/bash-prompt1.PNG) 110 | 111 | #### The bash prompt is set in control by a set of special shell environment variables. The most common of these and the one we will focus on is **`PS1`** variable. 112 | 113 | ![bash-prompt2](../../images/bash-prompt2.PNG) 114 | 115 | To see the value assign to **`PS1`**, type **`echo $PS1`** 116 | ``` 117 | $ echo $PS1 118 | ``` 119 | 120 | To change the PS1 to only display the word **`ubuntu-server`**. 121 | ``` 122 | $ PS1="ubuntu-server" 123 | $ echo $PS1 124 | ``` 125 | 126 | #### To customize further, have a look at the below special character. 127 | 128 | ![bash-prompt3](../../images/bash-prompt3.PNG) 129 | 130 | To change the bash prompt to display **`date`**, **`time`**, **`username of the current user`**, the **`hostname`** and the **`current working directory`** 131 | ``` 132 | $ PS1="[\d \t \u@\h:\w ] $ " 133 | ``` 134 | -------------------------------------------------------------------------------- /docs/07-Networking/02-DNS.md: -------------------------------------------------------------------------------- 1 | # DNS 2 | 3 | - Take me to the [Tutorial](https://kodekloud.com/topic/dns/) 4 | 5 | - The domain name system is a distributed way to share these name-to-IP associations instead of requiring each computer to synchronize a hosts file. A name server publishes the IP address for a domain and provides a single location to update when an IP changes. 6 | 7 | 8 | #### Ping 9 | 10 | - **`Ping`** Command is use to check the remote machine is reachable or not. 11 | 12 | ``` 13 | [~]$ ping 192.168.1.11 14 | Reply from 192.168.1.11: bytes=32 time=4ms TTL=117 15 | Reply from 192.168.1.11: bytes=32 time=4ms TTL=117 16 | ``` 17 | 18 | - To **`Ping`** the remote host with a name instead of **`IP Address`** make an entry in **`/etc/hosts`** file 19 | 20 | ``` 21 | [~]$ cat >> /etc/hosts 22 | 192.168.1.11 db 23 | ``` 24 | 25 | ``` 26 | [~]$ ping db 27 | PING db (192.168.1.11) 56(84) bytes of data. 28 | 64 bytes from db (192.168.1.11): icmp_seq=1 ttl=64 time=0.052 ms 29 | 64 bytes from db (192.168.1.11): icmp_seq=2 ttl=64 time=0.079 ms 30 | ``` 31 | - You can configure as many hosts you want in the **`/etc/hosts`** file. 32 | 33 | ``` 34 | [~]$ cat >> /etc/hosts 35 | 192.168.1.10 web 36 | 192.168.1.11 db 37 | 192.168.1.12 nfs 38 | 192.168.1.20 web 39 | 192.168.1.21 db-1 40 | 192.168.1.22 nfs-1 41 | 192.168.1.30 web-1 42 | 192.168.1.31 db-2 43 | 192.168.1.32 nfs-2 44 | 192.168.1.40 web-2 45 | 192.168.1.41 sql 46 | 192.168.1.42 web-5 47 | 192.168.1.50 web-test 48 | 192.168.1.61 db-prod 49 | 192.168.1.52 nfs-4 50 | 192.168.1.60 web-3 51 | 192.168.1.61 db-test 52 | 192.168.1.62 nfs-prod 53 | ``` 54 | 55 | - Every host has a DNS resolution file **`/etc/resolv.conf`** 56 | 57 | ``` 58 | [~]$ cat /etc/resolv.conf 59 | nameserver 192.168.1.100 60 | ``` 61 | 62 | - The **`/etc/nsswitch.conf`** file is used to configure which services are to be used to determine information such as hostnames, password files, and group files.There is a specific search order according to which it is performed. This order is set in this configuration file. 63 | 64 | ``` 65 | [~]$ cat /etc/nsswitch.conf 66 | … 67 | hosts: files dns 68 | … 69 | ``` 70 | 71 | # DOMAIN NAMES 72 | 73 | ![DNS](../../images//dns.PNG) 74 | 75 | - .com - Commerical or General Purpose. 76 | - .net - Network or General Purpose. 77 | - .edu - Education Purpose 78 | - .org - Organizations for non profit organizations etc. 79 | 80 | ![Root](../../images//root.PNG) 81 | 82 | # RECORD TYPES 83 | 84 | ![Record](../../images//record.PNG) 85 | 86 | - A - IP to host names. 87 | - AAAA - Storing ipv6 to hostnames. 88 | - CNAME - Mapping one name to another. 89 | 90 | - To test the DNS resolution you can use **`nslookup`** command, this will query a hostname from a DNS Server. 91 | 92 | ``` 93 | [~]$ nslookup www.google.com 94 | Server: 8.8.8.8 95 | Address: 8.8.8.8#53 96 | Non-authoritative answer: 97 | Name: www.google.com 98 | Address: 172.217.0.132 99 | ``` 100 | 101 | - Another useful tool to query a hostname from a DNS server is **`dig`** which return more detailed information as shown. 102 | 103 | ``` 104 | [~]$ dig www.google.com 105 | ; <<>> DiG 9.10.3-P4-Ubuntu <<>> www.google.com 106 | ;; global options: +cmd 107 | ;; Got answer: 108 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28065 109 | ;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 1 110 | ;; OPT PSEUDOSECTION: 111 | ; EDNS: version: 0, flags:; udp: 512 112 | ;; QUESTION SECTION: 113 | ;www.google.com. IN A 114 | ;; ANSWER SECTION: 115 | www.google.com. 245 IN A 64.233.177.103 116 | www.google.com. 245 IN A 64.233.177.105 117 | www.google.com. 245 IN A 64.233.177.147 118 | www.google.com. 245 IN A 64.233.177.106 119 | www.google.com. 245 IN A 64.233.177.104 120 | www.google.com. 245 IN A 64.233.177.99 121 | ;; Query time: 5 msec 122 | ;; SERVER: 8.8.8.8#53(8.8.8.8) 123 | ;; WHEN: Sun Mar 24 04:34:33 UTC 2019 124 | ;; MSG SIZE rcvd: 139 125 | ``` 126 | 127 | # HANDS-ON LABS 128 | 129 | - Lets have some fun and challenging [exercises](https://kodekloud.com/courses/873064/lectures/17074530) 130 | -------------------------------------------------------------------------------- /docs/08-Storage-in-Linux/05-LVM.md: -------------------------------------------------------------------------------- 1 | # LOGICAL VOLUME MANAGER 2 | 3 | - Take me to the [Tutorial](https://kodekloud.com/topic/lvm/) 4 | 5 | - LVM allows grouping of multiple physical volumes, which are hard disks or partitions into a volume group. 6 | - Volumegroups can be carve out logical volumes. 7 | 8 | ![LVM](../../images/lvm.PNG) 9 | 10 | #### Working with LVM 11 | 12 | - To make use of LVM, install the package **`LVM`** . 13 | 14 | ``` 15 | [~]$ apt-get install lvm2 16 | ``` 17 | 18 | - Use **`pvcreate`** command to create a Physical Volume. 19 | 20 | ``` 21 | [~]$ pvcreate /dev/sdb 22 | Physical volume "/dev/sdb" successfully created 23 | ``` 24 | 25 | - Use **`vgcreate`** command to create a Volume Group. 26 | 27 | ``` 28 | [~]$ vgcreate caleston_vg /dev/sdb 29 | Volume group "caleston_vg" successfully created 30 | ``` 31 | 32 | - Use **`pvdisplay`** command to list all the PVs their names, size and the Volume group it is part of. 33 | 34 | ``` 35 | [~]$ pvdisplay 36 | --- Physical volume --- 37 | PV Name /dev/sdb 38 | VG Name caleston_vg 39 | PV Size 20.00 GiB / not usable 3.00 MiB 40 | Allocatable yes 41 | PE Size 4.00 MiB 42 | Total PE 5119 43 | Free PE 5119 44 | Allocated PE 0 45 | PV UUID iDCXIN-En2h-5ilJ-Yjqv-GcsR-gDfV-zaf66E 46 | ``` 47 | 48 | - Use **`vgdisplay`** to see more details of the VG. 49 | 50 | ``` 51 | [~]$ vgdisplay 52 | --- Volume group --- 53 | VG Name caleston_vg 54 | System ID 55 | Format lvm2 56 | Metadata Areas 1 57 | Metadata Sequence No 1 58 | VG Access read/write 59 | VG Status resizable 60 | MAX LV 0 61 | Cur LV 0 62 | Open LV 0 63 | Max PV 0 64 | Cur PV 1 65 | Act PV 1 66 | VG Size 20.00 GiB 67 | PE Size 4.00 MiB 68 | Total PE 5119 69 | Alloc PE / Size 0 / 0 70 | Free PE / Size 5119 / 20.00 GiB 71 | VG UUID VzmIAn-9cEl5bA-lVtm-wHKX-KQaObR 72 | ``` 73 | 74 | - To create the Logical Volumes, you can use **`lvcreate`** command 75 | 76 | ``` 77 | [~]$ lvcreate –L 1G –n vol1 caleston_vg 78 | Logical volume "vol1" created. 79 | ``` 80 | 81 | - To display the Logical Volumes, you can use **`lvdisplay`** command 82 | 83 | ``` 84 | [~]$ lvdisplay 85 | --- Logical volume --- 86 | LV Path /dev/caleston_vg/vol1 87 | LV Name vol1 88 | VG Name caleston_vg 89 | LV UUID LueYC3-VWpE31-UaYk-wjIR-FjAOyL 90 | LV Write Access read/write 91 | LV Creation host, time master, 2020-03-31 06:26:14 92 | LV Status available 93 | # open 0 94 | LV Size 1.00 GiB 95 | Current LE 256 96 | Segments 1 97 | Allocation inherit 98 | Read ahead sectors auto 99 | - currently set to 256 100 | Block device 252:0 101 | ``` 102 | 103 | - To list the volume, you can use **`lvs`** command 104 | 105 | ``` 106 | [~]$ lvs 107 | LV VG Attr LSize Pool 108 | vol1 caleston_vg -wi-a----- 1.00g 109 | ``` 110 | 111 | - Now to create an filesystem you can use **`mkfs`** command 112 | 113 | ``` 114 | [~]$ mkfs.ext4 /dev/caleston_vg/vol1 115 | ``` 116 | 117 | - To mount the filesystem use **`mount`** command 118 | 119 | ``` 120 | [~]$ mount –t ext4 /dev/caleston_vg/vol1 /mnt/vol1 121 | ``` 122 | 123 | - Now logical volume is now available for use. Lets resize the filesystem on vol1 while it is mounted. Check the free space available. 124 | 125 | ``` 126 | [~]$ vgs 127 | VG #PV #LV #SN Attr VSize VFree 128 | caleston_vg 1 1 0 wz--n- 20.00g 19.00g 129 | ``` 130 | 131 | ``` 132 | [~]$ lvresize -L +1G -n /dev/caleston_vg/vol1 133 | Logical volume vol1 successfully resized. 134 | ``` 135 | 136 | ``` 137 | [~]$ df –hP /mnt/vol1 138 | Filesystem Size Used Avail Use% Mounted on 139 | /dev/mapper/caleston_vg-vol1 976M 1.3M 908M 1% /mnt/vol1 140 | ``` 141 | 142 | - Now to resize the file system use **`resize2fs`** command. 143 | 144 | ``` 145 | [~]$ resize2fs /dev/caleston_vg/vol1 146 | resize2fs 1.42.13 (17-May-2015) 147 | Filesystem at /dev/mapper/caleston_vg-vol1 is mounted on 148 | /mnt/vol1; on-line resizing required 149 | old_desc_blocks = 1, new_desc_blocks = 1 150 | The filesystem on //dev/mapper/caleston_vg-vol1 is now 524288 151 | (4k) blocks long. 152 | ``` 153 | 154 | - Now run **`df -hp`** command to verify the size of the mounted filesystem 155 | 156 | ``` 157 | [~]$ df –hP /mnt/vol1 158 | Filesystem Size Used Avail Use% Mounted on 159 | /dev/mapper/caleston_vg-vol1 2.0G 1.6M 1.9G 1% /mnt/vol1 160 | ``` 161 | 162 | ![LVM2](../../images/lvm2.PNG) 163 | 164 | # HANDS-ON LABS 165 | 166 | - Lets head over to the hands-on labs of [LVM](https://kodekloud.com/courses/873064/lectures/17074607) -------------------------------------------------------------------------------- /docs/02-Working-With-Shell-Part-I/01-Introduction-to-Shell.md: -------------------------------------------------------------------------------- 1 | # Working with the shell - I 2 | 3 | ### Introduction to Shell 4 | 5 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/introduction-to-shell/) 6 | 7 | In this section, we will take a look at linux shell in detail. 8 | - We will learn how to use linux commands and understand how to work with files and directories. 9 | - We will also see different ways to get help with linux commands. 10 | - Finally, we will learn about different types of shells used in Linux (particulary focusing on the bash shell) 11 | 12 | #### Linux shell 13 | 14 | ![Shell](../../images/Shell.PNG) 15 | 16 | - This command line interface (CLI) will enable you to effectively work on linux laptop/server/virtual machine. 17 | - While the graphical version may see more appealing to the users but can be limited in case of functionality. These is where the Linux command line commonly known as **`Linux Shell`** shines. 18 | 19 | #### What is a shell? 20 | 21 | - Linux shell is a program that allows text based interaction between the user and the operating system, this interaction is carried out by typing commands into the interface and receving the response in the same way. 22 | - The Linux shell is a powerful tool with which you can navigate between different locations within the system, however when you login to the shell the very first directory you were take into is your home directory. 23 | 24 | #### The Home Directory 25 | 26 | ![The-Home-Directory](../../images/The_Home_Directory.JPG) 27 | 28 | - A user **`michael`** home directory created under **`/home/michael`**, where **`/home`** is a system created home directory that contains the home directories for almost all users in the linux system. 29 | - The name of the home directory is by default identical to the name of the user, hence **`michael's`** home directory is **`/home/michael`**. 30 | - Remember the home directory is unique for each user. Another user called **`allen`** will have a different home directory which by default created under **`/home/allen`**. 31 | 32 | ##### Why do we need a home directoy? 33 | - The home directory allows users to store their personal data in the form of files and directories 34 | - Each user in the system gets their own unique home directory with complete access to it (to be able to save, retreive , delete data). 35 | - Think of it as a dedicated locker assign to you in which you can store or retreive items. 36 | - Other users can't access your files and folders with in your home directory (only you can). 37 | 38 | **Note** : The representation of the home directory is represented as by the `~ (tilde symbol).` 39 | 40 | #### Command Prompt 41 | 42 | - You can configure the command prompt to show whatever you want, such as the **`hostname`** , **`date`** or **`time`**. 43 | - It is currently configured to show the current working directory. The **`~` symbol** here represents the home directory 44 | 45 | #### Command and Arguments 46 | 47 | - To interact with the linux system using the shell, a user has to type in commands 48 | - When a command is run it executes a program to achieve a specific task. 49 | - **`For example`**: The **`echo`** command is used to print a line of text on the screen. 50 | ``` 51 | $ echo 52 | ``` 53 | - An argument acts as an input to command 54 | - **`For example`**: To print a **`hello`** message type **`echo hello`** command. 55 | ``` 56 | $ echo hello 57 | ``` 58 | - There are several commands that can work without an argument too. 59 | - **`For example`**: Type in the command called **`uptime`**, this is used to print information about how long a system has been running for since the last reboot along with the other information (This command doesn't need an argument) 60 | ``` 61 | $ uptime 62 | ``` 63 | - A command can also have options that modify its behaviour in some predetermine way. The option also sometime referred to as a switch or a flag 64 | - **`For example`**: To print a same word `hello` but without a trailing line, use **`echo`** command with **`-n`** flag. 65 | ``` 66 | $ echo -n hello 67 | ``` 68 | 69 | ![Command-and-Arguments](../../images/Command-and-Arguments.PNG) 70 | 71 | #### Command Types 72 | 73 | Command types in linux can be generally categorized in two types 74 | 1. Internal or Built-in Commands 75 | - Internal commands are part of the shell itself. It come bundled with it, there are in total about 30 such commands 76 | - **`For example`**: echo, cd, pwd, set e.t.c. 77 | 1. External Commands 78 | - External commands on the other hand are binary programs or scripts which are usually located in distinct files in the system. They either come with pre-install with the distribution package manager or can be created or installed by the user 79 | - **`For Example`**: mv, date, uptime, cp e.t.c. 80 | 81 | To determine a command is internal or external, use **`type`** command 82 | 83 | ![Command-Types](../../images/Command-Types.PNG) 84 | -------------------------------------------------------------------------------- /docs/09-Service-management-with-SYSTEMD/03-SYSTEMD-Tools.md: -------------------------------------------------------------------------------- 1 | # SYSTEMD Tools to Manage SYSTEMD service 2 | 3 | - Take me to the [Tutorial](https://kodekloud.com/topic/systemd-tools/) 4 | 5 | In this lecture we will explore two major SYSTEMD tools: 6 | - SYSTEMCTL 7 | - JOURNALCTL 8 | 9 | ## SYSTEMCTL 10 | 11 | - __Systemctl__ is the main command used to manage services on a **`SYSTEMD`** managed server. 12 | - It can be used to manage services such as **`START/STOP/RESTART/RELOAD`** as well as **`ENABLE/DISABLE`** services 13 | during the system boot. 14 | - It is also used to **`LIST AND MANAGE UNITS`** and **`LIST AND UPDATE TARGETS`** 15 | 16 | ![Systemctl](../../images/systemctl.png) 17 | 18 | ### Systemctl Commands 19 | 20 | - To start a service use the start command, for example to start a docker service use **`systemctl start docker`** 21 | 22 | ``` 23 | [~]$ systemctl start docker 24 | ``` 25 | 26 | - To stop a service use the stop command, for example to stop a docker service use **`systemctl stop docker`** 27 | 28 | ``` 29 | [~]$ systemctl stop docker 30 | ``` 31 | - To restart a service use the restart command, for example to restart a docker service use **`systemctl restart docker`** this will stop and start again. 32 | 33 | ``` 34 | [~]$ systemctl restart docker 35 | ``` 36 | - To reload a service use the reload command, for example to reload a docker service use **`systemctl reload docker`**, this will reload all the configuration without interrupting the normal functionaltiy of the service 37 | 38 | ``` 39 | [~]$ systemctl reload docker 40 | ``` 41 | - To enable a service and make it persistent accross reboots use the enable command, for example to enable a docker service use **`systemctl enable docker`** 42 | 43 | ``` 44 | [~]$ systemctl enable docker 45 | ``` 46 | 47 | - To disable a service at boot use the disable command, for example to disable a docker service use **`systemctl disable docker`** command. 48 | 49 | ``` 50 | [~]$ systemctl disable docker 51 | ``` 52 | 53 | - To know the status of the service use **`systemctl status docker`** command. This command provided the state of the service. If running properly is should show **`active (running)`** state as shown in screenshot below. 54 | 55 | ``` 56 | [~]$ systemctl status docker 57 | ``` 58 | 59 | - Besides **`active (running)`** state there are few other state that you should be aware off. 60 | 61 | ![Other](../../images/otherstate.PNG) 62 | 63 | - Running **`systemctl daemon reload`** command after making changes to service unit file reloads the system manager configuration and makes the systemd aware of the changes. 64 | 65 | - To edit the service file use command **`systemctl edit project-mercury.service --full`** this will open a text editor, you can make the changes and re-write the settings as needed, making changing this way applied immediately without running the **`systemctl daemon reload`** command 66 | 67 | ``` 68 | [~]$ systemctl daemon-reload 69 | [~]$ systemctl edit project-mercury.service --full 70 | ``` 71 | - To see the current runlevel use **`systemctl get-default`** 72 | 73 | ``` 74 | [~]$ systemctl get default 75 | ``` 76 | 77 | - To change the runleve to a different target use **`systemctl set-default multi-user.target`** 78 | 79 | ``` 80 | [~]$ systemctl set-default multi-user.target 81 | ``` 82 | 83 | - To list all the units that systemd has loaded use **`systemctl list-units --all`**, this lists all the unit which are active, inactive or anyother state. 84 | 85 | ``` 86 | [~]$ systemctl list-units --all 87 | ``` 88 | 89 | - To list only active units use **`systemctl list-units`** command 90 | 91 | ``` 92 | [~]$ systemctl list-units 93 | ``` 94 | 95 | - To view, and also locate a unit file use **`systemctl cat`** command. A comment line containing the path to the unit file is printed as the first line of output. 96 | 97 | ``` 98 | [~]$ systemctl cat project-mercury.service 99 | ``` 100 | 101 | ## JOURNALCTL 102 | 103 | - __Journalctl__ is a command for quering/viewing logs collected by systemd. 104 | - The systemd-journald service is responsible for systemd’s log collection, and it retrieves messages from the kernel systemd services, and other sources. 105 | - Very useful when you are troubleshooting issues with systemd services. 106 | 107 | ![Journalctl](../../images/journalctl.png) 108 | 109 | - Using **`journalctl`** commands print all the log entries from oldest to the newest. 110 | 111 | ``` 112 | [~]$ journalctl 113 | ``` 114 | - Using **`journalctl -b`** command print all the logs from the current boot. 115 | 116 | ``` 117 | [~]$ journalctl -b 118 | ``` 119 | - Using **`journalctl -u docker.service`** command print all the logs specific to the unit specified, for example docker in this case. 120 | 121 | ``` 122 | [~]$ journalctl -u docker.service 123 | ``` 124 | 125 | - Using **`journalctl -u docker.service --since`** command print all the logs specific to the unit specified since the given time, for example docker in this case. 126 | 127 | ``` 128 | [~]$ journalctl -u docker.service --since "2022-01-01 13:45:00" 129 | ``` 130 | 131 | ## HANDS-ON LABS 132 | 133 | - Now lets troubleshoot and help **`Bob`** [Let's Help Bob](https://kodekloud.com/courses/the-linux-basics-course/lectures/17074647) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Linux Basics Course 2 | 3 | These are notes from the [Linux Basics Course](https://bit.ly/3gGnxm0) hosted on KodeKloud. 4 | 5 | # Table of Contents 6 | 7 | - [01-Introduction](docs/01-Introduction) 8 | 9 | - [02-Working-With-Shell-Part-I](docs/02-Working-With-Shell-Part-I) 10 | 11 | - [01-Introduction-to-Shell](docs/02-Working-With-Shell-Part-I/01-Introduction-to-Shell.md) 12 | - [02-Basic-Commands](docs/02-Working-With-Shell-Part-I/02-Basic-Commands.md) 13 | - [03-Command-Line-Help](docs/02-Working-With-Shell-Part-I/03-Command-Line-Help.md) 14 | - [04-Lab-Working-With-Shell](docs/02-Working-With-Shell-Part-I/04-lab-working-with-shell.md) 15 | - [05-Bash-Shell](docs/02-Working-With-Shell-Part-I/05-Bash-Shell.md) 16 | - [06-Lab-Linux-Bash-Shell](docs/02-Working-With-Shell-Part-I/06-Lab-Linux-Bash-Shell.md) 17 | 18 | - [03-Linux-Core-Concepts](docs/03-Linux-Core-Concepts) 19 | 20 | - [01-Bobs-First-Team-Meeting](docs/03-Linux-Core-Concepts/01-Bobs-first-team-meeting.md) 21 | - [02-The-Linux-Kernel](docs/03-Linux-Core-Concepts/02-The-Linux-Kernel.md) 22 | - [03-Working-With-Hardware](docs/03-Linux-Core-Concepts/03-Working-with-hardware.md) 23 | - [04-Lab-Linux-Kernel](docs/03-Linux-Core-Concepts/04-Lab-Linux-Kernel.md) 24 | - [05-Linux-Boot-Sequence](docs/03-Linux-Core-Concepts/05-Linux-Boot-Sequence.md) 25 | - [06-Run-Levels](docs/03-Linux-Core-Concepts/06-Run-Levels.md) 26 | - [07-File-Types](docs/03-Linux-Core-Concepts/07-File-Types.md) 27 | - [08-Filesystem-Hierarchy](docs/03-Linux-Core-Concepts/08-Filesystem-Hierarchy.md) 28 | - [09-Lab-Linux-RunLevels-Filesystem-Hierarchy](docs/03-Linux-Core-Concepts/09-Lab-Linux-RunLevels-Filesystem-Hierarchy.md) 29 | 30 | 31 | - [04-Package-Mangement](docs/04-Package-Mangement) 32 | 33 | - [01-Package-Management-Distribution](docs/04-Package-Mangement/01-Package-Management-Distribution.md) 34 | - [02-RPM-and-YUM](docs/04-Package-Mangement/02-RPM-and-YUM.md) 35 | - [03-Lab-RPM-and-YUM](docs/04-Package-Mangement/03-Lab-RPM-and-YUM.md) 36 | - [04-DPKG-AND-APT](docs/04-Package-Mangement/04-DPKG-AND-APT.md) 37 | - [05-APT-vs-APT-GET](docs/04-Package-Mangement/05-APT-vs-APT-GET.md) 38 | - [06-Lab-DPKG-AND-APT](docs/04-Package-Mangement/06-Lab-DPKG-AND-APT.md) 39 | 40 | 41 | - [05-Working-With-Shell-Part-II](docs/05-Working-With-Shell-Part-II) 42 | 43 | - [01-Behind-Schedule(story)](docs/05-Working-With-Shell-Part-II/01-Behind-Schedule(story).md) 44 | - [02-File-Compression-and-Archival](docs/05-Working-With-Shell-Part-II/02-File-Compression-and-Archival.md) 45 | - [03-Searching-For-Files-and-Patterns](docs/05-Working-With-Shell-Part-II/03-Searching-for-files-and-patterns.md) 46 | - [04-IO-Redirection](docs/05-Working-With-Shell-Part-II/04-IO-Redirection.md) 47 | - [05-Lab-Working-With-Shell-Part-II](docs/05-Working-With-Shell-Part-II/05-Lab-Working-With-Shell-Part-II.md) 48 | - [06-Vi-Editor](docs/05-Working-With-Shell-Part-II/06-Vi-Editor.md) 49 | - [07-Lab-VI-Editor](docs/05-Working-With-Shell-Part-II/07-Lab-VI-Editor.md) 50 | 51 | - [06-Security-and-File-Permissions](docs/06-Security-and-File-Permissions) 52 | 53 | - [01-The-Security-Incident(story)](docs/06-Security-and-File-Permissions/01-The-Security-Incident(story).md) 54 | - [02-Linux-Accounts](docs/06-Security-and-File-Permissions/02-Linux-Accounts.md) 55 | - [03-User-Management](docs/06-Security-and-File-Permissions/03-User-Management.md) 56 | - [04-Access-Control-Files](docs/06-Security-and-File-Permissions/04-Access-Control-Files.md) 57 | - [05-File-Permissions](docs/06-Security-and-File-Permissions/05-File-Permissions.md) 58 | - [06-SSH-and-SCP](docs/06-Security-and-File-Permissions/06-SSH-and-SCP.md) 59 | - [07-IPtables](docs/06-Security-and-File-Permissions/07-IPtables.md) 60 | - [08-Cronjob](docs/06-Security-and-File-Permissions/08-Cronjob.md) 61 | 62 | - [07-Networking](docs/07-Networking) 63 | 64 | - [01-The-Network-Issue(story)](docs/07-Networking/01-The-Network-Issue(story).md) 65 | - [02-DNS](docs/07-Networking/02-DNS.md) 66 | - [03-Networking-Basics](docs/07-Networking/03-Networking-Basics.md) 67 | - [04-Troubleshooting](docs/07-Networking/04-Troubleshooting.md) 68 | 69 | - [08-Storage-in-Linux](docs/08-Storage-in-Linux) 70 | 71 | - [01-Where's-my-Storage](docs/08-Storage-in-Linux/01-Where's-my-Storage.md) 72 | - [02-Storage-Basics](docs/08-Storage-in-Linux/02-Storage-Basics.md) 73 | - [03-File-System-in-Linux](docs/08-Storage-in-Linux/03-File-System-in-Linux.md) 74 | - [04-DAS-NAS-and-SAN](docs/08-Storage-in-Linux/04-DAS-NAS-and-SAN.md) 75 | - [05-LVM](docs/08-Storage-in-Linux/05-LVM.md) 76 | - [06-Project-Status-Meeting](docs/08-Storage-in-Linux/06-Project-Status-Meeting.md) 77 | 78 | - [09-Service-management-with-SYSTEMD](docs/09-Service-management-with-SYSTEMD) 79 | 80 | - [01-Working-Overtime-Story](docs/09-Service-management-with-SYSTEMD/01-Working-Overtime-Story.md) 81 | - [02-Creating-a-SYSTEMD-Service](docs/09-Service-management-with-SYSTEMD/02-Creating-a-SYSTEMD-Service.md) 82 | - [03-SYSTEMD-Tools](docs/09-Service-management-with-SYSTEMD/03-SYSTEMD-Tools.md) 83 | 84 | - [10-The-Client-Demonstration](docs/10-The-Client-Demonstration) 85 | 86 | - [01-Client-Demonstration-in-Jeopardy!(story)](docs/10-The-Client-Demonstration/01-Client-Demonstration-in-Jeopardy!(story).md) 87 | - [02-Troubleshoot-the-Development-Environment](docs/10-The-Client-Demonstration/02-Troubleshoot-the-Development-Environment.md) 88 | - [03-Finale(story)](docs/10-The-Client-Demonstration/03-Finale(story).md) 89 | -------------------------------------------------------------------------------- /docs/02-Working-With-Shell-Part-I/02-Basic-Commands.md: -------------------------------------------------------------------------------- 1 | # Basic Linux Commands 2 | 3 | - Take me to the [Video Tutorial](https://kodekloud.com/topic/basic-linux-commands-3/) 4 | 5 | In this section, we will take a look at basic linux commands 6 | - Specifically related to navigation and creating new files and directories. 7 | - We will do this by completing a simple task using a linux shell. 8 | 9 | #### Our goal is to create a directory structure, the top most directory which is **`/home/michael`** which is already created as it as a home directory but everything else underneath has to be created. 10 | 11 | ![mkdir_cd_working_with_shell_I](../../images/mkdir_cd_working_with_shell_I.PNG) 12 | 13 | To print the present working directory. Run **`pwd`** command 14 | ``` 15 | $ pwd 16 | ``` 17 | 18 | To see the contents of the directory. Run **`ls`** command 19 | ``` 20 | $ ls 21 | ```` 22 | 23 | To make (or) create a directory. Run **`mkdir`** command 24 | ``` 25 | $ mkdir Asia 26 | ``` 27 | 28 | To make (or) create multiple directories. Run **`mkdir`** command followed by **` .. `** 29 | ``` 30 | $ mkdir Europe Africa America 31 | ``` 32 | 33 | To change a directory from the current directory. Run **`cd `** 34 | ``` 35 | $ cd Asia 36 | ``` 37 | 38 | To recursively created directories. Run **`mkdir -p /`** 39 | ``` 40 | $ mkdir -p India/Mumbai 41 | ``` 42 | 43 | To go back to one directory up. Run **`cd ..`** 44 | ``` 45 | $ cd .. 46 | ``` 47 | 48 | To go back directly to a home directory of the current user from any location in the system. Run **`cd`** 49 | ``` 50 | $ cd 51 | ``` 52 | 53 | #### Lets now look at absolute path and relative path 54 | 55 | 56 | 57 | ![Absolute_and_relative_path_working_with_shell_I](../../images/Absolute_and_relative_path_working_with_shell_I.PNG) 58 | 59 | **Difference Between Absolute and Relative Path** 60 | 61 | - **Absolute Path** : An absolute path is defined as specifying the location of a file or directory from the root directory(/). 62 | - **Relative Path** : Relative path is defined as the path related to the present working directly(pwd). 63 | 64 | To change to a directory with absolute path. Run **`cd `** 65 | ``` 66 | $ cd /home/michael 67 | ``` 68 | 69 | To Change to a directory with relative path. Run **`cd `** 70 | ``` 71 | $ cd Asia 72 | ``` 73 | 74 | #### Lets now take a look at alternatives to the **`cd`** command 75 | 76 | ![pushd_popd](../../images/pushd_popd.PNG) 77 | 78 | Alternative to the **`cd`** is the **`pushd\popd`** command. To change directory using pushd, run **`pushd `** 79 | ``` 80 | $ pushd /etc 81 | ``` 82 | 83 | You can change to subdirecties under /etc as many times as you wish 84 | ``` 85 | $ pushd /var 86 | $ pushd /tmp 87 | $ pwd 88 | /etc/var/tmp 89 | ``` 90 | 91 | To return back to origin directory(say your home directory), use the **`popd`** command 92 | ``` 93 | $ popd 94 | ``` 95 | 96 | #### Now lets move on to look some more basic commands in linux. To learn these commands we will make use of the same directory structure as before, however now there are some new files and directories added as shown in the diagram. The goal of this task is to make sure the directory structure looks like the below diagram . 97 | 98 | ![before_after_commands](../../images/before_after_commands.PNG) 99 | 100 | To move file or directory. Run **`mv `** command 101 | ``` 102 | $ mv /home/michael/Europe/Morocco /home/michael/Africa/ (Absolute path) 103 | $ mv Europe/Morocco Africa/ (Relative Path) 104 | ``` 105 | 106 | To rename a directory. Run **`mv `** command 107 | ``` 108 | $ mv Asia/India/Munbai Asia/India/Mumbai 109 | ``` 110 | 111 | To copy a file to a directory. Run **`cp `** command 112 | ``` 113 | $ cp Asia/India/Mumbai/City.txt Africa/Egypt/Cairo 114 | ``` 115 | 116 | To delete a file from a directory. Run **`rm /path/`** command 117 | ``` 118 | $ rm Europe/UK/London/Tottenham.txt 119 | ``` 120 | 121 | To copy a directory recursively. Run **`cp -r `** command 122 | ``` 123 | $ cp -r Europe/UK Europe/UnitedKingdom 124 | ``` 125 | 126 | To print the content of a file. Run **`cat /path/to/`** command 127 | ``` 128 | $ cat Asia/India/Mumbai/City.txt 129 | ``` 130 | 131 | To add a content to a file with cat(redirect) . Run **`cat > /path/to/`** command 132 | ``` 133 | $ cat > Africa/Egypt/Cairo/City.txt 134 | Cairo 135 | `Type Ctrl + d from keyboard` 136 | ``` 137 | 138 | To create an empty file. Run **`touch /path/to/filename`** command 139 | ``` 140 | $ touch /home/michael/Asia/China/Country.txt 141 | ``` 142 | 143 | To see the content of a file in a scrollable manner. Run **`more /path/to/filename`** command <-- not recommended for large files 144 | ``` 145 | $ more new_file.txt 146 | ``` 147 | 148 | To see the content of a file and navigate throught the file. Run **`less /path/to/filename`** command 149 | ``` 150 | $ less new_file.txt 151 | ``` 152 | 153 | To get the long list of files and directories. Run **`ls -l`** command 154 | ``` 155 | $ ls -l 156 | ``` 157 | 158 | To list all files including the hidden. Run **`ls -la`** command 159 | ``` 160 | $ ls -a 161 | ``` 162 | 163 | To list all the files in the order they were modified. Run **`ls -lt`** command 164 | ``` 165 | $ ls -lt 166 | ``` 167 | 168 | To list all the files form oldest to newest. Run **`ls -ltr`** command 169 | ``` 170 | $ ls -ltr 171 | ``` 172 | 173 | -------------------------------------------------------------------------------- /docs/06-Security-and-File-Permissions/07-IPtables.md: -------------------------------------------------------------------------------- 1 | # IPTABLES 2 | 3 | - Take me to the [Tutorial](https://kodekloud.com/topic/iptables-introduction/) 4 | - In this lecture, we will learn about IPtables basic commands. 5 | 6 | **Iptables** uses a set of tables that have chains that contain a set of built-in or user-defined rules. 7 | - The two types of tables/rules: 8 | 1. **FILTER** – this is the default table, which contains the built-in chains for: 9 | **`INPUT`** – packages destined for local sockets. 10 | **`FORWARD`** – packets routed through the system. 11 | **`OUTPUT`** – packets generated locally. 12 | 2. **NAT** – a table that is consulted when a packet tries to create a new connection. It has the following built-in: 13 | **`PREROUTING`** – used for altering a packet as soon as it’s received. 14 | **`OUTPUT`** – used for altering locally-generated packets. 15 | **`POSTROUTING`** – used for altering packets as they are about to go out. 16 | 17 | - For **installing** IPtables in **Ubuntu** servers, 18 | 19 | ``` 20 | bob@devapp01:~$sudo apt install iptables 21 | ``` 22 | 23 | - To **list** the iptables rules, 24 | 25 | ``` 26 | bob@devapp01:~$sudo iptables -L 27 | 28 | Chain INPUT (policy ACCEPT) 29 | target prot opt source destination 30 | 31 | Chain FORWARD (policy ACCEPT) 32 | target prot opt source destination 33 | 34 | Chain OUTPUT (policy ACCEPT) 35 | target prot opt source destination 36 | ``` 37 | 38 | - To allow incoming connection from **IP** **172.16.238.187** to port **22** and **80**, you can run the following command. 39 | 40 | ``` 41 | sudo iptables -A INPUT -p TCP -s 172.16.238.187 --dport 22 -j ACCEPT 42 | ``` 43 | 44 | ``` 45 | sudo iptables -A INPUT -p TCP -s 172.16.238.187 --dport 80 -j ACCEPT 46 | ``` 47 | 48 | The -A or --append option appends the rule at the end of the selected chain. 49 | The -s or --source option Source specification. 50 | The -j, --jump option specifies the target of the rule. 51 | The -p, --protocol option defines protocol of the rule or the packet to check 52 | The --dport or --destination-port refers to the destination port. 53 | The --sport or --source-port refers to source port. 54 | 55 | - To list the **iptables rules**, 56 | 57 | ``` 58 | bob@devapp01:~$ sudo iptables -L 59 | Chain INPUT (policy ACCEPT) 60 | target prot opt source destination 61 | ACCEPT tcp -- caleston-lp10 anywhere tcp dpt:ssh 62 | ACCEPT tcp -- caleston-lp10 anywhere tcp dpt:http 63 | 64 | Chain FORWARD (policy ACCEPT) 65 | target prot opt source destination 66 | 67 | Chain OUTPUT (policy ACCEPT) 68 | target prot opt source destination 69 | ``` 70 | 71 | - To drop **incoming connections** from any **source** on any **destination port** for any **protocol** 72 | 73 | ``` 74 | bob@devapp01:~$sudo iptables -A INPUT -j DROP 75 | ``` 76 | 77 | ``` 78 | bob@devapp01:~$ sudo iptables -L 79 | Chain INPUT (policy ACCEPT) 80 | target prot opt source destination 81 | ACCEPT tcp -- caleston-lp10 anywhere tcp dpt:ssh 82 | ACCEPT tcp -- caleston-lp10 anywhere tcp dpt:ssh 83 | ACCEPT tcp -- caleston-lp10 anywhere tcp dpt:http 84 | DROP all -- anywhere anywhere 85 | 86 | Chain FORWARD (policy ACCEPT) 87 | target prot opt source destination 88 | 89 | Chain OUTPUT (policy ACCEPT) 90 | target prot opt source destination 91 | ``` 92 | 93 | Difference between **`DROP`** and **`REJECT`** 94 | Both DROP and REJECT prohibits packets from passing through the firewall. But, the main difference between them is the response message. 95 | 96 | When we use the DROP command, it will not forward the packet or answer it. But, simply drops the packet silently. 97 | 98 | And, no indication is sent to the client or server. 99 | 100 | But, the REJECT command sends an error message back to the source indicating a connection failure. 101 | 102 | - To block outgoing traffic to any destination on **port 80** 103 | 104 | ``` 105 | bob@devapp01:~$sudo iptables -A OUTPUT -p tcp --dport 80 -j DROP 106 | ``` 107 | This will add rule in the **OUTPUT** chain 108 | 109 | ``` 110 | bob@devapp01:~$ sudo iptables -L 111 | Chain INPUT (policy ACCEPT) 112 | target prot opt source destination 113 | ACCEPT tcp -- caleston-lp10 anywhere tcp dpt:ssh 114 | ACCEPT tcp -- caleston-lp10 anywhere tcp dpt:ssh 115 | ACCEPT tcp -- caleston-lp10 anywhere tcp dpt:http 116 | DROP all -- anywhere anywhere 117 | 118 | Chain FORWARD (policy ACCEPT) 119 | target prot opt source destination 120 | 121 | Chain OUTPUT (policy ACCEPT) 122 | target prot opt source destination 123 | DROP tcp -- anywhere anywhere tcp dpt:http 124 | ``` 125 | 126 | - To allow https connection from the server to **`google.com`** 127 | ``` 128 | bob@devapp01:~$ sudo iptables -I OUTPUT -p tcp -d google.com --dport 443 -j ACCEPT 129 | ``` 130 | 131 | - **Unblock IP Address** or to **delete** a rule in IPtables Firewall 132 | 133 | - First find the **line-number** of the rule using the command below 134 | 135 | ``` 136 | bob@devapp01:~$ sudo iptables -L --line-numbers 137 | Chain INPUT (policy ACCEPT) 138 | num target prot opt source destination 139 | 1 ACCEPT tcp -- caleston-lp10 anywhere tcp dpt:ssh 140 | 2 ACCEPT tcp -- caleston-lp10 anywhere tcp dpt:ssh 141 | 3 DROP all -- anywhere anywhere 142 | 143 | Chain FORWARD (policy ACCEPT) 144 | num target prot opt source destination 145 | 146 | Chain OUTPUT (policy ACCEPT) 147 | num target prot opt source destination 148 | 1 ACCEPT tcp -- anywhere google.com tcp dpt:https 149 | 2 ACCEPT tcp -- anywhere devdb01 tcp dpt:postgresql 150 | 3 ACCEPT tcp -- anywhere caleston-repo-01 tcp dpt:http 151 | 4 DROP tcp -- anywhere anywhere tcp dpt:http 152 | 5 DROP tcp -- anywhere anywhere tcp dpt:https 153 | ``` 154 | 155 | - Now if you want to delete the **INPUT** rule number 3, run 156 | 157 | ``` 158 | sudo iptables -D INPUT 3 159 | ``` 160 | - To display the **line number** for the rules, 161 | 162 | ``` 163 | bob@devapp01:~$ sudo iptables -L --line-numbers 164 | Chain INPUT (policy ACCEPT) 165 | num target prot opt source destination 166 | 1 ACCEPT tcp -- caleston-lp10 anywhere tcp dpt:ssh 167 | 2 ACCEPT tcp -- caleston-lp10 anywhere tcp dpt:ssh 168 | 169 | Chain FORWARD (policy ACCEPT) 170 | num target prot opt source destination 171 | 172 | Chain OUTPUT (policy ACCEPT) 173 | num target prot opt source destination 174 | 1 ACCEPT tcp -- anywhere google.com tcp dpt:https 175 | 2 ACCEPT tcp -- anywhere devdb01 tcp dpt:postgresql 176 | 3 ACCEPT tcp -- anywhere caleston-repo-01 tcp dpt:http 177 | 4 DROP tcp -- anywhere anywhere tcp dpt:http 178 | 5 DROP tcp -- anywhere anywhere tcp dpt:https 179 | ``` 180 | 181 | - Allow Multiple Ports on IPtables using **`Multiport`** 182 | 183 | ``` 184 | iptables -A INPUT -p tcp -m multiport --dports 22,80,443 -j ACCEPT 185 | iptables -A OUTPUT -p tcp -m multiport --sports 22,80,443 -j ACCEPT 186 | ``` 187 | 188 | --sport or --source-port refers to source port. 189 | 190 | - To Block Incoming **`Ping Requests`** on IPtables on an interface say **eth0**, 191 | 192 | ``` 193 | iptables -A INPUT -p icmp -i eth0 -j DROP 194 | ``` 195 | 196 | - To Block Access to Specific **`MAC Address`** on IPtables 197 | 198 | ``` 199 | iptables -A INPUT -m mac --mac-source 0e:Ds:8n:mq:00:de -j DROP 200 | 201 | 0e:Ds:8n:mq:00:de refers to mac address to be blocked 202 | ``` -------------------------------------------------------------------------------- /docs/10-The-Client-Demonstration/02-Troubleshoot-the-Development-Environment.md: -------------------------------------------------------------------------------- 1 | # Troubleshoot the Development Environment 2 | 3 | [Troubleshoot](https://kodekloud.com/topic/lab-troubleshoot-the-development-environment/) the Development Environment 4 | 5 | 6 | 1. Information only 7 | 1. Information only 8 | 1.
9 | Copy the file caleston-code.tar.gz from Bob's laptop to Bob's home directory on the webserver devapp01 10 | 11 | ```bash 12 | scp caleston-code.tar.gz devapp01:~/ 13 | ``` 14 | 15 |
16 | 1.
17 | On the devapp01 webserver, unzip and extract the copied file in the directory /opt/. 18 | 19 | Note that the `/opt` directory is owned by root on `devapp01` so we'll need sudo 20 | 21 | ```bash 22 | ssh devapp01 23 | 24 | sudo tar -zxf caleston-code.tar.gz -C /opt 25 | ``` 26 | 27 | Don't exit from the ssh session just yet. We need to remain on `devapp01` 28 | 29 |
30 | 1.
31 | Delete the tar file from devapp01 webserver. 32 | 33 | ```bash 34 | rm caleston-code.tar.gz 35 | ``` 36 | 37 |
38 | 1.
39 | Make sure that the directory is extracted in such a way that the path /opt/caleston-code/mercuryProject/ exists on the webserver. 40 | 41 | Nothing to do here. If you got Q4 right, then this will work too - press OK. 42 | 43 | You can verify if you like: 44 | 45 | ```bash 46 | ls -l /opt/caleston-code/mercuryProject/ 47 | ``` 48 | 49 |
50 | 1.
51 | For the client demo, Bob has installed a postgres database in devdb01.
SSH to the database devdb01 and check the status of the postgresql.service
What is the state of the DB?
52 | 53 | At this point you are still logged into `devapp01`, so first return to Bob's laptop 54 | 55 | ```bash 56 | exit 57 | ``` 58 | 59 | Now go to the db node 60 | 61 | ```bash 62 | ssh devdb01 63 | 64 | systemctl status postgresql.service 65 | ``` 66 | 67 | Note the status: `Active: inactive (dead) ...` 68 | 69 | Don't exit from the ssh session just yet. We need to remain on `devdb01` 70 |
71 | 1.
72 | Add an entry host all all 0.0.0.0/0 md5 to the end of the file /etc/postgresql/10/main/pg_hba.conf on the DB server.
This will allow the web application to connect to the DB.
73 | 74 | ```bash 75 | sudo vi /etc/postgresql/10/main/pg_hba.conf 76 | ``` 77 | 78 | Make the change as directed, save and exit `vi`. 79 | 80 |
81 | 1.
82 | Start the postgres DB on the devdb01 server. 83 | 84 | ```bash 85 | sudo systemctl start postgresql.service 86 | ``` 87 | 88 |
89 | 1.
90 | What port is postgres running on? Check using the netstat command? 91 | 92 | ```bash 93 | sudo netstat -ptean 94 | ``` 95 | 96 | There's 2 entries for postgres, one each for IPv4 and IPv6, but both are using the same port. Note this port down - you will need it later! 97 | 98 |
99 | 1.
100 | Back on the devapp01 webserver. Attempt to start the web application by:
Navigate to the directory /opt/caleston-code/mercuryProject
Next, run the command python3 manage.py runserver 0.0.0.0:8000
101 | 102 | At this point you are still logged into `devdb01`, so first return to Bob's laptop 103 | 104 | ```bash 105 | exit 106 | ``` 107 | 108 | Now go to the app node 109 | 110 | ```bash 111 | ssh devapp01 112 | 113 | cd /opt/caleston-code/mercuryProject 114 | python3 manage.py runserver 0.0.0.0:8000 115 | ``` 116 | 117 | Note it dumps a stack trace on the screen, i.e. it crashed! Thus the answer is `No`. 118 | 119 | Press `CRTL + C` 120 | 121 |
122 | 1.
123 | Why did the command not work? 124 | 125 | The answer to this is in the stack trace at the end. The app cannot connect to the database on the address and port indicated. Also remember the earlier question where you were asked to find the port that the database server is listening on! 126 | 127 |
128 | 1.
129 | It appears that Bob did not configure his app to connect a postgres database running on a different server. 130 | 131 | That explains why things are working on his laptop and not in the `DEV` servers. 132 | 133 | It also appears that he is using the `wrong` port for postgres! 134 | 135 | 1. Find the file in the directory under `/opt/caleston-code` that has a string matching DATABASES = {. 136 | 1. Replace the value of `localhost` to `devdb01` 137 | 1. In the same file fix the postgres port to match the port being used on `devdb01` 138 | 139 | For this, we need to first find the file we need to edit, so we're going to use `find` to find _files_ and use `grep` to find the specific text, with the `-l` switch to print the file path the text was found in. 140 | 141 | ```bash 142 | find . -type f -exec grep -l 'DATABASES = {' "{}" \; 143 | ``` 144 | 145 | Edit the file that was returned by the above 146 | 147 | ```bash 148 | vi ./mercury/settings.py 149 | ``` 150 | 151 | Scroll down to `DATABASES = {` and beneath this set the correct host and port. Save and exit. 152 | 153 |
154 | 1.
155 | Now that has been set up, change the ownership of ALL files and directories under /opt/caleston-code to user mercury. 156 | 157 | You'll need to be root to reassign ownership 158 | 159 | ```bash 160 | sudo chown -R mercury /opt/caleston-code 161 | ``` 162 | 163 | Note that sometimes this step is marked incorrect even though it *is* correct! Ignore this and move on. It has been reported to the lab team. 164 | 165 |
166 | 1.
167 | Great! Everything should now be in order to restart the application. 168 | 169 | On the devapp01 server start the webserver again by running the command: 170 | 171 | 1. Navigate to the directory `/opt/caleston-code/mercuryProject` 172 | 1. Next, run the command `python3 manage.py runserver 0.0.0.0:8000` 173 | 174 | Note:- Make sure to activate the virtual environment using `source ../venv/bin/activate` within the current project before executing `python3 manage.py migrate`. 175 | 176 | If you've followed all the above steps, you should still be in directory `/opt/caleston-code/mercuryProject` 177 | 178 | Run the migration. 179 | 180 | ```bash 181 | source ../venv/bin/activate 182 | python3 manage.py migrate 183 | ``` 184 | 185 | Start the app again so the question will validate. 186 | 187 | ``` 188 | python3 manage.py runserver 0.0.0.0:8000 189 | ``` 190 | 191 | **What is this venv stuff?** 192 | 193 | If you're considering learning Python (highly recommended as it is required in many DevOps jobs), this means Virtual ENVironment. It allows you to install Python packages on a project-by-project basis, thus not polluting the main Python installation. This is especially useful on your development environment where you may have multiple Python projects all with different package requirements. 194 | 195 |
196 | 1.
197 | Well done! Now, for the final task before the client presentation. 198 | 199 | Create a new service called mercury.service with the following requirements. 200 | 201 | 1. Service name: - `mercury.service`, WorkingDirectory: - `/opt/caleston-code/mercuryProject/`, Command to run: `/usr/bin/python3 manage.py runserver 0.0.0.0:8000`. 202 | 1. Restart `on failure` and enable for `multi-user.target`. 203 | 1. Run as user `mercury`. 204 | 1. Set description: `Project Mercury Web Application`. 205 | 206 | Here we have to create a [systemd unit file](https://kodekloud.com/topic/creating-a-systemd-service/) to make the Python app be runnable as a service. 207 | 208 | First quit the running webapp by pressing `CTRL-C` 209 | 210 | Now create the unit file 211 | 212 | ```bash 213 | sudo vi /etc/systemd/system/mercury.service 214 | ``` 215 | 216 | And put the following in to satisfy the question requirements 217 | 218 | ``` 219 | [Unit] 220 | Description=Project Mercury Web Application 221 | 222 | [Service] 223 | ExecStart=/usr/bin/python3 manage.py runserver 0.0.0.0:8000 224 | Restart=on-failure 225 | WorkingDirectory=/opt/caleston-code/mercuryProject/ 226 | User=mercury 227 | 228 | [Install] 229 | WantedBy=multi-user.target 230 | ``` 231 | 232 | Now enable and start the service. We must run a `daemon-reload` whenever we have created, edited or deleted a unit file. Note that the `.service` extension is optional with `systemctl` commands. We can say `mercury.service`, or simply `mercury` 233 | 234 | ```bash 235 | sudo systemctl daemon-reload 236 | sudo systemctl enable mercury 237 | sudo systemctl start mercury 238 | ``` 239 | 240 |
241 | 1. Information only - browse the running application! 242 | --------------------------------------------------------------------------------