
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.
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 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.
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.
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.
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.
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.
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.
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.
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☠️
(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
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.
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.
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.
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.
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.
⭐️⭐️⭐️⭐️⭐️
❖ 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.