i take one breath / mint at a time

Class Activities: Week 6.1,6.2,6.3

  1. Create a research directory and copy all system logs along with the shadow, passwd, and hosts files in one long command.

sudo cp -r /var/log* ~/research; sudo cp /etc/shadow; sudo cp /etc/passwd ~/research/passwd; sudo cp /etc/hosts ~/research/hosts

do I need this many repetitive sudo's?

  1. Create a list of all executable files in the home folder and save it to a text file in the research folder with one long command.

sudo find ~ -executable -type f ~/research/executable_files.txt

  1. Create a list of the 10 most active processes. The list should only contain the USER, PID, %CPU, %MEM and COMMAND. Save this list to a text file in your research directory with one long command.

ps -eo user,pid,%mem,%cpu,comm --sort=%cpu | tail

question: how do I reverse order something I sort?

ps -eo user,pid,%mem,%cpu,comm --sort=%cpu | head -10

Bonus

awk -F : '$3 >= "1000" {print "User: " $1, "UID: " $3, "HomeDir: " $6 }' /etc/passwd

#!/bin/bash

IPADDR=$(ip addr show | grep inet | head -1)
DNS=$(nmcli dev show | grep DNS)

cat << EOF
"Hello $USER! Today's date is $(date)."
"The machine you are using is $(uname) at... $IPADDR for $HOSTNAME."
"The current users logged on are: $(who)"
EOF