Question
Linux Tutorial 55pts Grading: Source code and typescript 20pts each, answers to questions 1-3, 5pts each Objective Get familiar with the Linux/C environment, specifically use
Linux Tutorial
55pts
Grading: Source code and typescript 20pts each, answers to questions 1-3, 5pts each
Objective
Get familiar with the Linux/C environment, specifically use a ssh (Secure Shell), a secure file transfer program (FTP), an editor, and a compiler.
Applications:
putty ssh (Secure Shell) only for loging in to remote terminals - free download at: https://www.putty.org
winSCP ssh and secure file transfer (ftp) together - free download at: https://winscp.net/eng/download.php
Note: you will need your Linux account for this. Use your netId and password to login to csweb01
Open up a remote terminal to a Linux machine from a PC machine using putty or winSCP.
WinSCP defaults to opening an FTP connection, but you can choose: Commands -> Open in Putty to get an ssh window into which you can type commands. The machine you will connect to is csweb01.csueastbay.edu
If you click on Help in WinSCP, you will be directed to a website which describes how to use the application.
You can also choose to use WinSCP for file transfer only and putty for remote login as demonstrated in class
2. Learn how to use a text editor on the Linux machines. You can pick whichever one you want. Some commonly used editors are vim, joe, or emacs. Any of these are good choices if you have not used one before. Read the man (manual) page describing the editor either directly on the Linux machine (type: man vim) or at http://www.die.net/doc/linux/man/
3. Now use your editor to create a very simple C language program. The contents of the file are given below. Name the file yourinitialsLinux.c (e.g. lcLinux.c)
#include
#include
int main() {
printf("Leann Christianson ");
int i = 0;
int val = 0;
float total = 0.0;
printf("Enter 5 numbers and I will find the average (hit enter after each number ");
while (i < 5){
scanf( "%d", &val);
total = total + val;
printf("Summing: num %d ",val);
i++;
}
printf("Total is %f Average is %f ",total,total/5);
exit(0);
}
4. Now compile your program using the gcc compiler. You can compile it by typing: gcc o your InitialsLinux yourInitialsLinux.c
Note the first file name is the object file hence the o in front
5. Now run the program typing the name of your executable program: yourInitialsLinux
6.Now list your files, type: ls
7.You can also list your files and their permissions and sizes like this: ls - a
8.Print the contents of your current directory, type: pwd
9.Make a new directory called CS311, type: mkdir CS311
10.Change into this directory by typing: cd CS311
11.Create a file called junk and copy it to a new file by typing: cp junk junk2
12.To rename a file use the move command this renames a file named junk to stuff: mv junk stuff
13.Now remove the file stuff by typing: rm stuff
14.Now move up to your home directory by typing: cd ..
15.Use WinScp to transfer a file from your local machine to your Linux account. List your files to make sure the file made it.
16.You can remove a directory by typing: rmdir nameOfDirectory however you need to remove the files in the directory first. To remove all files, type: rm *
Questions:
When accessing the Linux machine
1.Show the output if you type ls on your remote terminal in your home directory
2.Read the manual on the editor you have chosen.
a) State which editor you chose to use. Explain how you
b) add a new line of code,
c) search for a string, and
d) save the file and exit.
3.Read (or perhaps skim) the man page on gcc. You may use other C compilers on Linux if you prefer (e.g., g++).
A.State which compiler you used.
B.Explain how you link in a library. (Note that linking in a library is not the same as just including an "include" file in your code.)
4.Change the program you created to input values into an array and print out the values from an array. Save the changes to your program, recompile it, and run to be sure it works.
5.Creating a typescript a typescript records the commands you type and the output of any program that is run. Here is how to create one: Type: script to begin recording all output. Display your program by typing: cat yourInitialsLinux.c
6.Now recompile your new program and run it.
7.To end the recording session type: exit The output file is called typescript. Print out this file. (You might want to transfer it to your local machine first using WinSCP.)
8.Upload your source code and typescript file to the assignment link by the due date and time
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started