linux:bash
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| linux:bash [2020/05/24 14:10] – created bstafford | linux:bash [2023/07/25 15:20] (current) – [Read File] bstafford | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ======BASH====== | ======BASH====== | ||
| + | ===== Set VIM as visudo ===== | ||
| + | Run as root | ||
| + | < | ||
| + | |||
| + | From | ||
| + | < | ||
| + | EDITOR=" | ||
| + | |||
| + | ===== Read File ===== | ||
| + | Read a list of words from a file [[https:// | ||
| + | |||
| + | < | ||
| + | domainsfile=" | ||
| + | |||
| + | while read domain | ||
| + | do | ||
| + | echo " | ||
| + | echo " | ||
| + | echo " | ||
| + | |||
| + | host -W 5 -t txt " | ||
| + | done < " | ||
| + | < | ||
| + | ===== Sudo ===== | ||
| + | Add user to sudo list in '' | ||
| + | < | ||
| + | The add user where they don't need password, use the following. | ||
| + | |||
| + | REMEMBER: put this at the bottom of the file or other lines may get applied after this and change the user permission. | ||
| + | < | ||
| =====Toggle Bash History===== | =====Toggle Bash History===== | ||
| Turn Off< | Turn Off< | ||
| Line 8: | Line 38: | ||
| < | < | ||
| + | =====Copy and Preserve Permissions===== | ||
| + | Add -p to the cp command to preserve ownership and permissions | ||
| + | =====Copy Permissions===== | ||
| + | To replicate the permissions of one file onto a second file, use the following | ||
| + | < | ||
| + | chmod --reference=file1 file2 | ||
| + | restorecon --reference=file1 file2</ | ||
| + | =====cat Multiple Lines===== | ||
| + | This will append the text to outputfile.txt. Replace < | ||
| + | < | ||
| + | Line1 - The first line | ||
| + | Line2 - The middle line | ||
| + | Line3 - The last line | ||
| + | EOF</ | ||
| + | =====Polish Start/Stop Scripts===== | ||
| + | On CentOS, you can use echo_success and echo_failure to add [ OK ] and [ FAILED] to the screen | ||
| + | < | ||
| + | # This next line must be included | ||
| + | . / | ||
| + | |||
| + | echo -n " | ||
| + | # Success or Failure will depend on whether the function | ||
| + | # start_my_service_function returns a 0 or a non0 number | ||
| + | start_my_service_function && echo_success || echo_failure | ||
| + | echo</ | ||
| + | ===== Bash Colour ===== | ||
| + | < | ||
| + | export LS_COLORS | ||
| + | |||
| + | PS1=' | ||
| + | |||
| + | < | ||
| + | |||
| + | ===== Other ===== | ||
| + | < | ||
| + | alias dns=' | ||
| + | alias dnswifi=' | ||
| + | alias dnslan=' | ||
| + | alias dig=" | ||
| + | alias nmap=" | ||
linux/bash.1590329414.txt.gz · Last modified: (external edit)
