Study Aids
Read books online » Study Aids » Debian GNU/Linux: Guide to Installation and Usage by John Goerzen and Ossama Othman (best business books of all time txt) 📖

Book online «Debian GNU/Linux: Guide to Installation and Usage by John Goerzen and Ossama Othman (best business books of all time txt) đŸ“–Â». Author John Goerzen and Ossama Othman



1 ... 10 11 12 13 14 15 16 17 18 ... 28
Go to page:
effects.

 

chmod go-r myfile

Here you’ve subtracted (-) read permission (r) from the group (g) owning the file and from everyone else (others, o). Again, use ls -l to verify the effects.

 

chmod ugo=rx myfile

Here you’ve set (=) user, group, and other permissions to read and execute. This sets permissions to exactly what you’ve specified and unsets any other permissions. So all rx should be set, and all w should be unset.

Now, no one can write to the file.

 

chmod a-x myfile

a is a shortcut for ugo, or “all.” So all the x permissions should now be unset.

 

rm myfile

With this command, you’re removing the file, but without write permissions. rm will ask if you’re sure by displaying the following message:

 

rm: remove `myfile’, overriding mode 0444?

You should respond by typing y and pressing Enter. This is a feature of rm, not a fact of permissions. Permission to delete a file comes from the directory permissions, and you have write permission in the directory.

However, rm tries to be helpful, figuring that if you didn’t want to change the file (and thus remove write permission), you don’t want to delete it either, so it asks you.

 

What was that 0444 business in the question from rm? The permissions mode is a twelve-digit binary number, like this: 000100100100. 0444 is this binary number represented as an octal (base 8) number, which is the conventional way to write a mode. So you can type chmod 444 myfile instead of chmod ugo=r myfile.

 

Files Present and Their Locations Now that you can navigate the directory tree, let’s take a guided tour of the files and directories you created when you installed Debian. If you’re curious, cd to each directory and type ls to see its contents. If the listing doesn’t fit on the screen, try ls | less, where | is the “pipe”

character, generally found on the same key with backslash.

/

As already mentioned, this is the root directory, which contains every other directory.

 

/root

But don’t get confused with root! root is the home directory of the root user, or superuser. It’s a directory called root, but it isn’t the root directory /.

 

/home

This is where all normal users - that is, all users except root -

have their home directories. Each home directory is named after the user who owns it, for example, homejane. If you’re using a large system at a school or business, your system administrator may create additional directories to contain home directories: home1 and home2 for example. On some other systems, you’ll see an additional level of subdirectories: homestudents/username, homestaff/username, etc.

 

Your home directory is where you put all your personal work, e-mail and other documents, and personal configuration preferences. It’s your home on the system.

 

/bin

This directory contains “binaries,” executable files that are essential to the operation of the system. Examples are the shell (bash) and file commands such as cp.

 

/sbin

This directory contains “system binaries,” utilities that the root user or system administrator might want to use, but that you probably won’t want to use in your day-to-day activities.

 

/usr

/usr contains most of the files you’ll be interested in. It has many subdirectories. usrbin and usrsbin are pretty much like bin and sbin, except that the directories in /usr are not considered “essential to the operation of the system.”

 

While not essential to getting the computer working, /usr does contain the applications you’ll use to get real work done. Also in /usr, you’ll find the usrman, usrinfo, and usrdoc directories. These contain manual pages, info pages, and other documentation, respectively. And don’t forget usrgames!

 

usrlocal

The Debian system doesn’t install anything in this directory. You should use it if you want to install software that you compile yourself or any software not contained in a Debian package. You can also install software in your home directory if you’ll be the only one using it.

 

/etc

/etc contains all the system-wide configuration files. Whenever you want to change something that affects all users of your computer - such as how you connect to the Internet or what kind of video card you have - you’ll probably have to log on as root and change a file in /etc.

 

/tmp

Here you’ll find temporary files, most of them created by the system. This directory is generally erased on a regular basis or every time you reboot the system. You can create files here if you want, just be aware that they might get deleted automatically.

 

/var

/var contains “variable” files that the system changes automatically. For example, incoming mail is stored here. The system keeps a log of its actions here. There are a number of other automatically generated files here as well. You’ll mostly be interested in the contents of varlog, where you can find error messages that can help you figure out what you’re system’s up to if something goes wrong.

 

Clearly there are many more directories on the system - far too many to describe every one.

 

For changing things, you’ll usually want to confine yourself to your home directory and /etc. On a Debian system, there’s rarely an occasion to change anything else, because everything else is automatically installed for you.

 

/etc is used to configure the system as a whole. You’ll use your own home directory, a subdirectory of /home, for configuring your own preferences and storing your personal data. The idea is that on a day-to-day basis, you confine yourself to homeyourname, so there’s no way you can break anything. Occasionally you log in as root to change something in a system-wide directory, but only when it’s absolutely necessary. Of course, if you’re using Debian at a school or business and someone else is the system administrator, you won’t have root access and will be able to change only your home directory and any other directory that you own. This limits what you can do with the system.

 

File Compression with gzip Often it would be nice to make a file smaller - say, to download it faster, or so it takes up less space on your disk. The program to do this is called gzip (GNU zip). Here’s how it works: $ cd; cp etcprofile ./mysamplefile This switches to your home directory and copies an arbitrarily chosen file (etcprofile) to your current directory, in the process renaming it mysamplefile. This gives you a file to play with when using gzip.

 

$ ls -l

Lists the contents of the current directory. Note the size of mysamplefile.

 

$ gzip mysamplefile

Compresses mysamplefile.

 

$ ls -l

Observe the results of this command: mysamplefile is now called mysamplefile.gz . It’s also a good bit smaller.

 

$ gunzip mysamplefile.gz; ls -l

This uncompresses the file. Observe that mysamplefile has returned to its original state. Notice that to uncompress, one uses gunzip, not gzip.

 

$ rm mysamplefile

Use this command to remove the file, since it was just to practice with.

 

Finding Files There are two different facilities for finding files: find and locate.

find searches the actual files in their present state. locate searches an index generated by the system every morning at 6:42 a.m. (this is a cron job, explained elsewhere in this book). locate won’t find any files that were created after the index was generated. However, because locate searches an index, it’s much faster - like using the index of a book rather than looking through the whole thing.

 

To compare the two ways of finding files, pretend you can’t remember where the X configuration file XF86Config resides.

 

$ locate XF86Config

This should be pretty fast. You’ll get a list of filenames that contain XF86Config, something like this:

 

etcX11/XF86Config

 

usrX11R6/lib/X11/XF86Config

 

usrX11R6/lib/X11/XF86Config.eg

 

usrX11R6/man/man5/XF86Config.5x.gz Now try the find command:

 

$ find / -name XF86Config

You will hear a lot of disk activity, and this will take a lot longer.

Results will look something like this:

 

etcX11/XF86Config

 

usrX11R6/lib/X11/XF86Config

 

find: varspool/cron/atjobs: Permission denied find: varspool/cron/atspool: Permission denied find: varlib/xdm/authdir: Permission denied Notice that find found only files that were named exactly XF86Config, rather than any files containing that string of letters. Also, find actually tried to look in every directory on the system - including some where you didn’t have read permissions. That’s why you got the Permission denied messages.

 

The syntax is different as well. With find, you had to specify what directory to search in, whereas locate automatically chose the root directory. And you had to specify a search by name using the -name option.

You could also have searched for files using many other criteria, such as modification date or owner. To have find search for files whose names match XF86Config, you’d have to use a wildcard: $ find / -name ‘XF86Config’

Like most of the command line tools, find accepts wildcards as arguments.

 

In general, find is a more powerful utility, and locate is faster for everyday quick searches. The full range of possible searches would take a long time to explain; for more details , type info find, which will bring up the very thorough info pages on find and locate.

 

Determining a File’s Contents Debian comes with a utility that can guess at the contents of a file for you. Although it is not 100% accurate, you can use the following command to explore your system:

 

$ file bincp

You should see something like this:

 

bincp: ELF 32-bit LSB executable, Intel 386, version 1

 

Skipping the technical parts, this is an executable file for Intel machines.

 

$ file etcinit.d/boot

The preceding command gives this response: etcinit.d/boot: Bourne shell script text meaning that this is a text file containing a Bourne shell script.

 

Using a File Manager Instead of moving files around by hand, you can use a file manager. If you move a lot of files around, a file manager can make your work more efficient. There are text-based file managers, such as GNU Midnight Commander (mc), and a number of file managers for the X Window system (for example gmc for the X Window version of GNU Midnight Commander).

 

Describing each of these is outside the scope of this book, but you may want to try them out if the command line doesn’t meet your needs.

 

Working with Text Files Text files are prevelant on a GNU/Linux system. They hold everything from documentation to configuration files. Fortunately, it’s easy to work with them.

 

Viewing Text Files A text file is simply a normal file that happens to contain human-readable text. There’s nothing special about it otherwise. The other kind of file, a binary file, is meant to be interpreted by the computer.

 

You can view either kind of file with the less file pager if you have it installed (install it if you haven’t, it’s quite useful). Type less etcprofile to view a sample text file. Notice that you can read the characters even if their meaning is obscure. Type less binls to view a binary file. As you can see, the ls program is not meant to be read by humans.

 

Sometimes, you’ll find files that end with .gz. These files may be viewed with zless; you can run it like so:

 

zless usrdoc/ae/changelog.Debian.gz Tip: zless is great for viewing documentation, which is often shipped in .gz form.

 

The difference between the two kinds of files is purely a matter of what they contain, unlike in some other systems (such as DOS and MacOS), which actually treat the

1 ... 10 11 12 13 14 15 16 17 18 ... 28
Go to page:

Free ebook «Debian GNU/Linux: Guide to Installation and Usage by John Goerzen and Ossama Othman (best business books of all time txt) đŸ“–Â» - read online now

Comments (0)

There are no comments yet. You can be the first!
Add a comment