0% found this document useful (0 votes)
13 views8 pages

McGill COMP 206 Lecture 3 Notes

Lecture 3 covers the basics of operating systems, file systems, and command line usage, including directory manipulation and file permissions. It explains the distinction between Linux as a kernel and Linux distributions as complete operating systems, as well as the importance of absolute and relative paths. Additionally, it introduces commands for file and directory management, as well as archive manipulation using tar.

Uploaded by

Dinah Ibrahim
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)
13 views8 pages

McGill COMP 206 Lecture 3 Notes

Lecture 3 covers the basics of operating systems, file systems, and command line usage, including directory manipulation and file permissions. It explains the distinction between Linux as a kernel and Linux distributions as complete operating systems, as well as the importance of absolute and relative paths. Additionally, it introduces commands for file and directory management, as well as archive manipulation using tar.

Uploaded by

Dinah Ibrahim
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

Lecture 3

Date @September 4, 2025

[Link] comp206-lesson02-Archive,
Slides
permissions, and vim - [Link]

Subject cmd line + Archives

Review:
What is an operating system?

Manage computer ressources. ex:

Memory

CPU scheduling

Allocates space for different programs

File system:

Tree structure

Everything organized into directories (folder). Directories organized into


hierarchy

Path:

The location of a specific directory/file or any data on the system

Way to traverse this tree to reach this file

Grade: 6/6

Lecture 2 Review [Link]

Lecture 3 1
Hard disk not part of the OS, it is part of the hardware. The file system that
organizes the files on the hard disk is part of the OS.

Linux is ONLY the kernel, by itself it cannot be a full operating system.

Linux distributions (distros) — NOT different implementation of Linux kernel

Linux distribution = complete operating system with Linux as the kernel

What indicates an absolute path?

Doesnt depend on which directory you are currently in

It needs to start from the root. Any path starting from the root is absolute

Starts with a forward slash. If depended, could just write cd <directory>

Both absolute and relative paths can be used as an arguments in commands

How to know if the final element in a path is a directory or a file?

You can go into the directory by adding a forward slash. If it was a file, you
would get an error

If it only has a forward slash at the end, this means it is a directory. If it


doesn’t, it might be a file or directory.

If there is no slash, there is no way of knowing if it is a file or a directory.

If you start writing and click on <tab> it will add the forward slash at the
end of the path, indicating that it is a directory and not a file.

Commands for the command line


Command Format
Command [options] [arguments]

(1) Name of program to run. command name is case sensitive


(2) Switch or flags. Adjust the behaviour of the command. Can be one or more
options. Starts with one dash - or two dashes —

(3) Indicates the targets of the command that should operate on. Eg: file
names, directory name, user-name

Lecture 3 2
Example Syntax:

$ls List elements in the current directory

$ls -l → do the listing with extra information

Didn’t give any arguments — default: the argument is the current


working directory

$ls -l /bin List elements in the directory \bin

Current Directory
pwd (present working directory) displays the current dirrectory you are in

cd (change directory) allows a user to change their current directory

ex: cd ../home

cd .. goes to parent directory of the pwd, and then /home goes to the
directory named home in the parent directory.

ex: cd with no argument brings you to the home directory.

ex: cd . doesn’t do anything since the dot represents the current working
directory

ex: cd .. changes to parent directory

ex: cd / changes to root directory (?)

ex: cd - changes to the directory you were in previously (not necessarily


the parent or home directory)

Directory Content
ls → See content of a directory

ls -a see ALL content of a directory, including hidden directories/files.

Hidden files are basically the configuration files

ls -l [Link] see a particular file in long format (in that case, [Link] file)

Directory Manipulation

Lecture 3 3
cd [directory]

Change directory

ls [options] [directory or file list]

Directory contents or file permissions

mkdir [options] directory

Make a directory

No need to have quotes when writing directory name EXCEPT if the name
you want has a space in it because a space is interpreted as a separation
between arguments.

ex: can write mkdir comp-206 . CANNOT write mkdir comp 206 . Instead, write mkdir

‘comp 206’ or mkdir “comp 206”

pwd

print working (current) directory

rmdir [options] directory

Remove an empty directory

rmdir will refuse to remove a non-existant directory, as well as a directory


that has anything in it.

File Manipulation
touch filename

Create a file if it doesn’t exist

Update the time-stamp of the file to the current time if the file already
exists

cp from to

Copy a file

From and to can be a file name in the working directory or a path

mv [options] file1 file2

move file1 into file2

Lecture 3 4
this will remove the file completely from its original directory

rm [options] file

remove (delete) a file or directory

careful, there is no going back once it is deleted!!!!

-i : interactive (cp, mv and rm)

prompt and wait for confirmation before proceeding

-r or -R : recursive (cp, rm)

it deletes the directory and everything that is inside/beneath it

When you use the -r or -R ALSO USE THE -i

-f : force (mv, rm)

don’t prompt for confirmation (overrides -i)

Archives
Collection of files combined into one file

Easier to manipulate

Often compressed so they require less space

TAR, GZIP, GUNZIP

Tar
Allows manipulation (creation, extraction) of archive files

-c : create a new archive

Going from many files to one file

-x : extract from the tar archive

Reverse operation. Going from one file to many files

-f : specifies the archive file name

Lecture 3 5
-v : activates verbose mode, which means the tar command will output lots of
information

-z : allows you to compress the archive (the archive is


compressed/decompressed using gzip)

examples:

tar -cvf [Link] *.log

create a new archive named [Link].

*.log selects all the files that end by .log

* means any number of characters of any kind

tar -zcvf [Link] *.log

compress the archive we are creating. New compressed archive file will
have gz in the extension

……..

QUESTION: What happens if we forget to put the extension in the file name

Permissions on the File Systems


All files are owned by a user and a group

Permission denied — you do not have permission to access this thing or to do


this operation

View permissions of files


ls -l /ls -l [Link]

Lecture 3 6
r — read permission

w — write permission

e — execute permission

Lecture 3 7
Example: -rw-r—r—

- means it is a file, not a directory. If it was a directory, the first


letter/element would be a d

owner has read and write permission

group has read permission only

other users have read permission only

Lecture 3 8

You might also like