
Download practice example source
Master linux filename conventions, including the 255 character limit and the use of letters, numbers, periods, underscores, and hyphens, with uppercase and lowercase letters distinguished and spaces handled via quotes.
Master Linux shell auto completion by using the tab key to navigate paths and auto-fill path and file names, including /usr/local/include. Practice this feature to speed up typing and navigation.
Explore the linux directory structure from the root to folders like bin, sbin, usr/bin, and usr/local/bin, and see how libraries, device files, and env files organize programs and system data.
Master how to move directory paths in Linux by using absolute and relative paths, including /usr/local/include, ./include, and ../ to reach parent and grandparent directories.
Explore how to view and interpret file and directory permissions with ls -l, understanding file types, rwx bits, owner, group, and other, plus hard links and metadata.
Explore hard links and symbolic links in linux with the ln command on helloworld.txt, where hard links create links to the same file and symbolic links point to the original.
Learn how to use the echo command to display strings, manage spaces with quotes, and control output with -e and -n options, including printing file lists like ls.
Explore how Linux commands use options and arguments, illustrated by ls with -l for detailed listing, and distinguish single versus double hyphen options.
Learn glob patterns and whitespace handling in the Linux shell by creating, updating, and deleting zero-byte files named Apple, Banana, and Orange using touch and rm.
Learn how to handle file names with spaces in the Linux shell by using quotes with touch, preventing unintended splits, and choosing between single and double quotes when creating files.
Navigate to the mydir directory and verify the file 'Gone With the Wind' exists using the test command with square brackets, illustrating their role in shell conditions.
Master the wc command to count words with -w, lines by adjusting options, and characters with -L, using fruits.txt as an example to apply these counts in shell scripts.
Learn how to generate numbers with seq, save output to a file, and use tail to display the last lines, including from a specific line via the plus operator.
Learn linux aliasing to create shorthand commands like mkdir and history, simplify directory creation with -p, and use a flexible function for arguments, including cases like ttyS0 and minicom.
Master the pushd and popd commands to save the current path on a stack, move to saved paths including nested ones, and navigate between directories efficiently.
Demonstrate printf’s formatted output, including two-digit numbers with leading zeros, compare it to echo, and declare and reference shell variables like legend holding Michael Jackson using the dollar sign.
Learn to read user input with the read command, store it in a variable, and validate it using echo or printf, with options for -s silent input, prompts, and timeouts.
Explore how to implement iteration with a while loop in shell scripting, using a printf counter from 1 to 12. Analyze the loop condition and the do, done blocks.
Learn four methods to run executable scripts in Linux: set execution with chmod, copy to /usr/bin with root privileges, use full or relative paths, and modify PATH.
The shell is a command interpreter that connects users to the kernel for interactive commands. Bash is the Linux shell with Bourne lineage, teaching its basic syntax for batch execution.
Learn how to write a bash script and run it reliably. Understand the role of shebang and the env alternative for locating bash.
Learn how Linux and Windows handle line endings, focusing on line feed (LF) and carriage return (CR), 0x0A, 0x0D, and avoid Notepad by using vi.
Explore four methods to execute a script: set execution with chmod, run directly with bash, use source, or run with a period followed by the script name.
Explore how whitespace defines word boundaries and how command names and arguments are parsed. Examine double and single quotes, backslashes, dollar expansions, comments, redirection, pipes, braces, and tilde expansion.
Learn to initialize shell variables without spaces around the assignment operator, for example animal=tiger and color=white, and reference them with a leading dollar sign.
Master parameter substitution and quotation marks in Linux shell scripting by learning variable initialization, proper quoting for spaces, dollar expansion, and curly brace usage for clear variable names.
Learn to use special parameters in shell scripts, such as $0, $1, $2, $*, $@, and $#, and understand back quotes, argument handling, and basic pid and exit code expansions.
Examine environment variables in Linux shell scripting by using uid and euid, testing root privileges with sudo, and printing a changing random value via env.
Explore the declare command for shell scripting, creating arrays with -a, enforcing integer types with -i, setting read-only variables, and exporting variables for child processes.
Explore parameter expansion in shell scripting to manipulate strings, including substrings, trimming, removing matches, and targeted replacements, using variables and pattern matching.
Learn how glob patterns in the linux shell use wildcards to filter files by length and starting letters, and practice listing three-letter and four-letter names with echo, including range syntax.
Master the tr command to translate characters, using hereString or file input, mapping lowercase to uppercase and more. Learn posix representations, and control whitespace with squeeze, -d, and -c.
Master the cut command to extract substrings and fields from text and files, using delimiters and ranges, as shown with fruits.txt, password, and ip address examples.
Activate the extended glob feature to filter files, listing only jpg or bmp or excluding them. Use not, or, and extended glob characters such as plus, question mark, and asterisk.
Use shellcheck.net for static analysis of shell scripts by pasting code to check for syntax errors and bugs. Rely on its findings to catch many issues, though it isn't perfect.
Master color text in Linux shell scripts by using escape sequences to set font styles and foreground and background colors, including bold, underline, italic, flicker, and reverse effects.
(ANS)
export PS1="\e[0;35m[\u@\h \W]\$ \e[m"
export PS1="\e[0;33;1m[\u\e[m@\e[0;35;1m\h\e[m \W]"
Master regular expressions to search and replace strings in Linux with grep, sed, and awk, and practice metacharacters, groups, quantifiers, and anchors.
Explore bash regular expression comparisons, using patterns on both sides, the REPLY variable, and the exclamation mark for NEGATE to control results, with BASH_REMATCH storing matches for LANG.
(ANS)
read -p "Enter a number" number
pat='^[0-9]+$'
if ! [[ $number =~ $pat ]]; then
echo "Not a number" >&2
else
echo "a number"
fi
Master grep basics for pattern matching in text using regular expressions, including -c and -o options, case-insensitive -i, and leveraging egrep and fgrep as variants.
Learn how to use the sed command for text substitution, pattern matching, and data extraction in linux shells, including replacing strings, applying global changes, and simple text transformations.
Master brace expansion in bash by using curly braces with comma-separated options and ranges to create directories and files, and learn how eval enables variable expansion within braces.
Learn how command substitution embeds command outputs in strings using dollar signs and parentheses or backticks, and improves readability by executing commands before echoing results.
Explore arithmetic expansion in shell scripting by performing operations on variables like v1 and v2, using dollar signs correctly, and comparing true and false values through if statements.
Learn how the shell reports exit status using $?, where 0 signals success and non-zero signals failure, and how exit commands like exit 1 convey errors in scripts.
Explore how logical operators and pipes control shell commands, executing right-hand tasks when the left fails or succeeds, with examples like creating a dir if absent and make on success.
Explore login and non-login shells across console, ssh, and graphical logins, including interactive login shells, interactive non-login shells, and non-interactive shells, with shopt to verify the current shell.
Explore the command separator in shell scripting, using semicolons to join commands, compare with newlines, and understand variable expansion and scope effects during echo and command execution.
Discover how inline group syntax uses braces to bundle commands and conditionally execute actions—such as checking a directory, creating it with mkdir, and echoing results.
Explore shell scripting with conditional if/else/fi statements, test expressions, and one-line versus multi-style approaches in the complete Linux shell script master course.
compare string tests in bash using [ .. ] vs [[ .. ]], highlighting how quotes, whitespace, and redirection characters affect results and how double square brackets simplify testing.
Master shell scripting by using careful quoting; learn how empty strings affect tests, why quoting matters, and how double brackets simplify comparisons.
Examine shell script conditionals with the if command, using metacharacters to test files, strings, and integers, and compare with single and double bracket syntax for robust scripting.
(ANS)goodday.sh
#!/bin/bash
if [ -z "$1" ]; then
echo "usage: $0 directory"
exit
fi
echo 'Have a nice day!'
Explore how while and for loops drive repetition in shell scripts, using test commands, colon endings, and always-true conditions to repeatedly execute commands such as printing hello world every second.
(ANS)
admin☠️ sum=0;for num in {1..100}; do ((sum=sum+num)); done; echo "SUM=$sum"
SUM=5050
Declare an array and print its contents, then access elements with a for loop using array index. Replace the word pen with a null string to show the loop works.
(ANS)
admin☠️ for locale in en es fr ja ko th vi zh-cn zh-tw; do convert -size 256x256 -background transparent -gravity Center -fill black -font arial.ttf -pointsize 240 label:${locale} ${locale}.png; done
Explore the shell's for loop, mirroring C language logic to iterate over strings, increment indices, and print characters one by one, as demonstrated with hello world.
Explore how the date command processes dates and prints formatted outputs, including year, month, day, and time; learn multiple ways to format and combine date and time as needed.
(ANS)
admin☠️ while true; do TIME=`date +'%Y-%m-%d %H:%M:%S'`;echo -ne "${TIME}\r"; sleep 1; done
2020-12-07 02:27:28
admin☠️
Learn loop statements and glob usage in shell scripts, examine common mistakes with deleting mp3 files, and understand how quotation marks affect for loops.
(ANS) practice in this directory( ./shell_cmd/images )
admin☠️ for file in *; do cp ${file}{,.bak}; done
admin☠️ ls
Balloon.jpg glob.gif.bak shadingimage.tiff
Balloon.jpg.bak settings_down.png shadingimage.tiff.bak
Candy.jpg settings_down.png.bak smaller.tiff
Candy.jpg.bak settings_up.png smaller.tiff.bak
glob.gif settings_up.png.bak
admin☠️
Master the seq command to generate numeric serial numbers, print 1 to 10, start from 0 with increments of 2 to produce even numbers, and create comma-separated sequences, including decrements.
(ANS) fnum.sh
#!/usr/bin/env bash
for i in `seq 1 10`; do printf "%03d\t" $i; done; echo
execution result
admin☠️ chmod +x fnum.sh
admin☠️ ./fnum.sh
001 002 003 004 005 006 007 008 009 010
Learn how the Linux shell case statement acts like a switch, using REPLY and POSIX patterns to classify input as digits or not digits.
(ANS) case.sh
#!/bin/bash
read -s -n 1 -p "You really want to exit? " response
case "$response" in
Y|y)echo YES;;
N|n)echo NO;;
*)kill -SIGKILL $$;;
esac
Learn how getopts processes user arguments in a shell script, using hyphenated options like b f h, a loop, a case statement, and proper usage.
Master shell scripting by building select menus from arrays, using PS3 prompts and case statements, and handling user input and exit conditions with break to exit loops.
Declare and use arrays with the declare -a option, combine them in for loops, and print or access elements by index and whitespace-separated values.
Declare and initialize arrays in shell scripts, use for loops to access elements, and safely populate arrays with globs while quoting elements to prevent word splitting.
(ANS) makeTagDirectory.sh
#!/usr/bin/env bash
IFS=$',' read -r -a array < $1
for element in "${array[@]}"
do
echo "---" > "$element.md"
echo "name: $element" >> "$element.md"
echo "title: '$element'" >> "$element.md"
echo "---" >> "$element.md"
done
Learn to reliably find and delete files with spaces or newlines by using find -print0 and xargs -0, verifying with hexdump and passing null-separated results to rm.
Master the find command in linux to search the current path and subdirectories, apply maxdepth and -exec, and filter by type, hidden files, permissions 644, and ownership.
Explore how bash scripts receive input via command line arguments, environment variables, files, pipes, file descriptors. Learn output methods via files and inter-program communication using file descriptors and environment variables.
Master positional parameters in shell scripting by renaming png to jpg with a rename.sh script, passing arguments like $1 and $2, and using braces for tenth and beyond.
Learn how the locale is controlled by the environment variable LANG, how export enables LANG1 to be inherited by scripts and subshells, and how general variables differ from environment variables.
Explore variable scope in shell scripts across functions, subshells, and inline groups, and see how changes to year propagate inside or stay isolated outside each context.
Learn how file descriptors act as pointers to data sources and how stdin, stdout, and stderr with fds 0, 1, and 2 are used for input, output, and error messages.
Learn how Linux redirection routes standard output and errors to files, using >, >>, and file descriptors 1 and 2; create, overwrite, append, and merge files with examples.
Learn to use ImageMagick to select and change image colors, extract ten colors to a colors.txt via redirection, and read that data to generate a new image.
Learn to use nohup to run a bash script as a daemon that survives logout, stays in the background, and redirects output, error, and input.
Explore creating a shell installer by packaging a binary in a tar, integrating md5sum checks, and building a defensive install script that validates checksums before installation.
Use the tee command to log standard output and standard error to steven.txt while displaying it on screen, with -a for append and real-time logging.
Explore heredoc and here string usage in shell scripting, illustrate with sed examples, anchor-based here document syntax, and how quoting affects environment variable expansion during SSH sessions.
Learn how to use here documents to pass information to users by creating a function in a script, display long strings, and deliver simple help messages in shell scripts.
Master here strings in shell scripting, using angle brackets, without anchors, to pass strings to sed commands, redefine IFS for comma separated input, read into an array, and expand expressions.
Master the uniq command to collapse repeated words in a file, count occurrences with -c, and print only duplicates with -d, while understanding unique words like orange.
Explore the sort command by sorting fruits.txt alphabetically, piping results through other commands, and applying reverse sort by field, including the third field in passwd, to reveal different sort orders.
Learn how to create and use pipes, including named pipes (fifo) via mknod, and unnamed pipes to pass command output to cat and build a processing flow.
Explore process substitution in Linux using the comm command to compare two file lists and reveal differences, such as candy.jpg, with options 2 and 3 guiding what is printed.
Explore subshells by using parentheses to run commands as separate processes and monitor progress with tail -f. Demonstrate moving, tarring, and extracting directories via pipes and anonymous files.
Define and call functions in shell scripts to improve readability and reusability. The example shows sum as a function, using declare, $1, $2, and command substitution.
Explore the shift command to parameterize the next passed value by shifting the argument list, viewing how $# reflects the five arguments and how a loop displays each one.
Learn how the source command and the dot operator execute bashrc contents, preserving environment variables in the current shell, unlike running the script, and understand their differences.
Learn Linux job control by managing foreground and background processes, using ampersand to start in the background, and fg or bg to resume or suspend, with signals and Ctrl-Z.
Master shell script debugging by running pre-written scripts, enabling set -x with PS4 for line and function tracing, and using TRAP for single-step execution.
Learn to schedule scripts with cron using crontab -e and vim, set timing with asterisks for each field (minute, hour, day, weekday), and check with crontab -l.
⭐️⭐️⭐️⭐️⭐️
❖ This lecture provides a quick explanation of the tricky bash shell grammar of Linux, such as quotation marks, pipes, and redirections, and presents a procedural method of shell coding.
This will make it an opportunity to have a strong confidence in the development of the Linux environment.
In the modern computing environment, Linux has long been an important mainstream with Windows.
Linux is no longer exclusive to hackers, and many developers are asked to develop in the Linux environment.
Artificial intelligence, autonomous driving, machine learning, big data, cloud computing, IoT, and other future technologies are all created on the basis of the Linux environment.
Numerous open sources are first tested and supported on Linux.
❖ The Linux shell is like a Swiss Army knife for developers
For server-side JavaScript, Python and other languages, the development environment is actually a shell.
Many engineers have realized that direct access to simple command line tools can be very efficient when working.
In order to use modern programming languages, you can manage dependency management and packaging on a shell-based basis.
The shell provides users with a common environment and interface that anyone can access without installing complex components.
The diversity of programming languages and developer tools has increased, but in many ways the operating platform used by engineers has been rather simplified.
❖ Many corporate customers have moved from Unix to the Linux platform
Engineers expect Docker to make the operating environment much more uniform and Linux-like.
For containerized tasks, Linux and shell skills are important.
"This has led to increased interest in shells"
For open source, it is often built to run in a container on Linux.
The shell is now the most common way to manage Linux systems, and as many developers standardize Linux systems as operating environments, shell technology has become even more important.
DevOps, the main flow of modern software development methods, is where a single group is responsible for both, instead of one group focusing on functional development and the other focusing on reliable software operation.
❖ Automation is closely tied to shell scripting.
Many tasks that require automation can be easily handled using shell scripts.
If you can't script it, you can't automate it, and automation is essential to operating increasingly complex systems.
ps. Shell scripts were used for filming, editing, and uploading this video. †
❖ This lecture was produced for the same purpose as above.
Having been using shell scripts for over 10 years, I know what is difficult and what is important.
❖ To be good at shell scripts in Linux you need two elements
First, you need to be familiar with the shell syntax.
Special characters can be used for different functions depending on where they are used.
For example, the redirection symbols < > are also used in test statements.
Also, in the case of quotation marks, single quotation marks and double quotation marks must be used separately, but it is easy to fail if you do not pay attention to the command when it is linked.
Second, you need to remember about 20 to 30 essential commands of Linux, even options.
The reason this is necessary is when you quickly construct a workflow using the pipe symbol, you will need to come up with a suitable command to use it.
We have to immediately decide whether to use cut, tr, or curly brace expansion.
❁ "I made the video with care to make it as easy to understand as possible for beginners to Linux " ❤️
Basic terms are explained using a rich subtitle system and animations so that you can follow the class without difficulty.