Advanced Programming in the UNIX Environment

Week 3: chmod(2) and chown(2)

Having seen a lot of examples in our previous videos of creating files, changing their ownership, changing their permissions, we now focus on the system calls that are used to implement the chmod(1) and chown(8) commands.

https://youtu.be/5MJmCanZDyk

#apue #unix #programming

Advanced Programming in the UNIX Environment: Week 03, Segment 4 - chmod(2) and chown(2)

Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.

YouTube

Advanced Programming in the UNIX Environment

Week 3: umask(2)

In this video lecture, we'll take a look at what file ownership and permissions are applied when we create a new file. In the process, we'll learn about the concept of a process's "umask", and look at how the 'umask' shell built-in is implemented.

https://youtu.be/bRAR2bv2HSM

#apue #unix #programming

Advanced Programming in the UNIX Environment: Week 03, Segment 5 - umask(2)

Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.

YouTube

Advanced Programming in the UNIX Environment

An illustration of how permission octal modes and umasks work.

#apue #unix #programming

Advanced Programming in the UNIX Environment

Week 3: Union Mounts and Whiteout Files

One of the file types we've encountered are those of type S_IFWHT, so called "whiteout" files. But what the hell is that?? Let's illustrate! We describe the concept of union mounts and see what happens when a file in the upper layer is removed while the same file still exists in the lower layer: a whiteout file is created to cover up the lower file.

https://youtu.be/MkFExG9jhEE

#apue #unix #programming #netbsd

Advanced Programming in the UNIX Environment: Week 3, Segment 6 - Union Mounts and Whiteout Files

Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.

YouTube

Advanced Programming in the UNIX Environment

Week 4: The Unix Filesystem

In this video lecture, we begin a closer look at the Unix Filesystem (UFS). We visualize how the filesystem structures the disk and organizes files and directories. We illustrate how directory entries are created and moved around.

https://youtu.be/kY4JAXYyByQ

#apue #unix #programming

Advanced Programming in the UNIX Environment

Week 4: Links

In this video lecture, we'll take a look at the system calls used to create, remove, and rename both hard- and symbolic links. We'll compare expected output against trivial implementations of the ln(1) and mv(1) commands.

https://youtu.be/0l8o2goJ1kc

#apue #unix #programming

Advanced Programming in the UNIX Environment

Week 4: Directories

In this video lecture, we take a look at how directories are created and removed, as well as how to move around the filesystem hierarchy. We also learn why the 'cd' command must be a shell builtin in order to work.

https://youtu.be/xZ7dNXZ58G8

#apue #unix #programming

Advanced Programming in the UNIX Environment: Week 04, Segment 3 - Directories

Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.

YouTube

Advanced Programming in the UNIX Environment

Week 4: Directory Size

In this video lecture, we dive deep into the structure of the directory on a traditional Unix File System and see how its size is independent of the file sizes of its entries, but dependent on the filename lengths. We'll also use hexdump(1) to cheat a bit and look at the directory structure on disk.

https://youtu.be/gY0SE-71LZA

#apue #unix #programming

Advanced Programming in the UNIX Environment: Week 04, Segment 4 - Directory Size

Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.

YouTube

Advanced Programming in the UNIX Environment

Week 4: /etc/passwd

In this short video, we try to answer the awkward question "Mommy, where do UIDs come from?". We look at the /etc/passwd user database and identify the various fields before we look at how things can get weird.

https://youtu.be/fv16TWDnLYM

#apue #unix #programming

Advanced Programming in the UNIX Environment: Week 04, Segment 5 - /etc/passwd

Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.

YouTube

Advanced Programming in the UNIX Environment

Week 4: getpwuid(2) and /etc/groups

In this video lecture, we look at the library functions used to look up account information. We learn about how primary and supplementary groups are handled as well as how the hashed passwords are stored outside of the world readable /etc/passwd file.

https://youtu.be/aomkx6_aWpc

#apue #unix #programming

Advanced Programming in the UNIX Environment: Week 04, Segment 6 - getpwuid(2) and /etc/groups

YouTube

Advanced Programming in the UNIX Environment

Week 4: atime, mtime, ctime

In this video lecture, we start looking a little bit closer into what our systems think of "time", something that experts most accurately describe as a big ball of wibbly, wobbly, timey, wimey... stuff. In short, analyze how the atime, mtime, and ctimes of a file connect.

https://youtu.be/ffYEEj5vnlw

#apue #unix #programming

Advanced Programming in the UNIX Environment: Week 04, Segment 7 - atime, mtime, ctime

Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.

YouTube

Advanced Programming in the UNIX Environment

Week 4: time(3) is an illusion

Having revisited the atime, mtime, and time in our last video segment, we now have to come to terms with time(3) itself. We'll discuss managing the data structures and handling arbitrary concepts such as leap seconds, timezones, and (ugh) Daylight Savings Time. It gets silly real quick.

