The Missing Semester on Computer Science Notes
In computer programming, web development, and Linux system administration, understanding absolute and relative paths is crucial for identifying the location of files and directories. Let’s dive into the differences between them:
Absolute Path:
An absolute path starts from the root directory (/) and describes every step you must take through the filesystem to reach the target location.
It makes no assumptions about your current location.
For example, the absolute path
/usr/share/widgets/button
always points to the same location, regardless of where you start in the filesystem.Think of it like a treasure map that provides precise directions from the very beginning.
Relative Path:
A relative path describes the location of a file or directory relative to your current working directory.
It doesn’t start from the root directory; instead, it uses the context of your current location.
Relative paths are more flexible because they adapt to different starting points.
They use special symbols like
.
(current directory) and..
(parent directory) to navigate.For example:
If your current directory is
/home/user
, a relative path likeDocuments/report.txt
refers to/home/user/Documents/report.txt
.If you’re in
/home/user/projects
, the same relative path points to/home/user/projects/Documents/report.txt
.
Difference between folders and directories
On the surface, folder on the C: drive of Windows, is the same place as the C:\ directory in MS-DOS ( Microsoftsoft Disk Operating System ), therefore in the location sense there is no difference.
Though Folders, in a GUI like windows, don't necessarily map a folder to a hard-drive location.
With a command-line interface (e.g., MS-DOS or Linux), you would say directory instead of folder as a directory is mapped to a physical location on a storage medium.
What is a Kernal?
Kernel is central component of an operating system that manages operations of computer and hardware. It basically manages operations of memory and CPU time. It is core component of an operating system. Kernel acts as a bridge between applications and data processing performed at hardware level using inter-process communication and system calls.
Shebang (Unix)
Character sequence consisting of the characters number sign and exclamination mark at the beginning of a script
The shebang line is usually ignored by the interpreter, because the "#" character is a comment marker in many scripting languages;
More research: https://en.wikipedia.org/wiki/Shebang_(Unix)
Different commands in GitBash:
Touch
Updating Timestamps without changing content
You can literally make it so you updated it in the 2000s
touch -d 'day month year time' file_name
Or it can be used to create an empty file
touch file_name
sh
Bourne Shell -> Command language interpreter
Executes commands from a command line string, standard input, or specified files
chmod
Control File Permissions
3 groups of 3 characters rxw
1 is the User(Owner ) -> Permission for Owner
2 -is the Group -> For members of teh file's group
3 - Others -> Permissions for everyone else
For editing text documents.
! and many other characters have special meanings in double quotations which often means single quotations are just better.
>--> Is redirecting the output stream, and < is redirecting the inptu stream
appending to a file is >>
Pipes
| opereator lets you chain programs
The output of one command is the input of the next one chained over
ls -l / | tail -n1
Last updated