My Ubuntu Bag of Tricks

    These are commands that I commonly find myself using when trying to manage mining rigs. Perhaps you will find them useful as well!
    • Different ways to transfer files and directories between hosts using scp. scp stands for secure copy. It copies the files over the ssh protocol.

      Send a file from your local host to a remote host:

      scp file.txt username@remotehost:/some/remote/directory

      Send a file from a remote host to your local host:

      $ scp username@remotehost:file.txt /some/local/directory

      Copy files between two remote hosts:

      $ scp username@remotehostx:/some/remote/directory/file.txt username@remotehosty:/some/remote/directory/

      Copy a local directory to a remote host:

      $ scp -r local_folder username@remotehost:/some/remote/directory/destination/
    • Get the sha256 hash of a file on a mac. Sometimes when you download software they will show a big long list of characters. This is a unique signature for the file, and after you download the file you can see if you can check to see if you get the same signature locally. This comes in handy when you download critical software (in my case a crypto coin wallet for Vertcoin).
      $ openssl sha -sha256 filename_of_interest
    • Log a website’s performance over time using a Mac’s terminal and some fancy commands.
      $ while sleep 360; do curl -s -w '\nLookup time:\t%{time_namelookup}\nConnect time:\t%{time_connect}\nPreXfer time:\t%{time_pretransfer}\nStartXfer time:\t%{time_starttransfer}\n\nTotal time:\t%{time_total}\n' -o /dev/null http://208.97.140.30:7903/static/ > latency_output && date > latency_output; done
      

      Fields in bold you need to change to your own, with the first being how many seconds between attempts, the second being what URL you are interested in, and then the third is the name of the file you want the output to be stored in.

      To follow along on the progress, open up another terminal window and run the following against the output file.

      $ tail -f latency_output
      

      Again, change the bolded filename to what you named it in the command before this one.

      References: 1 2

    • To change your hostname (requires a reboot), edit the following two files
$ sudo nano /etc/hostname
$ sudo nano /etc/hosts
  • For a given process id determine what the full path is
    $ sudo ls -l /proc/WHATEVER_THE_PROCESS_IS_ID_IS/exe
  • Pull down only the latest code from a git repository
    $ git clone --depth=1 git@github.com:organization/your-repo.git
  • Other commands I will write about later
    $ spd-say "hello"