News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

Linux Commands

Started by VelMurugan, May 08, 2009, 12:11 PM

Previous topic - Next topic

VelMurugan

lastlog COMMAND:

     lastlog command is used to print the last login times for system accounts. Login information is read from the file /var/log/lastlog.

SYNTAX:

  The Syntax is
     lastlog [options]

OPTIONS:
     
-t n    Print only logins more recent than 'n' days ago..
-u username    Print only login information for username.

VelMurugan

less COMMAND:

     less command is used to display text in the terminal screen. It just prints the text in the given file, you cannot edit or manipulate the text here. To display the file from the specified line, enter the line number followed by colon(:). It allows Forward and backward movement in the file.

SYNTAX:

  The Syntax is
     less [options] filename

OPTIONS:
     
-c    Clear screen before displaying.
+n    Starts up the file from the given number.
:p    Examine the pervious file in the command line list.
:d    Remove the current file from the list of files.

VelMurugan

link COMMAND:

     link command is used to create a link to a file. It is also called as hard link. Inode will be same for source and destination.

SYNTAX:

  The Syntax is
     link existingfilename newfilename (or) link source destination

OPTIONS:

     
--help    Print help message and exit
--version    Print version and exit

VelMurugan

ln COMMAND:

     ln command is used to create link to a file (or) directory. It helps to provide soft link for desired files. Inode will be different for source and destination.

SYNTAX:


  The Syntax is
     ln [options] existingfile(or directory)name newfile(or directory)name

OPTIONS:

     
-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 (not on System V.) existingfile - The file that you want to create a new link.

VelMurugan

ls COMMAND:

     ls command lists the files and directories under current working directory.

SYNTAX:


  The Syntax is
     ls [OPTIONS]... [FILE]

OPTIONS:
     
-l    Lists all the files, directories and their mode, Number of links, owner of the file, file size, Modified date and time and filename.
-t    Lists in order of last modification time.
-a    Lists all entries including hidden files.
-d    Lists directory files instead of contents.
-p    Puts slash at the end of each directories.
-u    List in order of last access time.
-i    Display inode information.
-ltr    List files order by date.
-lSr    List files order by file size.

VelMurugan

lsattr COMMAND:

     lsattr command is used to list the attributes of the specified file or directory.

SYNTAX:

  The Syntax is
     lsattr [options]

OPTIONS:
     