https://youtu.be/3N2aH1vUacQ

#apue #unix #programming

Advanced Programming in the UNIX Environment: Week 04, Segment 8 - time(3) is an illusion

Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.

YouTube

Related to our discussion of time(3), here's a deeper dive into the Unix epoch, its origins, and how the Y2K38 issue actually affects different unix systems well before the heat-death of the universe.

https://www.netmeister.org/blog/epoch.html

#apue #unix #programming #time

Time is an illusion, Unix time doubly so...

Unix counts time as seconds since the epoch. Seems straight forward. What could possibly go wrong?

Advanced Programming in the Unix Environment

Week 5: The Unix Development Environment

This week, we cover the concept of the Unix userland as an Integrated Development Environment. This introduction outlines the different tools we will cover in subsequent videos, including the editor, the compiler chain, make(1), the debugger, and code revision and management tools. No vibe coding here.

https://youtu.be/QYwYLR3UD2w

#apue #unix #programming

Advanced Programming in the UNIX Environment: Week 05, Segment 1 - The Unix Development Environment

Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.

YouTube

Advanced Programming in the Unix Environment

Week 5: The Editor

In this video lecture, we look at the required feature for a full-fledged programmer's editor and illustrate some of the core functionality by example of vim(1). This includes basic motion commands, setting and moving to markers, using folds, and the use of the ':make' and quick fix lists to address compiler errors efficiently.

(Don't worry, we'll talk about ed(1) later.)

https://youtu.be/DdaJ87G9Kes

#apue #unix #programming #vim

Advanced Programming in the UNIX Environment: Week 05, Segment 2 - The Editor

YouTube

Advanced Programming in the Unix Environment

Week 5: The Compiler Chain, Part I

In this video lecture, we begin our discussion of compilers as part of the Unix programming environment. We provide a high-level overview of how compilers process input source code and turn it into an executable.

https://youtu.be/SOeo4zLBqdI

#apue #unix #programming #gcc

Advanced Programming in the UNIX Environment: Week 05, Segment 3 - Compilers (Part I)

YouTube

Advanced Programming in the Unix Environment

Week 5: The Compiler Chain, Part II

In this video lecture, we look at the preprocessing stage of the compiler and observe how it invokes the cpp(1) command to include header files or replace macro definitions in place.

https://youtu.be/8qPxQ3g8bso

#apue #unix #programming #gcc

Advanced Programming in the UNIX Environment: Week 05, Segment 4 - The Preprocessor

YouTube

Advanced Programming in the Unix Environment

Week 5: The Compiler Chain, Part III

In this next-to-last part on the compiler chain, we look at the compilation proper and the optimization and assembly of the intermediate code into an object file. (We will revisit some of this when we take a closer look at shared libraries in week 11.)

https://youtu.be/ddvYL-G3oew

#apue #unix #programming #gcc

Advanced Programming in the UNIX Environment: Week 05, Segment 5 - Compilation and Assembly

YouTube

Advanced Programming in the Unix Environment

Week 5: The Compiler Chain, Part IV

In this video lecture, we conclude our discussion of the compiler chain, analyzing the last step in the process: linking the object files into the executable. We identify aspects of the C Runtime libraries as well as the standard C library that we need to include and cover a few of the most important flags to ld(1).

https://youtu.be/8LCyPmjknBY

#apue #unix #programming #gcc

Advanced Programming in the UNIX Environment: Week 05, Segment 6 - The Compiler Chain, Part IV

YouTube

Advanced Programming in the Unix Environment

Week 5: make(1)

Moving on from the compiler, we now look at how the make(1) utility can be used to help us selectively build our code project.

https://youtu.be/WLTuUtj7LPw

#apue #unix #programming #make

Advanced Programming in the UNIX Environment: Week 05, Segment 7 - make(1)

YouTube

Advanced Programming in the Unix Environment

Week 5: Debugging your code

Next in our discussion of the Unix _development_ environment, we start a short series on the use of a debugger by example of gdb(1). First, we illustrate just why exactly we might want to use a separate tool instead of sprinkling "printf" statements all over our code...

https://youtu.be/61YwbTQy2G0

#apue #unix #programming #gdb

Advanced Programming in the UNIX Environment: Week 05, Segment 08 - Debugging your code

YouTube

Advanced Programming in the Unix Environment

Week 5: Using gdb(1)

Alright, let's look at gdb(1)! We begin by using it to troubleshoot our failing programs and immediately identify the location of our program where it segfaults. We also see how to inspect variables and call functions from within the debugger.

https://youtu.be/Miw0XLzHCws

#apue #unix #programming #gdb

Advanced Programming in the UNIX Environment: Week 05, Segment 09 - Using gdb(1)

YouTube

Advanced Programming in the Unix Environment

Week 5: Using gdb(1), part II

In this video lecture, we continue to explore the capabilities of the debugger. We show how you can set a breakpoint to pause the program and how to step through the program while watching our code.

