![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Looking AroundNow that you know how to move from working directory to working directory, we're going to take a tour of your Linux system and, along the way, learn some things about what makes it tick. But before we begin, I have to teach you some tools that will come in handy during our adventure. These are: lsThe ls command is used to
list the contents of a directory. It is probably
the most commonly used Linux command. It can be
used in a number of different ways. Here are some
examples:
These examples also point out an important concept about commands. Most commands operate like this: command -options arguments where command is the name of the command, -options is one or more adjustments to the command's behavior, and arguments is one or more "things" upon which the command operates. In the case of ls, we see that ls is the name of the command, and that it can have one or more options, such as -a and -l, and it can operate on one or more files or directories. A Closer Look At Long FormatIf you use the -l option with ls, you will get a file listing that
contains a wealth of information about the files
being listed. Here's an example: -rw------- 1 bshotts bshotts 576 Apr 17 1998 weather.txt drwxr-xr-x 6 bshotts bshotts 1024 Oct 9 1999 web_page -rw-rw-r-- 1 bshotts bshotts 276480 Feb 11 20:41 web_site.tar -rw------- 1 bshotts bshotts 5743 Dec 16 1998 xmas_file.txt ---------- ------- ------- -------- ------------ ------------- | | | | | | | | | | | File Name | | | | | | | | | +--- Modification Time | | | | | | | +------------- Size (in bytes) | | | | | +----------------------- Group | | | +-------------------------------- Owner | +---------------------------------------------- File Permissions
lessless is a program that lets you view text files. This is very handy since many of the files used to control and configure Linux are human readable. The less program is invoked by simply typing: less text_file This will display the file. Controlling lessOnce started, less will
display the text file one page at a time. You may
use the Page Up and Page Down keys to move through
the text file. To exit less,
type "q". Here are some commands that less will accept:
fileAs you wander around your Linux system, it is helpful to determine what kind of data a file contains before you try to view it. This is where the file command comes in. file will examine a file and tell you what kind of file it is. To use the file program, just type: file name_of_file The file program can
recognize most types of files, such as:
While it may seem that most files cannot be viewed as text, you will be surprised how many can. This is especially true of the important configuration files. You will also notice during our adventure that many features of the operating system are controlled by shell scripts. In Linux, there are no secrets! |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
© 2000-2019, William E. Shotts, Jr. Verbatim copying and distribution of this entire article is permitted in any medium, provided this copyright notice is preserved. Linux® is a registered trademark of Linus Torvalds. |