Files
labs/lab-1/LAB-REPORT.md
2025-06-10 10:54:13 -07:00

4.9 KiB

Lab 1

Tasks

  • 1. Connect
I ran the commands from VirtualBox
  • 2. Explore
I ran the sample commands
  • 3. Play
    • grep

      vboxuser@ubel:~/lab-1$ vim extra/folders/example.txt 
      vboxuser@ubel:~/lab-1$ grep -i "Error" syslog
      this is an error i am an error!
      yeah I am another error!
      vboxuser@ubel:~/lab-1$ grep -ir "Error" syslog
      this is an error i am an error!
      yeah I am another error!
      vboxuser@ubel:~/lab-1$ ls
      extra  syslog
      vboxuser@ubel:~/lab-1$ ls
      extra  syslog
      vboxuser@ubel:~/lab-1$ grep -r "error" syslog
      this is an error i am an error!
      yeah I am another error!
      vboxuser@ubel:~/lab-1$ ls
      extra  syslog
      vboxuser@ubel:~/lab-1$ cat extra/folders/example.txt 
      error I am a file
      hello world
      i am not an
      but this is an error!
      vboxuser@ubel:~/lab-1$ grep -r "error" .
      ./extra/folders/example.txt:error I am a file
      ./extra/folders/example.txt:but this is an error!
      ./syslog:this is an error i am an error!
      ./syslog:yeah I am another error!
      vboxuser@ubel:~/lab-1$ grep -rc "error" .
      ./extra/folders/example.txt:2
      ./syslog:2
      vboxuser@ubel:~/lab-1$ grep -ra "error" .
      ./extra/folders/example.txt:error I am a file
      ./extra/folders/example.txt:but this is an error!
      ./syslog:this is an error i am an error!
      ./syslog:yeah I am another error!
      vboxuser@ubel:~/lab-1$ grep -rb "error" .
      ./extra/folders/example.txt:0:error I am a file
      ./extra/folders/example.txt:48:but this is an error!
      ./syslog:0:this is an error i am an error!
      ./syslog:47:yeah I am another error!
      
    • tail Displays the end of the file -- if you add -f (for follow), you can display the contents indefinitely. It is fun to snoop on bots who are trying to log into my server, and this command is useful for that.

       sudo tail -f /var/log/auth.log
      
    • man Better than Google when you have no internet connection or access to chatGPT. Holds an exhaustive (I assume) list of available commands.

      man grep
      man man
      
    • history Shows command history. I would usually use zsh and, if I needed to run a command, I would just press the "up" arrow. That is very tedious if I need to run something that I did > 5 commands ago. This is very useful if I needed to run an obscure command. Or maybe to just figure out what I did.

      history
      history | grep "tail"
      man history
      
    • df Never used this command before. I randomly decided to check this on both MacOS (my computer is always running out of space for some reason or other) as well as on one of my linux boxes.

      There are a lot of differences. Feels like more similarities than differences, but a lot of the important columns are the same. It's also a good command for keeping an eye on the mounted volumes on my linux box.

      Also, since the two commands are so different, I don't think I'll ever be able to remember them!

      Stands for "disk free".

      df (display free disk space)
      df -h
      
      df (report file system space usage)
      df -h
      
    • du Displays file usage. Should use this to investigate where all the space on my local Mac is going.

      man du
      du -hS
      du -s * | sort -nr > $HOME/user_space_report.txt
      
    • ps Showed me a list of running processes. By default it only shows you the processes that were started/were run personally by you on a terminal.

      Also: the man for ps under the Ubuntu box mentioned you can use UNIX (?), BSD (default for mac os?), and GNU (what I assume are the usual default commands) options for ps, provided you use the flags in a specific way.

      Once in a blue moon I have to use pkill some orphaned program, and without fail I have to google how to every time. Maybe I can just use the pids from here instead?

      man ps
      ps -A
      
      man ps
      
    • top Looks similar to ps, but you get a whole dashboard. I could see how you could use this to monitor programs. This is the text version of what I'd use the activity monitor for.

      top
      
    • htop Top, but fancier! It's keyboard navigable AND mouse navigable, and comes with a bunch of colors out of the box. Very cool!

      htop
      
    • exit Exits you out of the current terminal session.

extra reading