[Solved] CS0449 Lab 1-Thoth, SSH, and C

$25

File Name: CS0449_Lab_1_Thoth__SSH__and_C.zip
File Size: 282.6 KB

SKU: [Solved] CS0449 Lab 1-Thoth, SSH, and C Category: Tag:
5/5 - (1 vote)

thoth is a computer in the CS building. Its hooked up to Pitts network, but the CS department manages it and puts software on it useful for this and other courses.

By logging into thoth remotely, you dont have to worry about setting up a C compiler on your own computer.

ssh is a way of running commands on a remote machine. Its like your command line, but the console is connected across the internet instead of to your own computer.

Later projects will also use features only available on thoth. So please dont try to compile your projects on your local machine.

1. Getting connected and set up

Nothing will show up when you type your password. Thats normal.

When you log in, dont worry about the unauthorized access message. You are supposed to be logging in. Youre authorized 😉

Windows users

You need to get an ssh client, like PuTTY (use the 64-bit installer). Run it, and use thoth.cs.pitt.edu as the address.

Say Yes to the certificate, give your username (lowercase) and password, and youre in!

Mac users

Open up Terminal (+Space, type terminal, hit enter). Then run:

$ ssh [email protected]

Say Yes to the certificate, give your username (lowercase) and password, and youre in!

If you cant log in, please ask the TA for help. If you are sure youre putting in your username in lowercase, and the right password, please email me and CC Dr. Khattab ([email protected]). Hes the thoth administrator.

2. Common UNIX commands

Heres a quick reference guide to refer back to.

  • pwd display the current directory
  • cd dirname change current directory to dirname
    • cd .. moves up one directory
    • cd ~ goes to your home directory
    • cd toggles back and forth between the last two directories you were in
  • ls list all files/folders in current directory
    • ls dirname will list files/folders in the directory dirname
  • mv source dest move or rename a file
    • source is the file you want to move/rename
    • dest is the new place/name
  • cp source dest copy a file from source to dest
  • mkdir name make a new directory named name
  • touch filename make an empty file named filename
  • cat filename display contents of text file filename
  • less filename view contents of text file filename good for longer files
    • press q to exit!
  • rm filename delete (remove) filename
  • rmdir dirname delete an EMPTY directory named dirname

Where are we?

When you log in, you are placed in your home directory.

  1. Try using pwd; itll show you the full path of your home directory.
    • Your home directory can be referred to as ~ in many commands as a typing shortcut.
  2. Try using ls. It will list the files and directories.
    • Your private directory is what you want to do your work in. No one else can see it.
  3. Do cd private and youll move into that directory.
    • pwd again, and youll see that your directory changed.
    • You can use cd .. to move up one directory.
    • You can use cd ~ to go to your home directory.

3. Setting up your ~/.bash_profile a little bit

bash is what youre using right now the thing you type commands into. .bash_profile is the configuration file for bash.

  1. Do cd ~.
    • This goes back to your home directory.
  2. Do chmod u+rw .bash_profile
  3. Now lets edit it: nano .bash_profile
    • nano is a very simplistic text editor that runs inside the terminal. The controls are at the bottom of the screen something like ^X means press Ctrl+X. (Mac users, use the actual control key.)
  4. Scroll down to the bottom of the file. There, youll see:

5. # Define your own private shell functions and other commands here

  1. Use the arrow keys to put your cursor after that line. Now, copy and paste this exactly:
    • In putty, you can right click and paste
    • In Terminal on a mac, V will paste

7. if [ $HOSTNAME = thoth.cs.pitt.edu ]; then8. source /opt/set_specific_profile.sh;9. fi

  1. If you want a nice-looking terminal prompt like I have, find the line that starts with export PS1, and replace it with this:

11. export PS1=[[33[1;32m]h[33[0m] [33[1;34m]w[33[0m]]: ;

  1. Now hit Ctrl+O and hit enter to save. Then hit Ctrl+X to exit.
  2. Do source .bash_profile
  1. Try doing man open. If you see this, yay! Hit q to exit.

If you see No manual entry for open then you messed up somewhere. Ask for help!

4. Making a hello world program

Organization is good. Dont just do all your work in private. Make a directory for your 449 work!

  1. Make sure you are in your private directory. Then do mkdir cs449.
  2. Do ls, and you should now see cs449 listed. cd into cs449.
  3. Now make a lab1 directory inside your cs449 directory, and cd into that.
  4. Lets make a C file. Do nano lab1.c. This will create a new file and open it in nano.
  5. Now type the following into the editor.

6. // Your Name (username)7. #include <stdio.h>8. 9. int main() {10. printf(Hello World!
);11. return 0;12. }

  1. Save the file and exit nano.
  2. Now, compile it like so:

15. gcc std=c99 -Wall -Werror -o lab1 lab1.c

If you did it right, it should print nothing. With UNIX, no news is good news. Successful commands will usually be quiet. But if you ls, you should now see a new file, lab1. This is your executable!

  1. Type ./lab1 to run your program. It should say Hello, World!

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CS0449 Lab 1-Thoth, SSH, and C[Solved] CS0449 Lab 1-Thoth, SSH, and C
$25