ONE COMMAND A DAY

28.04.2009

9>rm command.

SUMMERY:
rm linux command is used to remove/delete the file from the directory.

SYNTAX:
The Syntax is
rm [options..] [file | directory]

OPTIONS:

-f     Remove all files in a directory without prompting the user.
-i     Interactive. With this option, rm prompts for confirmation before removing any files.
-r (or) -R     Recursively remove directories and subdirectories in the argument list. The directory will be emptied of files and removed. The user is normally prompted for removal of any write-protected files which the directory contains.

EXAMPLES:
1. To Remove / Delete a file:

rm file1.txt

Here rm command will remove/delete the file file1.txt.
2. To delete a directory tree:

rm -ir tmp

This rm command recursively removes the contents of all subdirectories of the tmp directory, prompting you regarding the removal of each file, and then removes the tmp directory itself.
3. To remove more files at once

rm file1.txt file2.txt

rm command removes file1.txt and file2.txt files at the same time.

ONE COMMAND A DAY

27.04.2009

8> mv command.

SUMMERY:

The Linux command ‘mv‘ can be use to rename files or to rename directory in Linux system. The ‘mv‘ command also can be use to moving the files or to moving directory to different directory. The ‘mv‘ command can be interpret as copying and then deleting the files or directory but this is done in much faster paste than manually copying and then deleting the files or folder.

SYNTAX:

mv [-f] [-i] oldname newname

-f mv will move the file(s) without prompting even if it is writing over an existing target. Note that this is the default if the standard input is not a terminal.
-i Prompts before overwriting another file.
oldname The oldname of the file renaming.
newname The newname of the file renaming.
filename The name of the file you want to move directory – The directory of were you want the file to go.

Examples

mv myfile.txt newdirectory/ – moves the file myfile.txt to the directory newdirectory.

mv myfile.txt ../ – moves the file myfile.txt back one directory (if available).

ONE COMMAND A DAY

25.04.2009

7>ln command.

SUMMERY

This command is used to create links to a files.Make links between files.

SYNTAX:

ln [-f] [-n] [-s] existingfile newname

-f Link files without questioning the user, even if the mode of target forbids writing. This is the default if the standard input is not a terminal.
-n Does not overwrite existing files.
-s Makes it so that it does not create a symbolic link existingfile – The file that you want to create a new link.
existingfile Specifies file(s) that you want to create a link to.
newname The new name of the file.
directory The directory were you want the new link.

EXAMPLES:

ln -s file1 file2

Creates a symbolic link to file1 with the name of the file2.


ONE COMMAND A DAY

24.04.2009

6>cat command

SUMMERY:

This command allows you to look,modify,or combine a file.It can be used to concatenate multiple files together and print result on screen.

SYNTAX:

cat filename[-n] [-b] [-u] [-s]

-n Precede each line output with its line number.
-b Number the lines, as -n, but omit the line numbers from blank lines.
-u The output is not buffered. (The default is buffered output.)
-s cat is silent about non-existent files.

- – help                             displays the help manual.

EXAMPLES:

cat file1.txt file2.txt > file3.txt – Reads file1.txt and file2.txt and combines those files to make file3.txt.

RELATED COMMAND:

tac command

This command concatenates or combines the files in reverse order.

(SOURCE for above tac command: LFY APRIL SUBSCRIPTION)

ONE COMMAND A DAY.

23.04.2009

5>find command.

SUMMERY:

Finds one or more files assuming that you know their approximate filenames.find – search for files in a directory hierarchy.

SYNTAX:

find path expressions

path A path name of a starting point in the directory hierarchy.
-atime n True if the file was accessed n days ago. The access time of directories in path is changed by find itself.
-cpio device Always true; write the current file on device in cpio format (5120-byte records).
-ctime n True if the file’s status was changed n days ago.
-depth Always true; causes descent of the directory hierarchy to be done so that all entries in a directory are acted on before the directory itself. This can be useful when find is used with cpio to transfer files that are contain edin directories without write permission.
-exec command True if the executed command returns a zero value as exit status. The end of command must be punctuated by an escaped semicolon. A command argument {} is replaced by the current path name.
-follow Always true; causes symbolic links to be followed. When following symbolic links, find keeps track of the directories visited so that it can detect infinite loops; for example, such a loop would occur if a symbolic link pointed to an ancestor. This expression should not be used with the -type l expression.
-fstype type True if the filesystem to which the file belongs is of type type .
-group gname True if the file belongs to the group gname. If gname is numeric and does not appear in the /etc/group file, it is taken as a group ID.
-inum n True if the file has inode number n.
-links True if the file has n links.
-local True if the file system type is not a remote file system type as defined in the /etc/dfs/fstypes file. nfsis used as the default remote filesystem type if the/etc/dfs/fstypes file is not present.
-ls Always true; prints current path name together
with its associated statistics. These include
(respectively):>inode number

>size in kilobytes (1024 bytes)

>protection mode

>number of hard links

>user

>group

>size in bytes

