Advertisement
sxiii

Руководство по основным и расширенным Bash-командам, скрипты

Jan 27th, 2016
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.79 KB | None | 0 0
  1. #!/bin/bash
  2. ###############################################################################
  3. # Понимание исполняемых файлов (программ) / команд "./shell.sh"
  4. # Понимание аргументов "argument=value"
  5. # Понимание флагов "-f hello-world"
  6. # Понимание системы ввода\вывода команд "> to file < from file | pipes"
  7. # Понимание горячих клавиш Ctrl+C, Ctrl+D, Ctrl+O, Ctrl+X
  8. ###############################################################################
  9.  
  10. # Базовые знания по командам (15)
  11.  
  12. width="90"           # Ширина терминала
  13. largefont="mono12"   # Кегель и шрифт для крупных надписей
  14. smallfont="mono9"    # Кегель и шрифт для мелких надписей
  15.  
  16. level1=( "ls" "pwd" "cd" "mkdir/rmdir" "touch/rm" "cat" "cp" "mv" "echo" "clear" "sudo/su" "man" "date" "cal" "hostname" )
  17. text1=( "List" "Print Working Directory" "Change Directory" "Make / Remove Directory" "Touch / Remove" "Concatenate" "Copy" "Move" "Echo" "Clear" "Switch User Do" "Manual" "Date" "Calendar" "Hostname" )
  18.  
  19. for i in "${!text1[@]}"; do
  20.    clear
  21.    echo "$(toilet --width $width -F border -f $largefont --metal ${level1[i]})"
  22.    txt=$(printf '%s \n' "${text1[i]}")
  23.    echo "$(toilet --width $width -f $smallfont --gay $txt)"
  24.    read -rsp $'Next (space)...\n' -n1 key
  25. done
  26.  
  27. # Средний уровень (загрузка, отображение, pipelines, права доступа, устройства) (15)
  28.  
  29. level2=( "wget" "curl" "head/tail" "less/more" "ifconfig/iwconfig" ">, <, |" "chmod/chown" "grep" "wc" "lsusb" "lspci" "sleep" "df" "du" "mount/umount" )
  30. text2=( "Web Get" "Concatinate URL" "(read from) Head/Tail" "(show) Less / More" "InterFace Configuration / Interface Wireless Configuration" "Direct to/from file, pipe" "Change (file/directory) Mode/Change (file/directory) Owner" "Grep..." "Word Count" "List USB" "List PCI" "Sleep" "Disk Files (filesystem usage)" "Disk Usage" "Mount/Unmount" )
  31.  
  32. for i in "${!text2[@]}"; do
  33.    clear
  34.    echo "$(toilet --width $width -F border -f $largefont --metal ${level2[i]})"
  35.    txt=$(printf '%s \n' "${text2[i]}")
  36.    echo "$(toilet --width $width -f $smallfont --gay $txt)"
  37.    read -rsp $'Next (space)...\n' -n1 key
  38. done
  39.  
  40. # Высший уровень (компиляция, управление процессами) (14)
  41.  
  42. level3=( "make" "gcc/g++" "kill/killall" "bg/fg" "pidof" "service" "lshw" "time" "ps/ps aux/pstree" "top/htop" "sort/uniq" "ln" "awk" "dd/dcfldd" )
  43. text3=( "Make" "Gnu C Compiler" "Kill" "BackGround / ForeGround" "Process ID Of" "Service" "List Hardware" "(execution) Time" "Process Snapshot/Process Snapshot Tree" "Top" "(file/dir Sorting / Unique)" "LiNk" "Awk" "Disk Dump" )
  44.  
  45. for i in "${!text3[@]}"; do
  46.    clear
  47.    echo "$(toilet --width $width -F border -f $largefont --metal ${level3[i]})"
  48.    txt=$(printf '%s \n' "${text3[i]}")
  49.    echo "$(toilet --width $width -f $smallfont --gay $txt)"
  50.    read -rsp $'Next (space)...\n' -n1 key
  51. done
  52.  
  53. # Удаленная работа (12)
  54.  
  55. remote=( "ping" "ssh" "scp" "rsync" "ftp" "logout/exit/Ctrl+D/Ctrl+C" "tar" "zip/unzip" "export/env" "screen" "dig" "nmap" )
  56. text4=( "Ping" "Secure Shell" "Secure Copy" "Remote Synchronization" "File Transfer Protocol" "Do I Need To Tell You What Does Logout Means (NINTTYWDLM)?" "Tape ARchive" "Zip" "Export/Environment" "Screen..." "Dig (for some cool info...)" "Network Map" )
  57.  
  58. for i in "${!text4[@]}"; do
  59.    clear
  60.    echo "$(toilet --width $width -F border -f $largefont --metal ${remote[i]})"
  61.    txt=$(printf '%s \n' "${text4[i]}")
  62.    echo "$(toilet --width $width -f $smallfont --gay $txt)"
  63.    read -rsp $'Next (space)...\n' -n1 key
  64. done
  65.  
  66. # Поиск (11)
  67.  
  68. search=( "which" "where" "whoami" "whois" "whatis" "who/w" "history/!" "lsof" "locate" "find" "md5sum/sha256sum" )
  69. text5=( "Which?!" "Where The ...!?" "Who Am I?!?!?!!!" "Who Is This Domain?" "What is this ...?!" "Who" "History..." "List of Open Files" "Locate" "Find" "message digest 5 summ/sha256summ" )
  70.  
  71. for i in "${!text5[@]}"; do
  72.    clear
  73.    echo "$(toilet --width $width -F border -f $largefont --metal ${search[i]})"
  74.    txt=$(printf '%s \n' "${text5[i]}")
  75.    echo "$(toilet --width $width -f $smallfont --gay $txt)"
  76.    read -rsp $'Next (space)...\n' -n1 key
  77. done
  78.  
  79. # Distro-related (5)
  80.  
  81. dl=( "apt-get" "yum" "packer" "pacman" "yaourt" )
  82. text6=("Application Get" "Yum" "Packer" "Package Manager" "Yaourt" )
  83.  
  84. for i in "${!text6[@]}"; do
  85.    clear
  86.    echo "$(toilet --width $width -F border -f $largefont --metal ${dl[i]})"
  87.    txt=$(printf '%s \n' "${text6[i]}")
  88.    echo "$(toilet --width $width -f $smallfont --gay $txt)"
  89.    read -rsp $'Next (space)...\n' -n1 key
  90. done
  91.  
  92. # Полезные сайты (4)
  93. sites=( "commandlinefu.com" "pastebin.com" "distrowatch.com" "alternativeto.net" "github.com" )
  94. text7=( "Command Line Examples" "Paste Bin" "Distribution Watch" "Alternative To" "Git Hub..." )
  95.  
  96. for i in "${!text7[@]}"; do
  97.    clear
  98.    echo "$(toilet --width $width -F border -f $largefont --metal ${sites[i]})"
  99.    txt=$(printf '%s \n' "${text7[i]}")
  100.    echo "$(toilet --width $width -f $smallfont --gay $txt)"
  101.    read -rsp $'Next (space)...\n' -n1 key
  102. done
  103.  
  104. # Bash scripting (5)
  105. scripts=( "if/then/fi" "exit" "while" "arrays" "(command results in arguments)" )
  106. text8=( "Conditions" "EXIT!" "While something goes on.." "Arrays are cool!" "Inline results" )
  107.  
  108. for i in "${!text8[@]}"; do
  109.    clear
  110.    echo "$(toilet --width $width -F border -f $largefont --metal ${scripts[i]})"
  111.    txt=$(printf '%s \n' "${text8[i]}")
  112.    echo "$(toilet --width $width -f $smallfont --gay $txt)"
  113.    read -rsp $'Next (space)...\n' -n1 key
  114. done
  115.  
  116. toilet --width 180 -F border -f mono12 --metal 'Congrats - this is the END!'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement