Operating System (1) - Week 02 Lab
Course: CS211P - Operating System (1)
Institution: Mansoura University - Faculty of Computers and Information
Department: Computer Science
Grade Level: 2
Lab Overview
This lab introduces students to the Linux Operating System, specifically Ubuntu, and covers fundamental terminal commands for file and directory management. The focus is on command-line interface (CLI) operations, which are essential for system administration and development work.
Topics Covered
1. Terminal Basics
- Understanding the terminal interface
- The tilde (
~) symbol as an abbreviation for the user's home directory - Command syntax:
command [options] [arguments] - Separating multiple commands with semicolon (
;)
2. Getting Help
- man command: Access manual pages for detailed command documentation
man [command_name]- Options:
-k(search by keyword),-f(search exact name)
- --help option: Quick usage information
command_name --help
3. Essential Linux Commands
Directory Navigation & Information
-
pwd - Print Working Directory
- Shows current directory location
-
cd - Change Directory
cd /path/to/directory- Move to specific pathcd ..- Move up one directory levelcd ~orcd- Move to home directorycd -- Return to previous directory
Directory Listing
- ls - List Directory Contents
- Basic usage:
ls [directory_name] - Common options:
-a- Show all files (including hidden)-l- Long format with detailed information-lh- Long format with human-readable file sizes-ld- Directory information only (not contents)-d- Information about directory/file itself-F- Append indicator characters to special files
- Basic usage:
File & Directory Creation
-
touch - Create New File
touch file1
-
mkdir - Make Directory
mkdir folder_name-poption: Create parent directories as neededmkdir -p new_folder/folder1
File & Directory Operations
-
cp - Copy Files/Directories
cp [options] source target-i- Interactive mode (prevent overwriting)-r- Recursive copy (for directories with contents)
-
mv - Move or Rename Files/Directories
mv [options] source target-i- Interactive mode (prevent overwriting)
File & Directory Removal
-
rm - Remove Files
rm file_name-roption: Remove directory and contents
-
rmdir - Remove Empty Directory
rmdir directory_name(only works if directory is empty)- Use
rm -r directory_namefor non-empty directories
Command Syntax Structure
All Linux commands follow this general syntax:
command [options] [arguments]- command: The action to perform
- options: Modifiers that change command behavior (usually prefixed with
-or--) - arguments: Files, directories, or other information the command needs
- Items are separated by spaces
Learning Objectives
By completing this lab, students will be able to:
- Navigate the Linux file system using terminal commands
- List and view directory contents with various formatting options
- Create, copy, move, and delete files and directories
- Use help resources (man pages and --help) to learn about commands
- Understand basic command syntax and structure
- Work efficiently with the Linux command-line interface
Prerequisites
- Ubuntu Linux installed (or any Linux distribution)
- Access to the terminal/command line
- Basic understanding of file system hierarchy
Getting Started
To open the terminal in Ubuntu:
- Click on the search option
- Enter "command" or "terminal" in the search box
- Double-click the Terminal option from search results
Practice Tips
- Use the
mancommand to explore more options for each command - Practice navigating between directories using relative and absolute paths
- Always use the
-ioption when copying or moving files to prevent accidental overwrites - Use
Tabkey for auto-completion of file and directory names - Use arrow keys to navigate through command history
Additional Resources
- Ubuntu Official Documentation: https://help.ubuntu.com
- Linux Command Line Basics: Use
man introfor introduction - Practice commands in a safe environment before using them on important files
Notes
- The
~symbol is shorthand for your home directory - Hidden files in Linux start with a dot (
.) - Be careful with
rmcommand - deleted files cannot be easily recovered - Use
pwdfrequently to know your current location in the file system
Last Updated: Week 02, First Semester 2024-2025