>modification time.

    If the file is a special file the size field will instead contain the major and minor device numbers.

    If the file is a symbolic link the pathname of the linked-to file is printed preceded by `->’. The format is identical to that of ls -gilds ls Note: Formatting is done internally, without executing the ls program.

    -mount Always true; restricts the search to the file system containing the directory specified. Does not list mount points to other file systems.
    -mtime n True if the file’s data was modified n days ago.
    -name pattern True if pattern matches the current file name.  Normal shell file name generation characters (see sh) may be used. A backslash (\) is used as an escape character within the pattern. The pattern should be escaped or quoted when find is invoked from the shell.
    -ncpio device Always true; write the current file on device in cpio -c format (5120 byte records).
    -newer file True if the current file has been modified more recently than the argument file.
    -nogroup True if the file belongs to a group not in the /etc/group file.
    -nouser True if the file belongs to a user not in the /etc/passwd file.
    -ok command Like -exec except that the generated command line is printed with a question mark first, and is executed only if the user responds by typing y.
    -perm [-]mode The mode argument is used to represent file mode bits. It will be identical in format to the <symbolicmode> operand described in chmod, and will be interpreted as follows. To start, a template will be assumed with all file mode bits cleared. An op symbol of:

    + will set the appropriate mode bits in the template;
    - will clear the appropriate bits;
    = will set the appropriate mode bits, without regard to the contents of process’ file mode creation mask.

    The op symbol of – cannot be the first character of mode; this avoids ambiguity with the optional leading hyphen. Since the initial mode is all bits off, there are not any symbolic modes that need to use – as the first character.

    If the hyphen is omitted, the primary will evaluate as true when the file permission bits exactly match the value of the resulting template.

    Otherwise, if mode is prefixed by a hyphen, the primary will evaluate as true if at least all the bits in the resulting template are set in the file permission bits.

    -perm [-]onum True if the file permission flags exactly match the octal number onum see chmod). If onum is prefixed by a minus sign (-), only the bits that are set in onum are compared with the file permission flags, and the expression evaluates true if they match.
    -print Always true; causes the current path name to be printed.
    -prune Always yields true. Do not examine any directories or files in the directory structure below the pattern just matched. If -depth is specified, -prune will have no effect.
    -size n[c] True if the file is n blocks long (512 bytes per block). If n is followed by a c, the size is in
    bytes.
    -type c True if the type of the file is c, where c is b, c, d, D, f, l, p, or s for block special file, character special file, directory, door, plain file, symbolic link, fifo (named pipe), or socket, respectively.
    -user uname True if the file belongs to the user uname . If uname is numeric and does not appear as a login name in the /etc/passwd file, it is taken as a user ID.
    -xdev Same as the -mount primary.

    When using find to determine files modified within a range of time, one must use the ?time argument before the -print argument; otherwise, find will give all files.

    EXAMPLES:

    find -name ‘mypage.htm’

    In the above command the system would search for any file named mypage.htm in the current directory and any subdirectory.

    find -name ‘*’ -size +1000k

    In the above example the system would search for any file that is larger then 1000k.

    ONE COMMAND A DAY

    22.04.2009

    3>who command.

    SUMMERY:


    The who command displays information about all users currently on the system. The following information is displayed: login name, tty, date and time of login. Typing who am i or who am I displays your login name, tty, date and time you logged in. If the user is logged in from a remote machine, then the host name of that machine is displayed as well.

    The who command can also display the elapsed time since line activity occurred, logins, logoffs, restarts, and changes to the system clock, as well as other processes generated by the initialization process.

    SYNTAX:

    -a Process /var/adm/utmp or the named file with -b, -d, -l, -p, -r, -t, -T, and -u options turned on.
    -b Indicate the time and date of the last reboot.
    -d Display all processes that have expired and not been respawned by init . The exit field appears for dead processes and contains the termination and exit values (as returned by wait), of the dead process. This can be useful in determining why a process terminated.
    -H Output column headings above the regular output.
    -l List only those lines on which the system is waiting for someone to login. The name field is LOGIN in such cases. Other fields are the same as for user entries except that the state field does not exist.
    -m Output only information about the current terminal.
    -n x Take a numeric argument, x, which specifies the number of users to display per line. x must be at least 1. The -n option may only be used with -q.

    man who always helps..

    ONE COMMAND A DAY

    21.04.2009

    3>cp command.

    SUMMARY

    Copies files from one location to another.cp [options] file1 file2 cp [options] files directory.Copy file1 to file2, or copy one or more files to the same names under directory. If the destination is an existing file, the file is overwritten; if the destination is an existing directory, the file is copied into the directory.

    SYNTAX:

    -a, –archive

    Preserve attributes of original files where possible. The same as -dpr.

    -b, –backup

    Back up files that would otherwise be overwritten.

    -d, –no-dereference

    Do not dereference symbolic links; preserve hard-link relationships between source and copy.

    -f, –force

    Remove existing files in the destination.

    -i, –interactive

    Prompt before overwriting destination files. On most systems, this flag is turned off by default except for the root user, who is normally prompted before overwriting files.

    -l, –link

    Make hard links, not copies, of nondirectories.

    -p, –preserve

    Preserve all information, including owner, group, permissions, and timestamps.

    -P, –parents

    Preserve intermediate directories in source. The last argument must be the name of an existing directory.


    -r, -R, –recursive

    Copy directories recursively.

    -S backup-suffix, –suffix=backup-suffix

    Set suffix to be appended to backup files. This may also be set with the SIMPLE_BACKUP_SUFFIX environment variable. The default is ~. You need to explicitly include a period if you want one before the suffix (for example, specify .bak, not bak).

    -s, –symbolic-link

    Make symbolic links instead of copying. Source filenames must be absolute.

    –sparse=[always|auto|never]

    Handle files that have “holes” (are defined as a certain size but have less data). always creates a sparse file, auto creates one if the input file is sparse, and never creates a non-sparse file without holes.

    -u, –update

    Do not copy a file to an existing destination with the same or newer modification time.

    -v, –verbose

    Before copying, print the name of each file.

    man cp is always there.

    EXAMPLES:

    Suppose some image is there in a pen drive named corn and you wanna copy an image named abc.png from it to home directory.First we become a super user by doing su – .Then we use the cp command followed by the path name and the source directory.

    ~]# cp /media/corn/abc.png /home/yevlempy

    ONE COMMAND A DAY

    20.04.2009

    2> cd command.

    SUMMARY

    This command is used to change to another directory.Suppose we are in any directory and then we do cd /bin ,this changes  our current directory or the working directory to /bin.

    SYNTAX:

    -m keymap
    Use keymap as the keymap to be affected by the subsequent bindings. Acceptable keymap names are emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move, vi-command, and vi-insert. vi is equivalent to vi-command; emacs is equivalent to emacs-standard.
    -l
    List the names of all readline functions.
    -p
    Display readline function names and bindings in such a way that they can be re-read.
    -P
    List current readline function names and bindings.
    -v
    Display readline variable names and values in such a way that they can be re-read.
    -V
    List current readline variable names and values.
    -s
    Display readline key sequences bound to macros and the strings they output in such a way that they can be re-read.
    -S
    Display readline key sequences bound to macros and the strings they output.
    -f filename
    Read key bindings from filename.
    -q function
    Query about which keys invoke the named function.
    -u function
    Unbind all keys bound to the named function.
    -r keyseq
    Remove any current binding for keyseq.
    -x keyseq:shell-command
    Cause shell-command to be executed whenever keyseq is entered

    And yes man cd is always there for complete description.

    EXAMPLES:

    Use the cd command to change into the / (root) directory.

    $ cd /

    Now change into the usr directory, below the / directory

      $ cd /usr

    ONE COMMAND A DAY.

    18.04.2009

    1>   ls command.

    SUMMARY

    This command displays a listing files in a directory.We can list the names of files available in a directory with this command.It basically displays the listing file of the current directory,suppose we do ‘ls’ after going in root directory,it lists the files present in the root directory.We can also see the listed files by going through the path i.e ls /home/  lists the files in home directory.

    SYNTAX:

    -a Shows you all files, even files that are hidden (these files begin with a dot.)
    -A List all files including the hidden files. However, does not display the working directory (.) or the parent directory (..).
    -b Force printing of non-printable characters to be in octal \ddd notation.
    -c Use time of last modification of the i-node (file created, mode changed, and so forth) for sorting (-t) or printing (-l or -n).
    -C Multi-column output with entries sorted down the columns. Generally this is the default option.
    -d If an argument is a directory it only lists its name not its contents.
    -f Force each argument to be interpreted as a directory and list the name found in each slot. This option turns off -l, -t, -s, and -r, and turns on -a; the order is the order in which entries appear in the directory.
    -F Mark directories with a trailing slash (/), doors with a trailing greater-than sign (>), executable files with a trailing asterisk (*), FIFOs with a trailing vertical bar (|), symbolic links with a trailing at-sign (@), and AF_Unix address family sockets with a trailing equals sign (=).
    -g Same as -l except the owner is not printed.
    -i For each file, print the i-node number in the first column of the report.
    -l Shows you huge amounts of information (permissions, owners, size, and when last modified.)
    -L If an argument is a symbolic link, list the file or directory the link references rather than the link itself.
    -m Stream output format; files are listed across the page, separated by commas.
    -n The same as -l, except that the owner’s UID and group’s GID numbers are printed, rather than the associated character strings.
    -o The same as -l, except that the group is not printed.
    -p Displays a slash ( / ) in front of all directories.
    -q Force printing of non-printable characters in file names as the character question mark (?).
    -r Reverses the order of how the files are displayed.
    -R Includes the contents of subdirectories.
    -s Give size in blocks, including indirect blocks, for each entry.
    -t Shows you the files in modification time.
    -u Use time of last access instead of last modification for sorting (with the -t option) or printing (with the -l option).
    -x Displays files in columns.
    -1 Print one entry per line of output.
    pathnames File or directory to list.

    There are many more options, we can see them by doing man ls.

    Introduction to gcc.

    Basics of compiling c programme using gcc compiler.

    This is the basic how a new linux user can compile c programs using gcc compiler.It will help the new linux users to compile c programs.

    Newer entries »