0% found this document useful (0 votes)
10 views17 pages

Operating System Lab2

The document provides an overview of the Linux filesystem in Ubuntu, explaining the types of files and the hierarchical structure. It introduces essential directory commands such as `pwd`, `cd`, `ls`, `mkdir`, and `rmdir`, which are crucial for navigating and managing files in the terminal. A practice exercise is included to reinforce the learned commands.

Uploaded by

mr3370628
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)
10 views17 pages

Operating System Lab2

The document provides an overview of the Linux filesystem in Ubuntu, explaining the types of files and the hierarchical structure. It introduces essential directory commands such as `pwd`, `cd`, `ls`, `mkdir`, and `rmdir`, which are crucial for navigating and managing files in the terminal. A practice exercise is included to reinforce the learned commands.

Uploaded by

mr3370628
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/ 17

Operating System:

Lab2
Linux Files in Ubuntu

1 Text files and images 2 Compiled programs 3 Partitions


For example, a text document like Such as /usr/bin/firefox e.g., /dev/sda1
/home/user/documents/report.
txt is a file.

4 Hardware device drivers 5 Directories


Like /dev/video0 for a webcam. Like /home/user/

In Ubuntu, everything is treated as a file, simplifying system management and enabling flexible interaction with system
resources using standard file operations.
Types of Files in Ubuntu
Regular Files (-) Directory Files (d) Special Files
These are standard files These files organize other files These files represent hardware
containing data, text, or program and directories into a devices and system resources.
instructions. hierarchical structure.
Welcome to the Linux Filesystem!
Linux uses a hierarchical filesystem. It is structured like an upside-down tree.

Mastering basic directory commands is crucial. It's key for working in the terminal.

Analogy Text Commands

Think of navigating folders. It's like Windows or macOS. You'll do this entirely through text commands.
pwd: Know Where You Are
`pwd` stands for "print working directory." It displays your current
location's absolute path.

Example: `/home/user/documents` indicates your location.

This shows the `documents` folder, inside `user`, inside `home`.

Why It's Important


It prevents accidental file modifications in the wrong place.
The output will show the full path to your current location (e.g., /home/yourusername).
cd: Moving Around
`cd` changes your current directory.

Examples:

`cd Documents`: Moves into the "Documents" subdirectory.

`cd ..`: Moves up one directory level (to the parent directory).

`cd /home/yourusername`: Moves directly to your home directory.

`cd ~`: Moves directly to your home directory.


Allows you to navigate between different directories.
ls: Listing Directory
Contents
`ls` stands for "list." It shows files and subdirectories.

Basic: `ls` lists the current directory's content.

`ls -l` `ls -a`


Detailed listing with Shows all files, including
permissions, size, owner, date. hidden ones (starting with `.`).

`ls -t` `ls -lh`


Sorts files by modification time Lists in long format with
(newest first). human-readable file sizes.
The output Lets you see what files and folders are present in a location.
mkdir: Making New
Directories
`mkdir` stands for "make directory." Use `mkdir [directory_name]`.

It creates a new directory in the current location.

`mkdir my_new_folder` `mkdir -p


path/to/new/folder`
Creates a directory named
"my_new_folder" in the current Creates nested directories if
location. they don't exist.
The output Lets you organize your files into folders.
rmdir: Deleting Empty
Folders
`rmdir` removes an empty directory.

`rmdir` removes an empty directory.

`rmdir` only works if the directory is empty. For non-empty directories,


you need `rm -r` (be cautious with `rm -r`).

Typing `rmdir empty_folder` removes the directory "empty_folder".

Typing `rm -ri non_empty_folder` command is used to interactively


and recursively remove directories and their content
• The output Lets you organize your files into folders.
• -r (recursive): Deletes directories and all their files/subdirectories.
• -i (interactive): Asks for confirmation before deleting each file.
Clean up empty directories.
Practice Exercise
Let's test your skills with these commands:

1. Create a directory named "Practice".


2. Navigate into the "Practice" directory.
3. Make another directory inside called “Test”.
4. Now, remove the “Test” directory.
5. Move back to your home directory.
Conclusion
You've learned essential directory commands. You can now navigate
Ubuntu!

`pwd`, `cd`, `ls`, `mkdir`, and `rmdir` are fundamental tools.

5
Tools
The number of essential tools you now understand.

Explore more file manipulation commands: Guide to Useful File


Manipulation Commands

You might also like