After you learn the commands in this chapter from Linux Phrasebook, 2nd Edition, you can start controlling your shell and finding out all sorts of interesting things about your files, folders, data, and environment.

This chapter is from the book

This chapter is from the book

This chapter introduces the basic commands you’ll find yourself using several times every day. Think of these as the hammer, screwdriver, and pliers that a carpenter keeps in the top of his toolbox. After you learn these commands, you can start controlling your shell and finding out all sorts of interesting things about your files, folders, data, and environment. In particular, you’ll be learning about some of the metadata—the data describing your data—that Linux has to keep track of, and it may just surprise you how much there is.

NOTE

When I updated this book for its second edition, I removed the section about mkdir -v (which shows you what mkdir is doing as it does it) and rm -v (which does the same thing, but for rm). You can find the original text on my website, www.granneman.com/linux-redactions.

Also, I took the sections on touch, mkdir, cp, mv, rm, and rmdir and used them to create a new Chapter 3 titled “Creation and Destruction” (which of course renumbered everything after it!). Finally, the section on su was moved to Chapter 8, “Ownership and Permissions,” which makes a lot more sense.

List Files and Folders

ls

The ls command is probably the one that people find themselves using the most. After all, before you can manipulate and use files in a directory (remember, file and directory are interchangeable), you first have to know what files are available. That’s where ls comes in, as it lists the files and subdirectories found in a directory.

NOTE

The ls command might sound simple—just show me the files!—but there are a surprising number of permutations to this amazingly pliable command, as you’ll see.

Typing ls lists the contents of the directory in which you’re currently working. When you first log in to your shell, you’ll find yourself in your home directory. Enter ls, and you might see something like the following: