Neil C. Obremski
  • About
  • Blog
  • Music
    • Moo
    • Necros
    • colbie
    • TravelEra
  • CPP
    • Multi Dimension Arrays and Pointer Pointers
    • Structures
  • Tech
    • ASP
    • Apache2 SSL Windows
    • Celery
    • Chromebook
    • Django
    • FFMPEG
    • IIS
    • JS >
      • Save Binary File to Disk in JavaScript
      • Simple JavaScript/AJAX Optimizations
    • Kindle Self-Publishing
    • Linux Shell
    • Mac OS X
    • QB
    • Pyodbc
    • SQL
    • Subversion for VSS Users
    • VSS
    • WinHttp
    • WSH
  • Games
    • Daggerfall
    • Minecraft
    • Thief >
      • Install Thief on 2000/XP
      • Run Thief without CD
      • Fix Thief Freeze
+1 (206) 795-1327

Linux Shell

Last Updated March 2014

Copy without overwrite (ignore existing)

yes n | cp -i src dest

Mount remote folder over SSH

sudo apt-get install sshfs
mkdir ~/folder
sshfs user@server:/remote/path/to/folder ~/folder

TAR+GZIP directory recursively

tar -zcvf archive.tar.gz folder
Afterwards, untar and gunzip with the following:
tar -zxvf archive.tar.gz
References:
  • http://stackoverflow.com/questions/12331633/how-to-gzip-all-files-in-all-sub-directories-into-one-compressed-file-in-bash
  • http://www.manticmoo.com/articles/jeff/programming/linux/gunzip-and-tar-at-same-time.php

Watch file size grow

Here's a nifty little command you can run to watch the size of a file grow (such as if it's being transferred over SFTP by another process like CRON):
watch -n 5 "du -h filename"

Start program over SSH w/o ending by disconnect

Some things take a while and when the SSH connection times out it will quit all running programs in that session. I found this simple method to run those long commands and disconnect without killing them:
  1. SSH to server
  2. Run "screen" command
  3. Start whatever things you want
  4. Press CTRL+A, CTRL+D to detach from screen session

Later ...
  1. SSH to server
  2. Run "screen -r" to reattach to screen session

Reference: http://superuser.com/questions/134554/how-to-keep-program-running-after-ssh-disconnection

SCP: Copy file via SSH

scp -P port hostname:/remote/path/file.txt /local/path

SFTP shell script

  • http://stackoverflow.com/questions/5386482/how-to-run-the-sftp-command-with-a-password-from-bash-script
  • http://stackoverflow.com/questions/19531699/sftp-file-manipulation-using-shell-script

Cancel stuck SSH session

Press ~. (TILDE + PERIOD). You may have to press ENTER before that. CTRL+C, as you may have noticed, does not end a session that needs to timeout due to a broken pipe. This often happens to me when I put my laptop in suspend and then return to it later.

  • http://apple.stackexchange.com/questions/35524/what-can-i-do-when-my-ssh-session-is-stuck
Submit
Proudly powered by Weebly