Thursday, January 19, 2017

Linux Command Line Tutorial For Beginners 37 - netstat command

NETSTAT(8)                 Linux Programmer's Manual                NETSTAT(8)

       netstat  - Print network connections, routing tables, interface statis‐
       tics, masquerade connections, and multicast memberships

       netstat  [address_family_options]  [--tcp|-t]   [--udp|-u]   [--raw|-w]
       [--listening|-l]     [--all|-a]     [--numeric|-n]    [--numeric-hosts]
       [--numeric-ports]           [--numeric-users]           [--symbolic|-N]
       [--extend|-e[--extend|-e]]  [--timers|-o] [--program|-p] [--verbose|-v]

       netstat              {--route|-r}              [address_family_options]
       [--extend|-e[--extend|-e]]         [--verbose|-v]        [--numeric|-n]
       [--numeric-hosts] [--numeric-ports] [--numeric-users] [--continuous|-c]

       netstat {--interfaces|-i} [--all|-a] [--extend|-e[--extend|-e]] [--ver‐
       bose|-v]  [--program|-p]  [--numeric|-n]  [--numeric-hosts] [--numeric-
       ports] [--numeric-users] [--continuous|-c]

       netstat      {--groups|-g}       [--numeric|-n]       [--numeric-hosts]
       [--numeric-ports] [--numeric-users] [--continuous|-c]

       netstat       {--masquerade|-M}       [--extend|-e]      [--numeric|-n]
       [--numeric-hosts] [--numeric-ports] [--numeric-users] [--continuous|-c]

       netstat {--statistics|-s} [--tcp|-t] [--udp|-u] [--raw|-w]

       netstat {--version|-V}

       netstat {--help|-h}


       [-4]      [-6]       [--protocol={inet,unix,ipx,ax25,netrom,ddp}[,...]]
       [--unix|-x] [--inet|--ip] [--ax25] [--ipx] [--netrom] [--ddp]

       Netstat  prints  information about the Linux networking subsystem.  The
       type of information printed is controlled by  the  first  argument,  as

       By  default,  netstat  displays  a  list of open sockets.  If you don't
       specify any address families, then the active sockets of all configured
       address families will be printed.

   --route , -r
       Display  the kernel routing tables. See the description in route(8) for
       details.  netstat -r and route -e produce the same output.

   --groups , -g
       Display multicast group membership information for IPv4 and IPv6.

   --interfaces, -i
       Display a table of all network interfaces.

   --masquerade , -M
       Display a list of masqueraded connections.

   --statistics , -s
       Display summary statistics for each protocol.

   --verbose , -v
       Tell the user what is going on by being verbose. Especially print  some
       useful information about unconfigured address families.

   --wide , -W
       Do not truncate IP addresses by using output as wide as needed. This is
       optional for now to not break existing scripts.

   --numeric , -n
       Show numerical addresses instead of trying to determine symbolic  host,
       port or user names.

       shows  numerical  host  addresses but does not affect the resolution of
       port or user names.

       shows numerical port numbers but does not affect the resolution of host
       or user names.

       shows  numerical user IDs but does not affect the resolution of host or
       port names.

   --protocol=family , -A
       Specifies the address families (perhaps better described as  low  level
       protocols)  for  which  connections are to be shown.  family is a comma
       (',') separated list of address family keywords like inet,  unix,  ipx,
       ax25,  netrom,  and ddp.  This has the same effect as using the --inet,
       --unix (-x), --ipx, --ax25, --netrom, and --ddp options.

       The address family inet includes raw, udp and tcp protocol sockets.

   -c, --continuous
       This will cause netstat to print the selected information every  second

   -e, --extend
       Display  additional  information.   Use  this  option twice for maximum

   -o, --timers
       Include information related to networking timers.

   -p, --program
       Show the PID and name of the program to which each socket belongs.

   -l, --listening
       Show only listening sockets.  (These are omitted by default.)

   -a, --all
       Show both listening and non-listening sockets.  With  the  --interfaces
       option, show interfaces that are not up

       Print routing information from the FIB.  (This is the default.)

       Print routing information from the route cache.

   Active Internet connections (TCP, UDP, raw)
       The protocol (tcp, udp, raw) used by the socket.

       The  count  of  bytes  not copied by the user program connected to this

       The count of bytes not acknowledged by the remote host.

   Local Address
       Address and port number of the local end of  the  socket.   Unless  the
       --numeric  (-n)  option is specified, the socket address is resolved to
       its canonical host name (FQDN), and the port number is translated  into
       the corresponding service name.

   Foreign Address
       Address  and port number of the remote end of the socket.  Analogous to
       "Local Address."

       The state of the socket. Since there are no states in raw mode and usu‐
       ally  no  states  used  in UDP, this column may be left blank. Normally
       this can be one of several values:

              The socket has an established connection.

              The socket is actively attempting to establish a connection.

              A connection request has been received from the network.

              The socket is closed, and the connection is shutting down.

              Connection is closed, and the socket is waiting for  a  shutdown
              from the remote end.

              The socket is waiting after close to handle packets still in the

       CLOSE  The socket is not being used.

              The remote end has shut down, waiting for the socket to close.

              The remote end has shut down, and the socket is closed.  Waiting
              for acknowledgement.

       LISTEN The  socket is listening for incoming connections.  Such sockets
              are not included in the output unless you specify the  --listen‐
              ing (-l) or --all (-a) option.

              Both  sockets are shut down but we still don't have all our data

              The state of the socket is unknown.

       The username or the user id (UID) of the owner of the socket.

   PID/Program name
       Slash-separated pair of the process id (PID) and process  name  of  the
       process  that  owns  the  socket.   --program  causes this column to be
       included.  You will also need superuser privileges to see this informa‐
       tion  on sockets you don't own.  This identification information is not
       yet available for IPX sockets.

       (this needs to be written)

   Active UNIX domain Sockets
       The protocol (usually unix) used by the socket.

       The reference count (i.e. attached processes via this socket).

       The flags displayed is SO_ACCEPTON (displayed as ACC), SO_WAITDATA  (W)
       or  SO_NOSPACE  (N).   SO_ACCECPTON  is  used on unconnected sockets if
       their corresponding processes are waiting for a  connect  request.  The
       other flags are not of normal interest.

       There are several types of socket access:

              The socket is used in Datagram (connectionless) mode.

              This is a stream (connection) socket.

              The socket is used as a raw socket.

              This one serves reliably-delivered messages.

              This is a sequential packet socket.

              Raw interface access socket.

              Who ever knows what the future will bring us - just fill in here

       This field will contain one of the following Keywords:

       FREE   The socket is not allocated

              The socket is listening for a connection request.  Such  sockets
              are  only  included in the output if you specify the --listening
              (-l) or --all (-a) option.

              The socket is about to establish a connection.

              The socket is connected.

              The socket is disconnecting.

              The socket is not connected to another one.

              This state should never happen.

   PID/Program name
       Process ID (PID) and process name of the process that  has  the  socket
       open.  More info available in Active Internet connections section writ‐
       ten above.

       This is the path name as which the corresponding processes attached  to
       the socket.

   Active IPX sockets
       (this needs to be done by somebody who knows it)

   Active NET/ROM sockets
       (this needs to be done by somebody who knows it)

   Active AX.25 sockets
       (this needs to be done by somebody who knows it)

       Starting with Linux release 2.2 netstat -i does not show interface sta‐
       tistics for alias interfaces. To get per alias interface  counters  you
       need to setup explicit rules using the ipchains(8) command.

       /etc/services -- The services translation file

       /proc  --  Mount  point  for the proc filesystem, which gives access to
       kernel status information via the following files.

       /proc/net/dev -- device information

       /proc/net/raw -- raw socket information

       /proc/net/tcp -- TCP socket information

       /proc/net/udp -- UDP socket information

       /proc/net/igmp -- IGMP multicast information

       /proc/net/unix -- Unix domain socket information

       /proc/net/ipx -- IPX socket information

       /proc/net/ax25 -- AX25 socket information

       /proc/net/appletalk -- DDP (appletalk) socket information

       /proc/net/nr -- NET/ROM socket information

       /proc/net/route -- IP routing information

       /proc/net/ax25_route -- AX25 routing information

       /proc/net/ipx_route -- IPX routing information

       /proc/net/nr_nodes -- NET/ROM nodelist

       /proc/net/nr_neigh -- NET/ROM neighbours

       /proc/net/ip_masquerade -- masqueraded connections

       /proc/net/snmp -- statistics

       route(8), ifconfig(8), ipchains(8), iptables(8), proc(5)

       Occasionally strange information may appear if a socket changes  as  it
       is viewed. This is unlikely to occur.

       The   netstat   user   interface   was   written   by  Fred  Baumgarten
       <>, the man  page  basically  by  Matt
       Welsh    <>.    It    was   updated   by   Alan   Cox
       <> but could do with a bit more work.  It was updated
       again by Tuan Hoang <>.
       The  man  page  and  the  command  included in the net-tools package is
       totally rewritten by Bernd Eckenfels <>.

