Lecture 1 - Systems-level Programming

Navigating a Command Line Interface (CLI)

Course Overview

  • Course Title: CSC 3320: System-level Programming

  • Instructor: Faris Hawamdeh

    • Email: fhawamdeh1@esu.edu

    • Office Hours: TR 3:00 pm-4:00 pm, Room 742, 25 Park Place 7th floor

    • TA: Sean Brown (sbrown264@student.esu.edu), Vaishnavi Veeranki (veeranki2@student.gsu.edu), Keerthana Aluri (kaluri1@student.esu.edu)

Course Description

  • Experience using C to interface with UNIX.

  • Learn UNIX concepts: files, processes, interprocess communication, shells.

  • Writing and testing C programs utilizing UNIX editors and tools.

Course Outcomes

  1. Proficient in using remote systems through SSH and SFTP.

  2. Use UNIX/Linux and shell commands.

  3. Solve problems through C programming.

  4. Understand process mechanisms (pipe, fork, exec).

  5. Utilize structs for accessing directory contents/process data.

Textbooks

  • Required: None

  • Recommended:

    1. C Programming: A Modern Approach by King (2nd Edition, 2008)

    2. UNIX for Programmers and Users by Glass and Ables (3rd Edition, 2003)

Grade Distribution

  • Syllabus: 5%

  • Participation/Attendance: 20%

  • Homework: 10%

  • Quizzes: 25%

  • Labs: 20%

  • Mid-Term Exam: 20%


Lab Sessions

  • Attendance is mandatory.

  • Labs start next Wednesday; check course schedule.

  • Two different lab locations.


Computing Resources

  • Public-use Workstations: Available on Windows and Macs.

  • Laptop Checkout: In-Library only for Windows & MacBooks.

  • Chromebook Checkout: Two weeks with one renewal at GSU Libraries.

  • Library Membership: GSU students eligible for library cards.


Snowball Server

  • Instructional server for GSU Computer Science.

  • Used for teaching C Programming and UNIX/Linux architecture.

  • Requires GSU single sign-on.

  • Student programs graded on Snowball.

  • Snowball Server Knowledge Guide


Course Topics Overview

  • Computer Systems: Hardware (CPU, Memory, Displays, etc.) and Software (OS, Applications).

  • Overview of UNIX and its significance to modern operating systems.

  • C programming essentials and its integration with UNIX.


User Interfaces

  • Early computers used CLI (Command Line Interfaces).

  • GUI (Graphical User Interfaces) became commercially successful with Macintosh.

Shells

  • Common shells include:

    • Bourne Shell

    • Korn Shell

    • C Shell

    • Bash (Bourne Again Shell)

  • Shell scripts: text files with shell commands.


Connecting to a Remote Server

  • Snowball as the instructional server.

  • Login Methods:

    • Locally: username and password.

    • Remotely: SSH/telnet utility for CLI.

  • Reference CS IT Knowledge Guide for login details.


SSH Protocol

  • SSH (Secure Shell Protocol): encrypts data over unsecured networks.

  • Used for remote login and command execution.

  • Consists of SSH client and server, primarily for Unix-like OS.


SSH Client Information

  • UNIX-like systems (Linux, macOS) have built-in SSH client/server.

  • Windows requires external programs like PuTTY or PowerShell (now supports SSH natively).


Connecting Via SSH Steps

  1. Open PuTTY or Terminal.

  2. Use command: ssh username@snowball.cs.gsu.edu

  3. Confirm key fingerprint if prompted.

  4. Enter GSU Password.


Running Utilities/Commands

  • To run a utility type its name at the prompt and press Enter.

  • Common commands:

    • man: Help.

    • cd: Change directory.

    • clear: Clear terminal.

    • ls: List files.

    • pwd: Print working directory.

    • Logout via exit or CTRL+D.


Keyboard Shortcuts

  • Interrupt: CTRL-C

  • Suspend: CTRL-Z

  • End of File (EOF): CTRL-D

  • Use stty -a to list all keyboard shortcuts.


Common UNIX Commands Overview

  • Utilities:

    • ls: List files

    • cat, more, head, tail: Show file contents

    • mkdir, cd, pwd: Directories

    • mv, cp, rm: Working with files

    • wc: Word count

    • chmod, chgrp: File permissions

    • vi, nano: Text editors


File/Directory Navigation

Making Directories

  • Create: mkdir <dir-name>.

  • Change Directory: cd <dir-name>.

  • Print Working Directory: pwd.

Listing Files

  • Basic command: ls -algFsdR <file-spec-list> with options for hidden files, formats, etc.

Understanding Pathnames

  • Root directory /.

  • Current directory . and Parent directory ...

  • Absolute paths: start from /, relative paths are current.


Viewing File Contents

Common Commands

  • cat: Display full content, no pause.

  • more: Display one screen, next with spacebar.

  • less: Allows backward movement.

  • head and tail: View first/last n lines of files.


Text Editors

  • Vi(vim): Command mode and text entry mode.

  • Nano: Simpler alternative for beginners.


File Management

Move/Rename Files

  • Command: mv <old> <new>.

Copying Files

  • Command: cp <old> <new> (recursive for directories).

Removing Files/Directories

  • Warning: rm (permanent deletion).

    • Command: rm -fir <file-spec-list>.


File Operations

Word Count

  • Command: wc -clw <file-spec> for bytes, lines, words count.

User Groups

  • Lists user groups with groups <userid>, change group with chgrp, start new group shell with newgrp.

File Permissions

  • Change permissions: chmod <u g o a>(+-)<r w x s>.

  • Examples provided on modifying file permissions.


File Transfer Methods

SFTP Protocol

  • SFTP for secure file transfer, syntax and examples provided.

Downloading/Uploading Files

  • Commands: get for downloading, put for uploading with options for recursive transfers.

Resuming Transfers

  • Use reget or reput to continue interrupted transfers.


GUI SFTP Clients

  • Recommended: WinSCP (Windows) or FileZilla (cross-platform).

  • User-friendly for file transfer operations.