https://youtu.be/fOp4Q4mnTD4

#apue #unix #programming #gdb

Advanced Programming in the UNIX Environment: Week 05, Segment 10 - Using gdb(1), part II

YouTube

Advanced Programming in the Unix Environment

Week 5: Using gdb(1), part III

In this video lecture, we'll use our newly learned debugging skills to analyze and fix yet another flawed program. In the process, we learn to debug code from multiple source files and find out how to change the value of variables while the program is running.

https://youtu.be/hgcj7iAxhhU

#apue #unix #programming #gdb

Advanced Programming in the UNIX Environment: Week 05, Segment 11 - Using gdb(1), part III

YouTube

Advanced Programming in the Unix Environment

Week 5: Using gdb(1), part IV

In our last segment on gdb(1), we use the debugger to examine memory locations in a running program and illustrate how pointers and arrays work in the C programming language.

https://youtu.be/hr-rn0yUhAw

#apue #unix #programming #gdb

Advanced Programming in the UNIX Environment: Week 05, Segment 12 - Using gdb to understand pointers

YouTube

Advanced Programming in the Unix Environment

Tool Tip: ed(1) is the standard text editor

As part of our discussion of unix development tools, we take a short detour to provide a quick walkthrough of ed(1), the standard text editor. This is not done merely to up your geek creds, but understanding ed(1) will also helps us better understand other tools like vi(1), sed(1), and ultimately even things like diff(1) and patch(1) better.

https://youtu.be/mRZsV7aMK0I

#apue #unix #programming #ed

Advanced Programming in the UNIX Environment: Tool Tip: ed(1) is the standard text editor

YouTube

Advanced Programming in the Unix Environment

Week 6: Memory Layout of a Process

Let's talk about the details of a process. We start with a visual representation of a process in memory and create a program that prints out the addresses of different elements of a program and observe the alignment of the text, data, and bss segments as well as the placement of the heap and stack. We also illustrate what a stack overflow looks like.

https://youtu.be/aHmcowhoOzU

#apue #unix #programming

Advanced Programming in the Unix Environment

Week 6: Program Startup

In this video lecture, we learn how a program starts. "What, you write 'main()' and off you go!" you say? Not so fast! Let's look at the program entry point '_start' and see if we can change it, and in the process find out that the function prototype of 'main' may not be what you think it is. Use your debugger to better understand how the process begins and ends its life.

https://youtu.be/Yul4d-BDdx8

#apue #unix #programming

Advanced Programming in the UNIX Environment: Week 06, Segment 2 - Program Startup

YouTube

Advanced Programming in the Unix Environment

Week 6: Process Termination

After we talked about program startup in our previous video, we now look at how programs terminate. We observe the return status and how exit handlers are registered.

https://youtu.be/xNeEw1f_js8

#apue #unix #programming

Advanced Programming in the UNIX Environment: Week 06, Segment 3 - Program Termination

YouTube

Advanced Programming in the Unix Environment

Week 6: Process Termination

Relevant to our discussion of process termination, using the debugger to understand program behavior, our little pop quiz "What does `int main() { printf("Hello World!\n"); }` return?" provides for a short detour into the realm of nasal daemons:

https://www.netmeister.org/blog/return-printf.html

#apue #unix #programming

There is no 'printf'.

In C, 'main' returns an int. What happens when you don't explicitly return a value, though? C99 provides a return value of 0, but C89... well, that's undefined, my favorite kind of behavior.

Advanced Programming in the Unix Environment

Week 6: The Environment

In this video lecture, we're going to take a look at the process environment. We'll use what we learned about the process layout in memory to understand how the environment variables are stored and, if necessary, moved around. We'll also get a quick look at what malloc(3) does.

https://youtu.be/8DEPA6nJXNY

#apue #unix #programming

Advanced Programming in the UNIX Environment: Week 06, Segment 4 - The Environment

YouTube

Advanced Programming in the Unix Environment

Week 6: Process Limits and Identifiers

In the last few videos, we've looked at the details of the process layout in memory, and how a process starts and is terminated. In this video lecture, we we will spend a few short minutes on two additional aspects of every process: its resource limits and its process ID.

https://youtu.be/bnki8QKjSfQ

#apue #unix #programming

Advanced Programming in the UNIX Environment: Week 06, Segment 5 - Process Limits and Identifiers

YouTube
@jschauma
I'm still sad that many linux distros come without ed. They have tools like vi and nano installed, but not ed.

For reference, ed is my preferred editor for smaller on-console editing, like writing git commits and doing smaller tweaks on files. I regularly use it within the embedded shell of my visual editor!
@jschauma And RCS, svn, and then why git abandoned the reverse diff model, but patch 3-way diffs are still critical.
@jschauma "Lunch time doubly so".
@jschauma ok so leap seconds get a pass but not dst ?