Friday, February 08, 2008

Linux : How to mount remote windows partition (windows share) under Linux

All files accessible in a Linux (and UNIX) system are arranged in one big tree, the file hierarchy, rooted at /. These files can be spread out over several devices. The mount command serves to attach the file system found on some device to the big file tree.

Use the mount command to mount remote windows partition or windows share under Linux as follows:

Procedure to mount remote windows partition (NAS share)

1) Make sure you have following information:
==> Windows username and password to access share name
==> Sharename (such as //server/share) or IP address
==> root level access on Linux

2) Login to Linux as a root user (or use su command)

3) Create the required mount point:
# mkdir -p /mnt/ntserver
4) Use the mount command as follows:
# mount -t cifs //ntserver/download -o username=vivek,password=myPassword /mnt/ntserver

Use following command if you are using Old version such as RHEL <=4 or Debian <= 3:
# mount -t smbfs -o username=vivek,password=D1W4x9sw //ntserver/download /mnt/ntserver

5) Access Windows 2003/2000/NT share using cd and ls command:
# cd /mnt/ntserver; ls -l
Where,

  • -t smbfs : File system type to be mount (outdated, use cifs)
  • -t cifs : File system type to be mount
  • -o : are options passed to mount command, in this example I had passed two options. First argument is password (vivek) and second argument is password to connect remote windows box
  • //ntserver/download : Windows 2000/NT share name
  • /mnt/ntserver Linux mount point (to access share after mounting)

Oracle : Oracle's In-Memory Undo

The Oracle database is extremely complex software. Part of the solution to performance optimization is Oracle Corporation itself optimizing the core database kernel code. One such optimization is the introduction of Oracle's patented In-memory undo (IMU). Essentially, instead of maintaining undo in Oracle segments, the undo is managed, as much as possible, in memory using structures optimized for in-memory operations. How Oracle does this is fascinating and foreshadows even greater things to come. But with any piece of code, there is always the possibility of a bottleneck, so this paper covers how to detect IMU performance issues and multiple ways to potentially solve the problem (in addition to just tuning it off).


Click here to download the whitepaper

Tuesday, February 05, 2008

Linux : Unbreakable Linux

I have been working as an Oracle Database Administrator for about 2 years now and one thing that really bugs me when installing a new Oracle Enterprise Database is that the configuration and the libraries that will be needed when you try to install one. I have experienced it that I have to scour the internet to find the program or the libraries needed to run this Oracle Enterprise Database in this certain Linux operating system. Thanks to Oracle they have released this Linux that is called

UNBREAKABLE LINUX


Thanks to this Linux Distro (Oracle Enterprise Linux), I can easily setup a new Oracle Database without all the hassle of having to search for libraries that are not included in some Linux Distros. One thing I have notice is that almost all of the Oracle essentials are here in this Linux Distribution. The package installer for ASM, OCFS2 and some other libraries are here so you will not have a hard time in installing or downloading those stuffs. This OEL (Oracle Enterprise Linux) is like a tailored made operating system for Oracle products. It has all the programs and securities that an Oracle product would need.

If you would like to have more info please visit the link below
Ubreakable Linux

Linux : chown: Changes the owner of a file and/or the group the file is associated with

chown [options] owner file-list

chown [options] owner:group file-list

chown [options] owner: file-list

chown [options] :group file-list

chown [options] ––reference=rfile file-list


The chown utility changes the owner of a file and/or the group the file is associated with. Only root can change the owner of a file. Only root or the owner of a file who belongs to the new group can change the group a file is associated with.

Arguments

The owner is the username or numeric user ID of the new owner. The file-list is a list of the pathnames of the files whose ownership and/or group association you want to change. The group is the group name or numeric group ID of the new group that the file is associated with. Table V-9 shows the ways you can specify the new owner and/or group.

Table V-9. Specifying the new owner and/or group

Argument

Meaning

owner

The new owner of file-list; the group is not changed

owner:group

The new owner and new group association of file-list

owner:

The new owner of file-list; the group association is changed to that of the new owner's login group

:group

The new group associated with file-list; the owner is not changed


Options

Accepts the common options described on page 587.

––changes

–c

Displays a message for each file whose ownership/group is changed.

––dereference

Changes the ownership/group of the files symbolic links point to, not the symbolic links themselves. The default is ––no-dereference.

––quiet or ––silent

–f

Prevents chown from displaying error messages when it is unable to change the ownership/group of a file.


