Initial commit v0.1.0
This commit is contained in:
commit
d8d7c9ddfa
4 changed files with 174 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*.swp
|
7
LICENSE.txt
Normal file
7
LICENSE.txt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
Copyright (c) 2016 William Brawner <billybrawner@gmail.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
88
README.md
Normal file
88
README.md
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
Interactive Linux/Bash Tutorial
|
||||||
|
===============================
|
||||||
|
|
||||||
|
## v0.1.0
|
||||||
|
|
||||||
|
### What is this?
|
||||||
|
|
||||||
|
The purpose of this tutorial is to teach the basic concepts of Linux and bash to aspiring Linux system administrators. While there are plenty of on-line tutorials that already achieve this, I've set out to create one that would be run from the command line, to integrate learners even more in the environment that they will be working in. This is just a work in progress, so feel free to take it and do what you want with it.
|
||||||
|
|
||||||
|
### How does it work?
|
||||||
|
|
||||||
|
This tutorial goes over several commands and concepts related to bash and linux, before prompting the user to run them and see for themselves how it works. None of the commands are actually run, however, until the user gets the command right. This is a security feature to prevent newbies from accidentally ruining their system.
|
||||||
|
|
||||||
|
### License and Contributing
|
||||||
|
|
||||||
|
I've decided to use the MIT license for this project, because I want this to be freely available to anyone and everyone. So take it, change it, modify it, do what you want with it. Feel free to make a pull request if you want to contribute something to the code as well. I'd be happy to include them :)
|
||||||
|
|
||||||
|
Roadmap
|
||||||
|
-------
|
||||||
|
|
||||||
|
### v1.0 File system management
|
||||||
|
* Concepts:
|
||||||
|
- Basic overview of file system structure
|
||||||
|
- running commands, using flags & arguments
|
||||||
|
* Commands:
|
||||||
|
- ~~ls~~
|
||||||
|
- cd
|
||||||
|
- mv
|
||||||
|
- cp
|
||||||
|
- rm
|
||||||
|
- touch
|
||||||
|
- mkdir
|
||||||
|
- pwd
|
||||||
|
|
||||||
|
### v2.0 Reading and editing files
|
||||||
|
* Concepts:
|
||||||
|
- pipes
|
||||||
|
- directing output (overwrite vs append)
|
||||||
|
* Commands
|
||||||
|
- vim
|
||||||
|
- vimtutor
|
||||||
|
- cat
|
||||||
|
- tail
|
||||||
|
- head
|
||||||
|
- echo
|
||||||
|
|
||||||
|
### v3.0 User and group management
|
||||||
|
* Concepts:
|
||||||
|
- Users & Groups
|
||||||
|
- Permissions
|
||||||
|
- File attributes
|
||||||
|
* Commands:
|
||||||
|
- useradd
|
||||||
|
- usermod
|
||||||
|
- groupadd
|
||||||
|
- chmod
|
||||||
|
- chown
|
||||||
|
- lsattr
|
||||||
|
- chattr
|
||||||
|
|
||||||
|
### v4.0 Managing software
|
||||||
|
* Concepts:
|
||||||
|
- Packages
|
||||||
|
- Package managers
|
||||||
|
* Commands
|
||||||
|
- dpkg/rpm
|
||||||
|
- apt-get/dnf/yum/zypper
|
||||||
|
|
||||||
|
### v5.0 SSH
|
||||||
|
* Concepts:
|
||||||
|
- Managing remote systems
|
||||||
|
- SSH Keys
|
||||||
|
* Commands
|
||||||
|
- ssh
|
||||||
|
- sftp
|
||||||
|
- scp
|
||||||
|
- ssh-keygen
|
||||||
|
|
||||||
|
### v6.0 System processes:
|
||||||
|
* Concepts:
|
||||||
|
- Processes
|
||||||
|
- Memory/CPU usage
|
||||||
|
* Commands:
|
||||||
|
- ps
|
||||||
|
- top
|
||||||
|
- htop
|
||||||
|
- kill
|
||||||
|
- killall
|
78
bash-tutor.sh
Executable file
78
bash-tutor.sh
Executable file
|
@ -0,0 +1,78 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# First, we'll define some paths to programs that we'll need. This is good
|
||||||
|
# practice for security and it also arguably keeps the script clean
|
||||||
|
|
||||||
|
LS="/usr/bin/ls --color=auto"
|
||||||
|
|
||||||
|
# Next, we'll simplify the mini-quizzes by wrapping them in a function. The
|
||||||
|
# idea behind this is to provide a safe environment for the learner to run
|
||||||
|
# commands in, while still feeling like a bash shell.
|
||||||
|
|
||||||
|
function test_command {
|
||||||
|
while true; do
|
||||||
|
read -p "$TUTOR_PROMPT" command
|
||||||
|
case $command in
|
||||||
|
"$1") $2; break;;
|
||||||
|
*) echo "Hmm, that didn't quite look right. Try typing '$1' and pressing Enter"
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
______ __ ___ _ _ ______ _ _ ______ _____ ______
|
||||||
|
| _ \\ / \\ / __|| | | | |__ __|| | | ||__ __|/ _ \\| _ \\
|
||||||
|
| |_| // 0 \\ | |__ | |_| | | | | | | | | | | / \\ || |_| /
|
||||||
|
| _ < | __ | \\___ \\| _ | | | | | | | | | | | | || <
|
||||||
|
| |_| \\| | | | ___| || | | | | | | \\_/ | | | | \\_/ || |\\ \\
|
||||||
|
|_____/|_| |_| |____/|_| |_| |_| \\_____/ |_| \\_____/|_| |_|
|
||||||
|
|
||||||
|
Welcome to the interactive bash tutorial! To exit this tutorial at any \
|
||||||
|
time, press Ctrl+C. That is, press and hold the Control Key (Ctrl), and then \
|
||||||
|
press the C Key.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [[ -z $USER ]]; then
|
||||||
|
echo -e "What is your name?"
|
||||||
|
while [[ -z $USER ]]; do
|
||||||
|
read USER
|
||||||
|
done
|
||||||
|
echo "Great! Let's get started then, $USER"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# The user's progress will be stored in a hidden file in their home directory.
|
||||||
|
# This will just store a bunch of environment variables to track their
|
||||||
|
# progress. This will be more useful as the tutorial gets longer.
|
||||||
|
|
||||||
|
if [[ ! -e ~/.bash_tutor_progress ]]; then
|
||||||
|
echo "USER=$USER" > ~/.bash_tutor_progress
|
||||||
|
else
|
||||||
|
source ~/.bash_tutor_progress
|
||||||
|
echo "Welcome back, $USER"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
TUTOR_PROMPT="$USER@bash-tutor \$ "
|
||||||
|
|
||||||
|
echo "First and foremost, let's get you familiar with your environemt. Bash \
|
||||||
|
is a type of shell, which allows you to run commands on your computer or \
|
||||||
|
server. You can think of it like a window that strips away all the fancy \
|
||||||
|
graphics and user interfaces and leads you directly to the operating system. \
|
||||||
|
The part of the shell where you type these commands for the computer or server \
|
||||||
|
is called the prompt. For this tutorial, your prompt will consist of your \
|
||||||
|
name, the '@' symbol, and the name of this tutorial (bash-tutor) followed by \
|
||||||
|
your current working directory (the folder that you are currently in) and a $ \
|
||||||
|
sign, which is a common convention in bash. Let's start with your first \
|
||||||
|
command: ls. The ls command lists the files and directories in the folder that \
|
||||||
|
you are in by default. Try running it now"
|
||||||
|
|
||||||
|
test_command ls $LS
|
||||||
|
|
||||||
|
echo "Great work! Most commands can also take options (also known as flags) that modify their behavior. These options are usually preceded by a single or double hyphen. For example, with ls you can pass the -l flag to list more information on each of the files and directories. Try it now:"
|
||||||
|
|
||||||
|
test_command "ls -l" "$LS -l"
|
||||||
|
|
||||||
|
echo "Don't worry about what all of this means right now. We'll cover it later. For now, you can practice some other flags. A good one to remember is the --help flag, which usually provides you with a list of options you can use. This is sometimes shortened to just -h. For now though, let's talk about arguments. Arguments are additional pieces of information that you can give to a command to "
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue