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
- Performer: -
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
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
Comments (0)