––no-dereference

–h

Changes the ownership/group of symbolic links, not the files that the links point to (default).

––recursive

–R

When you include directories in the file-list, this option descends the directory hierarchy, setting the specified ownership/group for all files encountered.


––reference=rfile

Changes the ownership and group association of the files in the file-list to that of rfile.

––verbose

–v

Displays for each file a message saying whether its ownership/group was retained or changed.


Notes

The chown utility clears setuid and setgid bits when it changes the owner of a file.

Examples

The following command changes the owner of the chapter1 file in the manuals directory. The new owner is Jenny:

# chown jenny manuals/chapter1


The following command makes Alex the owner of, and Alex's login group the group associated with, all files in the /home/alex/literature directory and in all its subdirectories:

# chown --recursive alex: /home/alex/literature


The next command changes the ownership of the files in literature to alex and the group associated with these files to pubs:

# chown alex:pubs /home/alex/literature/*


The final example changes the group association of the files in manuals to pubs without altering their ownership. The owner of the files, who is executing this command, must belong to the pubs group.

$ chown :pubs manuals/* 

Linux : chmod: Changes the access mode (permissions) of a file

chmod [options] who operator permission file-list (symbolic)

chmod [options] mode file-list (absolute)

chmod [options] ––reference=rfile file-list (referential)


The chmod utility changes the ways in which a file can be accessed by the owner of the file, the group to which the file belongs, and/or all other users. Only the owner of a file or Superuser can change the access mode, or permissions, of a file. You can specify the new access mode absolutely, symbolically, or referentially.

Arguments

Arguments specify which files are to have their modes changed in what ways.

Symbolic

You can specify multiple sets of symbolic modes (who operator permission) by separating each set from the next with a comma.

The chmod utility changes the access permission for the class of users specified by who. The class of users is designated by one or more of the letters specified in the who column of Table V-4.

Table V-4. Symbolic mode user class specification

who

User class

Meaning

u

User

Owner of the file

g

Group

Group to which the owner belongs

o

Other

All other users

a

All

Can be used in place of ugo


Table V-5 lists the symbolic mode operators.

Table V-5. Symbolic mode operators

operator

Meaning

+

Adds permission for the specified user class

Removes permission for the specified user class

=

Sets permission for the specified user class—resets all other permissions for that user class


The access permission is specified by one or more of the letters listed in Table V-6.

Table V-6. Symbolic mode permissions

permission

Meaning

r

Sets read permission

w

Sets write permission

x

Sets execute permission

s

Sets user ID or group ID (depending on the who argument) to that of the owner of the file while the file is being executed (For more information see page 94.)

t

Sets the sticky bit (Only Superuser can set the sticky bit, and it can be used only with u; see page 903.)

X

Makes the file executable only if it is a directory or if another user class has execute permission

u

Sets specified permissions to those of the owner

g

Sets specified permissions to those of the group

o

Sets specified permissions to those of others


Absolute

You can use an octal number to specify the access mode. Construct the number by ORing the appropriate values from Table V-7. To OR two octal numbers from this table, just add them. (Refer to Table V-8 for examples.)

Table V-7. Absolute mode specifications

mode

Meaning

4000

Sets user ID when the program is executed (page 94)

2000

Sets group ID when the program is executed (page 94)

1000

Sticky bit (page 903)

0400

Owner can read the file

0200

Owner can write to the file

0100

Owner can execute the file

0040

Group can read the file

0020

Group can write to the file

0010

Group can execute the file

0004

Others can read the file

0002

Others can write to the file

0001

Others can execute the file


Table V-8. Examples of absolute mode specifications

Mode

Meaning

0777

Owner, group, and others can read, write, and execute file

0755

Owner can read, write, and execute file; group and others can read and execute file

0711

Owner can read, write, and execute file; group and others can execute file

0644

Owner can read and write file; group and others can read file

0640

Owner can read and write file, group can read file, and others cannot access file


Table V-8 lists some typical modes.

Options

––changes

–c

Displays a message giving the new permissions for each file whose mode is changed.

––quiet or ––silent

–f

Prevents the display of warning messages about files whose permissions prevent chmod from changing the permissions of the file.

––recursive

–R

Recursively descends a directory specified in file-list and changes the permissions on all files in the directory hierarchy.


––reference=rfile

Changes the permissions of the files in file-list to that of rfile.

––verbose

–v

Displays for each file a message saying that its permissions were changed (even if they were not changed) and specifying the permissions. Use ––changes to display messages only when permissions are actually changed.


Notes

When you are using symbolic arguments, you can omit the permission from the command line only when the operator is =. This omission takes away all permissions. See the second example in the next section.

Examples

The following examples show how to use the chmod utility to change the permissions of the file named temp. The initial access mode of temp is shown by ls (see "Discussion" on page 710 for information about the ls display):

$ ls -l temp

-rw-rw-r-- 1 alex pubs 57 Jul 12 16:47 temp


When you do not follow an equal sign with a permission, chmod removes all permissions for the specified user class. The following command removes all access permissions for the group and all other users so that only the owner has access to the file:

$ chmod go= temp

$ ls -l temp

-rw------- 1 alex pubs 57 Jul 12 16:47 temp


The next command changes the access modes for all users (owner, group, and others) to read and write. Now anyone can read from or write to the file.

$ chmod a=rw temp

$ ls -l temp

-rw-rw-rw- 1 alex pubs 57 Jul 12 16:47 temp


Using an absolute argument, a=rw becomes 666. The next command performs the same function as the previous one:

$ chmod 666 temp


The next command removes write access permission for other users. As a result members of the pubs group can still read from and write to the file, but other users can only read from the file:

$ chmod o-w temp

$ ls -l temp

-rw-rw-r-- 1 alex pubs 57 Jul 12 16:47 temp


The following command yields the same result, using an absolute argument:

$ chmod 664 temp


The next command adds execute access permission for all users:

$ chmod a+x temp

$ ls -l temp

-rwxrwxr-x 1 alex pubs 57 Jul 12 16:47 temp


If temp is a shell script or other executable file, all users can now execute it. (You need read and execute access to execute a shell script but only execute access to execute a binary file.) The absolute command that yields the same result is

$ chmod 775 temp


The final command uses symbolic arguments to achieve the same result as the preceding one. It sets permissions to read, write, and execute for the owner, and to read and write for the group and other users. A comma separates the sets of symbolic modes.

$ chmod u=rwx,go=rw temp

Linux : chgrp: Changes the group associated with a file

chgrp [options] group file-list

chgrp [options] ––reference=rfile file-list


The chgrp utility changes the group associated with one or more files.

Arguments

The group is the name or numeric group ID of the new group. The file-list is a list of the pathnames of the files whose group association is to be changed. The rfile is the pathname of a file whose group is to become the new group associated with file-list.

Options

––changes

–c

Displays a message for each file whose group is changed.

––dereference

Changes the group IDs of the files symbolic links point to, not the symbolic links themselves. The default is ––no-dereference.

––quiet or ––silent

–f

Prevents the display of warning messages about files whose permissions prevent you from changing their group IDs.


––no-dereference

–h

Changes the group IDs of symbolic links, not the files that the links point to (default).

––recursive

–R

Recursively descends a directory specified in file-list and changes the group ID on all files in the directory hierarchy.


––reference=rfile

Changes the group of the files in file-list to that of rfile.

––verbose

–v

Displays for each file a message saying whether its group was retained or changed.


Notes

Only the owner of a file or root can change the group association of a file. Also, unless you are root, you must belong to the specified group to change the group ID of a file to that group.

Examples

The following command changes the group that the manuals file is associated with; the new group is pubs.

$ chgrp pubs manuals 

Linux : cd: Changes to another working directory

cd [options] [directory]


The cd builtin makes directory the working directory.

Arguments

The directory is the pathname of the directory you want to be the new working directory. Without an argument, cd makes your home directory the working directory. Using a hyphen in place of directory changes to the previous working directory.

Notes

The cd command is a bash and tcsh builtin.


Without an argument, cd makes your home directory the working directory; it uses the value of the HOME (bash;) or home (tcsh) variable for this purpose.

With an argument of a hyphen, cd makes the previous working directory the working directory. It uses the value of the OLDPWD (bash) or owd (tcsh) variable for this purpose.

The CDPATH (bash;) or cdpath (tcsh; ) variable contains a colon-separated list of directories that cd searches. Within the list a null directory name (::) or a period (:.:) represents the working directory. If CDPATH or cdpath is not set, cd searches only the working directory for directory. If this variable is set and directory is not an absolute pathname (does not begin with a slash), cd searches the directories in the list; if the search fails, cd searches the working directory.

Examples

The following cd command makes Alex's home directory his working directory. The pwd builtin verifies the change:

$ pwd

/home/alex/literature

$ cd

$ pwd

/home/alex


The next command makes the /home/alex/literature directory the working directory:

$ cd /home/alex/literature

$ pwd

/home/alex/literature


Next the cd utility makes a subdirectory of the working directory the new working directory:

$ cd memos

$ pwd

/home/alex/literature/memos


Finally cd uses the . . reference to the parent of the working directory to make the parent the new working directory:

$ cd ..

$ pwd

/home/alex/literature

Linux : cat: Joins and displays files

cat [options] [file-list]


The cat utility copies files to standard output. You can use cat to display the contents of one or more text files on the screen.

Arguments

The file-list is a list of the pathnames of one or more files that cat processes. If you do not specify an argument or if you specify a hyphen () in place of a filename, cat reads from standard input.

Options

Accepts the common options described on page 587.

––show-all

–A

Same as –vET.


––number-nonblank

–b

Numbers all lines that are not blank as they are written to standard output.

–e

(end) Same as –vE.

––show-ends

–E

Marks the ends of lines with dollar signs.

––number

–n

(number) Numbers all lines as they are written to standard output.

––squeeze-blank

–s

Removes extra blank lines so there are never two or more blank lines in a row.

–t

(tab) Same as –vT.

––show-tabs

–T

Marks each TAB with ^I.


––show-nonprinting

–v

Displays CONTROL characters with the caret notation (^M) and displays characters that have the high bit set (META characters) with the M- notation. This option does not convert TABs and LINEFEEDs. Use ––show-tabs if you want to display TABs as ^I. LINEFEEDs cannot be displayed as anything but themselves; otherwise, the line would be too long.


Notes

See page 115 for a discussion of cat, standard input, and standard output.

Use the od utility (page 737) to display the contents of a file that does not contain text (for example, an executable program file).

Use the tac utility to display lines of a text file in reverse order. See the tac info page for more information.

The name cat is derived from one of the functions of this utility, catenate, which means to join together sequentially, or end to end.

caution: Set noclobber to avoid overwriting a file

Despite cat's warning message, the shell destroys the input file (letter) before invoking cat in the following example:

$ cat memo letter > letter

cat: letter: input file is output file


You can prevent overwriting a file in this situation by setting the noclobber variable (pages 119 and 367).


Examples

The following command displays the contents of the memo text file on the terminal:

$ cat memo

...


The next example catenates three text files and redirects the output to the all file:

$ cat page1 letter memo > all


You can use cat to create short text files without using an editor. Enter the following command line, type (or paste) the text you want in the file, and press CONTROL-D on a line by itself:

$ cat > new_file

...

(text)

...

CONTROL-D


In this case cat takes input from standard input (the keyboard) and the shell redirects standard output (a copy of the input) to the file you specify. The CONTROL-D signals the EOF (end of file) and causes cat to return control to the shell

In the next example, a pipe sends the output from who to standard input of cat. The shell redirects cat's output to the file named output that, after the commands have finished executing, contains the contents of the header file, the output of who, and footer. The hyphen on the command line causes cat to read standard input after reading header and before reading footer.

$ who | cat header - footer > output 

Linux : Checks a file for spelling errors

aspell check [options]filename

aspell list [options] < filename

aspell config

aspell help


The aspell utility checks the spelling of words in a document against a standard dictionary. You can use aspell interactively: It displays each misspelled word in context, together with a menu that gives you the choice of accepting the word as is, choosing one of aspell's suggested replacements for the word, inserting the word into your personal dictionary, or replacing the word with one you enter. You can also use aspell in batch mode so that it reads from standard input and writes to standard output.

tip: aspell is not like other utilities regarding its input

Unlike many other utilities, aspell does not accept input from standard input when you do not specify a filename on the command line. Instead, the action specifies where aspell gets its input.


Action

You must choose one and only one action when you run aspell.

check

–c

Runs aspell as an interactive spelling checker. Input comes from a single file named on the command line. Refer to "Discussion" on page 590.

config

Displays aspell's configuration, both default and current values. Send the output through a pipe to less for easier viewing, or use grep to find the option you are looking for (for example, aspell config | grep backup).

help

–?

Displays an extensive page of help. Send the output through a pipe to less for easier viewing.

list

–l

Runs aspell in batch mode (noninteractively) with input coming from standard input and output going to standard output.


Arguments

The filename is the name of the file you want to check. The aspell utility accepts this argument only when you use the check (–c) action. With the list (–l) action, input must come from standard input.

Options

The aspell utility has many options. A few of the more commonly used ones are listed in this section; see the manual for a complete list. Default values of many options are determined when aspell is compiled (see the config action).

You can specify options on the command line, in value of the ASPELL_CONF shell variable, or in your personal configuration file (~/.aspell.conf). Superuser can create a global configuration file (/etc/aspell.conf). Put one option per line in a configuration file; separate options with a semicolon (;) in ASPELL_CONF. Options on the command line override those in ASPELL_CONF, which override those in your personal configuration file, which override those in the global configuration file.

There are two types of options in the following list: Boolean and value. The Boolean options turn a feature on (enable the feature) or off (disable the feature). Precede a Boolean option with dont– to turn it off. For example, ––ignore-case turns the ignore-case feature on and ––dont-ignore-case turns it off.

Value options assign a value to a feature. Follow the option with an equal sign and a value—for example, ––ignore=4.

For all options in a configuration file or in the ASPELL_CONF variable, drop the leading hyphens (ignore-case or dont-ignore-case).

caution: aspell options and leading hyphens

The way you specify options differs depending on whether you are specifying them on the command line, using the ASPELL_CONF shell variable, or in a configuration file.

On the command line prefix long options with two hyphens (for example, ––ignore-case or ––dont-ignore-case). In ASPELL_CONF and configuration files, drop the leading hyphens (for example, ignore-case or dont-ignore-case).


––dont-backup

Does not create a backup file named filename.bak (default is ––backup when action is check).

––ignore=n

Ignores words with n or fewer characters (default is 1).

––ignore-case

Ignores the case of letters in words being checked (default is ––dont-ignore-case).

––lang=cc

Specifies the two-letter language code (cc). The language code defaults to the value of LC_MESSAGES (page 291).

––mode=mod

Specifies a filter to use. Select mod from url (default), none, sgml, and others. The modes work as follows: url: skips URLs, hostnames, and email addresses; none: turns off all filters; sgml: skips SGML, HTML, XHTML, and XML commands.

––strip-accents

Removes accent marks from all the words in the dictionary before checking words (default is ––dont-strip-accents).


Discussion

The aspell utility has two basic modes of operation: batch and interactive. You specify batch mode by using the list or –l action. In batch mode aspell takes the document you want to check for spelling errors as standard input and sends the list of potentially misspelled words to standard output.

You specify interactive mode by using the check or –c action. In interactive mode aspell displays a screen with the potentially misspelled word in context highlighted in the middle and a menu of choices at the bottom. See "Examples" for an illustation. The menu includes various commands (Table V-3) as well as some suggestions of similar, correctly spelled words. You either enter one of the numbers from the menu to select a suggested word to replace the word in question or enter a letter to give a command.

Table V-3. Commands

Command

Action

SPACE

Takes no action and goes on to next the misspelled word.

n

Replaces the misspelled word with suggested word number n.

a

Adds the "misspelled" word to your personal dictionary.

b

Aborts aspell; does not save changes.

i or I (letter "i")

Ignores the misspelled word. I (uppercase "I") ignores all occurrences of this word; i ignores this occurrence only and is the same as SPACE.

l (lowercase "l")

Shifts the "misspelled" word to lowercase and adds it to your personal dictionary.

r or R

Replaces the misspelled word with the word that you enter at the bottom of the screen. R replaces all occurrences of this word; r replaces this occurrence only.

x

Saves the file as corrected so far and exits from aspell.


Notes

For more information refer to the /usr/share/doc/aspell directory with manuals in the man-html and man-text subdirectories and to the aspell home page located at aspell.sourceforge.net.

The aspell utility is not a foolproof way of finding spelling errors. It also does not check for misused, properly spelled words (such as red instead of read).

Spelling from emacs

You can make it easy to use aspell from emacs by adding the following line to your ~/.emacs file. This line causes emacs' ispell functions to call aspell:

(setq-default ispell-program-name "aspell")


Spelling from vim

Similarly, you can make it easy to use aspell from vim by adding the following line to your ~/.vimrc file:

map ^T :w!:!aspell check %:e! %


When you enter this line in ~/.vimrc using vim, enter the ^T as CONTROL-V CONTROL-T (page 159). With this line in ~/.vimrc, CONTROL-T brings up aspell to spell check the file you are editing with vim.

Examples

The following examples use aspell to correct the spelling in the memo.txt file:

$ cat memo.txt

Here's a document for teh aspell utilitey

to check. It obviosly needs proofing

quiet badly.


The first example uses aspell with the check action and no options. The appearance of the screen for the first misspelled word, teh, is shown. At the bottom of the screen is the menu of commands and suggested words. The numbered words each differ slightly from the misspelled word:

$ aspell check memo.txt





Here's a document for teh aspell utilitey

to check. It obviosly needs proofing

quiet badly.



============================================================

1) the 6) th

2) Te 7) tea

3) tech 8) tee

4) Th 9) Ted

5) eh 0) tel

i) Ignore I) Ignore all

r) Replace R) Replace all

a) Add l) Add Lower

b) Abort x) Exit

============================================================

?


Enter one of the menu choices in response to the preceding display; aspell will do your bidding and move the highlight to the next misspelled word (unless you choose to abort or exit).

The next example uses the list action to display a list of misspelled words. The word quiet is not in the list—it is not properly used but is properly spelled.

$ aspell list <>

teh

aspell

utilitey

obviosly


The last example also uses the uses the list action. It shows a quick way to check the spelling of a word or two with a single command. The user gives the aspell list command and then enters seperate temperature into aspell's standard input (the keyboard). After the user enters RETURN and CONTROL-D (to mark the end of file), aspell writes the misspelled word to standard output (the screen):

$ aspell list

seperate temperatureRETURN

CONTROL-D

seperate

Linux : Very brief description of what the utility does

sample [options] arguments


Following the syntax line is a description of the utility. The syntax line shows how to run the utility from the command line. Options and arguments enclosed in brackets ( [ ] ) are not required. Type words that appear in this italic typeface as is. Words that you must substitute when you type appear in this bold italic typeface. Words listed as arguments to a command identify single arguments (for example, source-file) or groups of similar arguments (for example, directory-list ).

Arguments

This section describes the arguments that you can use when you run the utility. The argument itself, as shown in the preceding syntax line, is printed in this bold italic typeface.

Options

This section lists some of the options you can use with the command. Unless otherwise specified, you must precede options with one or two hyphens. Most commands accept a single hyphen before multiple options (page 109). Options in this section are ordered alphabetically by short (single-hyphen) options. If an option has only a long version (two hyphens), it is ordered by its long option. Following are some sample options:

––make-dirs

–d

This option has a long and a short version. You can use either option; they are equivalent.


––delimiter=dchar

–d dchar

This option includes an argument. The argument is set in a bold italic typeface in both the heading and the description. You substitute another word (filename, string of characters, or other value) for any arguments you see in this typeface. Type characters that are in bold type (such as the ––delimiter and –d) as is, letter for letter.

–t

(table of contents) This is an example of a simple option preceded by a single hyphen and not followed with any arguments. It has no long version. The table of contents appearing in parentheses at the beginning of the description is a cue, suggestive of what the option letter stands for.


Discussion

This optional section contains a discussion about how to use the utility and any quirks it may have.

Notes

This section contains miscellaneous notes—some important and others merely interesting.

Examples

This section contains examples of how to use the utility. This section is tutorial and is more casual than the preceding sections of the description.

Linux : Displays Calendar

cal [options] [[month] year]


The cal utility displays a calendar for a month or a year.

Arguments

The arguments specify the month and year for which cal displays a calendar. The month is a decimal integer from 1 to 12 and the year is a decimal integer. Without any arguments, cal displays a calendar for the current month. When you specify a single argument, it is taken to be the year.

Options

–j

(Julian) Displays a Julian calendar—a calendar that numbers the days consecutively from January 1 (1) through December 31 (365 or 366).

–m

(Monday) Makes Monday the first day of the week. Without this option, Sunday is the first day of the week.

–y

(year) Displays a calendar for the current year.

–3

(three months) Displays the previous, current, and next months.


Notes

Do not abbreviate the year. The year 05 is not the same as 2005.

Examples

The following command displays a calendar for August 2007:

$ cal 8 2007

August 2007

Su Mo Tu We Th Fr Sa

1 2 3 4

5 6 7 8 9 10 11

12 13 14 15 16 17 18

19 20 21 22 23 24 25

26 27 28 29 30 31


Next is a Julian calendar for 1949 with Monday as the first day of the week:

$ cal -jm 1949

1949

January February

Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun

1 2 32 33 34 35 36 37

3 4 5 6 7 8 9 38 39 40 41 42 43 44

10 11 12 13 14 15 16 45 46 47 48 49 50 51

17 18 19 20 21 22 23 52 53 54 55 56 57 58

24 25 26 27 28 29 30 59

31 ...

Linux : Compresses or decompresses files

bzip2 [options] [file-list]

bunzip2 [options] [file-list]

bzcat [options] [file-list]

bzip2recover [file]


The bzip2 utility compresses files; bunzip2 restores files compressed with bzip2; bzcat displays files compressed with bzip2.

Arguments

The file-list is a list of one or more files (no directories) that are to be compressed or decompressed. If file-list is empty or if the special option is present, bzip2 reads from standard input. The ––stdout option causes bzip2 to write to standard output.

Options

Accepts the common options described on page 587.

––stdout

–c

Writes the results of compression or decompression to standard output.

––decompress

–d

Decompresses a file compressed with bzip2. This option with bzip2 is equivalent to the bunzip2 command.

––fast or ––best

n

Sets the block size when compressing a file. The n is a digit from 1 to 9, where 1 (––fast) generates a block size of 100 kilobytes and 9 (––best) generates a block size of 900 kilobytes. The default level is 9. The options ––fast and ––best are provided for compatibility with gzip and do not necessarily yield the fastest or best compression.

––force

–f

Forces compression even if a file already exists, has multiple links, or comes directly from a terminal. The option has a similar effect with bunzip2.

––keep

–k

Does not delete input files while compressing or decompressing them.

––quiet

–q

Suppresses warning messages; does display critical messages.

––test

–t

Verifies the integrity of a compressed file. Displays nothing if the file is OK.

––verbose

–v

For each file being compressed displays the name of the file, the compression ratio, the percentage of space saved, and the sizes of the decompressed and compressed files.


Discussion

The bzip2 and bunzip2 utilities work similarly to gzip and gunzip; see the discussion of gzip (page 689) for more information. Normally bzip2 does not overwrite a file; you must use ––force to overwrite a file during compression or decompression.

Notes

The bzip2 home page is sources.redhat.com/bzip2.

The bzip2 utility does a better job of compressing files than gzip.

Use the ––bzip2 modifier with tar (page 788) to compress archive files with bzip2.

bzcat file-list

Works like cat except that it uses bunzip2 to decompress file-list as it copies files to standard output.

bzip2recover

Attempts to recover a damaged file that was compressed with bzip2.

Examples

In the following example, bzip2 compresses a file and gives the resulting file the same name with a .bz2 filename extension. The –v option displays statistics about the compression.

$ ls -l

total 728

-rw-r--r-- 1 sam sam 737414 Feb 20 19:05 bigfile

$ bzip2 -v bigfile

bigfile: 3.926:1, 2.037 bits/byte, 74.53% saved, 737414 in, 187806 out

$ ls -l

total 188

-rw-r--r-- 1 sam sam 187806 Feb 20 19:05 bigfile.bz2


Next touch creates a file with the same name as the original file; bunzip2 refuses to overwrite the file in the process of decompressing bigfile.bz2. The ––force option enables bunzip2 to overwrite the file.

$ touch bigfile

$ bunzip2 bigfile.bz2

bunzip2: Output file bigfile already exists.

$ bunzip2 --force bigfile.bz2

$ ls -l

total 728

-rw-r--r-- 1 sam sam 737414 Feb 20 19:05 bigfile

Linux : Executes commands at a specified time

at [options] time [date | +increment]

atq

atrm job-list

batch [options] [time]


The at and batch utilities execute commands at a specified time. They accept commands from standard input or, with the –f option, from a file. Commands are executed in the same environment as the at or batch command. Unless redirected, standard output and standard error from commands are emailed to the user who ran at or batch. A job is the group of commands that is executed by one call to at. The batch utility differs from at in that it schedules jobs so that they run when the CPU load on the system is low.

The atq utility displays a list of at jobs you have queued; atrm cancels pending at jobs.

Arguments

The time is the time of day that at runs the job. You can specify the time as a one-, two-, or four-digit number. One- and two-digit numbers specify an hour, and four-digit numbers specify an hour and minute. You can also give the time in the form hh:mm. The at utility assumes a 24-hour clock unless you place am or pm immediately after the number, in which case it uses a 12-hour clock. You can also specify time as now, midnight, noon, or teatime (4:00 PM).

The date is the day of the week or day of the month on which you want at to execute the job. When you do not specify a day, at executes the job today if the hour you specify in time is greater than the current hour. If the hour is less than the current hour, at executes the job tomorrow.

You specify a day of the week by spelling it out or abbreviating it to three letters. You can also use the words today and tomorrow. Use the name of a month followed by the number of the day in the month to specify a date. You can follow the month and day number with a year.

The increment is a number followed by one of the following (plural or singular is allowed): minutes, hours, days, or weeks. The at utility adds the increment to time. You cannot specify an increment for a date.

When using atrm, job-list is a list of one or more at job numbers. You can list job numbers by running at with the –l option or by using atq.

Options

The –l and –d options are not for use when you initiate a job with at. You can use them only to determine the status of a job or to cancel a job.

–c job-list

(cat) Displays the environment and commands specified by job-list.

–d job-list

(delete) Cancels jobs that you previously submitted with at. The job-list argument is a list of one or more at job numbers to cancel. If you do not remember the job number, use the –l option or run atq to list your jobs and their numbers. Using this option with at is the same as running atrm.

–f file

(file) Specifies that commands come from file instead of standard input. This option is useful for long lists of commands or commands that are executed repeatedly.

–l

(list) Displays a list of your at jobs. Using this option with at is the same as running atq.

–m

(mail) Sends you email after a job is run, even when nothing is sent to standard output or standard error. When a job generates output, at always emails it to you, regardless of this option.


Notes

The shell saves the environment variables and the working directory at the time you submit an at job so that they are available when at executes commands.

/etc/at.allow and /etc/at.deny

The root user can always use at. The /etc/at.allow and /etc/at.deny files, which should be read0able and writable by root only (mode 600), control which ordinary, local users can use at. When /etc/at.deny exists and is empty, all users can use at. When /etc/at.deny does not exist, only users listed in /etc/at.allow can use at. Users listed in /etc/at.deny cannot use at unless they are also listed in /etc/at.allow.

Jobs you submit using at are run by the at daemon (atd). This daemon stores jobs in /var/spool/at and output in /var/spool/at/spool, both of which should be set to mode 700 and owned by the user named daemon.

Examples

You can use any of the following techniques to paginate and print long_file tomorrow at 2:00 AM. The first example executes the command directly from the command line; the last two examples use the pr_tonight file, which contains the necessary command, and execute it using at.

$ at 2am

at> pr long_file | lpr

at>CONTROL-D

job 8 at 2005-08-17 02:00



$ cat pr_tonight

#!/bin/bash

pr long_file | lpr



$ at -f pr_tonight 2am

job 9 at 2005-08-17 02:00



$ at 2am <>

job 10 at 2005-08-17 02:00


If you execute commands directly from the command line, you must signal the end of the commands by pressing CONTROL-D at the beginning of a line. After you press CONTROL-D, at displays a line that begins with job followed by the job number and the time at will execute the job.

If you run atq after the preceding commands, it displays a list of jobs in its queue:

$ atq

8 2005-08-17 02:00 a

9 2005-08-17 02:00 a

10 2005-08-17 02:00 a


The following command removes job number 9 from the queue:

$ atrm 9

$ atq

8 2005-08-17 02:00 a

10 2005-08-17 02:00 a


The next example executes cmdfile at 3:30 PM (1530 hours) one week from today:

$ at -f cmdfile 1530 +1 week

job 12 at 2005-08-23 15:30


Next at executes a job at 7 PM on Thursday. This job uses find to create an intermediate file, redirects the output sent to standard error, and prints the file.

$ at 7pm Thursday

at> find / -name "core" -print >report.out 2>report.err

at> lpr report.out

at>CONTROL-D

job 13 at 2005-08-18 19:00


The final example shows some of the output generated by the –c option when at is queried about the preceding job. Most of the lines show the environment; only the last few lines execute the commands:

$ at -c 13

#!/bin/sh

# atrun uid=500 gid=500

# mail mark 0

umask 2

PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:.;

export PATH

PWD=/home/mark/book.examples/99/cp; export PWD

EXINIT=set\ ai\ aw; export EXINIT

LANG=C; export LANG

PS1=\\\$\ ; export PS1

...

cd /home/mark/book\.examples/99/cp || {

echo 'Execution directory inaccessible' >&2

exit 1

}

find / -name "core" -print >report.out 2>report.err

lpr report.out