OPS145 Lab 3 Newversion: Difference between revisions

From Littlesvr Wiki
Jump to navigation Jump to search
(Replaced content with "The latest version is here: OPS145_Lab_3 Category:OPS145")
Tag: Replaced
 
(22 intermediate revisions by the same user not shown)
Line 1: Line 1:
= !!!THIS PAGE IS NOT READY YET!!! =
The latest version is here: [[OPS145_Lab_3]]


= Filesystems =
[[Category:OPS145]]
A filesystem is a system of organizing files on a storage device. Such a system consists of:
 
* A standard specifying the meaning and order of bytes on the storage device, and
* Driver-like software which hides the filesystem-dependent details, and allows user-level software to perform generic operations (e.g. copy this file to that directory)
 
Files and directories are very different things from a human point of view, but on a filesystem they are almost the same thing. Each has a name, permissions, modification date, and the location of its contents. The contents of a file are whatever you'd expect they are, it's different for each type of file. The contents of a directory are the list of its contents.
 
In this course we're only going to look at the user level of Linux filesystems.
 
We'll start exploring these ideas by paying attention to the directories and files in the following diagram:[[File:FilesystemIntro.png|center|499x499px]]
 
You should have all of these if you finished lab 2.
= Absolute paths start at root =
In Linux there are no drive letters. All the storage which is accessible is accessible via a path which starts at the '''root (a single forward slash)'''.
 
For example your first.txt file is in the Documents directory. The Documents directory is in the asmith15 directory. The asmith15 directory is in the home directory, and the home directory is in the root directory. The root directory does not have a parent directory, technically it is its own parent.
 
There might be other first.txt files on the system. In order to specify the path to this specific first.txt you use an absolute path: '''/home/youruserid/Documents/first.txt'''
 
The directories in a path are separated by '''forward slashes (/)'''. This is different from Windows where backslashes are used.
 
If a path starts with a slash: it's an absolute path.
 
* Open a terminal and use ls, or ls -l to confirm that first.txt exists and you have the correct path to it:<syntaxhighlight lang="bash">
ls /home/youruserid/Documents/first.txt
</syntaxhighlight>
* Read the contents of first.txt using an absolute path:<syntaxhighlight lang="bash">
cat /home/youruserid/Documents/first.txt
</syntaxhighlight>
 
= Relative paths start at PWD =
In the last lab you used relative paths when you ran your ls and cat commands. All that means is that the path you used (e.g. first.txt), because it didn't start with a slash, was automatically appended to the present working directory in your terminal (e.g. /home/youruserid/Documents/), resulting in an unambiguous path (e.g. /home/youruserid/Documents/first.txt).
 
A file or directory name on its own is the simplest type of relative path - you used that last week.
 
This week we can look at slightly more complicated relative paths so you can navigate the filesystem more efficiently.
 
* Use '''pwd''' to confirm you're in /home/youruserid
* Change your PWD to the Documents directory using a relative path, and confirm that worked: <syntaxhighlight lang="bash">
cd Documents
pwd
ls
</syntaxhighlight>
* Now go back to '''your home''' directory (/home/youruserid, not /home):<syntaxhighlight lang="bash">
cd ..
pwd
ls
</syntaxhighlight>
 
Two dots ('''..''') means "parent directory" in the shell. Since /home/youruserid is the parent directory of /home/youruserid/Documents: that does what you want in this case.
 
* From your home directory change directly into the SampleFiles directory:
* That
 
= Also: =
Linux filesystem
 
Navigate filesystem
 
Home directory, directories
 
~
 
mkdir
 
rmdir
 
tree
 
ls -r
 
cp
 
mv
 
rm
 
ln -s

Latest revision as of 00:28, 30 January 2024

The latest version is here: OPS145_Lab_3