O'Reilly logo

Linux Application Development, Second Edition by Erik W. Troan, Michael K. Johnson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 14. Directory Operations

Linux, like many other operating systems, uses directories to organize files. Directories (which are just special types of files that contain lists of file names) contain files, as well as other directories, allowing a file hierarchy to be built. All Linux systems have a root directory, known as /, through which (directly or indirectly) you access all the files on the system.

The Current Working Directory

Finding the Current Working Directory

The getcwd() function allows a process to find the name of its current directory relative to the system’s root directory.

#include <unistd.h>
char * getcwd(char * buf, size_t size);

The first parameter, buf, points to a buffer that is filled in with the path to the current working ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required