preload
Oct 12

“tail” command – used to Print the last few lines of each FILE to standard output.

Syntax :
tail [options] filename

[Source from Wikipedia]
By default, tail will print the last 10 lines of its input to the standard output. With command line options the number of lines printed and the printing units (lines, blocks or bytes) may be changed. The following example shows the last 20 lines of filename:
tail -n 20 filename

This example shows the last 15 bytes of all files starting with filename :
tail -c 15 filename

This example shows all lines of filename from the second line onwards:
tail -n +2 filename

Using an older syntax (still used in Sun Solaris as the -n option is not supported), the last 20 lines and the last 50 bytes of filename can be shown with the following command:
tail -20 filename
tail -50c filename

However this syntax is now obsolete and does not conform with the POSIX 1003.1-2001 standard. Even if still supported in current versions, when used with other options (like -f, see below), these switches could not work at all.

File monitoring

tail has a special command line option -f (follow) that allows a file to be monitored. Instead of displaying the last few lines and exiting, tail displays the lines and then monitors the file. As new lines are added to the file by another process, tail updates the display. This is particularly useful for monitoring log files. The following command will display the last 10 lines of messages and append new lines to the display as new lines are added to messages:

tail -f /var/adm/messages

To interrupt tail while it is monitoring, break-in with CTRL-C. This command can be run “in the background” with &, see job control.

Oct 10

1.mkdir –make directories or folder
# mkdir [dirname]–> creates specified directory

2.cd – change directory path
# cd [dirname]–> switches into specified directory
# cd .. –>moves one directory up
# cd ../../ —> moves two directories up (and so on)
# cd –> brings you to highest level of your home directory

3.rm – delete files and directories
# rmdir –> removes empty directory
# rm –> removes file name
# rm -r –> removes directory including its content, but asks for confirmation, ‘f’ argument turns confirmation off

4.mv – move or rename the file or directory
# mv [name1] [name2] –> renames directories or files
# mv [name] [dir]–> moves file/directory as specified in path
# rename [oldfilename] [newfilename] [oldfilename]

5.cp -copy files and directory
# cp [file] [path] –> copy file/directory as specified in path (-r to include content in directories)

6. pwd –> present working directory
7. ls –> content of pwd
8. ll –> similar as ls, but provides additional info on files and directories
9. ll -a –> includes hidden files (.name) as well
10. ll -R –> lists subdirectories recursively
11 ll -t –> lists files in chronological order
12.dir – display the directory contents
13.stat [filename]–> provides all attributes of a file

Sep 22

1. For creating Archive file use tar command
Syntax:
tar -cf archivename filenames (seperated with space)

Example :
VIT:/home/antony# tar -cf model.tar sample.c sample2.c

2. For displaying contents of archive file
VIT:/home/antony# tar -tvf model.tar
-rw-r–r– antony/antony 54 2007-09-22 03:10 sample.c
-rw-r–r– root/root 0 2007-09-22 03:12 sample2.c

3. For extracting files from archive
VIT:/home/antony# tar -xf model.tar