Demo of starting Knoppix
To use Knoppix in the lab, find it in Program Files, then click on the .vbox file. None of the stuff you do here is persistent, so save all your work on Matrix.
There are many distros for Linux, some of them are very niche. You can try any of these out without affecting your system configuration. Search for ‘Live USB Creator’, and you will many options for creating a Live USB. From here, you can reboot your computer, boot from the USB drive (you may need to change your BIOS settings to enable this), and follow the instructions. This can often be a simple solution if you aren’t used to setting up virtual machines.
What distro to choose? Here are a few of the common ones:
Whatever you choose, you will still have many configuration options available to you. A Desktop Environment, for example, changes how your GUI looks. Ubuntu and Fedora both use GNOME 3, and as a result they look pretty similar by default. But you can easily play with Cinnamon, Plasma, Budgie, XFCE, etc.
Now that we are in Knoppix, I can show you how we would use our SSH command:
ssh <user>@matrix.senecacollege.ca
If this was my persistent system, I might generate a key-pair and then copy a public key to Matrix.
What is SSH? It stands for Secure SHell. In the past, we might have used a program like Telnet to log into our machine. Telnet is old, and insecure. At this point there is no reason to use it. With SSH, everything between your remote and local machine is encrypted. You can even use SSH as a ‘tunnel’, and manipulate programs with GUIs using SSH.
Another important command to learn is SCP, which uses SSH for file transfers. Just like our cp
command, we need to give it a target and a destination. The difference is that one or both of these paths is going to be remote, and so we need to provide more information.
scp <target> <destination>
So let’s say our target is remote, and our destination is local. I’m going to choose ‘frankenstein.txt’ as my target. I have access to my own account, so this should work.
scp eric.brauer@matrix.senecacollege.ca:~/frankenstein.txt ~
The syntax of the first argument is important. username@hostname:filepath. If you ever get confused, follow the same syntax you see on your command prompt.
eric@eric-eriga:~/uli/courseNotes$
– don’t include the $!
To transfer an entire directory, you will need the -r
option! Let’s push a directory from Knoppix, rather than pulling a file this time.
scp -r /tmp eric.brauer@matrix.senecacollege.ca:~
Let’s take a look…
If you go through the process of setting up mail
on your system, you can send mail from the command line. More importantly, any scripts that you write can send out mail if your server encounters a problem.
mail recipent@hostname
, then enter subject and body of message. Or:
mail recipient@hostname -s "Subject" < body-of-mail
You can also send mail to other users on Matrix:
mail recipient@localhost
FTP is a protocol used for downloading files. It isn’t secure by default, so it’s been replaced by SFTP. SFTP uses SSL encryption.
sftp user@host
: to log in.
ls, pwd, etc
: to navigate remotely.
!ls, !pwd, etc.
: to navigate locally.
get filename, put filename
: to pull and push files.
Ctrl_d
: exits.
Networking is something we sadly don’t cover enough of in this course. But here’s a quick crash course.
ip address
: Returns important information like your… ip address.
netstat
: Among other things, you can use it to see open ports on your system.
nslookup matrix.senecacollege.ca
: Returns IP from URL, and URL from IP address.
ping matrix.senecacollege.ca
: Ping is still the simplest way to start network troubleshooting.
wget <url>
: So whenever you have a link to file to download from a website, this command will download it to your current location. This is different from scp
, because you don’t need any kind of credentials and you also can’t expect any encryption. But it’s useful if, say, you need to grab a driver or document online and you have the URL handy.
curl
: There are many ways to use curl, and too much to cover. But basically you can use it like wget, or to return HTTP assets. Or test a RESTful interface.
If you’d like to really dive into using curl, check out this post by Julia Evans.
Whenever you want to edit text files and the job requires more than just echo
, you will probably have a couple of options.
For quick simple jobs, try using nano
. For more complex jobs, try using vim
.
You’ll see references to both vi and vim. Vim stands for v(im)proved. Both are available to you on Matrix.
Vim is an extremely powerful text editor that can years to master. Some developers love Vim above and beyond all other IDEs and text editors. Everyone else will struggle to exit Vim…
As part of Assignment #1, you are required to finish the Vim tutorial, which honestly does a very good job of showing you the basics.
In Vim, there are three important modes:
colorscheme
then start hitting TAB. Hit Enter to try out a new color.Another important option is turning on line numbers. Try entering command mode again and type set number
.
I recommend using a tool such as vimtutor to get more comfortable with the basics.
Vim is a necessary tool when all else fails, and you should try to get a basic understanding of it. You certainly don’t have to love it, though! In addition, keep in mind that there are no questions about Vim on tests/quizzes.
ssh user@host
: Logs into the remote serverscp <target> <destination>
: Transfer files securely. Use -r
for directories. Use user@host:filepath
for the remote file or directory.“How do you log into Matrix so quickly?”
If you’ve noticed, I can log into Matrix by typing ssh matrix
. There’s two parts to this:
First of all, I have an alias set up. This means that matrix
== eric.brauer@matrix.senecac.on.ca
. There are a couple ways to do this, but here’s one: In your home directory, there is a hidden directory called .ssh
. You can create a file in .ssh
called config
.
cat ~/.ssh/config
Be sure to test this by typing in ssh matrix
and making sure that you get prompted for your password.
Now you can work on the next part, which is generating a private/public key pair. On Linux this is easy:
ssh-keygen
You will be prompted to set a location. Press Enter to accept the default. You will also be prompted to enter a passphrase, but that’s optional.
Once you generate the keypair, you will need to transfer your public key to Matrix. The command to do this:
ssh-copy-id matrix
If you checked your config file before, this should work. You will be prompted for your password for the last time..! Be sure to keep your private key secure, but now you should be able to log in much quicker.
Putty will require a few more steps, including installing a separate program. Keep in mind that you will need to specify a safe location for your private key! These instructions should be more or less complete, but don’t attempt this if you have a looming deadline.