Learning the bash Shell 2nd Edition [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Learning the bash Shell 2nd Edition [Electronic resources] - نسخه متنی

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید

10.2 Environment Customization

Like the Bourne shell, bash uses the file /etc/profile for system-wide customization. When a user logs in, the shell reads and runs /etc/profile before running the user's .bash_profile.

We won't cover all the possible commands you might want to put in /etc/profile. But bash has a few unique features that are particularly relevant to system-wide customization; we'll discuss them here.

We'll start with two built-in commands that you can use in /etc/profile to tailor your users' environments and constrain their use of system resources. Users can also use these commands in their .bash_profile, or at any other time, to override the default settings.

10.2.1 umask

umask, like the same command in most other shells, lets you specify the default permissions that files have when users create them. It takes the same types of arguments that the chmod command does, i.e., absolute (octal numbers) or symbolic permission values.

The umask contains the permissions that are turned off by default whenever a process creates a file, regardless of what permission the process specifies. [7]

[7] If you are comfortable with Boolean logic, think of the umask as a number that the operating system logically ANDs with the permission given by the creating process.

We'll use octal notation to show how this works. As you probably know, the digits in a permission number stand (left to right) for the permissions of the owner, owner's group, and all other users, respectively. Each digit, in turn, consists of three bits, which specify read, write, and execute permissions from left to right. (If a file is a directory, the "execute" permission becomes "search" permission, i.e., permission to cd to it, list its files, etc.)

For example, the octal number 640 equals the binary number 110 100 000. If a file has this permission, then its owner can read and write it; users in the owner's group can only read it; everyone else has no permission on it. A file with permission 755 gives its owner the right to read, write, and execute it and everyone else the right to read and execute (but not write).

022 is a common umask value. This implies that when a file is created, the "most" permission it could possibly have is 755which is the usual permission of an executable that a compiler might create. A text editor, on the other hand, might create a file with 666 permission (read and write for everyone), but the umask forces it to be 644 instead.

10.2.2 ulimit

The ulimit command was originally used to specify the limit on file creation size. But bash's version has options that let you put limits on several different system resources. Table 10.2 lists the options.

Table 10.2. ulimit Resource Options

Option

Resource Limited

-a

All limits (for printing values only)

-c

Core file size (1 Kb blocks)

-d

Process data segment (Kb)

-f

File size (1 Kb blocks)

-l

Maximum size of a process that can be locked in memory (Kb)a

-m

Maximum resident set size

-n

File descriptors

-p

Pipe size (512 byte blocks)

-s

Process stack segment (Kb)

-t

Process CPU time (seconds)

-u

Maximum number of processes available to a user

-v

Virtual memory (Kb)

[8]

/ 104