net-tools                         2008-11-16                        NETSTAT(8)

Monday, January 16, 2017

Linux Command Line Tutorial For Beginners 37 - grep command

GREP(1)               GREP(1)

       grep,  egrep,  fgrep, zgrep, zegrep, zfgrep, bzgrep, bzegrep, bzfgrep -
       print lines matching a pattern

       grep [options] PATTERN [FILE...]
       grep [options] [-e PATTERN | -f FILE] [FILE...]

       grep searches the named input FILEs (or standard input if no files  are
       named, or the file name - is given) for lines containing a match to the
       given PATTERN.  By default, grep prints the matching lines.

       In addition, two variant programs egrep and fgrep are available.  egrep
       is  the same  as grep -E.  fgrep is the same as grep -F.  zgrep is the
       same as grep -Z.  zegrep is the same as grep -EZ.  zfgrep is  the  same
       as grep -FZ.

       -A NUM, --after-context=NUM
       Print  NUM  lines  of  trailing  context after  matching lines.
       Places  a  line  containing  --  between contiguous  groups  of

       -a, --text
       Process  a binary file as if it were text; this is equivalent to
       the --binary-files=text option.

       -B NUM, --before-context=NUM
       Print NUM  lines of  leading  context  before  matching lines.
       Places  a  line  containing  --  between contiguous  groups  of

       -C NUM, --context=NUM
       Print NUM lines of output context.  Places a line containing  --
       between contiguous groups of matches.

       -b, --byte-offset
       Print  the byte offset within the input file before each line of

       If the first few bytes of a file indicate that the file contains
       binary  data, assume that the file is of type TYPE.  By default,
       TYPE is binary, and grep normally outputs either a one-line mes-
       sage  saying  that a binary file matches, or no message if there
       is no match.  If TYPE is without-match, grep  assumes  that  a
       binary file does not match; this is equivalent to the -I option.
       If TYPE is text, grep processes a binary file  as  if  it  were
       text;  this  is  equivalent  to  the  -a option.  Warning: grep
       --binary-files=text might output binary garbage, which can  have
       nasty side effects if the output is a terminal and if the termi-
       nal driver interprets some of it as commands.

       --colour[=WHEN], --color[=WHEN]
       Surround the matching string with the marker find in  GREP_COLOR
       environment variable. WHEN may be `never', `always', or `auto'

       -c, --count
       Suppress normal output; instead print a count of matching lines
       for each input file.  With the -v,  --invert-match  option  (see
       below), count non-matching lines.

       -D ACTION, --devices=ACTION
       If  an  input  file  is  a device, FIFO or socket, use ACTION to
       process it.  By  default,  ACTION  is  read,  which  means  that
       devices are read just as if they were ordinary files.  If ACTION
       is skip, devices are silently skipped.

       -d ACTION, --directories=ACTION
       If an input file is a directory, use ACTION to process  it.   By
       default, ACTION is read, which means that directories are read
       just as if they were ordinary files.  If ACTION is skip, direc-
       tories  are  silently skipped.  If ACTION is recurse, grep reads
       all files under each directory, recursively; this is  equivalent
       to the -r option.

       -E, --extended-regexp
       Interpret PATTERN as an extended regular expression (see below).

       -e PATTERN, --regexp=PATTERN
       Use PATTERN as the pattern; useful to protect patterns beginning
       with -.

       -F, --fixed-strings
       Interpret  PATTERN as a list of fixed strings, separated by new-
       lines, any of which is to be matched.

       -P, --perl-regexp
       Interpret PATTERN as a Perl regular expression.  This option  is
       not supported in FreeBSD.

       -f FILE, --file=FILE
       Obtain  patterns from  FILE, one per line.  The empty file con-
       tains zero patterns, and therefore matches nothing.

       -G, --basic-regexp
       Interpret PATTERN as a basic  regular  expression  (see  below).
       This is the default.

       -H, --with-filename
       Print the filename for each match.

       -h, --no-filename
       Suppress the  prefixing of  filenames  on output when multiple
       files are searched.

       --help Output a brief help message.

       -I     Process a binary file as if it did not  contain  matching  data;
       this is equivalent to the --binary-files=without-match option.

       -i, --ignore-case
       Ignore  case  distinctions  in  both  the  PATTERN and the input

       -L, --files-without-match
       Suppress normal output; instead print the  name  of  each  input
       file from which no output would normally have been printed.  The
       scanning will stop on the first match.

       -l, --files-with-matches
       Suppress normal output; instead print the  name  of  each  input
       file  from  which  output would normally have been printed.  The
       scanning will stop on the first match.

       -m NUM, --max-count=NUM
       Stop reading a file after NUM matching lines.  If the  input  is
       standard input  from a regular file, and NUM matching lines are
       output, grep ensures that the standard input  is positioned  to
       just  after the last matching line before exiting, regardless of
       the presence of trailing context lines.  This enables a  calling
       process  to resume a search.  When grep stops after NUM matching
       lines, it outputs any trailing context lines.  When  the -c  or
       --count  option  is  also  used, grep  does  not output a count
       greater than NUM.  When the -v or --invert-match option is  also
       used, grep stops after outputting NUM non-matching lines.

       --mmap If  possible, use the mmap(2) system call to read input, instead
       of the default read(2) system call.  In some situations, --mmap
       yields  better performance.  However, --mmap can cause undefined
       behavior (including core dumps) if an input file shrinks  while
       grep is operating, or if an I/O error occurs.

       -n, --line-number
       Prefix each line of output with the line number within its input

       -o, --only-matching
       Show only the part of a matching line that matches PATTERN.

       Displays input actually coming from standard input as input com-
       ing  from  file LABEL.  This is especially useful for tools like
       zgrep, e.g.  gzip -cd foo.gz |grep --label=foo something

       Flush output on every line.  Note that this incurs a performance

       -q, --quiet, --silent
       Quiet;  do  not write anything to standard output.  Exit immedi-
       ately with zero status if any match is found, even if  an  error
       was detected.  Also see the -s or --no-messages option.

       -R, -r, --recursive
       Read all files under each directory, recursively; this is equiv-
       alent to the -d recurse option.

       Recurse in directories only searching file matching PATTERN.

       Recurse in directories skip file matching PATTERN.

       -s, --no-messages
       Suppress error messages about nonexistent or  unreadable files.
       Portability note: unlike GNU grep, traditional grep did not con-
       form to POSIX.2, because traditional grep lacked a -q option and
       its  -s option behaved like GNU grep's -q option.  Shell scripts
       intended to be portable to traditional grep should avoid both -q
       and -s and should redirect output to /dev/null instead.

       -U, --binary
       Treat  the  file(s) as binary.  By default, under MS-DOS and MS-
       Windows, grep guesses the file type by looking at  the  contents
       of  the first 32KB read from the file.  If grep decides the file
       is a text file, it strips the CR characters  from  the  original
       file  contents  (to  make  regular expressions with ^ and $ work
       correctly).  Specifying -U overrules this guesswork, causing all
       files  to be read and passed to the matching mechanism verbatim;
       if the file is a text file with CR/LF pairs at the end  of  each
       line,  this  will  cause some regular expressions to fail.  This
       option has no effect on platforms other than MS-DOS and  MS-Win-

       -u, --unix-byte-offsets
       Report  Unix-style  byte offsets.   This  switch causes grep to
       report byte offsets as if the file were  Unix-style  text  file,
       i.e. with CR characters stripped off.  This will produce results
       identical to running grep on a Unix machine.  This option has no
       effect  unless -b option is also used; it has no effect on plat-
       forms other than MS-DOS and MS-Windows.

       -V, --version
       Print the version number of grep to standard error.   This  ver-
       sion number should be included in all bug reports (see below).

       -v, --invert-match
       Invert the sense of matching, to select non-matching lines.

       -w, --word-regexp
       Select  only  those  lines  containing  matches  that form whole
       words.  The test is that the matching substring must  either  be
       at  the  beginning  of  the line, or preceded by a non-word con-
       stituent character.  Similarly, it must be either at the end  of
       the line or followed by a non-word constituent character.  Word-
       constituent characters are letters, digits, and the  underscore.

       -x, --line-regexp
       Select only those matches that exactly match the whole line.

       -y     Obsolete synonym for -i.

       --null Output  a  zero  byte  (the  ASCII NUL character) instead of the
       character that normally follows a file name.  For example,  grep
       -l  --null  outputs  a zero byte after each file name instead of
       the usual newline.  This option makes  the  output  unambiguous,
       even in the presence of file names containing unusual characters
       like newlines.  This option can be used with commands like  find
       -print0, perl  -0,  sort  -z, and xargs -0 to process arbitrary
       file names, even those that contain newline characters.

       -Z, --decompress
       Decompress the input data before searching.  This option is only
       available if compiled with zlib(3) library.

       -J, --bz2decompress
       Decompress  the bzip2(1) compressed input data before searching.

       A regular expression is a pattern that  describes  a  set  of  strings.
       Regular expressions  are constructed analogously to arithmetic expres-
       sions, by using various operators to combine smaller expressions.

       grep understands two different versions of regular  expression  syntax:
       "basic" and "extended."  In GNU grep, there is no difference in avail-
       able functionality using  either  syntax.   In  other  implementations,
       basic regular expressions are less powerful.  The following description
       applies to extended regular expressions; differences for basic  regular
       expressions are summarized afterwards.

       The  fundamental building blocks are the regular expressions that match
       a single character.  Most characters, including all letters and digits,
       are  regular expressions that match themselves. Any metacharacter with
       special meaning may be quoted by preceding it with a backslash.

       A bracket expression is a list of characters enclosed by [ and  ].   It
       matches any  single  character in that list; if the first character of
       the list is the caret ^ then it matches any character not in the  list.
       For  example,  the  regular  expression [0123456789] matches any single

       Within a bracket expression, a range expression consists of two charac-
       ters separated by a hyphen.  It matches any single character that sorts
       between the two characters, inclusive,  using  the  locale's  collating
       sequence  and  character  set. For  example, in the default C locale,
       [a-d] is equivalent to [abcd].  Many locales sort characters in dictio-
       nary  order,  and in these locales [a-d] is typically not equivalent to
       [abcd]; it might be equivalent to [aBbCcDd], for  example.   To obtain
       the  traditional interpretation of bracket expressions, you can use the
       C locale by setting the LC_ALL environment variable to the value C.

       Finally, certain named classes  of  characters  are  predefined within
       bracket expressions, as follows.  Their names are self explanatory, and
       they  are  [:alnum:],  [:alpha:],  [:blank:],   [:cntrl:],   [:digit:],
       [:graph:],  [:lower:],  [:print:], [:punct:], [:space:], [:upper:], and
       [:xdigit:].  For example, [[:alnum:]]  means  [0-9A-Za-z],  except  the
       latter form depends upon the C locale and the ASCII character encoding,
       whereas the former is independent of locale and character  set.  (Note
       that  the brackets in these class names are part of the symbolic names,
       and must be included in addition to the brackets delimiting the bracket
       list.) Most  metacharacters  lose their special meaning inside lists.
       To include a literal ] place it first  in  the list. Similarly,  to
       include a literal ^ place it anywhere but first.  Finally, to include a
       literal - place it last.

       The period .  matches any single character.  The symbol \w is a synonym
       for [[:alnum:]] and \W is a synonym for [^[:alnum:]].

       The  caret ^ and the dollar sign $ are metacharacters that respectively
       match the empty string at the beginning and end of a line.  The symbols
       \<  and \> respectively match the empty string at the beginning and end
       of a word.  The symbol \b matches the empty string at  the  edge  of  a
       word,  and \B matches the empty string provided it's not at the edge of
       a word.

       A regular expression may be followed by one of several repetition oper-
       ?      The preceding item is optional and matched at most once.
       *      The preceding item will be matched zero or more times.
       +      The preceding item will be matched one or more times.
       {n}    The preceding item is matched exactly n times.
       {n,}   The preceding item is matched n or more times.
       {n,m}  The  preceding  item  is matched at least n times, but not more
       than m times.

       Two regular expressions may  be concatenated;  the  resulting  regular
       expression  matches  any  string formed by concatenating two substrings
       that respectively match the concatenated subexpressions.

       Two regular expressions may be joined by  the  infix  operator  |;  the
       resulting  regular expression matches any string matching either subex-

       Repetition takes precedence over concatenation, which  in  turn  takes
       precedence  over alternation.  A whole subexpression may be enclosed in
       parentheses to override these precedence rules.

       The backreference \n, where n is a single digit, matches the  substring
       previously  matched by the nth parenthesized subexpression of the regu-
       lar expression.

       In basic regular expressions the metacharacters ?, +, {, |,  (, and  )
       lose  their  special  meaning; instead use the backslashed versions \?,
       \+, \{, \|, \(, and \).

       Traditional egrep did not support the { metacharacter, and  some  egrep
       implementations support \{ instead, so portable scripts should avoid {
       in egrep patterns and should use [{] to match a literal {.

       GNU egrep attempts to support traditional usage by assuming that  {  is
       not  special if it would be the start of an invalid interval specifica-
       tion.  For example, the shell command egrep '{1' searches for the  two-
       character  string {1 instead of reporting a syntax error in the regular
       expression.  POSIX.2 allows this behavior as an extension, but portable
       scripts should avoid it.

       Grep's behavior is affected by the following environment variables.

       A  locale  LC_foo is specified by examining the three environment vari-
       ables LC_ALL, LC_foo, LANG, in that order.  The first  of  these  vari-
       ables  that is set specifies the locale.  For example, if LC_ALL is not
       set, but LC_MESSAGES is set to pt_BR, then Brazilian Portuguese is used
       for  the  LC_MESSAGES  locale. The  C locale is used if none of these
       environment variables  are  set,  or  if  the  locale  catalog  is  not
       installed,  or  if grep was not compiled with national language support

       This variable specifies default options to be placed in front of
       any   explicit   options.    For example,  if  GREP_OPTIONS  is
       '--binary-files=without-match --directories=skip', grep  behaves
       as  if the two options --binary-files=without-match and --direc-
       tories=skip had been  specified  before  any  explicit  options.
       Option  specifications are separated by whitespace.  A backslash
       escapes the next character, so it can  be  used  to  specify  an
       option containing whitespace or a backslash.

       Specifies the marker for highlighting.

       These  variables specify the LC_COLLATE locale, which determines
       the collating sequence used to interpret range expressions  like

       These  variables specify  the LC_CTYPE locale, which determines
       the type of characters, e.g., which characters are whitespace.

       These variables specify the LC_MESSAGES locale, which determines
       the  language that grep uses for messages.  The default C locale
       uses American English messages.

       If set,  grep  behaves  as  POSIX.2  requires;  otherwise,  grep
       behaves  more  like  other  GNU programs.  POSIX.2 requires that
       options that follow file names must be treated as file names; by
       default, such  options are permuted to the front of the operand
       list and are treated as options. Also,  POSIX.2 requires  that
       unrecognized  options  be diagnosed as "illegal", but since they
       are not really against the law the default is to diagnose  them
       as "invalid".

       Normally, exit status is 0 if selected lines are found and 1 otherwise.
       But the exit status is 2 if an error occurred, unless the -q or --quiet
       or --silent option is used and a selected line is found.

       Email  bug  reports  to Be sure to include the
       word "grep" somewhere in the "Subject:" field.

       Large repetition counts in the {n,m} construct may cause  grep  to  use
       lots of memory. In addition, certain other obscure regular expressions
       require exponential time and space, and may cause grep to  run  out  of

       Backreferences are very slow, and may require exponential time.

GNU Project     2002/01/22          GREP(1)

Tuesday, January 10, 2017

Linux Command Line Tutorial For Beginners 36 - tar command to Compress a...

TAR(1)                    BSD General Commands Manual                   TAR(1)

     tar — The GNU version of the tar archiving utility

     tar [-] A --catenate --concatenate | c --create | d --diff --compare |
         --delete | r --append | t --list | --test-label | u --update | x
         --extract --get [options] [pathname ...]

     Tar stores and extracts files from a tape or disk archive.

     The first argument to tar should be a function; either one of the letters
     Acdrtux, or one of the long function names.  A function letter need not
     be prefixed with ``-'', and may be combined with other single-letter
     options.  A long function name must be prefixed with --.  Some options
     take a parameter; with the single-letter form these must be given as sep‐
     arate arguments.  With the long form, they may be given by appending
     =value to the option.

     Main operation mode:

     -A, --catenate, --concatenate
           append tar files to an archive

     -c, --create
           create a new archive

     -d, --diff, --compare
           find differences between archive and file system

           delete from the archive (not on mag tapes!)

     -r, --append
           append files to the end of an archive

     -t, --list
           list the contents of an archive

           test the archive volume label and exit

     -u, --update
           only append files newer than copy in archive

     -x, --extract, --get
           extract files from an archive

     Operation modifiers:

           specify drive and density

     -a, --auto-compress
           use archive suffix to determine the compression program

           Enable the POSIX ACLs support

           Disable the POSIX ACLs support

           add given FILE to the archive (useful if its name starts with a

           patterns match file name start

           patterns match after any '/' (default for exclusion)

           preserve access times on dumped files, either by restoring the

           do not use archive suffix to determine the compression program

     -b, --blocking-factor BLOCKS
           BLOCKS x 512 bytes per record

     -B, --read-full-records
           reblock as we read (for 4.2BSD pipes)

           backup before removal, choose version CONTROL

     -C, --directory DIR
           change to directory DIR

           check device numbers when creating incremental archives (default)

           do not check device numbers when creating incremental archives

           display progress messages every NUMBERth record (default 10)

           execute ACTION on each checkpoint

           delay setting modification times and permissions of extracted

           cancel the effect of --delay-directory-restore option

           exclude files, given as a PATTERN

           exclude backup and lock files

           exclude contents of directories containing CACHEDIR.TAG,

           exclude directories containing CACHEDIR.TAG

           exclude everything under directories containing CACHEDIR.TAG

           exclude contents of directories containing FILE, except

           exclude directories containing FILE

           exclude everything under directories containing FILE

           exclude version control system directories

     -f, --file ARCHIVE
           use archive file or device ARCHIVE

     -F, --info-script, --new-volume-script NAME
           run script at end of each tape (implies -M)

           archive file is local even if it has a colon

           print file time to its full resolution

     -g, --listed-incremental FILE
           handle new GNU-format incremental backup

     -G, --incremental
           handle old GNU-format incremental backup

           force NAME as group for added files

     -h, --dereference
           follow symlinks; archive and dump the files they point to

     -H, --format FORMAT
           create archive of the given formatFORMAT is one of the following:

                 GNU tar 1.13.x format

                 GNU format as per tar <= 1.12

                 POSIX 1003.1-2001 (pax) format

                 same as pax

                 POSIX 1003.1-1988 (ustar) format

                 old V7 tar format

           follow hard links; archive and dump the files they refer to

     -i, --ignore-zeros
           ignore zeroed blocks in archive (means EOF)

     -I, --use-compress-program PROG
           filter through PROG (must accept -d)

           ignore case

           case sensitive matching (default)

           ignore exit codes of children

           treat non-zero exit codes of children as error

           do not exit with nonzero on unreadable files

           send verbose output to FILE

     -j, --bzip2

     -J, --xz

     -k, --keep-old-files
           don't replace existing files when extracting,

     -K, --starting-file MEMBER-NAME
           begin at member MEMBER-NAME when reading the archive

           preserve existing symlinks to directories when extracting

           don't replace existing files that are newer than their archive

     -l, --check-links
           print a message if not all links are dumped

     -L, --tape-length NUMBER
           change tape after writing NUMBER x 1024 bytes

           dump level for created listed-incremental archive




     -m, --touch
           don't extract file modified time

     -M, --multi-volume
           create/list/extract multi-volume archive

           force (symbolic) mode CHANGES for added files

           set mtime for added files from DATE-OR-FILE

     -n, --seek
           archive is seekable

     -N, --newer, --after-date DATE-OR-FILE
           only store files newer than DATE-OR-FILE

           compare date and time when data changed only

           -T reads null-terminated names, disable -C

           disable the effect of the previous --null option

           always use numbers for user/group names

     -O, --to-stdout
           extract files to standard output

           process only the NUMBERth occurrence of each file in the archive;

     --old-archive, --portability
           same as --format=v7

           stay in local file system when creating archive

           overwrite existing files when extracting

           overwrite metadata of existing directories when extracting

           preserve metadata of existing directories

           force NAME as owner for added files

     -p, --preserve-permissions, --same-permissions
           extract information about file permissions (default for superuser)

     -P, --absolute-names
           don't strip leading '/'s from file names

           control pax keywords

           same as --format=posix

           same as both -p and -s

           additionally quote characters from STRING

           disable quoting for characters from STRING

           set name quoting style; see below for valid STYLE values

     -R, --block-number
           show block number within archive with each message

           NUMBER of bytes per record, multiple of 512

           recurse into directories (default)

           avoid descending automatically in directories

           empty hierarchies prior to extracting directory

           remove files after adding them to the archive

           disable use of some potentially harmful options

           use given rmt COMMAND instead of rmt

           use remote COMMAND instead of rsh

     -s, --preserve-order, --same-order
           member arguments are listed in the same order as the

     -S, --sparse
           handle sparse files efficiently

           try extracting files with the same ownership as exists in the ar‐
           chive (default for superuser)

           extract files as yourself (default for ordinary users)

           apply the user's umask when extracting permissions from the archive
           (default for ordinary users)

           archive is not seekable

           Enable the SELinux context support

           Disable the SELinux context support

           show tar defaults

           when listing or extracting, list each directory that does not match
           search criteria

           show valid ranges for snapshot-file fields

     --show-transformed-names, --show-stored-names
           show file or archive names after transformation

           don't replace existing files when extracting, silently skip over

           set version of the sparse format to use (implies --sparse)

           strip NUMBER leading components from file names on extraction

           backup before removal, override usual suffix ('~' unless overridden
           by environment variable SIMPLE_BACKUP_SUFFIX)

     -T, --files-from FILE
           get names to extract or create from FILE

           pipe extracted files to another program

           print total bytes after processing the archive;

     --transform, --xform EXPRESSION
           use sed replace EXPRESSION to transform file names

     -U, --unlink-first
           remove each file prior to extracting over it

           unquote filenames read with -T (default)

           do not unquote filenames read with -T

           print file modification times in UTC

     -v, --verbose
           verbosely list files processed

     -V, --label TEXT
           create archive with volume name TEXT; at list/extract time, use
           TEXT as a globbing pattern for volume name

           use/update the volume number in FILE

     -w, --interactive, --confirmation
           ask for confirmation for every action

     -W, --verify
           attempt to verify the archive after writing it

           warning control

           use wildcards (default for exclusion)

           wildcards match '/' (default for exclusion)

           wildcards do not match '/'

           verbatim string matching

     -X, --exclude-from FILE
           exclude patterns listed in FILE

           Enable extended attributes support

           specify the exclude pattern for xattr keys

           specify the include pattern for xattr keys

           Disable extended attributes support

     -z, --gzip, --gunzip --ungzip

     -Z, --compress, --uncompress

     The behavior of tar is controlled by the following environment variables,
     among others:



             Backup prefix to use when extracting, if --suffix is not speci‐
             fied.  The backup suffix defaults to `~' if neither is specified.

             Options to prepend to those specified on the command line, sepa‐
             rated by whitespace.  Embedded backslashes may be used to escape
             whitespace or backslashes within an option.

     TAPE    Device or file to use for the archive if --file is not specified.
             If this environment variable is unset, use stdin or stdout

     Create archive.tar from files foo and bar.
           tar -cf archive.tar foo bar
     List all files in archive.tar verbosely.
           tar -tvf archive.tar
     Extract all files from archive.tar.
           tar -xf archive.tar

     tar(5), symlink(7), rmt(8)

     The tar command appeared in Version 7 AT&T UNIX.

     The GNU folks, in general, abhor man pages, and create info documents
     instead.  Unfortunately, the info document describing tar is licensed
     under the GFDL with invariant cover texts, which makes it impossible to
     include any text from that document in this man page.  Most of the text
     in this document was automatically extracted from the usage text in the
     source.  It may not completely describe all features of the program.

                                  Feb 4, 2014

Wednesday, January 4, 2017

Linux Command Line Tutorial For Beginners 32 - date command

DATE(1)                        User Commands                       DATE(1)

       date - print or set the system date and time

       date [OPTION]... [+FORMAT]
       date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]

       Display  the  current  time  in the given FORMAT, or set the system

       Mandatory arguments to long options are mandatory for short options

       -d, --date=STRING
              display time described by STRING, not 'now'

       -f, --file=DATEFILE
              like --date once for each line of DATEFILE

       -I[TIMESPEC], --iso-8601[=TIMESPEC]
              output  date/time  in  ISO 8601 format.  TIMESPEC='date' for
              date only (the default), 'hours', 'minutes',  'seconds',  or
              'ns' for date and time to the indicated precision.

       -r, --reference=FILE
              display the last modification time of FILE

       -R, --rfc-2822
              output  date  and time in RFC 2822 format.  Example: Mon, 07
              Aug 2006 12:34:56 -0600

              output date and time in RFC 3339  format.   TIMESPEC='date',
              'seconds', or 'ns' for date and time to the indicated preci‐
              sion.  Date and time components are separated  by  a  single
              space: 2006-08-07 12:34:56-06:00

       -s, --set=STRING
              set time described by STRING

       -u, --utc, --universal
              print or set Coordinated Universal Time

       --help display this help and exit

              output version information and exit

       FORMAT controls the output.  Interpreted sequences are:

       %%     a literal %

       %a     locale's abbreviated weekday name (e.g., Sun)

       %A     locale's full weekday name (e.g., Sunday)

       %b     locale's abbreviated month name (e.g., Jan)

       %B     locale's full month name (e.g., January)

       %c     locale's date and time (e.g., Thu Mar  3 23:05:25 2005)

       %C     century; like %Y, except omit last two digits (e.g., 20)

       %d     day of month (e.g., 01)

       %D     date; same as %m/%d/%y

       %e     day of month, space padded; same as %_d

       %F     full date; same as %Y-%m-%d

       %g     last two digits of year of ISO week number (see %G)

       %G     year  of ISO week number (see %V); normally useful only with

       %h     same as %b

       %H     hour (00..23)

       %I     hour (01..12)

       %j     day of year (001..366)

       %k     hour, space padded ( 0..23); same as %_H

       %l     hour, space padded ( 1..12); same as %_I

       %m     month (01..12)

       %M     minute (00..59)

       %n     a newline

       %N     nanoseconds (000000000..999999999)

       %p     locale's equivalent of either AM or PM; blank if not known

       %P     like %p, but lower case

       %r     locale's 12-hour clock time (e.g., 11:11:04 PM)

       %R     24-hour hour and minute; same as %H:%M

       %s     seconds since 1970-01-01 00:00:00 UTC

       %S     second (00..60)

       %t     a tab

       %T     time; same as %H:%M:%S

       %u     day of week (1..7); 1 is Monday

       %U     week number of year,  with  Sunday  as  first  day  of  week

       %V     ISO week number, with Monday as first day of week (01..53)

       %w     day of week (0..6); 0 is Sunday

       %W     week  number  of  year,  with  Monday  as  first day of week

       %x     locale's date representation (e.g., 12/31/99)

       %X     locale's time representation (e.g., 23:13:48)

       %y     last two digits of year (00..99)

       %Y     year

       %z     +hhmm numeric time zone (e.g., -0400)

       %:z    +hh:mm numeric time zone (e.g., -04:00)

       %::z   +hh:mm:ss numeric time zone (e.g., -04:00:00)

       %:::z  numeric time zone with : to necessary precision (e.g.,  -04,

       %Z     alphabetic time zone abbreviation (e.g., EDT)

       By  default,  date  pads numeric fields with zeroes.  The following
       optional flags may follow '%':

       -      (hyphen) do not pad the field

       _      (underscore) pad with spaces

       0      (zero) pad with zeros

       ^      use upper case if possible

       #      use opposite case if possible

       After any flags comes an optional field width, as a decimal number;
       then  an  optional  modifier, which is either E to use the locale's
       alternate representations if available, or O to  use  the  locale's
       alternate numeric symbols if available.

       Convert seconds since the epoch (1970-01-01 UTC) to a date

              $ date --date='@2147483647'

       Show  the time on the west coast of the US (use tzselect(1) to find

              $ TZ='America/Los_Angeles' date

       Show the local time for 9AM next Friday on the west coast of the US

              $ date --date='TZ="America/Los_Angeles" 09:00 next Fri'

       The --date=STRING is a  mostly  free  format  human  readable  date
       string  such  as  "Sun,  29 Feb 2004 16:21:42 -0800" or "2004-02-29
       16:21:42" or even "next Thursday".  A date string may contain items
       indicating calendar date, time of day, time zone, day of week, rel‐
       ative time, relative date, and numbers.  An empty string  indicates
       the  beginning  of the day.  The date string format is more complex
       than is easily documented here but is fully described in  the  info

       Written by David MacKenzie.

       Report date bugs to
       GNU coreutils home page: <>
       General help using GNU software: <>
       Report    date    translation   bugs   to   <http://translationpro‐>

       Copyright © 2013 Free Software Foundation,  Inc.   License  GPLv3+:
       GNU GPL version 3 or later <>.
       This  is free software: you are free to change and redistribute it.
       There is NO WARRANTY, to the extent permitted by law.

       The full documentation for date is maintained as a Texinfo  manual.
       If  the info and date programs are properly installed at your site,
       the command

              info coreutils 'date invocation'

       should give you access to the complete manual.

GNU coreutils 8.21              March 2014                         DATE(1)

Linux Command Line Tutorial For Beginners 31 - cal command

CAL(1)                  BSD General Commands Manual                 CAL(1)

     cal, ncal — displays a calendar and the date of Easter

     cal [-3hjy] [-A number] [-B number] [[month] year]
     cal [-3hj] [-A number] [-B number] -m month [year]
     ncal [-3bhjJpwySM] [-A number] [-B number] [-s country_code] [[month]
     ncal [-3bhJeoSM] [-A number] [-B number] [year]
     ncal [-CN] [-H yyyy-mm-dd] [-d yyyy-mm]

     The cal utility displays a simple calendar in traditional format and
     ncal offers an alternative layout, more options and the date of
     Easter.  The new format is a little cramped but it makes a year fit
     on a 25x80 terminal.  If arguments are not specified, the current
     month is displayed.

     The options are as follows:

     -h      Turns off highlighting of today.

     -J      Display Julian Calendar, if combined with the -o option, dis‐
             play date of Orthodox Easter according to the Julian Calen‐

     -e      Display date of Easter (for western churches).

     -j      Display Julian days (days one-based, numbered from January

     -m month
             Display the specified month.  If month is specified as a dec‐
             imal number, it may be followed by the letter ‘f’ or ‘p’ to
             indicate the following or preceding month of that number,

     -o      Display date of Orthodox Easter (Greek and Russian Orthodox

     -p      Print the country codes and switching days from Julian to
             Gregorian Calendar as they are assumed by ncal.  The country
             code as determined from the local environment is marked with
             an asterisk.

     -s country_code
             Assume the switch from Julian to Gregorian Calendar at the
             date associated with the country_code.  If not specified,
             ncal tries to guess the switch date from the local environ‐
             ment or falls back to September 2, 1752.  This was when Great
             Britain and her colonies switched to the Gregorian Calendar.

     -w      Print the number of the week below each week column.

     -y      Display a calendar for the specified year. This option is
             implied when a year but no month are specified on the command

     -3      Display the previous, current and next month surrounding

     -1      Display only the current month. This is the default.

     -A number
             Months to add after. The specified number of months is added
             to the end of the display. This is in addition to any date
             range selected by the -y, -3, or -1 options. For example,
             “cal -y -B2 -A2” shows everything from November of the previ‐
             ous year to February of the following year. Negative numbers
             are allowed, in which case the specified number of months is
             subtracted. For example, “cal -y -B-6” shows July to Decem‐
             ber. And “cal -A11” simply shows the next 12 months.

     -B number
             Months to add before. The specified number of months is added
             to the beginning of the display. See -A for examples.

     -C      Switch to cal mode.

     -N      Switch to ncal mode.

     -d yyyy-mm
             Use yyyy-mm as the current date (for debugging of date selec‐

     -H yyyy-mm-dd
             Use yyyy-mm-dd as the current date (for debugging of high‐

     -M      Weeks start on Monday.

     -S      Weeks start on Sunday.

     -b      Use oldstyle format for ncal output.

     A single parameter specifies the year (1–9999) to be displayed; note
     the year must be fully specified: “cal 89” will not display a calen‐
     dar for 1989.  Two parameters denote the month and year; the month is
     either a number between 1 and 12, or a full or abbreviated name as
     specified by the current locale.  Month and year default to those of
     the current system clock and time zone (so “cal -m 8” will display a
     calendar for the month of August in the current year).

     Not all options can be used together. For example, the options -y,
     -3, and -1 are mutually exclusive. If inconsistent options are given,
     the later ones take precedence over the earlier ones.

     A year starts on January 1.

     calendar(3), strftime(3)

     A cal command appeared in Version 5 AT&T UNIX.  The ncal command
     appeared in FreeBSD 2.2.6.  The output of the cal command is supposed
     to be bit for bit compatible to the original Unix cal command,
     because its output is processed by other programs like CGI scripts,
     that should not be broken. Therefore it will always output 8 lines,
     even if only 7 contain data. This extra blank line also appears with
     the original cal command, at least on Solaris 8

     The ncal command and manual were written by Wolfgang Helbig

     The assignment of Julian–Gregorian switching dates to country codes
     is historically naive for many countries.

     Not all options are compatible and using them in different orders
     will give varying results.

BSD                           March 14, 2009                           BSD