A Few Words About Mice And Focus
- While the shell is all about the keyboard, you can also use a mouse with your terminal emulator.
- There is a mechanism built into the X Window System (the underlying engine that makes the GUI go) that supports a quick copy and paste technique.
- If you highlight some text by holding down the left mouse button and dragging the mouse over it (or double-clicking on a word), it is copied into a buffer maintained by X.
- Pressing the middle mouse button will cause the text to be pasted at the cursor location. Try it.
Note: Don’t be tempted to use Ctrl-c and Ctrl-v to perform copy and paste inside a terminal window. They don’t work. These control codes have different meanings to the shell and were assigned many years before Microsoft Windows.
Absolute and Relative path
- An absolute path name begins with the root directory and follows the tree branch by branch until the path to the desired directory or file is completed.
- A relative path name starts from the working directory.
The “.” notation refers to the working directory and the “..” notation refers to the working directory’s parent directory.
- Filenames that begin with a period of character are hidden.
- Linux has no concept of a “file extension” like some other operating systems.
- Limit the punctuation characters in the names of files you create to period, dash, and underscore. Most importantly, do not embed spaces in filenames. If you want to represent spaces between words in a filename, use underscore characters.
Exploring the System
Besides the current working directory, we can specify the directory to list, like so:
Or even specify multiple directories. In this example, we will list both the user’s home directory (symbolized by the “~” character) and the /usr directory:
Common ls options
Command ls: Long listing with -l option
One of the common ideas in Unix-like operating systems such as Linux is that “everything is a file.”
Why would we want to examine text files? Because many of the files that contain system settings (called configuration files) are stored in this format, and being able to read them gives us insight into how the system works.
The less command is a program to view text files. Throughout our Linux system, there are many files that contain human-readable text. The less program provides a convenient way to examine them.
Using wildcards (which is also known as globbing) allows you to select filenames based on patterns of characters.
Command cp: Examples of cp command
Command mv: Examples of mv command
Command rm: Examples of rm command
What exactly are commands?
A command can be one of four different things:
- An executable program like all those files we saw in /usr/bin. Within this category, programs can be compiled binaries such as programs written in C and C++, or programs written in scripting languages such as the shell, perl, python, ruby, etc.
- A command built into the shell itself. bash supports a number of commands internally called shell builtins. The cd command, for example, is a shell builtin.
- A shell function. These are miniature shell scripts incorporated into the environment. We will cover configuring the environment and writing shell functions in later chapters, but for now, just be aware that they exist.
- An alias. Commands that we can define ourselves, built from other commands.
The type command is a shell builtin that displays the kind of command the shell will execute, given a particular command name.
Here we see the results for three different commands. Notice that the one for ls (taken from a Fedora system) and how the ls command is actually an alias for the ls command with the “–color=tty” option added. Now we know why the output from ls is displayed in color!
Which displays an executable’s location. Sometimes there is more than one version of an executable program installed on a system. While this is not very common on desktop systems, it’s not unusual on large servers. To determine the exact location of a given executable, the which command is used
$ which ls /bin/ls