0% found this document useful (0 votes)
5 views

02 programming environment

The document provides an overview of the CSE 2451 Programming Environment course, focusing on UNIX/Linux systems and their commands. It details how to access UNIX/Linux through various methods, including WSL and virtual machines, and includes instructions for using Visual Studio Code and accessing the OSU student Linux server. Additionally, it covers essential UNIX/Linux commands for navigation, file manipulation, and process management, as well as resources for further learning.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

02 programming environment

The document provides an overview of the CSE 2451 Programming Environment course, focusing on UNIX/Linux systems and their commands. It details how to access UNIX/Linux through various methods, including WSL and virtual machines, and includes instructions for using Visual Studio Code and accessing the OSU student Linux server. Additionally, it covers essential UNIX/Linux commands for navigation, file manipulation, and process management, as well as resources for further learning.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

CSE 2451

Programming Environment
Tong Liang
Overview
• UNIX – Linux introduction
• Windows Subsystem for Linux (WSL)
• Setup Linux virtual machine
• Student Linux server of OSU
• UNIX/Linux commands
• gcc commands
UNIX
• UNIX is a multi-user and multi-tasking operating system
• Multi-user: Multiple users can use the system at the same time
• Multi-tasking: Multiple processes (programs) can run at the same time

• UNIX is originally developed with assembly language and later


reimplemented with C – C starts to gain popularity

• Our course’s programming environment is UNIX/Linux


How do I get access to UNIX?
• UNIX has some free version for development use
• Use Linux instead of UNIX, it’s a “clone” of UNIX without using its
code, a free and open-source alternative to proprietary UNIX system
• Three ways to get Linux (pick one that works for you):
• Install Windows Subsystem for Linux (WSL) with default Ubuntu distribution
of Linux (https://docs.microsoft.com/en-us/windows/wsl/install-win10) – no
graphic user interface (GUI)
• Import a Linux virtual machine (preinstalled virtual machine image is provided
on carmen: windows, mac) – with GUI
• OSU provides Linux server for students to use - supports both ssh access and
GUI
Import Linux Virtual Machine
• This is a virtual machine with Ubuntu OS that
contains a complete development
environment for C
• Download and Install VirtualBox
• Download the virtual machine image from
the class page (or download link below)
• Windows
• Mac

• Load virtual machine image


• Open VirtualBox
• Select File -> Import Appliance
• Select virtual machine image you downloaded
• Complete the import
Configuration of Virtual Machine
• Adjust the CPU and memory available to the virtual machine
• Go to settings -> System -> motherboard -> processor
• Try to set these as high as possible while remaining in the green zone
Start the Linux Virtual Machine
• Open VirtualBox
• Click on the cse2451 virtual machine to select it
• Click the associated green arrow to start the virtual machine
• Username: cse2451
• Password: cse2451
Display Size of Virtual Machine Screen
• The display resolution may be too low when you first start the
machine
• Click on the top right power off button -> settings - > display
• Then adjust the screen resolution to fit your monitor
Programs used in Virtual Machine
• Key programs
• Linux terminal: an efficient command-based way to interact with the system
• Visual Studio Code: a free, open-source text editor and development
environment

terminal Visual Studio Code


Using Visual Studio Code
• Create a new folder – your project folder
• Launch Visual Studio Code from the side bar

• Click on open folder in VS code


• Pick the newly created project folder
Using Visual Studio Code
• To start coding, create a new file in VS code
• Name the file, ending with “.c”

• Write your code in the newly created .c file


Using Visual Studio Code
• Click on Terminal on the menu bar of VS code
• Select New Terminal (An alternative to the actual terminal program,
which might be easier to use.)
• You can then compile and run your code
Access Student Linux Server – no GUI
• Setup Pulse Secure VPN for off-campus remote access
• Download Pulse Secure VPN here
• Installation guide here:
• Windows
• MacOS
• Download Duo Mobile (verification app)
• Connect Pulse Secure VPN with your OSU student account

• Open a terminal on your own computer


• Windows: command prompt or PowerShell
• MacOS: terminal

• Remote access student Linux Server via ssh in terminal


• Server address: coelinux.coeit.osu.edu
• Type the following command in your terminal: ssh [email protected]
• Replace name.number with your OSU student username dot number, e.g., [email protected]
• Enter your OSU account password in the follow up prompt
• Additional information on remote access: https://ets.osu.edu/ets-wiki
Access Student Linux Server – with GUI
• Setup Pulse Secure VPN for off-campus remote access
• The same as previous slides
• Setup FastX
• FastX installation guide here
• Remote access student Linux Server via FastX
• Create a FastX connection to Linux server, replace the user with your
own name.number
• Launch the connection by double click and enter your OSU student
account’s password
• After login, click on the + button
• Select XFCE in the pop-up window to enter GUI
UNIX/Linux Commands – navigation
• Basic commands

Command Meaning

ls list files and directories

mkdir directory make a directory

cd directory change to named directory

cd change to home-directory

cd .. change to parent directory

pwd display the path of the current directory


UNIX/Linux Commands – file manipulation
• More useful commands

Command Meaning
cp file1 file2 copy file1 and call it file2
mv file1 file2 move or rename file1 to file2
rm file remove a file
rmdir directory remove an empty directory
cat file display a file
less file display a file a page at a time
grep 'keyword' file search a file for keyword
touch file Create a file named file
UNIX/Linux Commands – redirect input/output
• More useful commands

Command Meaning
command > file redirect standard output to a file
command >> file append standard output to a file
command < file redirect standard input from a file
command1 | command2 pipe the output of command1 to the input of command2
cat file1 file2 > file0 concatenate file1 and file2 to file0
sort file sort file data line-by-line
who list users currently logged in

cat file1 file2 | grep keyword:


Concatenate file1 and file2, then pipe the output to search for keyword
UNIX/Linux Commands
• Manual pages give information about commands, C libraries,
functions, and more
• Type man <name> at the terminal to read the manual
• man gcc

• man 3 printf Specifies the section numbers of the manual


about printf (e.g., 1 for executable programs, 2 for
system calls, 3 for library calls )

• man man
Use man command to tell you how to use the
man command
How to stop a process?
• Foreground processes: Press CONTROL and C
• Background processes:
• ps:
• shows running programs
• pkill program:
• Asks program to stop
• pkill -9 program:
• Forces program to stop
Text Editors
• Terminal Editors
• nano
• Emacs
• vim

• Graphic Editors
• Visual Studio Code
• gedit Text Editor
• Emacs
UNIX Tutorial Resources
• http://www.ee.surrey.ac.uk/Teaching/Unix
• http://www.math.utah.edu/lab/unix/unix-tutorial.html
• http://www2.ocean.washington.edu/unix.tutorial.html
Compile Source Code and Run Program
• Open a terminal
• Navigate to the folder storing your source code (e.g.,
/home/liang.693/slides/CSE2451/test) with cd command
• Use gcc to build your program (enter the following cmd in terminal):
program we are running Input arguments we are passing to the program (gcc)

gcc hello.c –o myprogram –std=c99

Building tools: Source file -o myprogram: -std=c99:


gcc/clang path -o specifying the following specifying which standard (c99) the
argument (myprogram) is gcc compiler should use to convert
the name of the output file the C code to executable program
Compile Source Code and Run Program
• Successful compilation/build of the program -> no return error
message displays in terminal
• The output program file should be at the same directory of the source
code unless specified otherwise
• At the directory of the executable program file (named
“myprogram”), run the following command in terminal:

./myprogram

You might also like