{"id":474,"date":"2026-10-14T16:02:02","date_gmt":"2026-10-14T16:02:02","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2016\/03\/03\/complete-linux-shell-scripting-guide-and-tutorial-for-linux-admin-and-devops-engineer\/"},"modified":"2026-10-14T16:02:03","modified_gmt":"2026-10-14T16:02:03","slug":"complete-linux-shell-scripting-guide-and-tutorial-for-linux-admin-and-devops-engineer","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/complete-linux-shell-scripting-guide-and-tutorial-for-linux-admin-and-devops-engineer\/","title":{"rendered":"Linux Commands and Shell Scripting Reference for Linux Admins and DevOps Engineers"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><em>Originally published on 2016-03-03; fully revised and updated.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide is for Linux administrators, SREs, and DevOps engineers who need a practical path from day-to-day Linux commands to reusable shell automation. It reorganizes the original resource collection into a clearer reference with examples, comparisons, and direct links back to the source materials, including the <a href=\"https:\/\/www.devopsschool.com\/blog\/complete-linux-shell-scripting-guide-and-tutorial-for-linux-admin-and-devops-engineer\/\">original post<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to use this reference effectively<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you are building Linux depth for platform or delivery engineering, use this page in a sequence instead of treating it as a random bookmark dump.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Start with <strong>user and admin commands<\/strong> to build execution confidence.<\/li><li>Move to <strong>text-processing tools<\/strong> (grep, sed, xargs) for log and config workflows.<\/li><li>Add <strong>shell parameters and scripting patterns<\/strong> for repeatable operations.<\/li><li>Practice <strong>monitoring and troubleshooting commands<\/strong> during real incidents.<\/li><li>Use interview sets and exercises to validate practical understanding.<\/li><\/ul>\n\n\n\n<pre class=\"mermaid\">\nflowchart TD\n    A[Learn core user commands] --> B[Learn admin commands]\n    B --> C[Practice text processing]\n    C --> D[Write simple shell scripts]\n    D --> E[Add parameters and logging]\n    E --> F[Automate over SSH]\n    F --> G[Monitor CPU memory IO]\n    G --> H[Troubleshoot and document runbooks]\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Command families and DevOps use cases<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The original collection spans user-level Linux usage through incident diagnostics and scripting. This table helps you decide where each command family fits.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Category<\/th><th>Examples from this collection<\/th><th>Typical use in operations<\/th><\/tr><\/thead><tbody><tr><td>User commands<\/td><td>Linux Commands for User, common Unix utilities<\/td><td>Navigation, files, permissions, process checks<\/td><\/tr><tr><td>Admin commands<\/td><td>Linux Commands for Administrator, mount\/unmount, df usage<\/td><td>Host setup, storage work, access management<\/td><\/tr><tr><td>Monitoring<\/td><td>iostat, mpstat, vmstat, pmap<\/td><td>CPU, memory, and disk bottleneck analysis<\/td><\/tr><tr><td>Text processing<\/td><td>grep, sed, xargs<\/td><td>Log filtering, mass changes, command chaining<\/td><\/tr><tr><td>Remote automation<\/td><td>ssh-keygen, ssh-copy-id, gsh<\/td><td>Executing repeatable tasks across multiple servers<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Performance and troubleshooting commands compared<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These commands appear frequently in Linux troubleshooting interviews and real production triage.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Command<\/th><th>Primary focus<\/th><th>Example<\/th><th>When to run it<\/th><\/tr><\/thead><tbody><tr><td>iostat<\/td><td>Disk I\/O and device utilization<\/td><td>iostat -x 1 5<\/td><td>Slow builds, high wait time, storage latency suspicion<\/td><\/tr><tr><td>mpstat<\/td><td>CPU utilization by core<\/td><td>mpstat -P ALL 1 5<\/td><td>Thread imbalance or CPU saturation checks<\/td><\/tr><tr><td>vmstat<\/td><td>Memory, swap, run queue, context switches<\/td><td>vmstat 1 5<\/td><td>General host pressure triage<\/td><\/tr><tr><td>pmap<\/td><td>Memory map for a process<\/td><td>pmap -x 12345<\/td><td>Investigating process-level memory growth<\/td><\/tr><tr><td>xargs<\/td><td>Batch argument passing<\/td><td>find \/var\/log -type f -name &#8220;*.log&#8221; -print0 | xargs -0 grep -H &#8220;ERROR&#8221;<\/td><td>Applying one command over many files<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php language-bash\"><span class=\"hljs-comment\"># Quick triage sequence<\/span>\niostat -x <span class=\"hljs-number\">1<\/span> <span class=\"hljs-number\">5<\/span>\nmpstat -P ALL <span class=\"hljs-number\">1<\/span> <span class=\"hljs-number\">5<\/span>\nvmstat <span class=\"hljs-number\">1<\/span> <span class=\"hljs-number\">5<\/span>\npmap -x <span class=\"hljs-number\">12345<\/span>\nfind \/<span class=\"hljs-keyword\">var<\/span>\/log -type f -name <span class=\"hljs-string\">\"*.log\"<\/span> -print0 | xargs <span class=\"hljs-number\">-0<\/span> grep -H <span class=\"hljs-string\">\"ERROR\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Shell scripting pattern for routine operations<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This example demonstrates common practices from the shell-scripting resources: input parameters, validation, and log-friendly output.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php language-bash\"><span class=\"hljs-comment\">#!\/usr\/bin\/env bash<\/span>\nset -euo pipefail\n\nTHRESHOLD=<span class=\"hljs-string\">\"${1:-80}\"<\/span>\nLOG_FILE=<span class=\"hljs-string\">\"${2:-\/tmp\/disk-alerts.log}\"<\/span>\n\n<span class=\"hljs-keyword\">if<\/span> ! &#91;&#91; <span class=\"hljs-string\">\"$THRESHOLD\"<\/span> =~ ^&#91;<span class=\"hljs-number\">0<\/span><span class=\"hljs-number\">-9<\/span>]+$ ]]; then\n  <span class=\"hljs-keyword\">echo<\/span> <span class=\"hljs-string\">\"Usage: $0 threshold-percent &#91;log-file]\"<\/span>\n  <span class=\"hljs-keyword\">exit<\/span> <span class=\"hljs-number\">1<\/span>\nfi\n\ndf -P | awk <span class=\"hljs-string\">'NR!=1 {print $1,$5,$6}'<\/span> | <span class=\"hljs-keyword\">while<\/span> read -r fs <span class=\"hljs-keyword\">use<\/span> <span class=\"hljs-title\">mount<\/span>; <span class=\"hljs-keyword\">do<\/span>\n  used=<span class=\"hljs-string\">\"$(echo \"<\/span>$use<span class=\"hljs-string\">\" | tr -d '%')\"<\/span>\n  <span class=\"hljs-keyword\">if<\/span> &#91; <span class=\"hljs-string\">\"$used\"<\/span> -ge <span class=\"hljs-string\">\"$THRESHOLD\"<\/span> ]; then\n    <span class=\"hljs-keyword\">echo<\/span> <span class=\"hljs-string\">\"$(date '+%F %T') WARN $fs at $use on $mount\"<\/span> | tee -a <span class=\"hljs-string\">\"$LOG_FILE\"<\/span>\n  fi\ndone<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Automation example: passwordless SSH setup<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The original collection includes a guide for SSH key-based login. A typical flow looks like this:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript language-bash\">ssh-keygen -t ed25519 -C <span class=\"hljs-string\">\"devops@example.com\"<\/span>\nssh-copy-id user@server1\nssh user@server1<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Curated links from the original collection<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The links below are preserved from the original post and grouped by practical usage.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Linux commands and admin fundamentals<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"scm\/general\/interview-questions-answers\/linux-commands-for-user.html\">Linux Commands for User<\/a><\/li><li><a href=\"forum\/unix-linux.html\">Linux Commands reference in scmGalaxy forum<\/a><\/li><li><a href=\"scm\/general\/interview-questions-answers\/linux-commands-for-administrator.html\">Linux Commands for Administrator<\/a><\/li><li><a href=\"scm\/scripting\/shell-scripting\/main-responsibilities-of-the-linux-system-administrator.html\">Main Responsibilities of the Linux System Administrator<\/a><\/li><li><a href=\"scm\/scripting\/shell-scripting\/common-unix-commands-and-utilities.html\">Common unix commands and utilities<\/a><\/li><li><a href=\"scm\/scripting\/shell-scripting\/unix-command-grep.html\">Unix Command: Grep<\/a><\/li><li><a href=\"scm\/scripting\/shell-scripting\/unix-sed-quick-reference.html\">Unix Sed Quick Reference<\/a><\/li><li><a href=\"scm\/scripting\/shell-scripting\/vi-vim-editor-commands.html\">VI\/VIM editor Commands<\/a><\/li><li><a href=\"scm\/scripting\/shell-scripting\/understanding-epoch-unix-timestamp.html\">Understanding Epoch &amp; Unix Timestamp<\/a><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Monitoring, filesystem, and remote execution<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"scm\/operating-systems\/unix-linux\/20-pmap-commands-examples-in-linux-unix.html\">20 pmap Commands Examples in Linux \/ UNIX<\/a><\/li><li><a href=\"scm\/operating-systems\/unix-linux\/20-mpstat-command-examples-in-linux-unix.html\">20 mpstat Commands Examples in Linux \/ UNIX<\/a><\/li><li><a href=\"scm\/operating-systems\/unix-linux\/20-iostat-command-examples-in-linux-unix.html\">20 iostat Commands Examples in Linux \/ UNIX<\/a><\/li><li><a href=\"scm\/operating-systems\/unix-linux\/20-vmstat-command-examples-in-linux-unix.html\">20 vmstat Commands Examples in Linux \/ UNIX<\/a><\/li><li><a href=\"scm\/operating-systems\/unix-linux\/linux-performance-monitoring-using-iostat-mpstat-and-vmstat.html\">Linux Performance Monitoring using iostat, mpstat and vmstat<\/a><\/li><li><a href=\"scm\/operating-systems\/unix-linux\/20-xargs-command-examples-in-linux-unix.html\">20 Xargs Commands Examples in Linux \/ UNIX<\/a><\/li><li><a href=\"scm\/operating-systems\/unix-linux\/mount-and-unmount-filesystem-partition-in-linux.html\">20 Mount and Unmount Filesystem \/ Partition commands in Linux \/ UNIX<\/a><\/li><li><a href=\"scm\/operating-systems\/unix-linux\/steps-to-perform-ssh-login-without-password-using-ssh-keygen-and-ssh-copy-id.html\">Steps to Perform SSH Login Without Password Using ssh-keygen and ssh-copy-id<\/a><\/li><li><a href=\"scm\/operating-systems\/unix-linux\/gsh-run-linux-commands-on-many-other-linux-server-at-once.html\">gsh \u2013 Run linux commands on many other linux server at once<\/a><\/li><li><a href=\"http:\/\/community.scmgalaxy.com\/blog\/view\/41330\/configuring-nfs-to-access-the-files-from-remote-linux-machine-as-a-mount-point\">Configuring NFS to access the files from remote Linux machine as a mount point<\/a><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Shell scripting collection, interview prep, exercises, and videos<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"scm\/general\/interview-questions-answers\/interview-questions-sets-shell-script-descriptive.html\">Interview Questions Sets : Shell Script Descriptive<\/a><\/li><li><a href=\"scm\/general\/interview-questions-answers\/interview-questions-answer-sets-shell-programming.html\">Interview Questions &amp; Answer Sets : Shell Programming<\/a><\/li><li><a href=\"forum\/34-shell-script\/2165-must-have-collection-of-shell-script-for-any-scm-admin.html\">Must have collection of shell script for any SCM admin<\/a><\/li><li><a href=\"forum\/34-shell-script\/1921-frequently-used-shell-script.html\">Frequently Used Shell Script<\/a><\/li><li><a href=\"forum\/34-shell-script.html\">Shell Script collection in scmGalaxy Forum<\/a><\/li><li><a href=\"forum\/34-shell-script\/733-expect-command-in-unix-linux.html\">Automate mandatory user-parameter in Shell Script using expect<\/a><\/li><li><a href=\"forum\/34-shell-script\/1922-various-commands-to-send-an-email-in-linux.html\">Various Commands to send an email in Linux<\/a><\/li><li><a href=\"forum\/34-shell-script\/1846-df-command-usage.html\">df advance command usage<\/a><\/li><li><a href=\"forum\/34-shell-script\/1845-ftp-commands-for-linux-unix.html\">FTP commands for Linux \/ Unix<\/a><\/li><li><a href=\"forum\/34-shell-script\/267-shellscript-to-monitor-available-disk-space-on-aix.html\">ShellScript to monitor available disk space on AIX<\/a><\/li><li><a href=\"forum\/34-shell-script\/1818-find-linux-command-collection.html\">Find Linux Command Collection<\/a><\/li><li><a href=\"forum\/unix-linux\/2187-disable-ipv6-and-enable-ipv4-in-red-hat-linux.html\">Disable IPv6 and Enable IPv4 in Red Hat Linux<\/a><\/li><li><a href=\"http:\/\/www.gurukulgalaxy.com\/tutorials\/tri7\/cst_101\/o4a\/unit1\/index.htm\">Linux Shell Scripting Units and Exercise Unit \u2013 1<\/a><\/li><li><a href=\"http:\/\/www.gurukulgalaxy.com\/tutorials\/tri7\/cst_101\/o4a\/unit2\/index.htm\">Linux Shell Scripting Units and Exercise Unit \u2013 2<\/a><\/li><li><a href=\"\/www.gurukulgalaxy.com\/tutorials\/tri7\/cst_101\/o4a\/unit3\/index.htm\">Linux Shell Scripting Units and Exercise Unit \u2013 3<\/a><\/li><li><a href=\"http:\/\/www.gurukulgalaxy.com\/tutorials\/tri7\/cst_101\/o4a\/unit4\/index.htm\">Linux Shell Scripting Units and Exercise Unit \u2013 4<\/a><\/li><li><a href=\"http:\/\/www.gurukulgalaxy.com\/tutorials\/tri7\/cst_101\/o4a\/unit5\/index.htm\">Linux Shell Scripting Units and Exercise Unit \u2013 5<\/a><\/li><li><a href=\"scm\/general\/interview-questions-answers\/if-a-linux-build-server-suddenly-starts-getting-slow-what-would-you-check.html\">If a linux-build-server suddenly starts getting slow, what would you check?<\/a><\/li><li><a href=\"component\/com_ariquizlite\/Itemid,536\/quizId,1\/task,quiz\/\">Start Your Quiz<\/a><\/li><li><a href=\"forum\/34-shell-script\/2194-questions-to-test-your-linux-shell-script.html\">Test Your Linux Skills via these Exercise<\/a><\/li><li><a href=\"forum\/34-shell-script\/2010-recovering-a-recently-opended-deleted-files.html\">Recovering a Recently opended deleted files<\/a><\/li><li><a href=\"online-videos\/Bash-Training\/\">Bash Scripting CBT<\/a><\/li><li><a href=\"https:\/\/www.youtube.com\/playlist?list=PL8DSonqBNdRpiJ3SdxifHEE65fOpoK7hg\">Linux Comammands &amp; Shell Scripting Youtube<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best practices and common pitfalls<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Do not memorize command flags in isolation; map each command to an operational scenario.<\/li><li>Use scripts with parameter validation and predictable defaults.<\/li><li>Prefer incremental automation: prove the command manually, then script it.<\/li><li>Log script output clearly so incident timelines are easy to reconstruct.<\/li><li>Review older tutorials before production use; command options and defaults can change over time.<\/li><li>Keep a personal runbook of validated commands for your environment.<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A structured Linux command and shell scripting reference for operations and DevOps work, rebuilt from the original link collection. It includes a practical learning workflow, command comparison tables, ready-to-use examples, and curated source links.<\/p>\n","protected":false},"author":1,"featured_media":3060,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[454],"tags":[811,1122,460,1206,1213,1207,1205,1212,1210,1211,1208,1209,139,138,136,213],"class_list":["post-474","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-shell-script","tag-devops-engineer","tag-guide","tag-linux","tag-linux-shell-scripting-guide","tag-linux-shell-scripting-resources","tag-linux-shell-scripting-tutorial","tag-linux-admin","tag-linux-bash-scripting-video","tag-linux-exercise","tag-linux-quiz","tag-linux-shell-scripting-interview-guide","tag-linux-troubleshooting-guide","tag-scripting","tag-shell","tag-shell-scripting","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/474","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=474"}],"version-history":[{"count":5,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/474\/revisions"}],"predecessor-version":[{"id":79357,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/474\/revisions\/79357"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/3060"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}