Why this episode
A server is only useful if you can get files onto it, and keep things running after you log off. This is Networking and Remote Servers from zero, episode six: the last one. Five commands to copy files, sync folders, and keep your work alive.
Real-life analogies
Copying a file to a server is like sending a parcel by courier. That is scp. Syncing is a moving van that only carries what is new or changed. That is rsync. sftp is a conversation with a file clerk, where you browse and ask for files. tmux is a note that says: keep going, I will be back. And nohup tells a job to ignore the hang-up when you log off.
Command 1: scp
Command one: scp. It copies a file over SSH. Give it the file, then the server and the destination. The colon after the address separates the server from the path. Reverse the order to download. Add -r to copy a whole folder. It is simple and available everywhere, but it sends everything again each time.
Command 2: rsync
Command two: rsync. It copies only what has changed, and shows you what it sent. The flags -avz mean archive, verbose and compress. A trailing slash on the source means: copy the contents of the folder. Without it, you copy the folder itself. Run it again, and only the changes travel. That is why it is a favourite for deployments.
Command 3: sftp
Command three: sftp. It opens an interactive session, where you can browse the server and move files. Inside, use ls and cd to look around, put to upload, and get to download. Type exit when you are done.
Command 4: tmux
Command four: tmux. Normally, if your SSH connection drops, everything you were running dies. tmux keeps a session alive on the server. Start one with tmux new, -s, and a name. Press Control B, then D, to detach. Your work keeps running. Later, log in again, and run tmux attach, -t, and the name, to pick up where you left off.
Command 5: nohup
Command five: nohup. It runs a command that survives you logging out. Add an ampersand at the end to run it in the background, and send the output to a log file. Check progress with tail -f on the log file.
Recap
Recap. scp copies files. rsync syncs only the changes. sftp lets you browse and transfer. tmux keeps a session alive. And nohup keeps a job running after you log out.
Course complete
That completes the course. You can now find a server, secure it, log in, and move work onto it. Add these skills to your Master Profile on ChangeCV, and find more free courses at changecv.com/skills.