Lab 5 - Operating System Mini Project

 Introduction

In this Lab session, I will be doing a mini project for Operating System. 

  Part 1 - Troubleshooting bad connections  

This seems to happen occasionally, and at the worst possible time. These are the steps I normally take to diagnose and solve the problem on a wired connection. It is assumed that the connection worked properly at some time in the past.


Try these steps when diagnosing a network issue: 

1.  First let's make sure the connection is really down by pinging a known external address. I use my own blogspot website as my ISP, hence for me the command would be: ping www.arnonds.blogspot.com/

2. The output should be something like the picture below:

3. Press Ctrl + C to stop the output. If the command line says timed out, or says something about no host or bad route, the connection is indeed down.  



  Part 2 - Copying files to another machine - FTP and SCP  

Not counting email, the two most common ways to copy files to another machine are FTP(File Transfer Protocol) and SCP (Secure copy). Here we will discuss both. 

FTP has been around for many years and is still used quite a lot today. However, standard FTP does have a serious drawback. The data is sent in what is called "clear text". This means a knowledgeable person could obtain the data under the right conditions. We will talk about this a bit later. 


Here is how to use the ftp command: 

1. In a terminal session on the client, run the following command: ftp 192.168.0.142

*Use your own ip-address*


2. It should present you with a prompt. Type in the username and press Enter



3. Type in the password and press Enter



4. It should show something like Login successful.  If it doesn't, then you are not logged in, although there will still be an FTP prompt. Assuming it logged in run the following command: ls -la

As you can see, the files that you have created will be shown on the terminal. 



Here are the files which I created in ftp folder for this mini project purpose: 



5. You should see a listing of files. Run help to show a list of commands. They might not all be available on your system (which I consider a bug). 

6. One thing to remember when using ftp is to know where you are at all times. It is very to get confused. Use pwd often. Run it now: pwd 

7. The commands you type are on the server. To run a command locally, prefix it with an exclamation point. Try these commands: !pwd, !ls


8. So, let's actually do something. Change your local directory to /tmp by running: lcd /tmp


9. Run the !ls command. Now let's copy file f1.txt to the server: put f1.txt



Now what we can observe from the command above is, it will transfer the file f1.txt  to the ftp folder. Picture below shows the file that has been transfered which is f1 :


10. Now let's retrieve file f5.txt from the server: get f5.txt



This process is the opposite of the put command which we just did in step 9. By using the get command, we will retrieve a file from the ftp folder to the server. Once we typed in the get f5.txt command in Linux terminal, we can check and observe the changes in tmp folder in Linux. Below shows the f5.txt  file in tmp folder which didn't exist before we type the get f5.txt command: 

 


11. This may appear a bit confusing at first. That's because it is. However, if you use it a lot it will become much easier. Remember, you put it to the server, and get it from the server. 

12. When you are finished with your FTP session run the following command: quit 


Before proceeding to the next step, please take note that I created an alias for my host and username. The reason why I create an alias is because my windows username has spaces. Hence, the scp command can't retrieve the username. Please see my creating alias blog to see the tutorial on how to create an alias.
 

13. Now let's run some scp commands, to begin: cd /tmp


14. Create a test file by running: ls > f1.txt


15. Run the following command: scp f1.txt arnondscp:/Users


16. Enter the password for user guest. 


Now the file that we copy will transfer to the Users folder: 


17. Assuming file f5.txt is on the remote /temp, to get it run: scp guest1@192.168.0.142:/temp/f5.txt 

18. Don't forget the colon above. Run ls -la to see how it went. 


  Part 3 - Logging into another machine - Telnet and Secure Shell  

Telnet is an older protocol but is still used a lot today. It suffers from the same security problem as FTP; it sends text in a non-encrypted format. However, it is still useful in say a lab environment protected by a good firewall. 


Here we will run a few Telnet and SSH commands: 

1. First, make sure you already configure your Telnet client and server on your windows. For telnet server, I am using telnet server from Pragma System

2. Once installation has done, we can check whether telnet has activated by typing the following command in command prompt (cmd) : telnet 


If your telnet is working, it should show like the following: 


Using linux ip-address

1. Run the following command: telnet 192.168.13.129

*Use your own ip-address*



2. A banner and prompt should appear. Enter the username. 



3. Enter password. 



4. Once that done, you should see the following. 




4. The message of the (/etc/motd) file will probably be displayed. This is a good place to put messages and other information for anyone who is logging in. In this terminal you run pretty much any text-mode command you want. Try pwd


5. You can change to another directory, edit files, and pretty much whatever you would normally do if you were actually on the system. 

6. When you are done with the session, run: exit  


Using windows ip-address

3. Run the following command: telnet 192.168.0.142 

*Use your own ip-address*



4. A banner and prompt should appear. Enter the username. 


5. Enter the password. 


6. If it asks for your windows domain. Head to your command prompt (run as administrator) on your windows and type: systeminfo | findstr /B /C:"Domain

Your windows domain name should appear after pressing Enter




7. Once you enter all of your information, you should be logged in. This is a screenshot of Telnet running on Pragma Server: 


8. The message of the (/etc/motd) file will probably be displayed. This is a good place to put messages and other information for anyone who is logging in. In this terminal you run pretty much any text-mode command you want. Try pwd

9. You can change to another directory, edit files, and pretty much whatever you would normally do if you were actually on the system. 

10. When you are done with the session, run: exit  



1. Now let's try running a Secure Shell session: ssh "Arnond Suvannarat"@192.168.0.142 


2. Enter your password. The /etc/motd file should display as before. 


3.  Let's try some commands. Run the following command: cd


4.  Let's try some commands. Run the following command: dir





5. Run the following command: uptime 


If it doesn't work. Use the following command :  systeminfo| find "System Boot Time:"



6. As with Telnet, every text-based command should work just as if you were on the actual machine. When done with the session, run: exit



  Part 4 - Getting a web page without a browser - wget  

Probably everyone has received an e-mail from a questionable source. You know you shouldn't click on any of the links, but wouldn't it be nice if there was a safe way to determine what was on that site? Well, there is. 


The wget program allows you to download files from URLs. Although it can do a lot, the simplest form of the command is: wget <some URL>. Assuming no errors, it will place that file in the current directory. If you do not specitfy a filename, by default it will attempt to get the index.html file. 


The following is the method to run wget:

1. Run the following command: cd /tmp


2. Run the following command: wget www.arnonds.blogspot.com



3. The resulting file will be named index.html. View it with more index.html


4. You can also refer to specific files. Try: wget www.arnonds.blogspot.com/p/blog-page_31.html




5.  Try it with some other sites. You can do this on a suspicious site to see if it is safe. 

6. If you have a suspect site in mind do a wget on the file. View it and look for links to other sites. If you see something like http:/DoWeCheatThemAndHow.com. I probably wouldn't click on that.