4

Working with Files

IN THIS CHAPTER

Setting permissions

Traversing the filesystem

Creating/copying files

Using hard/symbolic links

Changing file attributes

Searching for files

Listing and verifying files

Everything in a Linux filesystem can be viewed as a file. This includes data files, directories, devices, named pipes, links, and other types of files. Associated with each file is a set of information that determines who can access the file and how they can access it. This chapter covers many commands for exploring and working with files.

Understanding File Types

Directories and regular files are by far the file types you will use most often. However, there are several other types of files you will encounter as you use Linux. From the command line, there are many ways you can create, find, and list different types of files.

Files that provide access to the hardware components on your computer are referred to as device files. There are character and block devices. There are hard links and soft links you can use to make the same file accessible from different locations. Less often used directly by regular users are named pipes and sockets, which provide access points for processes to communicate with each other.

Using Regular Files

Regular files consist of data files (documents, music, images, archives, and so on) and commands (binaries and scripts). You can determine the type of a file using the file command. In the following example, you change to the directory containing bash ...

Get Ubuntu Linux Toolbox: 1000+ Commands for Power Users, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.