-R    Recursively list attributes of directories and their contents.
-a    List all files in directories, including files that start with `.'.
-d    List directories like other files, rather than listing their contents.

VelMurugan

mail COMMAND:

     mail command is used to send and receive mails locally and globally.

SYNTAX:

  The Syntax is
     mail

OPTIONS:
     
-s    Specify subject on command line.
-c    Send carbon copies to list of users.
-b    Send blind carbon copies to list. List should be a comma-separated list of names.
-f    Read in the contents of your mbox for processing; when you quit, mail writes undeleted messages back to this file.
-i    Ignore tty interrupt signals. This is particularly useful when using mail on noisy phone lines.

VelMurugan

man COMMAND:

     man command which is short for manual, provides in depth information about the requested command (or) allows users to search for commands related to a particular keyword.

SYNTAX:


  The Syntax is
     man commandname [options]

OPTIONS:

     
-a    Print a one-line help message and exit.
-k    Searches for keywords in all of the manuals available..

VelMurugan

mkdir COMMAND:

     mkdir command is used to create one or more directories.

SYNTAX:

  The Syntax is
     mkdir [options] directories

OPTIONS:
     
-m    Set the access mode for the new directories.
-p    Create intervening parent directories if they don't exist.
-v    Print help message for each directory created.

VelMurugan

more COMMAND:

     more command is used to display text in the terminal screen. It allows only backward movement.

SYNTAX:


  The Syntax is
     more [options] filename

OPTIONS:
     
-c    Clear screen before displaying.
-e    Exit immediately after writing the last line of the last file in the argument list.
-n    Specify how many lines are printed in the screen for a given file.
+n    Starts up the file from the given number.

VelMurugan

mv COMMAND:

     mv command which is short for move. It is used to move/rename file from one directory to another. mv command is different from cp command as it completely removes the file from the source and moves to the directory specified, where cp command just copies the content from one file to another.

SYNTAX:

  The Syntax is
     mv [-f] [-i] oldname newname

OPTIONS:
     
-f    This will not prompt before overwriting (equivalent to --reply=yes). mv -f will move the file(s) without prompting even if it is writing over an existing target.
-i    Prompts before overwriting another file.

VelMurugan

netstat COMMAND:

      nestat command displays statistics information and current state of network connections, protocol, ports/ sockets and devices.

SYNTAX:

  The Syntax is
     netstat [options]

OPTIONS:
     
-s    dispalys statics information about protocols.
-i    dispalys statistics information about the network interface.
-r    diplays routing table.
-c    displays statistics information and updates every second.
-l    displays information about all sockets that are in listening state.
-a    displays information about all sockets that are in listening and non-listening state.
-p    displays information about sockets with ProcessName and PID.

VelMurugan

passwd COMMAND:

     passwd command is used to change your password.

SYNTAX:

  The Syntax is
     passwd [options]

OPTIONS:
     
-a    Show password attributes for all entries.
-l    Locks password entry for name.
-d    Deletes password for name. The login name will not be prompted for password.
-f    Force the user to change password at the next login by expiring the password for name.

VelMurugan

paste COMMAND:

     paste command is used to paste the content from one file to another file. It is also used to set column format for each line.

SYNTAX:

  The Syntax is
     paste [options]

OPTIONS:

     
-s    Paste one file at a time instead of in parallel.
-d    Reuse characters from LIST instead of TABs .

VelMurugan

pidof COMMAND:

     pidof linux command is used to find the process ID of a running program.

SYNTAX:

  The Syntax is
     pidof [options..] program

OPTIONS:

     
-s    Single shot - this instructs the program to only return one pid.
-x    Scripts too - this causes the program to also return process id's of shells running the named scripts.
-o    Tells pidof to omit processes with that process id. The special pid %PPID can be used to name the parent process of the pidof program, in other words the calling shell or shell script.

VelMurugan

ping COMMAND:

     System administration command. Confirm that a remote host is online and responding. Ping is used for verifying connectivity between two hosts on a network. It sends Internet Control Message Protocol (ICMP) echo request packets to a remote IP address and watches for ICMP responses.

SYNTAX:

  The Syntax is
     ping [options] host

OPTIONS:
     
-a    Make ping audible. Beep each time response is received.
-b    Ping a broadcast address.
-c count    Stop after sending count ECHO_REQUEST packets. With deadline option, ping waits for count ECHO_REPLY packets, until the timeout expires.
-n    Show network addresses as numbers. ping normally displays addresses as host names.
-q    Quiet output nothing is displayed except the summary lines at startup time and when finished.
-i    Specify the interval between successive transmissions. The default is one second.
-t    Set the IP Time to Live to n seconds.
-w    Exit ping after n seconds.

VelMurugan

printf COMMAND:

     printf command is used to write formatted output.

SYNTAX:

  The Syntax is
     printf format [argument]....

OPTIONS:

     The format characters and their meanings are:
\b    Backspace.
\n    Newline.
\t    Horizontal tab
\v    Vertical tab.

VelMurugan

ps COMMAND:

     ps command is used to report the process status. ps is the short name for Process Status.

SYNTAX:

  The Syntax is
     ps [options]

OPTIONS:
     
-a    List information about all processes most frequently requested: all those except process group leaders and processes not associated with a terminal..
-A or e    List information for all processes.
-d    List information about all processes except session leaders.
-e    List information about every process now running.
-f    Generates a full listing.
-j    Print session ID and process group ID.
-l    Generate a long listing.

VelMurugan

pwd COMMAND:

     pwd - Print Working Directory. pwd command prints the full filename of the current working directory.

SYNTAX:

  The Syntax is
     pwd [options]

OPTIONS:
     
-P    The pathname printed will not contain symbolic links.
-L    The pathname printed may contain symbolic links.

VelMurugan

restore COMMAND:

     restore - command restores the data from the dump-file or backup-file created using dump command.

SYNTAX:

  The Syntax is
     restore [options]

OPTIONS:
     
-f    Used to specify the backup or dump file
-C    Used to compare dump-file with original file
-i    Restore in Interactive mode
-v    Displays Verbose Information
-e    Exclude inode while making backup

    Commands used in interactive mode:
ls    List the files and directories in backup file
add    Add files in dump-file to current working directory
cd    Changes the directory
pwd    Displays the current working directory
extract    Extract the files from the dump
quit    Quit from the interactive mode

VelMurugan

rm COMMAND:

     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.

VelMurugan

rmdir COMMAND:

     rmdir command is used to delete/remove a directory and its subdirectories.

SYNTAX:


  The Syntax is
     rmdir [options..] Directory

OPTIONS:
     
-p    Allow users to remove the directory dirname and its parent directories which become empty.

VelMurugan

route COMMAND:

     route command displays routing table resides in kernel and also used to modify the routing table.The tables which specifies how packets are routed to a host is called routing table.

SYNTAX:

  The Syntax is
     route [options]

OPTIONS:

     
-n    dispalys routing table in numerical[IP Address] format
-e    dispalys routing table in Hostname format
add    Adds a new route to the routing table
del    Deletes a route from the routing table

    Options used with add and del :
-net    Indicate the target is network
-host    Indicate the target is network
gw    Specifies the gateway of target host/network
netmask    Used to specifiy the subnet-mask of destination network/host
dev    Specify the device or interface where the packets will be sent
reject    rejects the packets sent to particular route/host

VelMurugan

sort COMMAND:

     sort command is used to sort the lines in a text file.

SYNTAX:

  The Syntax is
     sort [options] filename

OPTIONS:
     
-r    Sorts in reverse order.
-u    If line is duplicated display only once.
-o filename    Sends sorted output to a file.

VelMurugan

sed COMMAND:

     sed is a stream editor. sed command helps to edit or delete all occurrences of one string to another within a file. It takes a file as input and prints the result on screen or redirects the output to a specified file.

SYNTAX:


  The Syntax is
     sed [options] '{command}' [filename]

OPTIONS:


      Command and its function
-n    do not output the trailing newline
-e    enable interpretation of the backslash-escaped characters listed below
-E    disable interpretation of those sequences in STRINGs

    Without -E, the following sequences are recognized and interpolated:
\NNN    the character whose ASCII code is NNN (octal)
\a    alert (BEL)
\b    backspace
\c    suppress trailing newline
\f    form feed
\n    new line
\r    carriage return
\t    horizontal tab
\v    vertical tab

VelMurugan

tail COMMAND:

     tail command is used to display the last or bottom part of the file. By default it displays last 10 lines of a file.

SYNTAX:

  The Syntax is
     tail [options] filename

OPTIONS:
     
-l    To specify the units of lines.
-b    To specify the units of blocks.
-n    To specify how many lines you want to display.
-c number    The number option-argument must be a decimal integer whose sign affects the location in the file, measured in bytes.
-n number    The number option-argument must be a decimal integer whose sign affects the location in the file, measured in lines.

VelMurugan


tar COMMAND:


     tar command is used to create archive and extract the archive files.

SYNTAX:

  The Syntax is
     tar [options] [archive-file] [File or directory to be archived]

OPTIONS:
     
-c    Creates Archive
-x    Extract the archive
-f    creates archive with give filename
-t    displays or lists files in archived file
-u    archives and adds to an existing archive file
-v    Displays Verbose Information
-A    Concatenates the archive files

VelMurugan

useradd COMMAND:

     useradd - Adds new user to the linux system, with specified user-name. When a new user is added then a corresponding entry is made in files /etc/passwd, /etc/group and /etc/shadow

SYNTAX:


  The Syntax is
     useradd [options] [username]

OPTIONS:

     
-d    Specifies the users home directory
-s    Specifies the users shell
-g    Specifies the users primary group
-G    Specifies the users secondary groups
-M    Specifies not to create home directory for the user
-e    Specifies the expire date of the user
-uid    Specifies the user-id of the user

VelMurugan

who COMMAND:

      who command can list the names of users currently logged in, their terminal, the time they have been logged in, and the name of the host from which they have logged in.

SYNTAX:


  The Syntax is
     who [options] [file]

OPTIONS:
     
am i    Print the username of the invoking user, The 'am' and 'i' must be space separated.
-b    Prints time of last system boot.
-d    print dead processes.
-H    Print column headings above the output.
-i    Include idle time as HOURS:MINUTES. An idle time of . indicates activity within the last minute.
-m    Same as who am i.
-q    Prints only the usernames and the user count/total no of users logged in.
-T,-w    Include user's message status in the output.

VelMurugan

whois COMMAND:

     whois command lists the information about the domain owner of the given domain.

SYNTAX:

  The Syntax is
     whois [option] query

OPTIONS:
     
-h    Host which holds the identification information in its database.
-p    connect to the specified port.

VelMurugan

yes COMMAND:

     yes command repeatedly prints the given string separated by a space and followed by a newline until it is killed. If no string is given, it just prints 'y' repeatedly until it is killed. It is normally used in scripts, its output is piped to a command or program that prompts you to do this or that (do you want to delete this file press 'y' or 'n')

SYNTAX:


  The Syntax is
     yes [string..]
     yes [options..]

OPTIONS:

     
--help    Print help message and exit
--version    Print version and exit