Backgrounding tasks in Linux with nohup and screen

Notes made while following along lecture in the course “Running Kali on Raspberry Pi” by Dr. Polstra on Pentest Academy

nohup

  • nohup –help (Run command, ignoring hangup signals. Basic command line direction)
  • nohup ls / -lR &
    • Runs the ls /-lR command in the background (&)
    • nohup ensures that output is written to nonhup.out and that command runs even if connection to terminal is lost
  • ls
  • logout (to simulate a loss of connection)
  • ssh -X root@<ip-add>
  • nano nohup.out

Expermiment with a script

create loopy.sh

#!/bin/bash
while true
do
echo “Computing..”
sleep 2

  • nohup ./loopy.sh &
  • tail -f nohup.out
  • nohup ./loopy.sh > loopy.out &
  • tail -f loopy.out

screen

  • which screen
  • no output imples scream not installed
  • apt update
  • apt install screen
  • screen
  • ps
  • ps -ef [pipe] grep screen
  • [CTRL A] ? — shows commands available in screen
  • [Return] to end
  • [CTRL A C] for a new screen
  • top
  • [CTRL A N] for next screen
  • vi
  • [CTRL A N] to scroll between top and vi
  • [CTRL A P] for previous
  • [CTRL A D] to detach from a screen
  • screen -r (to go back to where you started)
  • [CTRL A H] or log of sessions
    • ls -l
      • hardcopy.0
      • cat hardcopy.0
  • [CTRL A M] – to setup alterts
    • echo “starting”; sleep 10; echo “done”
    • will flash alert on the screen when there is output
  • [CTRL A X] to lock a screen
  • [CTRL A K] to kill the window

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.