Course recordings on DaDesktop for Training platform
Visit NobleProg websites for related course
Visit outline: Ansible for Network Engineers (Course code: ansiblenetwork)
Categories: Ansible
Summary
Overview
This is a hands-on Linux command-line fundamentals course designed to build practical proficiency in shell operations, file system navigation, command chaining, redirection, and basic scripting. The session covers alias management, command sequencing with semicolons and logical operators, piping for output filtering, standard output/error redirection, the use of /dev/null, live file monitoring with tail -f and watch, file permission management, script creation and execution, and advanced file searching with find. The instructor emphasizes real-world use cases, common pitfalls, and the importance of reading manual pages, culminating in an introduction to automation through scripting.
Topic (Timeline)
1. Alias Management and Command Execution [00:00:28 - 00:02:37]
- Introduced the concept of shell aliases (e.g.,
cpaliased tocp -i). - Demonstrated that directly invoking the full path to an executable (e.g.,
/bin/cp) bypasses the alias. - Emphasized that aliases are convenience tools for interactive use and do not affect direct path execution.
- Reinforced the purpose of aliases: to simplify complex or frequently used commands.
2. Command Sequencing and Conditional Execution [00:02:39 - 00:07:29]
- Explained how to chain multiple commands using semicolons (
;) — executes all regardless of success. - Introduced logical operators:
&&(execute next only if previous succeeds) and||(execute next only if previous fails). - Demonstrated with
touchandcdcommands: failedcddue to existing file prevents subsequent command. - Clarified that
&&and||provide conditional logic between commands, unlike semicolons. - Encouraged hands-on practice with command chaining and exit code logic.
3. Piping and Output Filtering with grep [00:07:31 - 00:14:38]
- Defined piping (
|) as passing output of one command as input to another. - Demonstrated
ls -l | wc -lto count lines of directory listing. - Introduced
grepfor filtering text:grep localhost /etc/hoststo show matching lines. - Showed inverse filtering with
grep -v localhostto exclude lines. - Highlighted case-insensitive search with
grep -i. - Combined
ls -l /etc | grep -i febto find configuration files modified in February. - Warned that options (e.g.,
-v) vary by command — do not assume universal meaning (e.g.,-vis not always verbose).
4. Redirection: Standard Output, Standard Error, and /dev/null [00:17:08 - 00:27:46]
- Explained
>(redirect stdout) and2>(redirect stderr). - Demonstrated that
command > filecaptures only successful output; errors remain on terminal. - Showed
command > file 2>&1to redirect both stdout and stderr to a file. - Introduced file descriptors:
1= stdout,2= stderr. - Demonstrated
command > file 2> /dev/nullto discard errors silently. - Explained
/dev/nullas a black hole that discards all input. - Warned that
>overwrites files; use>>to append.
5. File System Navigation, History, and Append Operations [00:29:04 - 00:33:14]
- Clarified that redirection targets (
> file) do not require the file to pre-exist — it is created if absent. - Warned that repeated
>overwrites content; use>>for appending. - Introduced command history:
!nto re-execute command by line number from history. - Demonstrated
historyto view command list and!shortcuts for quick recall. - Emphasized that mastering these features improves efficiency and reduces repetitive typing.
6. Live Monitoring: tail -f and watch [00:34:01 - 00:42:35]
- Introduced
tail -f filenameto continuously display new lines appended to a log file. - Demonstrated real-time log monitoring by appending text to a file while
tail -fruns. - Introduced
watch commandto repeatedly execute and display output (default every 2 seconds). - Showed
watch -n 1 dateto monitor time changes andwatch -d ls /tmpto highlight differences. - Clarified:
tail -fwatches file content changes;watchrepeatedly runs a command. - Noted
Ctrl+Cto terminate both.
7. Script Creation, Permissions, and Execution [00:44:25 - 00:52:42]
- Created a text file containing shell commands (e.g.,
hostname,uname -a). - Demonstrated that a text file is not executable by default.
- Showed that running
bash /path/to/scriptexecutes it via shell interpreter. - Used
chmod +x scriptnameto add execute permission to the file. - Demonstrated execution via
./scriptnameafter setting permissions. - Emphasized that scripts require both correct content and proper file permissions to run directly.
8. Advanced File Searching with find [00:56:38 - 01:03:07]
- Introduced
findwith two core parameters: starting path and search criteria. - Demonstrated
find /path -name "*.conf"to locate files by name pattern. - Showed use of
-type f(files),-type d(directories),-user username,-mtime -7(modified in last 7 days). - Explained
-execto run commands on found files (e.g.,find . -name "*.log" -exec rm {} \;). - Warned of high risk with
-exec— recommend testing with-printfirst. - Advised using
man findto explore full expression syntax (e.g.,-size,-perm,-atime).
9. locate, inodes, and System Tools [01:03:44 - 01:07:19]
- Contrasted
find(real-time traversal) withlocate(uses pre-built database; faster but may be outdated). - Noted
locatemay not be installed by default and requiresupdatedbto refresh index. - Explained inodes as unique identifiers for files on disk.
- Demonstrated that hard links point to the same inode — multiple names for same data.
- Clarified that inode numbers are visible in
ls -ioutput and are key to understanding hard links.
10. Background Processes, nohup, and System Context [01:07:29 - 01:12:26]
- Introduced
nohup command &to run processes that survive shell logout. - Explained that
nohupdetaches the process from the terminal and redirects output tonohup.out. - Noted that
screenandtmuxare modern alternatives for session persistence. - Discussed Unix vs. Linux evolution: modern Unix systems now adopt Linux features.
- Emphasized enterprise platform choices are based on stability, ecosystem, and long-term goals, not user preference.
11. Course Wrap-up and Final Thoughts [01:12:26 - 01:13:58]
- Concluded with encouragement to explore the terminal more confidently.
- Reinforced that mastery comes from practice, reading man pages, and experimenting.
- Acknowledged participant engagement and thanked attendees.
- Noted that the session was structured as a workshop — hands-on practice was the primary goal.
Appendix
Key Principles
- Aliases are interactive conveniences; they do not affect direct path execution.
- Semicolons (
;) run commands sequentially;&&and||add conditional logic. - Pipes (
|) enable chaining commands for filtering and processing output. - Redirection separates stdout (
>) and stderr (2>); use2>&1to combine. /dev/nulldiscards unwanted output — useful for silencing errors or logs.tail -fmonitors file growth;watchrepeatedly executes a command.- Scripts require execute permission (
chmod +x) to run directly. findis powerful for recursive searches; use-exec,-name,-type,-mtimefor precision.locateis faster thanfindbut relies on a database that may be outdated.- Inodes uniquely identify files; hard links share the same inode.
nohupallows processes to survive terminal disconnection.
Tools Used
alias,unalias;,&&,|||,grep,wc,ls>,>>,2>,2>&1,/dev/nulltail -f,watch,watch -dchmod,nano,vifind,locatenohup,history,!nuname,hostname,echo,touch,cd,mkdir
Common Pitfalls
- Assuming
-vmeans “verbose” across all commands — it means “invert match” ingrep. - Using
>instead of>>and accidentally overwriting log files. - Forgetting to set execute permissions on scripts.
- Running
find /on large systems without limiting scope — causes performance issues. - Typing “EOF” literally instead of pressing
Ctrl+Dto send end-of-file signal. - Confusing
watch(repeats a command) withtail -f(monitors file changes).
Practice Suggestions
- Create aliases for your most-used commands and test bypassing them with full paths.
- Chain 3+ commands using
&&and||to handle success/failure scenarios. - Use
ls -l /var/log | grep -i errorto find error logs. - Redirect output of a failing command to a file and observe what gets saved.
- Write a script that checks disk usage, lists recent files, and logs the result.
- Use
find /home -name "*.tmp" -mtime +30 -delete(test first with-print). - Run
watch -n 1 'ps aux | grep python'to monitor Python processes. - Use
nohup ping google.com &and log out — then log back in to verify it’s still running.