Skip to content

Latest commit

 

History

History
32 lines (28 loc) · 1.77 KB

File metadata and controls

32 lines (28 loc) · 1.77 KB

Linux security book - https://linux-training.be/linuxsec.pdf

Linux security courses

Linux security notes

Linux/Bash notes

Exit codes, chaining commands, -e,
  • $? saves the exit code of the previous command. 0=success, 1=failed, A non-zero (1-255) exit status indicates failure.
  • cat /etc/passwd && cat 123 returns code 1, cat /etc/passwd || cat 123 returns 0.
  • If 1st command success, do not run 2nd command cat 123 || touch 123
  • If 1st command fail, run 2nd command touch 123 && cat 123
  • #!/bin/bash, if we are not sure of bash path use #!/usr/bin/env bash
  • Make a file executable chmod +x ./file.sh
  • set +e to turn off the "exit on error" , set -e to turn on "exit on error"
  • Return values for bash can only be used for exit codes
  • $(command) to print output of a command in a string echo "Files are $(ls)"
  • rm $(ls) - Delete all the files from a folder using rm command in the current working dir
fd, stdin, stdout, stderr, file descriptors