- - - - - - ---=[Urbana Electronics & Programming Summer Program]=--- - - - - - [Trial Session 2/23/2018] TOPIC 1 - Linux System Maintenance [Section 1, SSH]---------------------------------------------------------------- Welcome to UEPSP, today you will learn how to use a remote shell. First off, what is a shell? On UNIX systems, the shell is the program you use to interact with the computer. It's the outermost layer of the Operating System, hence the name shell. On windows, the shell is called the command prompt. Specifically, you will be learning to use Bash(the shell) on Linux(the operating system) You might not be running a unix system, and you might not have the proper tools set up on your computer if you do. That's why I've set things up so that you can use the shell on my computer, through your computer. This is called a remote shell, remote meaning far away, or not the computer you're currently using. There are many protocols for remote shells, such as telnet or ssh. We will be using ssh today. To start off, download an ssh client. The client is the program you run on my computer, that talks with the program running on my computer, the server. ---If you are running Windows, go to: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html click on "putty.exe", under "Alternative Binary Files". Ask your me whether to use the 32 bit or 64 bit version. After the executable(program) has been downloaded, click on it. If it asks "Do you want to run this program", click run. in the text box titled "Host Name(or IP address)" type the ip address on the login slip I gave you. in the box next to it titled "Port", type the port on the login slip. Finally click "Open" and you should see a black window appear. If says "The authenticity of host ......", click yes The window should say "login as:", type in your username and press enter. Do you see Ducky? ---If you are running Mac or Linux Congratulations, you should already have ssh installed! simply find the "terminal" program, and run that. A black box should come up, this is the terminal, and it is running the shell for your computer. However you want to run the shell on my computer. it should look something like this: +--------------------------------------------------------------+ |[ducky@pond ~]$ | | | | | | | +--------------------------------------------------------------+ now to run ssh, you have to run a command, type in the command: "ssh -p [port] [username]@[ip]", replace [port] [username] and [ip] with what's on the login slip I handed you. For example, if the port is 1235, your username is ducky and the ip address is 123.456.7.89, you should type: +--------------------------------------------------------------+ |[ducky@pond ~]$ssh -p 5535 ducky@123.456.7.89 | | | | | | | +--------------------------------------------------------------+ press enter, it should ask "The authenticity of host ....", type "yes" and press enter +--------------------------------------------------------------+ |[ducky@pond ~]$ssh -p 5535 ducky@123.456.7.89 | |The authenticity of host '123.456.7.89' can't be established | |ECDSA key fingerprint is | |SHA256:yUDWcwEryMjEyrK9ajHogibqgLuSd3Y/orHF1BEbJeE. | |Are you sure you want to continue connecting (yes/no)?yes | | | | | +--------------------------------------------------------------+ do you see ducky? So what did we just do? Well to start off, you downloaded an ssh client, this connects to an ssh server on my computer. When you type things into the ssh client, it gets sent to the shell on my computer, and the output gets sent back to you. In order to connect to my computer, you need to know where it is. That's where the IP address comes in. An IP address is the location of a computer on a network, just like your house has an address that tells you where it is in town. In this case, we're all on the same local network, my wifi. The IP address on the slip is therefore a local ip. A computer has to handle a whole lot of connections at once, so to know what kind of thing it's connecting to, they use ports. For example, if you wanted to connect to a minecraft server, it would be on port 25565. The standard port for ssh is 22, but I changed it for security purposes. Ok now that you're connected to my ssh server, you should see ducky, type your password and press enter. please remember that you won't see your password when you type it. You should see something like the below: +------------------------------------------------------------------------------+ |WELCOME TO URBANA UEPSP! | |/----------------------\ | || __ ducky | | || <(o )___ says | | || ( ._> / hello | | || `---' | | |\----------------------/ | |ducky@123.456.7.89's password: | +------------------------------------------------------------------------------+ finally you should now see something like this +------------------------------------------------------------------------------+ |WELCOME TO URBANA UEPSP! | |/----------------------\ | || __ ducky | | || <(o )___ says | | || ( ._> / hello | | || `---' | | |\----------------------/ | |ducky@123.456.7.89's password: | |Last login: Fri Feb 23 22:19:43 2018 from 987.654.3.21 | |[ducky@otherpond ~]$ | +------------------------------------------------------------------------------+ Congratulations! you've opened a remote shell! You can now type commands that will be run on my computer. [Section 2, Bash]--------------------------------------------------------------- Ok, so now you have a shell, but what is a shell? The shell is a program that takes commands you type in, and runs them. There are many different kinds of shells and the one you are running is called bash. To start off, let's type your first command, "help" and press enter. +------------------------------------------------------------------------------+ |WELCOME TO URBANA UEPSP! | |/----------------------\ | || __ ducky | | || <(o )___ says | | || ( ._> / hello | | || `---' | | |\----------------------/ | |ducky@123.456.7.89's password: | |Last login: Fri Feb 23 22:19:43 2018 from 987.654.3.21 | |[ducky@otherpond ~]$help | +------------------------------------------------------------------------------+ You should see something like the below afterwards: +------------------------------------------------------------------------------+ |WELCOME TO URBANA UEPSP! | |/----------------------\ | || __ ducky | | || <(o )___ says | | || ( ._> / hello | | || `---' | | |\----------------------/ | |ducky@123.456.7.89's password: | |Last login: Fri Feb 23 22:19:43 2018 from 987.654.3.21 | |[ducky@otherpond ~]$help | |GNU bash, version 4.4.12(1)-release (x86_64-unknown-linux-gnu) | |These shell commands are defined internally. Type `help' to see this list. | |Type `help name' to find out more about the function `name'. | |Use `info bash' to find out more about the shell in general. | |Use `man -k' or `info' to find out more about commands not in this list. | | | | ... | +------------------------------------------------------------------------------+ Wow, that's a lot of text! to get rid of it, type "clear". You should see something like the below: +------------------------------------------------------------------------------+ |[ducky@otherpond ~]$ | | | +------------------------------------------------------------------------------+ Now let's introduce the concept of working directories. When using a shell, you're always in a certain directory(folder), that directory is called the current working directory. The name of the directory is right after your username, in this case it's "~". That's actually an abbreviation which means your home directory. Your home directory where all your personal files go. To find out what's in a directory, simply type the command "ls". Nothing comes up because your directory is empty. Directories have full names called "paths" that tell you it's exact location. To find the path of your current working directory, type "pwd" You should see something like "/home/ducky" Now you know where home is! So what is this path? well first off, it starts off with the root directory, which is written as "/". This is the directory everything is in. Inside of that is the "home" directory, where all the homes are. Finally inside of that is your home directory, "ducky". When a directory is inside of another directory, it is considered "below" it. If a directory includes another directory, it is considered "above" it. Ok but how do you move around? well that's simple, you type the command "cd"(short for change directory) and the name or path of a directory. for example if you want to move to the directory above your home, "/home", type: cd .. or cd /home cd takes in other information called arguments, which it uses to carry out it's task. In this case, this could either be the full path of "home", which is "/home". In another case, we type it's name "..". When you type the name of a directory, it's assumed that that directory is a "local directory", or directory under your current directory. But hold on, you said "home" was above my local directory! Well, that's why you don't type "home". ".." is the name of the directory above the current directory, which in this case is /home"" Now type "ls" again, you shoul see a lot of directories now. You can see your home directory, and everyone else's too! ok now try going to somebody else's home, type: cd knolax It'll come up with an error, something like: -bash: cd: knolax: Permission denied That's because you don't have permission. See that's somebody else's directory, and it's owned by knolax. You can only access files that you own, or that others own but give you permission to use. We'll go into permissions later on. Ok, let's go home, type: cd ~ Remember, ~ is an abbreviation for home. so when you type cd ~, you're changing direcory to home. How do I make directories? well, that's the final command you'll learn today, "mkdir". type the command: mkdir code Now you've made a directory named code insie of your home directory. type "ls" and you should see "code" [END OF SECTION 2]-------------------------------------------------------------- Section 3 well be given to you by teacher instruction.