LPI Linux Certification in a Nutshell - BestLightNovel.com
You’re reading novel LPI Linux Certification in a Nutshell Part 31 online at BestLightNovel.com. Please use the follow button to get notification about the latest chapter next time when you visit BestLightNovel.com. Use F11 button to read novel in full-screen(PC only). Drop by anytime you want to read free – fast – latest novel. It’s great if you could leave a comment, share your opinion about the new chapters, new novel with others on the internet. We’ll do our best to bring you the finest, latest novel everyday. Enjoy
Name groupmod Syntax groupmod[option]group Description Modify the parameters of group group.
Option -n name name Change the name of the group to name name.
Name groupdel Syntax groupdelgroup Description Delete group group from the system. Deleting groups can lead to the same confusion in the filesystem as described previously for deleting a user (see from the system. Deleting groups can lead to the same confusion in the filesystem as described previously for deleting a user (see userdel userdel).
Name pa.s.swd Syntax pa.s.swd[options]username Description Interactively set the pa.s.sword for username username. The pa.s.sword cannot be entered on the command line.
Option -l Available only to the superuser, this option locks the pa.s.sword for the account.
Name gpa.s.swd Syntax gpa.s.swdgroupname Description Interactively set the group pa.s.sword for groupname groupname. The pa.s.sword cannot be entered on the command line.
Objective 2: Automate System Administration Tasks by Scheduling Jobs There is a surprising amount of housekeeping that must be done to keep a complex operating system such as Linux running smoothly. Logfile rotation, cleanup of temporary files and directories, system database rebuilds, backups, and other tasks should be done routinely. Clearly such mundane things should be automated by the system, freeing weary system administrators for more interesting work. Fortunately, any system task that can be accomplished without real-time human intervention can be automated on Linux using the cron cron and and at at facilities. Both have the ability to execute system commands, which may start any executable program or script, at selectable times. Further, facilities. Both have the ability to execute system commands, which may start any executable program or script, at selectable times. Further, cron cron and and at at can execute these commands on behalf of any authorized system user. can execute these commands on behalf of any authorized system user. cron cron is intended mainly for regularly scheduled recurring activities, and is intended mainly for regularly scheduled recurring activities, and at at is most useful for scheduling single commands for execution in the future. is most useful for scheduling single commands for execution in the future.
Using cron The cron cron facility consists of two programs. (There is no individual program called facility consists of two programs. (There is no individual program called cron cron, which is the overall name given to the facility. If you execute man cron man cron, however, you will see the manpage for crond crond.) crond This is the cron cron daemon, which is the process that executes your instructions. It starts at system initialization time and runs in the background thereafter. daemon, which is the process that executes your instructions. It starts at system initialization time and runs in the background thereafter.
crontab This is the cron cron table manipulation program. This program gives you access to your table manipulation program. This program gives you access to your cron cron table or table or crontab crontab file. Each authorized user may have his own file. Each authorized user may have his own crontab crontab file to run commands and processes on a regular basis. file to run commands and processes on a regular basis.
The cron cron daemon wakes up every minute and examines all daemon wakes up every minute and examines all crontab crontab files, executing any commands scheduled for that time. files, executing any commands scheduled for that time.
User crontab files To use the cron cron facility, users do not need to interact directly with the facility, users do not need to interact directly with the crond crond daemon. Instead, each system user has access to the daemon. Instead, each system user has access to the cron cron facility through her facility through her crontab crontab file. These files are stored together in a single directory (usually file. These files are stored together in a single directory (usually /var/spool/cron /var/spool/cron) and are created and maintained using the crontab crontab utility. utility.
System crontab files In addition to crontab crontab files owned by individual users, files owned by individual users, crond crond also looks for the system also looks for the system crontab crontab files files /etc/crontab /etc/crontab and files in the directory and files in the directory /etc/cron.d /etc/cron.d. The format for these system crontabs crontabs differs slightly from user differs slightly from user crontabs crontabs. System crontabs crontabs have an additional field for a username between the time specifications and the command. For example: have an additional field for a username between the time specifications and the command. For example: #/etc/crontab #runmyprogramat6:15amasroot 156***rootmyprogram In this example, myprogram myprogram will be executed by will be executed by cron cron as the as the root root user. user.
System crontab crontab files located in files located in /etc/cron.d /etc/cron.d are of the same form as are of the same form as /etc/crontab /etc/crontab, including the extra user field. These files are usually a.s.sociated with some package or service that includes a system crontab crontab. Allowing a collection of files in /etc/cron.d /etc/cron.d allows software installation and upgrade procedures to keep the allows software installation and upgrade procedures to keep the cron cron configuration up-to-date on an individual package basis. In most cases, however, you won't need to change the configuration up-to-date on an individual package basis. In most cases, however, you won't need to change the crontab crontab files in files in /etc/cron.d /etc/cron.d.
On the ExamMemorize the sequence of time/date fields used in crontab crontab files. files.
On most Linux distributions, /etc/crontab /etc/crontab contains some standard content to enable the execution of programs and scripts on the minute, hour, week, and month. These arrangements allow you to simply drop executable files into the appropriate directory (such as contains some standard content to enable the execution of programs and scripts on the minute, hour, week, and month. These arrangements allow you to simply drop executable files into the appropriate directory (such as /etc/cron.hourly /etc/cron.hourly), where they are executed automatically. This eliminates cron cron configuration altogether for many tasks and avoids cluttering the root configuration altogether for many tasks and avoids cluttering the root crontab crontab file with common commands. file with common commands.
Using at The cron cron system is intended for the execution of commands on a regular, periodic schedule. When you need to simply delay execution of a command or a group of commands to some other time in the future, you should use system is intended for the execution of commands on a regular, periodic schedule. When you need to simply delay execution of a command or a group of commands to some other time in the future, you should use at at. The at at facility accepts commands from standard input or from a file. facility accepts commands from standard input or from a file.
Controlling User Access to cron and at In most cases, it is safe to allow users to use the cron cron and and at at facilities. However, if your circ.u.mstances dictate that one or more users should be prohibited from using these services, two simple authorization files exist for each: facilities. However, if your circ.u.mstances dictate that one or more users should be prohibited from using these services, two simple authorization files exist for each: cron.allow, cron.deny cron.deny at.allow, at.deny at.deny These files are simply lists of account names. If the allow allow file exists, only those users listed in the file exists, only those users listed in the allow allow file may use the service. If the file may use the service. If the allow allow file does not exist but the file does not exist but the deny deny file does, only those users not listed in the file does, only those users not listed in the deny deny file may use the service. For file may use the service. For cron cron, if neither file exists, all users have access to cron cron. For at at, if neither file exists, only root root has access to has access to at at. An empty at.deny at.deny file allows access to all users and is the default. file allows access to all users and is the default.
Name crontab Syntax crontab[options]
Description View or edit crontab crontab files. files.
Frequently used options -e Interactively edit the crontab crontab file. Unless otherwise specified in either the file. Unless otherwise specified in either the EDITOR EDITOR or or VISUAL VISUAL environment variables, the editor is environment variables, the editor is vi vi.
-l Display the contents of the crontab crontab file. file.
-r Remove the crontab crontab file. file.
-u user user Operate on user user's crontab crontab file instead of your own. Only file instead of your own. Only root root can edit or delete the can edit or delete the crontab crontab files of other users. files of other users.
Example Display the crontab crontab file for user file for user jdoe jdoe: #crontab-l-ujdoe Edit your own crontab crontab file: file: $crontab-e crontab files use a flexible format to specify times for command execution. Each line contains six fields: files use a flexible format to specify times for command execution. Each line contains six fields: minutehourdaymonthdayofweekcommand These fields are specified as follows: Minute (0 through 59) Hour (0 through 23) Day of the month (1 through 31) Month (1 through 12 or jan through dec) Day of the week (0 through 7-where 0 or 7 is Sunday-or sun through sat) Command (any valid command, including s.p.a.ces and standard Bourne sh.e.l.l syntax) For example, to execute myprogram myprogram once per day at 6:15 a.m., use this once per day at 6:15 a.m., use this crontab crontab entry: entry: #runmyprogramat6:15am 156***myprogram Lines that begin with the pound sign (#) are comment lines and are ignored by crond crond. Comments must begin on a new line and may not appear within commands. The asterisks in this crontab crontab are placeholders and match any date or time for the field where they're found. Here, they indicate that are placeholders and match any date or time for the field where they're found. Here, they indicate that myprogram myprogram should execute at 6:15 a.m. on all days of the month, every month, all days of the week. should execute at 6:15 a.m. on all days of the month, every month, all days of the week.
Each of the time specifications may be single, list (1,3,5), or range (1-5 or or wed-fri wed-fri) entries or combinations thereof. To modify the previous example to execute at 6:15 and 18:15 on the 1st and 15th of the month, use: #runmyprogramat6:15amand6:15pmonthe1stand15th 156,181,15**myprogram As you can see, the time specifications are very flexible.
Because the cron cron daemon evaluates each daemon evaluates each crontab crontab entry when it wakes up each minute, it is not necessary to restart or reinitialize entry when it wakes up each minute, it is not necessary to restart or reinitialize crond crond when when crontab crontab entries are changed or new files are created. entries are changed or new files are created.
Name at Syntax at[-ffile]time at[options]
Description In the first form, enter commands to the at at queue for execution at queue for execution at time time. at at allows fairly complex time specifications. It accepts times of the form allows fairly complex time specifications. It accepts times of the form HH:MM HH:MM to run a job at a specific time of day. (If that time is already past, the next day is a.s.sumed.) You may also specify to run a job at a specific time of day. (If that time is already past, the next day is a.s.sumed.) You may also specify midnight midnight, noon noon, or teatime teatime (4 p.m.), and you suffix a time of day with (4 p.m.), and you suffix a time of day with AM AM or or PM PM for running in the morning or evening. You can also say what day the job will be run by giving a date in month-day form, with the year being optional, or by giving a date in for running in the morning or evening. You can also say what day the job will be run by giving a date in month-day form, with the year being optional, or by giving a date in MMDDYY MMDDYY, MM/DD/YY MM/DD/YY, or DD.MM.YY DD.MM.YY form. The date specification must follow the time-of-day specification. You can also give times such as form. The date specification must follow the time-of-day specification. You can also give times such as now + now + count time-units count time-units, where time-units time-units can be minutes, hours, days, or weeks. You can tell can be minutes, hours, days, or weeks. You can tell at at to run the job today by suffixing the time with to run the job today by suffixing the time with today today, and you can tell it to run the job tomorrow by suffixing the time with tomorrow tomorrow.
If -f -f file file is given, commands are taken from the is given, commands are taken from the file file; otherwise, at at will prompt the user for commands. will prompt the user for commands.
In the second form, list or delete jobs from the at at queue. queue.
Frequently used options -d job1 job1 [, [, job2 job2, ...]
Delete jobs from the at at queue by number (same as the queue by number (same as the atrm atrm command). command).
-l List items in the at at queue (same as the queue (same as the atq atq command). command).
Example1 Run myprogram myprogram once at 6:15 p.m. tomorrow: once at 6:15 p.m. tomorrow: $at6:15pmtomorrow at>myprogram at>^D In the previous code listing, ^D ^D indicates that the user typed Ctrl-D on the keyboard, sending the end-of-file character to terminate the indicates that the user typed Ctrl-D on the keyboard, sending the end-of-file character to terminate the at at command. command.
Example2 Run commands that are listed in the file command_list command_list at 9 p.m. two days from now: at 9 p.m. two days from now: $at-fcommand_list9pm+2days List items in the at at queue ( queue (root sees all users' entries): sees all users' entries): $at-l Remove job number 5 from the at at queue: queue: $at-d5 Using at at to schedule jobs for delayed execution, such as while you're asleep or on vacation, is simple and doesn't require creation of a recurring to schedule jobs for delayed execution, such as while you're asleep or on vacation, is simple and doesn't require creation of a recurring cron cron entry. entry.
Objective 3: Localization and Internationalization In computing, internationalization and localization are means of adapting computer software to different languages and regional differences. Internationalization is the process of designing a software application so that it can be adapted to various languages and regions without engineering changes. Localization is the process of adapting internationalized software for a specific region or language by adding locale-specific components and translating text.
The terms are frequently abbreviated to the numeronyms i18n (where 18 stands for the number of letters between the first "i" and last "n" in internationalization, a usage coined at Digital Equipment Corporation in the 1970s or 1980s) and L10n respectively, due to the length of the words. The capital "L" in L10n helps to distinguish it from the lowercase "i" in i18n.
Since open source software can generally be freely modified and redistributed, it is more amenable to internationalization. The KDE project, for example, has been translated into over 100 languages.
The time zone under Linux is set by a symbolic link from /etc/localtime /etc/localtime to a file in the to a file in the /usr/share/zoneinfo /usr/share/zoneinfo directory that corresponds to your specific time zone. Generally this is defined during the installation process in order to provide the correct information to the system. However, manually running the command directory that corresponds to your specific time zone. Generally this is defined during the installation process in order to provide the correct information to the system. However, manually running the command tzconfig tzconfig can also do the job, and you won't have to remember the path to the time zones. can also do the job, and you won't have to remember the path to the time zones.
The tzselect tzselect program is a menu-based script that asks the user for information about the current location, and then sends the resulting time zone description to standard output. The output is suitable as a value for the program is a menu-based script that asks the user for information about the current location, and then sends the resulting time zone description to standard output. The output is suitable as a value for the TZ TZ environment variable: environment variable: $tzselect
Pleaseidentifyalocationsothattimezonerulescanbesetcorrectly.
Pleaseselectacontinentorocean.
1)Africa
2)Americas
3)Antarctica
4)ArcticOcean
5)Asia
6)AtlanticOcean
7)Australia
8)Europe
9)IndianOcean
10)PacificOcean
11)none-IwanttospecifythetimezoneusingthePosixTZformat.
The date date command can be used to print the current Coordinated Universal Time (UTC): command can be used to print the current Coordinated Universal Time (UTC): $date-u and also to show the time zone abbreviation: $date+%Z CET A locale is a set of information that most programs use for determining country- and language-specific settings. The following environment variables are used to store locale settings: LANG Defines all locale settings at once, while allowing further individual customization via the LC_* LC_* settings described next. settings described next.
LC_COLLATE Defines alphabetical ordering of strings. This affects the output of sorted directory listings, for example.
LC_CTYPE Defines the character-handling properties for the system. This determines which characters are seen as alphabetic, numeric, and so on. This also determines the character set used, if applicable.
LC_MESSAGES This defines the programs' localizations for applications that use a message-based localization scheme. This includes the majority of GNU programs.
LC_MONETARY Defines currency units and the formatting of currency type numeric values.
LC_NUMERIC Defines formatting of numeric values that aren't monetary. This affects things such as the thousands separator and decimal separator.
LC_TIME Defines the formatting of dates and times.
LC_PAPER Defines the default paper size.
LC_ALL A special variable for overriding all other settings.
The locale locale utility writes information about the current locale environment, or all public locales, to the standard output. For the purposes of this section, a public locale is one provided by the implementation that is accessible to the application. Issuing the utility writes information about the current locale environment, or all public locales, to the standard output. For the purposes of this section, a public locale is one provided by the implementation that is accessible to the application. Issuing the locale locale command without any flags will output the current configuration: command without any flags will output the current configuration: $locale LANG= LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL= The C locale, also known as the POSIX locale, is the POSIX system default locale for all POSIX-compliant systems.
The iconv iconv utility converts the encoding of characters in a file from one codeset to another and writes the results to standard output. utility converts the encoding of characters in a file from one codeset to another and writes the results to standard output.
The following example converts the contents of the file in.txt in.txt from the ISO/IEC 6937:1994 standard codeset to the ISO/IEC 8859-1:1998 standard codeset, and stores the results in the file from the ISO/IEC 6937:1994 standard codeset to the ISO/IEC 8859-1:1998 standard codeset, and stores the results in the file out.txt out.txt: $iconv-fIS6937-tIS8859in.txt>out.txt