ult/Using_Linux_Tools.rst
author amit@thunder
Mon, 12 Jul 2010 15:27:21 +0530
changeset 98 678c7c01b5d5
parent 74 7dbeae0fac70
child 121 caf2b538fa0a
permissions -rw-r--r--
changes to Intorduction to Linux and Text Processing in ULT
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
     1
Introducing Linux
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
     2
=================
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
     3
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
     4
We are here to welcome you to Linux. GNU/Linux is an operating system that is similar to the UNIX operating system, but is open source software. Being an open source program means that (if you wanted to) you could view the source code of the operating system and change it to suit your needs. 
25
4df1ca9766b8 Introduction, added session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents:
diff changeset
     5
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
     6
The name "Linux" properly refers to an operating system "kernel", a single but key component of a complete operating system. In everyday use, the term "Linux" is frequently used to refer to a complete operating system which consists of the kernel and some of the thousands of other programs required to make an operating system useful. Much of the important system software that is typically installed on a Linux system comes from The GNU Project, a project to build an operating system made entirely of free software.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
     7
The first Linux kernel was created by Linus Torvalds. It was started as an x86-only, single processor operating system, but grew to become one of the most ported pieces of software. Other parts of a complete GNU/Linux system come from other projects such as the GNU project, and are integrated into a complete GNU/Linux OS by your supplier. Usually your supplier will assign their own version number to the integrated whole.This collection of the kernal and programs maintained by vendor is called distro or distribution.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
     8
The GNU Project is overseen by the Free Software Foundation. The Free Software Foundation was founded by Richard Stallman. Stallman believes that the people should use the term "GNU/Linux" to refer to such an operating system, because so many of the required programs were in fact, written as part of the GNU Project.
25
4df1ca9766b8 Introduction, added session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents:
diff changeset
     9
4df1ca9766b8 Introduction, added session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents:
diff changeset
    10
4df1ca9766b8 Introduction, added session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents:
diff changeset
    11
4df1ca9766b8 Introduction, added session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents:
diff changeset
    12
Design and Implications
4df1ca9766b8 Introduction, added session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents:
diff changeset
    13
------------------------
4df1ca9766b8 Introduction, added session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents:
diff changeset
    14
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
    15
A Linux-based system is a modular Unix-like operating system, deriving much of its basic design from principles established in Unix earlier. Such a system uses a monolithic kernel, called the Linux kernel, which handles process control, networking, and peripheral and file system access. Device drivers are integrated directly with the kernel. Separate projects that interface with the kernel provide much of the system's higher-level functionality. The GNU userland is an important part of most Linux-based systems, providing the most common implementation of the C library, a popular shell, and many of the common Unix tools which carry out many basic operating system tasks. The graphical user interface (or GUI) used by most Linux systems is based on the "X Window System".
25
4df1ca9766b8 Introduction, added session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents:
diff changeset
    16
4df1ca9766b8 Introduction, added session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents:
diff changeset
    17
4df1ca9766b8 Introduction, added session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents:
diff changeset
    18
4df1ca9766b8 Introduction, added session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents:
diff changeset
    19
4df1ca9766b8 Introduction, added session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents:
diff changeset
    20
4df1ca9766b8 Introduction, added session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents:
diff changeset
    21
Reasons for Using Linux
4df1ca9766b8 Introduction, added session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents:
diff changeset
    22
-----------------------
27
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    23
- Linux is free:
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    24
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
    25
As in "free beer". Linux can be downloaded in its entirety from the Internet completely for free. No registration fees, no costs per user, free updates, and freely available source code in case you want to change the behavior of your system.
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
    26
Most of all, Linux is free as in "free speech":
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
    27
27
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    28
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    29
- Linux is portable to any hardware platform:
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    30
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
    31
A vendor, who wants to sell a new type of computer and who does not know what kind of OS his/her new machine will run, can take a Linux kernel and make it work on his/her hardware, because documentation related to this activity is freely available.
27
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    32
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    33
- Linux was made to keep on running:
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    34
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
    35
As with UNIX, a Linux system expects to run without rebooting all the time. That is why a lot of tasks are being executed at night or scheduled automatically for other times, resulting in higher availability during busier periods and a more balanced use of the hardware. This property allows for Linux to be applicable to environments where people do not have the time or the possibility to control their systems constantly.
27
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    36
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    37
- Linux is secure and versatile:
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    38
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
    39
The security model used in Linux is based on the UNIX idea of security, which is known to be robust and of proven quality. But Linux is not only safe from attacks from the Internet: it will adapt equally to other situations, utilizing the same high standards for security.
25
4df1ca9766b8 Introduction, added session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents:
diff changeset
    40
27
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    41
- Linux is scalable:
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    42
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
    43
From a Palmtop with 2 MB of memory to a petabyte storage cluster with hundreds of nodes: add or remove the appropriate packages and Linux fits all. 
27
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    44
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    45
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    46
44
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    47
Getting Started
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    48
================
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    49
27
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    50
Logging in, activating the user interface and logging out
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    51
----------------------------------------------------------
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
    52
In order to work on a Linux system directly, one needs to provide a user name and password. You always need to authenticate to the system. Most PC−based Linux systems have two basic modes for a system to run in: either quick and clean in text console mode,which includes with mouse, multitasking and multi−user features, or in graphical console mode.
27
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    53
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    54
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    55
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    56
When you see the login screen again, asking to enter user name and password, logout was successful.
fe0672fd1be4 Introduction, midway session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents: 25
diff changeset
    57
25
4df1ca9766b8 Introduction, added session 1.
Kadambari Devarajan <kadambarid@fossee.in>
parents:
diff changeset
    58
44
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    59
Basic Commands
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    60
===============
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    61
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
    62
ls
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
    63
---
44
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    64
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
    65
*ls* lists the files in the current working directory. A directory that is not the current working directory can be specified and ls will list the files there.::
44
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    66
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    67
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    68
	$ ls
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    69
	jeeves.rst psmith.html blandings.html
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
    70
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
    71
cd
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
    72
---
44
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    73
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
    74
This stands for "change directory". When one wants to change the directory .
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
    75
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
    76
       $cd Music 
44
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    77
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    78
One dot '.' represents the current directory while two dots '..' represent the parent directory.
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    79
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    80
“ cd -” will return you to the previous directory (a bit like an “undo”).
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    81
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    82
You can also use cd absolute path or cd relative path (see below):
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    83
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
    84
Absolute paths:
44
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    85
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    86
    An “ absolute path” is easily recognised from the leading forward slash, /. The / means that you start at the top level directory and continue down.
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    87
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    88
For example to get to /boot/grub you would type::
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    89
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    90
	$cd /boot/grub
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    91
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    92
This is an absolute path because you start at the top of the hierarchy and go downwards from there (it doesn't matter where in the filesystem you were when you typed the command).
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    93
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
    94
Relative paths:
44
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    95
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    96
    A “ relative path” doesn't have a preceding slash. Use a relative path when you start from a directory below the top level directory structure. This is dependent on where you are in the filesystem.
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    97
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    98
    For example if you are in root's home directory and want to get to /root/music, you type::
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
    99
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
   100
	$ cd music
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
   101
6a9f6526b4f4 Added few basic commands
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 27
diff changeset
   102
Please note that there is no / using the above cd command. Using a / would cause this to be an absolute path, working from the top of the hierarchy downward.
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   103
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   104
who
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   105
----
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   106
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   107
The standard Unix command *who* displays a list of users who are currently logged into a computer.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   108
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   109
The *who* command is related to the command *w*, which provides the same information but also displays additional data and statistics.::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   110
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   111
	$who
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   112
	beeblebrox tty7         2009-09-08 10:50 (:0)
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   113
	beeblebrox pts/0        2009-09-08 11:25 (:0.0)
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   114
	dumbledore pts/1        2009-09-08 18:11 (potter.xyz.in)
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   115
	beeblebrox pts/2        2009-09-08 18:53 (:0.0)
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   116
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   117
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   118
The command can be invoked with the arguments *am i* or *am I* (so it is invoked as *who am i* or * who am I*), showing information about the current terminal only (see the *-m* option below, of which this invocation is equivalent).
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   119
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   120
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   121
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   122
mkdir
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   123
-----
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   124
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   125
This command is used to make a new directory. Normal usage is as straightforward as follows::
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   126
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   127
	$mkdir name_of_directory
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   128
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   129
Where *name_of_directory* is the name of the directory one wants to create. When typed as above (ie. normal usage), the new directory would be created within the current directory. On Unix, multiple directories can be specified, and *mkdir* will try to create all of them.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   130
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   131
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   132
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   133
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   134
pwd
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   135
----
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   136
pwd is a Linux / Unix command which prints the current working directory. If you wish to know the full path of the  directory in which you are in from the Linux console, then the pwd command will come to your rescue. pwd stands for Print Working Directory.
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   137
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   138
pwd have one option called -P, which lists the current working directory with all the links resolved.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   139
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   140
Usage of pwd command
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   141
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   142
I have a directory called "Examples/" on my machine which is actually a soft link to the directory /usr/share/example-content/. 
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   143
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   144
I move into the "Examples" directory and run the pwd command to get the following output.
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   145
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   146
$ cd Examples
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   147
$ pwd
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   148
/home/laf/Examples
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   149
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   150
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   151
FLAGS
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   152
~~~~~
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   153
The standard commands in Linux have a lot of options also called flags to change or provide some additional functionality to the command For example ::
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   154
      
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   155
       $ls -l 
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   156
       
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   157
       * *ls with flag -l* displays the result in long format, displaying Unix file types, permissions, number of hard links, owner, group, size, date, and filename
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   158
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   159
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   160
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   161
Getting Help
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   162
============
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   163
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   164
apropos and whatis
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   165
-------------------
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   166
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   167
This is a command to search the manual pages files in Unix and Unix-like operating systems. ::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   168
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   169
	$ apropos grep
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   170
	egrep       egrep (1)       Search a file for a pattern using full regular expressions
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   171
	fgrep       fgrep (1)       Search a file for a fixed-character	string
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   172
	fmlgrep     fmlgrep (1)     Search a file for a pattern
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   173
	grep        grep (1)        Search a file for a pattern
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   174
	gzgrep      gzgrep (1)      Search a possibly compressed file for a regular expression
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   175
	nisgrep     nismatch (1)    Utilities for searching NIS+ tables
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   176
	pgrep       pgrep (1)       Find or signal a process by name or other attribute
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   177
	zgrep       zgrep (1)       Search a possibly compressed file for a regular expression
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   178
	...
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   179
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   180
In this example, the user uses *apropos* to search for the string "grep", and apropos returns the indicated *man* pages that include the term "grep".
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   181
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   182
A short index of explanations for commands is available using the *whatis* command, like in the examples below::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   183
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   184
	$whatis ls
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   185
	ls (1) 		 - list directory contents
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   186
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   187
This displays short information about a command, and the first section in the collection of man pages that contains an appropriate page.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   188
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   189
If you don't know where to get started and which man page to read, *apropos* gives more information. Say that you do not know how to start a browser, then you could enter the following command::
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   190
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   191
	$apropos browser
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   192
	gmusicbrowser (1)    - Jukebox for large collections of audio files
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   193
	infobrowser (1)      - read Info documents
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   194
	libsmbclient (7)     - An extension library for browsers and that 		can be used...
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   195
	opera (1)            - a standards-compliant graphical Web browser
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   196
	sensible-browser (1) - sensible editing, paging, and web browsing
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   197
	smbtree (1)          - A text based smb network browser
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   198
	tvtk_doc (1)         - A GUI based TVTK documentation search browser.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   199
	viewres (1)          - graphical class browser for Xt
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   200
	w3m (1)              - a text based Web browser and pager
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   201
	www-browser (1)      - a text based Web browser and pager
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   202
	...
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   203
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   204
man
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   205
----
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   206
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   207
Man pages (short for "manual pages") are the extensive documentation that comes preinstalled with almost all substantial Unix and Unix-like operating systems. The Unix command used to display them is *man*. Each page is a self-contained document.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   208
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   209
To read a manual page for a Unix command, one can use::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   210
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   211
	$ man <command_name>
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   212
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   213
at a shell prompt; for example, "man ftp". In order to simplify navigation through the output, *man* generally uses the less terminal pager.
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   214
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   215
To see the manual on man itself do::
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   216
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   217
	$man man
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   218
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   219
The previous example will take you to the "Manual" page entry about manual pages!
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   220
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   221
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   222
info
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   223
-----
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   224
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   225
*info* is a software utility which forms a hypertextual, multipage documentation and help viewer working on a command line interface, useful when there is no GUI available.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   226
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   227
The syntax is ::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   228
	
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   229
	$ info <command_name>
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   230
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   231
*info* processes info files, which are Texinfo formatted files, and presents the documentation as a tree, with simple commands to traverse the tree and to follow cross references. For instance
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   232
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   233
    - *n* goes to the next page.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   234
    - *p* goes to the previous page.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   235
    - *u* goes to the upper page.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   236
    - *l* goes to the last(visited) node
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   237
    - To follow a cross reference, the cursor can be moved over a link (a word preceded by a `*`) and enter pressed.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   238
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   239
info was initially written for use with GNU/Linux and then ported to other Unix-like operating systems.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   240
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   241
--help
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   242
-------
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   243
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   244
Most GNU commands support the --help, which gives a short explanation about how to use the command and a list of available options. Below is the output of this option with the *cat* command::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   245
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   246
	$ userprompt@host: cat --help
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   247
	Usage: cat [OPTION] [FILE]...
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   248
	Concatenate FILE(s), or standard input, to standard output.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   249
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   250
	  -A, --show-all           equivalent to -vET
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   251
	  -b, --number-nonblank    number nonempty output lines
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   252
	  -e                       equivalent to -vE
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   253
	  -E, --show-ends          display $ at end of each line
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   254
	  -n, --number             number all output lines
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   255
	  -s, --squeeze-blank      suppress repeated empty output lines
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   256
	  -t                       equivalent to -vT
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   257
	  -T, --show-tabs          display TAB characters as ^I
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   258
	  -u                       (ignored)
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   259
	  -v, --show-nonprinting   use ^ and M- notation, except for LFD and 		  TAB
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   260
	  --help     display this help and exit
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   261
      	  --version  output version information and exit
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   262
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   263
	With no FILE, or when FILE is -, read standard input.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   264
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   265
	Examples:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   266
	  cat f - g  Output f's contents, then standard input, then g's 	  contents.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   267
	  cat        Copy standard input to standard output.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   268
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   269
	Report bugs to <bug-coreutils@gnu.org>.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   270
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   271
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   272
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   273
Basic file handling
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   274
===================
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   275
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   276
cp
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   277
---
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   278
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   279
*cp* is the command entered in a Unix shell to copy a file from one place to another, possibly on a different filesystem. The original file remains unchanged, and the new file may have the same or a different name.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   280
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   281
Usage
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   282
~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   283
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   284
To copy a file to another file::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   285
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   286
	$ cp  SourceFile TargetFile
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   287
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   288
To copy a file to a directory::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   289
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   290
	$ cp  SourceFile  TargetDirectory
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   291
 
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   292
To copy a directory to a directory::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   293
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   294
	$ cp  -r SourceDirectory  TargetDirectory
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   295
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   296
Flags
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   297
~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   298
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   299
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   300
*-P* – makes the cp command copy symbolic links. The default is to follow symbolic links, that is, to copy files to which symbolic links point.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   301
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   302
*-i* (interactive) – prompts you with the name of a file to be overwritten. This occurs if the TargetDirectory or TargetFile parameter contains a file with the same name as a file specified in the SourceFile or SourceDirectory parameter. If you enter y or the locale's equivalent of y, the cp command continues. Any other answer prevents the cp command from overwriting the file.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   303
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   304
*-p* (preserve) – duplicates the following characteristics of each SourceFile/SourceDirectory in the corresponding TargetFile and/or TargetDirectory:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   305
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   306
    * The time of the last data modification and the time of the last access.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   307
    * The user ID and group ID (only if it has permissions to do this)
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   308
    * The file permission bits and the SUID and SGID bits.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   309
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   310
*-R* (recursive) – copy directories (recursively copying all the contents)
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   311
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   312
Examples
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   313
~~~~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   314
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   315
To make a copy of a file in the current directory, enter::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   316
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   317
    $ cp prog.c prog.bak
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   318
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   319
This copies prog.c to prog.bak. If the prog.bak file does not already exist, the cp command creates it. If it does exist, the cp command replaces it with a copy of the prog.c file.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   320
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   321
To copy a file in your current directory into another directory, enter::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   322
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   323
    $ cp zaphod /home/books/hhgg
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   324
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   325
This copies the jones file to /home/books/hhgg/zaphod.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   326
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   327
To copy a file to a new file and preserve the modification date, time, and access control list associated with the source file, enter::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   328
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   329
    $ cp -p martin_luther_king martin_luther_king.jr
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   330
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   331
This copies the *martin_luther_king* file to the *martin_luther_king.jr* file. Instead of creating the file with the current date and time stamp, the system gives the *martin_luther_king.jr* file the same date and time as the *martin_luther_king* file. The *martin_luther_king.jr* file also inherits the *martin_luther_king* file's access control protection.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   332
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   333
To copy all the files in a directory to a new directory, enter::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   334
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   335
    $ cp /home/galactica/clients/* /home/hhgg/customers
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   336
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   337
This copies only the files in the clients directory to the customers directory.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   338
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   339
To copy a directory, including all its files and subdirectories, to another directory, enter:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   340
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   341
    $ cp -R /home/hhgg/clients /home/hhgg/customers
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   342
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   343
This copies the clients directory, including all its files, subdirectories, and the files in those subdirectories, to the customers/clients directory.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   344
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   345
To copy a specific set of files of any extension to another directory, enter::
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   346
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   347
    $ cp zaphod arthur ford /home/hhgg/clients
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   348
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   349
This copies the *zaphod*, *arthur*, and *ford* files in your current working directory to the /home/hhgg/clients directory.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   350
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   351
To use pattern-matching characters to copy files, enter::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   352
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   353
    $ cp programs/*.py .
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   354
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   355
This copies the files in the programs directory that end with *.py* to the current directory, signified by the single "." (dot). You must type a space between the *py* and the final dot.
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   356
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   357
mv
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   358
---
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   359
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   360
*mv* (short for move) is a Unix command that moves one or more files or directories from one place to another. The original file is deleted, and the new file may have the same or a different name. If possible (i.e. when the original and new files are on the same file system), *mv* will rename the file instead. Write permission is required on all directories being modified.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   361
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   362
Conflicting existing file
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   363
~~~~~~~~~~~~~~~~~~~~~~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   364
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   365
In all cases, when a file is moved to have the name of an existing file (in the same directory), the existing file is deleted. If the existing file is not writable but is in a directory that is writable, then the mv command asks for confirmation if possible (i.e. if run from a terminal) before proceeding, unless the -f (force) option is used.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   366
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   367
Differences with copy and delete
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   368
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   369
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   370
Note that, usually, when moving files within the same volume, moving (and/or renaming) is not the same as simply copying and then deleting the original. When moving a file, the link is simply removed from the old parent directory and added to the new parent directory. However, the file itself is untouched (i.e. it has the same inodes and resides at the same place on the disk). For example, you cannot copy a file you cannot read, but you can move (and/or rename) it (provided you have write permission to its old and new parent directories). Also, suppose there is a non-empty directory you do not have write permission to. You cannot delete this directory (since you cannot delete its contents); but you can move (and/or rename) it. Also, since moving between filenames on a single volume does not involve copying, it is faster and does not place strain of lots of reads and writes on the disk. Moving files across different volumes, however, does necessitate copying and deleting.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   371
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   372
Examples
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   373
~~~~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   374
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   375
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   376
	$ mv myfile mynewfilename    renames a file
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   377
	$ mv myfile /myfile          moves 'myfile' from the current 		directory to the root directory
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   378
	$ mv myfile dir/myfile       moves 'myfile' to 'dir/myfile' relative 		to the current directory
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   379
	$ mv myfile dir              same as the previous command (the 		filename is implied to be the same)
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   380
	$ mv myfile dir/myfile2      moves 'myfile' to dir and renames it to 		'myfile2'
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   381
	$ mv foo bar baz dir         moves multiple files to directory dir
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   382
	$ mv --help                  shows a very concise help about the 		syntax of the command
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   383
	$ man mv                     prints an extensive user manual for 		'mv' in the terminal
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   384
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   385
In all cases, the file or files being moved or renamed can be a directory.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   386
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   387
Note that when the command is called with two arguments (as *mv name1 name2* or *mv name1 /dir/name2*), it can have three different effects, depending on whether *name2* does not exist, is an existing file, or is an existing directory. If the user intends to refer to an existing directory, */.* (or in some Unix versions */* is sufficient) may be appended to the name to force the system to check this. To move a file to a new directory, the directory must be created first.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   388
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   389
rm
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   390
---
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   391
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   392
*rm* (short for "remove") is one of several basic Unix command lines that operates on files. It is used to delete files from a filesystem. The data is not actually destroyed. Only the index listing where the file is stored is destroyed, and the storage is made available for reuse. There are undelete utilities that will attempt to reconstruct the index and can bring the file back if the parts were not reused.
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   393
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   394
Here's example to remove a file named "foo" from a directory, here shown with the -i option::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   395
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   396
  	$ rm -i foo
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   397
    	remove foo? y
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   398
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   399
Options
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   400
~~~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   401
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   402
Common options that rm accepts include:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   403
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   404
    * *-r*, which removes directories, removing the contents recursively beforehand (so as not to leave files without a directory to reside in) ("recursive")
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   405
    * *-i*, which asks for every deletion to be confirmed ("interactive")
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   406
    * *-f*, which ignores non-existent files and overrides any confirmation prompts ("force")
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   407
    * *-v*, which shows what is being removed as it happens ("verbose")
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   408
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   409
*rm* is often aliased to "rm -i" so as to avoid accidental deletion of files. If a user still wishes to delete a large number of files without confirmation, they can manually cancel out the -i argument by adding the -f option (as the option specified later on the expanded command line "rm -i -f" takes precedence).
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   410
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   411
*rm -rf* (variously, rm -rf /, rm -rf `*`, and others) is frequently used in jokes and anecdotes about Unix disasters. The rm -rf variant of the command, if run by a superuser on the root directory, would cause the contents of every writable mounted filesystem on the computer to be deleted.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   412
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   413
*rm* is often used in conjunction with xargs to supply a list of files to delete::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   414
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   415
	xargs rm < filelist
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   416
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   417
When *rm* is used on a symbolic link, it deletes the link, but does not affect the target of the link.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   418
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   419
Permissions
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   420
~~~~~~~~~~~
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   421
Linux is a proper multi-user environment. In a multi-user environment, security of user and system data is very important. Access should be given only to users who need to access the data. Since Linux is essentially a server OS, good and efficient file security is built right . The permissions are based on whether one is allowed to read, write or execute a file.
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   422
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   423
Usually, on most filesystems, deleting a file requires write permission on the parent directory (and execute permission, in order to enter the directory in the first place). (Note that, confusingly for beginners, permissions on the file itself are irrelevant. However, GNU rm asks for confirmation if a write-protected file is to be deleted, unless the -f option is used.)
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   424
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   425
To delete a directory (with rm -r), one must delete all of its contents recursively. This requires that one must have read and write and execute permission to that directory (if it's not empty) and all non-empty subdirectories recursively (if there are any).
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   426
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   427
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   428
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   429
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   430
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   431
Basic Text Processing
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   432
======================
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   433
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   434
head
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   435
-----
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   436
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   437
*head* is a program on Unix and Unix-like systems used to display the first few lines of a text file or piped data. The command syntax is::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   438
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   439
	$ head [options] <file_name>
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   440
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   441
By default, *head* will print the first 10 lines of its input to the standard output. The number of lines printed may be changed with a command line option. The following example shows the first 20 lines of filename::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   442
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   443
	$ head -n 20 filename
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   444
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   445
This displays the first 5 lines of all files starting with *foo*::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   446
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   447
	$ head -n 5 foo*
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   448
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   449
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   450
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   451
Flags
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   452
~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   453
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   454
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   455
	-c <x number of bytes> Copy first x number of bytes.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   456
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   457
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   458
tail
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   459
----
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   460
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   461
*tail* is a program on Unix and Unix-like systems used to display the last few lines of a text file or piped data.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   462
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   463
The command-syntax is::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   464
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   465
	$ tail [options] <file_name>
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   466
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   467
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::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   468
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   469
	$ tail -n 20 filename
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   470
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   471
This example shows the last 15 bytes of all files starting with *foo*::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   472
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   473
	$ tail -c 15 foo*
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   474
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   475
This example shows all lines of filename from the second line onwards::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   476
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   477
	$ tail -n +2 filename
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   478
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   479
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   480
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   481
File monitoring
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   482
~~~~~~~~~~~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   483
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   484
*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::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   485
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   486
	$ tail -f /var/adm/messages
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   487
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   488
To interrupt tail while it is monitoring, break-in with *Ctrl+C*. This command can be run "in the background" with &, see job control.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   489
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   490
If you have a command's result to monitor, you can use the *watch* command.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   491
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   492
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   493
cut
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   494
----
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   495
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   496
In computing, *cut* is a Unix command line utility which is used to extract sections from each line of input — usually from a file.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   497
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   498
Extraction of line segments can typically be done by *bytes (-b), characters (-c)*, or *fields (-f)* separated by a *delimiter (-d — the tab character by default)*. A range must be provided in each case which consists of one of N, N-M, N- (N to the end of the line), or -M (beginning of the line to M), where N and M are counted from 1 (there is no zeroth value). Since version 6, an error is thrown if you include a zeroth value. Prior to this the value was ignored and assumed to be 1.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   499
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   500
Assuming a file named file containing the lines::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   501
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   502
	foo:bar:baz:qux:quux
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   503
	one:two:three:four:five:six:seven
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   504
	alpha:beta:gamma:delta:epsilon:zeta:eta:teta:iota:kappa:lambda:mu
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   505
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   506
To output the fourth through tenth characters of each line::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   507
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   508
	$ cut -c 4-10 file
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   509
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   510
This gives the output::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   511
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   512
	:bar:ba
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   513
	:two:th
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   514
	ha:beta
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   515
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   516
To output the fifth field through the end of the line of each line using the colon character as the field delimiter::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   517
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   518
	$ cut -d : -f 5- file
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   519
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   520
This gives the output::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   521
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   522
	quux
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   523
	five:six:seven
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   524
	epsilon:zeta:eta:teta:iota:kappa:lambda:mu
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   525
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   526
paste
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   527
------
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   528
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   529
*paste* is a Unix command line utility which is used to join files horizontally (parallel merging) by outputting lines consisting of the sequentially corresponding lines of each file specified, separated by tabs, to the standard output. It is effectively the horizontal equivalent to the utility *cat* command which operates on the vertical plane of two or more files.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   530
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   531
To paste several columns of data together into the file *www* from files *who*, *where*, and *when*::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   532
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   533
	$ paste who where when > www
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   534
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   535
If the files contain:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   536
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   537
+-----------+------------+------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   538
|   who     |   where    |    when    |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   539
+===========+============+============+
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   540
|  Batman   | GothamCity | January 3  |
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   541
+-----------+------------+------------+	
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   542
| Trillian  | Andromeda  | February 4 |
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   543
+-----------+------------+------------+
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   544
|  Jeeves   | London     |  March 19  |
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   545
+-----------+------------+------------+	
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   546
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   547
This creates the file named *www* containing ::
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   548
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   549
	Batman            GothamCity       January 3
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   550
	Trillian          Andromeda        February 4
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   551
	Jeeves            London           March 19
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   552
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   553
Shell Meta Characters
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   554
======================
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   555
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   556
Unix recognizes certain special characters, called "meta characters," as command directives. The shell meta characters are recognized anywhere they appear in the command line, even if they are not surrounded by blank space. For that reason, it is safest to only use the characters A-Z, a-z, 0-9, and the period, dash, and underscore characters when naming files and directories on Unix. If your file or directory has a shell meta character in the name, you will find it difficult to use the name in a shell command.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   557
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   558
The shell meta characters include:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   559
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   560
\ / < > ! $ % ^ & * | { } [ ] " ' ` ~ ; 
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   561
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   562
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   563
As an example,
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   564
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   565
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   566
	$ ls file.*
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   567
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   568
run on a directory containing the files file, file.c, file.lst, and myfile would list the files file.c and file.lst. However,::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   569
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   570
	$ ls file.?
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   571
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   572
run on the same directory would only list file.c because the ? only matches one character, no more, no less. This can save you a great deal of typing time. For example, if there is a file called california_cornish_hens_with_wild_rice and no other files whose names begin with 'c', you could view the file without typing the whole name by typing this::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   573
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   574
	$ more c*
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   575
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   576
because the c* matches that long file name.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   577
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   578
Filenames containing metacharacters can pose many problems and should never be intentionally created.
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   579
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   580
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   581
Looking At Files
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   582
================
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   583
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   584
cat
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   585
---
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   586
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   587
The *cat* command is a standard Unix program used to concatenate and display files. The name is from "catenate", a synonym of *concatenate*.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   588
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   589
The Single Unix Specification specifies the behavior that the contents of each of the files given in sequence as arguments will be written to the standard output in the same sequence, and mandates one option, -u, where each byte is printed as it is read.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   590
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   591
If the filename is specified as -, then *cat* will read from standard input at that point in the sequence. If no files are specified, *cat* will read from standard input entered.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   592
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   593
Usage ::
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   594
        $ cat foo boo
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   595
	This is file foo
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   596
	
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   597
	This is file boo.
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   598
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   599
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   600
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   601
more
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   602
-----
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   603
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   604
In computing, *more* is a command to view (but not modify) the contents of a text file one screen at a time (terminal pager). It is available on Unix and Unix-like systems, DOS, OS/2 and Microsoft Windows. Programs of this sort are called pagers.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   605
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   606
Usage
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   607
~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   608
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   609
The command-syntax is::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   610
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   611
	$ more [options] [file_name]
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   612
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   613
If no file name is provided, *more* looks for input from stdin.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   614
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   615
Once *more* has obtained input, it displays as much as can fit on the current screen and waits for user input to advance, with the exception that a form feed (^L) will also cause *more* to wait at that line, regardless of the amount of text on the screen. In the lower-left corner of the screen is displayed the text "--More--" and a percentage, representing the percent of the file that *more* has paged through. (This percentage includes the text displayed on the current screen.) When *more* reaches the end of a file (100%) it exits. The most common methods of navigating through a file are *Enter*, which advances the output by one line, and *Space*, which advances the output by one screen.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   616
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   617
There are also other commands that can be used while navigating through the document; consult *more*'s *man* page for more details.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   618
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   619
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   620
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   621
less
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   622
-----
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   623
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   624
*less* is a terminal pager program on Unix, Windows and Unix-like systems used to view (but not change) the contents of a text file one screen at a time. It is similar to *more*, but has the extended capability of allowing both forward and backward navigation through the file. Unlike most Unix text editors/viewers, *less* does not need to read the entire file before starting, resulting in faster load times with large files.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   625
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   626
Usage
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   627
~~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   628
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   629
*less* can be invoked with options to change its behaviour, for example, the number of lines to display on the screen. A few options vary depending on the operating system. While *less* is displaying the file, various commands can be used to navigate through the file. These commands are based on those used by both *more* and *vi*. It is also possible to search for character patterns in the file.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   630
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   631
By default, *less* displays the contents of the file to the standard output (one screen at a time). If the file name argument is omitted, it displays the contents from standard input (usually the output of another command through a pipe). If the output is redirected to anything other than a terminal, for example a pipe to another command, less behaves like cat.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   632
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   633
The command-syntax is ::
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   634
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   635
	$ less [options] file_name
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   636
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   637
Frequently Used Options
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   638
~~~~~~~~~~~~~~~~~~~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   639
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   640
    * -g: Highlights just the current match of any searched string.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   641
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   642
    * -I: Case-insensitive searches.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   643
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   644
    * -M: Shows more detailed prompt, including file position.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   645
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   646
    * -N: Shows line numbers (useful for source code viewing).
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   647
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
   648
    * -S: Disables line wrap ("chop long lines"). Long lines can be seen by side scrolling.
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   649
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   650
    * -?: Shows help.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   651
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   652
Frequently Used Commands
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   653
~~~~~~~~~~~~~~~~~~~~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   654
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   655
    * [Arrows]/[Page Up]/[Page Down]/[Home]/[End]: Navigation.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   656
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   657
    * [Space bar]: Next page.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   658
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   659
    * b: Previous page.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   660
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   661
    * ng: Jump to line number n. Default is the start of the file.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   662
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   663
    * nG: Jump to line number n. Default is the end of the file.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   664
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   665
    * /pattern: Search for pattern. Regular expressions can be used.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   666
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   667
    * '^ or g: Go to start of file.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   668
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   669
    * '$ or G: Go to end of file.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   670
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   671
    * s: Save current content (got from another program like grep) in a file.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   672
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   673
    * =: File information.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   674
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   675
    * h: Help.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   676
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   677
    * q: Quit.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   678
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   679
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   680
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   681
-------------------------------------------------------------------
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   682
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   683
Examples 
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   684
~~~~~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   685
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   686
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   687
	$ less -M readme.txt                     #Read "readme.txt."
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   688
	$ less +F /var/log/mail.log              #Follow mode for log
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   689
	$ file * | less                          #Easier file analysis.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   690
	$ grep -i void *.c | less -I -p void     #Case insensitive search 		                                          for "void" in all .c files
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   691
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   692
Directory Structure
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   693
====================
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   694
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   695
In the File Hierarchy Standard (FHS) all files and directories appear under the root directory "/", even if they are stored on different physical devices. Note however that some of these directories may or may not be present on a Unix system depending on whether certain subsystems, such as the X Window System, are installed.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   696
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   697
The majority of these directories exist in all UNIX operating systems and are generally used in much the same way; however, the descriptions here are those used specifically for the FHS, and are not considered authoritative for platforms other thanmajor Linux distros.
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   698
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   699
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   700
|   Directory   |             Description                        |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   701
+===============+================================================+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   702
| /             | Primary hierarchy root and root directory of   |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   703
|               | the entire file system hierarchy.              |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   704
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   705
| /bin/         | Essential command binaries that need to be     |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   706
|               | available in single user mode; for all users,  |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   707
|               | e.g., *cat*, *ls*, *cp*.                       |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   708
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   709
| /boot/        | Boot loader files, e.g., *kernels*, *initrd*;  |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   710
|               | often a separate partition.                    |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   711
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   712
| /dev/         | Essential devices, e.g., /dev/null             |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   713
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   714
| /etc/         | Host-specific system-wide configuration files  |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   715
|               | (the name comes from *et cetera*)              |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   716
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   717
| /home/        | User's home directories, containing saved      |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   718
|               | files, personal settings, etc.; often a        |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   719
|               | separate partition.                            |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   720
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   721
| /lib/         | Libraries essential for the binaries in        |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   722
|               | */bin/* and */sbin/*                           |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   723
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   724
| /media/       | Mount points for removable media such as       |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   725
|               | CD-ROMs, external hard disks, USB sticks, etc. |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   726
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   727
| /mnt/         | Temporarily mounted file systems               |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   728
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   729
| /opt/         | Optional application software packages         |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   730
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   731
| /proc/        | Virtual filesystem documenting kernel and      |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   732
|               | process status as text files; e.g., uptime,    |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   733
|               | network. In Linux, corresponds to a *Procfs*   |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   734
|               | mount.                                         |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   735
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   736
| /root/        | Home directory for the root user               |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   737
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   738
| /sbin/        | Essential system binaries; e.g., *init*,       |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   739
|               | *route*, *mount*.                              |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   740
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   741
| /srv/         | Site-specific data which is served by the      |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   742
|               | system.                                        |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   743
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   744
| /tmp/         | Temporary files. Often not preserved between   |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   745
|               | system reboots.                                |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   746
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   747
| /usr/         | Secondary hierarchy for read-only user data;   |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   748
|               | contains the majority of (multi-)user          |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   749
|               | utilities and applications.                    |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   750
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   751
| /var/         | Variable files - files whose content is        |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   752
|               | expected to continually change during normal   |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   753
|               | operation of the system - such as logs, spool  |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   754
|               | files, and temporary e-mail files.             |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   755
|               | Sometimes a separate partition.                |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   756
+---------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   757
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   758
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   759
man hier
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   760
---------
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   761
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   762
This is the manual page on the UNIX filesystem. The syntax for this is::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   763
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   764
	$ man hier
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   765
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   766
ls -l
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   767
-----
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   768
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   769
Shows you huge amounts of information (permissions, owners, size, and when last modified) for folders and files. The syntax is ::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   770
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   771
	$ ls -l
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   772
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   773
This can be done after entering the required directory. 
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   774
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   775
Permissions and Ownership
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   776
=========================
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   777
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   778
let's check out the file permissions. File permissions are defined
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   779
for users, groups and others. User would be the username that you are
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   780
logging in as. Further more, users can be organized into groups for better
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   781
administration and control. Each user will belong to at least one default
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   782
group. Others includes anyone the above categories exclude.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   783
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   784
Given below is the result of an 'ls -l'
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   785
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   786
drwxr-x--- 2 user group 4096 Dec 28 04:09 tmp
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   787
-rw-r--r-- 1 user group 969 Dec 21 02:32 foo
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   788
-rwxr-xr-x 1 user group 345 Sep 1 04:12 somefile
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   789
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   790
Relevant information in the first column here is the file type followed by the file permissions. The third and the fourth column show the owner of the file and the group that the file belongs to.The fifth column is no bytes and sixth modification date .The first entry here is tmp. The first character in the first column is 'd', which means the tmp is a directory. The other entries here are files,as indicated by the '-'.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   791
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   792
d rwx r-x ---
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   793
file type users group others
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   794
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   795
The next 9 characters define the file permissions. These permissions are given in groups of 3 each. The first 3 characters are the permissions for the owner of the file or directory. The next 3 are permissions for the group that the file is owned by and the final 3 characters define the access permissions for everyone not part of the group. There are 3 possible attributes that make up file access permissions.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   796
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   797
r - Read permission. Whether the file may be read. In the case of a directory, this would mean the ability to list the contents of the directory.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   798
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   799
w - Write permission. Whether the file may be written to or modified. For a directory, this defines whether you can make any changes to the contents
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   800
of the directory. If write permission is not set then you will not be able
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   801
to delete, rename or create a file.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   802
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   803
x - Execute permission. Whether the file may be executed. In the case of a directory, this attribute decides whether you have permission to enter,run a search through that directory or execute some program from that directory.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   804
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   805
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   806
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   807
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   808
chmod
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
   809
------
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   810
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   811
The *chmod* command (abbreviated from 'change mode') is a shell command and C language function in Unix and Unix-like environments. When executed, it can change file system modes of files and directories. The modes include permissions and special modes.
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   812
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   813
Usage
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   814
~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   815
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   816
The *chmod* command options are specified like this:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   817
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   818
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   819
	$ chmod [options] mode[,mode] file1 [file2 ...]
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   820
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   821
To view what the permissions currently are, type:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   822
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   823
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   824
	$ ls -l file
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   825
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   826
Command line options
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   827
~~~~~~~~~~~~~~~~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   828
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   829
The *chmod* command has a number of command line options that affect its behavior. The most common options are:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   830
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   831
    * -R: Changes the modes of directories and files recursively
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   832
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   833
    * -v: Verbose mode; lists all files as they are being processed
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   834
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   835
Symbolic modes
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   836
+++++++++++++++
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   837
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   838
To the *chmod* utility, all permissions and special modes are represented by its mode parameter. One way to adjust the mode of files or directories is to specify a symbolic mode. The symbolic mode is composed of three components, which are combined to form a single string of text:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   839
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   840
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   841
	$ chmod [references][operator][modes] file1 ...
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   842
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   843
The references (or classes) are used to distinguish the users to whom the permissions apply. If no references are specified it defaults to “all” but modifies only the permissions allowed by the umask. The references are represented by one or more of the following letters:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   844
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   845
+--------------+--------+---------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   846
| Reference    | Class  |                Description                  |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   847
+==============+========+=============================================+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   848
|      u       | user   | the owner of the file                       |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   849
+--------------+--------+---------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   850
|      g       | group  | users who are members of the file's group   |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   851
+--------------+--------+---------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   852
|      o       | others | users who are not hte owner of the file or  |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   853
|              |        | members of the group                        |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   854
+--------------+--------+---------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   855
|      a       | all    | all three of the above; is the same as *ugo*|
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   856
+--------------+--------+---------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   857
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   858
The *chmod* program uses an operator to specify how the modes of a file should be adjusted. The following operators are accepted:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   859
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   860
+--------------+------------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   861
| Operator     |                      Description                     |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   862
+==============+======================================================+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   863
| +            | adds the specified modes to the specified classes    |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   864
+--------------+------------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   865
| -            | removes the specified modes from the specified       |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   866
|              | classes                                              |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   867
+--------------+------------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   868
| =            | the modes specified are to be made the exact modes   |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   869
|              | for the specified classes                            |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   870
+--------------+------------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   871
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   872
The modes indicate which permissions are to be granted or taken away from the specified classes. There are three basic modes which correspond to the basic permissions:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   873
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   874
+-----+--------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   875
|Mode |    Name      |                 Description                    |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   876
+=====+==============+================================================+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   877
| r   | read         | read a file or list a directory's contents     |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   878
+-----+--------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   879
| w   | write        | write to a file or directory                   |   
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   880
+-----+--------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   881
| x   | execute      | execute a file or recurse a directory tree     |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   882
+-----+--------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   883
| X   | special      | which is not a permission in itself but rather |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   884
|     | execute      | can be used instead of 'x'. It applies execute |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   885
|     |              | permissions to directories regardless of their |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   886
|     |              | current permissions and applies execute        |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   887
|     |              | permissions to a file which already has at     |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   888
|     |              | least 1 execute permission bit already set     |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   889
|     |              | (either user, group or other). It is only      |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   890
|     |              | really useful when used with '+' and usually   |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   891
|     |              | in combination with the *-R* option for giving |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   892
|     |              | group or other access to a big directory tree  |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   893
|     |              | without setting execute permission on normal   |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   894
|     |              | files (such as text files), which would        |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   895
|     |              | normally happen if one just used 'chmod -R     |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   896
|     |              | a+rx .', whereas with 'X' one can do 'chmod -R |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   897
|     |              | a+rX .' instead.                               |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   898
+-----+--------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   899
| s   | setuid/gid   | are Unix access rights flags that allow users  |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   900
|     |              | to run an executable with the permissions of   |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   901
|     |              | the executable's owner or group.They are often |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   902
|     |              | used to allow users on a computer system to run| 
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   903
|     |              | programs with temporarily elevated privileges  | 
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   904
|     |              | in order to perform a specific task. While the |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   905
|     |              | assumed user id or group id privileges provided|
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   906
|     |              | are not always elevated, at a minimum they are | 
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   907
|     |              | specific.They are needed for tasks that require|
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   908
|     |              | higher privileges than those which a common    |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   909
|     |              | user has, such as changing his or her login    |  
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   910
|     |              | password.                                      |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   911
+-----+--------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   912
| t   | sticky       | The most common use of the sticky bit today is |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   913
|     |              | on directories, where, when set, items inside  |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   914
|     |              | the directory can be renamed or deleted only by|
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   915
|     |              | the item's owner, the directory's owner, or the| 
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   916
|     |              | superuser; without the sticky bit set, any user|
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   917
|     |              | with write and execute permissions for the     |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   918
|     |              | directory can rename or delete contained files,| 
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   919
|     |              | regardless of owner.                           |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   920
+-----+--------------+------------------------------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   921
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   922
The combination of these three components produces a string that is understood by the chmod command. Multiple changes can be specified by separating multiple symbolic modes with commas.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   923
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   924
Symbolic examples
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   925
+++++++++++++++++
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   926
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   927
Add the 'read' and 'write' permissions to the 'user' and 'group' classes of a directory:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   928
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   929
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   930
	$ chmod ug+rw mydir
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   931
	$ ls -ld mydir
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   932
	drw-rw----   2 starwars  yoda  96 Dec 8 12:53 mydir
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   933
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   934
For a file, remove *write* permissions for all classes:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   935
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   936
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   937
	$ chmod a-w myfile
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   938
	$ ls -l myfile
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   939
	-r-xr-xr-x   2 starwars  yoda 96 Dec 8 12:53 myfile
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   940
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   941
Set the permissions for the *u*ser and the *g*roup to read and execute only (no write permission) on *mydir*.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   942
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   943
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   944
	$ chmod ug=rx mydir
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   945
	$ ls -ld mydir
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   946
	dr-xr-x---   2 starwars  yoda 96 Dec 8 12:53 mydir
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   947
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   948
Octal numbers
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   949
+++++++++++++
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   950
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   951
The *chmod* command also accepts three and four-digit octal numbers representing modes. Using a three-digit octal number to set the modes of a file named myfile :
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   952
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   953
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   954
	$ chmod 664 myfile
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   955
	$ ls -l myfile
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   956
	-rw-rw-r--  1   57 Jul  3 10:13  myfile
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   957
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   958
Foe each one, you define the right like that :
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   959
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   960
    * a read right correspond to 4
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   961
    * a write right correspond to 2
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   962
    * an execute right correspond to 1
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   963
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   964
You want the user to have all the rights? : 4 + 2 + 1 = 7
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   965
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   966
you want the group to have read and write rights : 4 + 2 = 6
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   967
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   968
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   969
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   970
Since the *setuid*, *setgid* and *sticky* bits are not set, this is equivalent to:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   971
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   972
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   973
	$ chmod 0664 myfile
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   974
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   975
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   976
chown
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   977
~~~~~
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   978
The chown command is used to change the owner and group of files, directories and links.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   979
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   980
By default, the owner of a filesystem object is the user that created it. The group is a set of users that share the same access permissions (i.e., read, write and execute) for that object.
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   981
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   982
The basic syntax for using chown to change owners is
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   983
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   984
    chown -v alice wonderland.txt
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   985
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   986
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   987
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   988
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   989
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   990
Redirection and Piping
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   991
=======================
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   992
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   993
In computing, *redirection* is a function common to most command-line interpreters, including the various Unix shells that can redirect standard streams to user-specified locations.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   994
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
   995
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   996
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   997
Redirecting standard input and standard output
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   998
-----------------------------------------------
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
   999
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1000
Redirection is usually implemented by placing certain characters between commands. Typically, the syntax of these characters is as follows::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1001
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1002
	$ command1 > file1
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1003
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1004
executes *command1*, placing the output in file1. Note that this will truncate any existing data in *file1*. To append output to the end of the file, use the >> operator.::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1005
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1006
	$ command1 < file1
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1007
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1008
executes *command1*, using *file1* as the source of input (as opposed to the keyboard).::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1009
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1010
	$ command1 < infile > outfile
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1011
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1012
combines the two capabilities: *command1* reads from *infile* and writes to *outfile*
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1013
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1014
Piping
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1015
-------
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1016
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1017
Programs can be run together such that one program reads the output from another with no need for an explicit intermediate file:
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1018
A pipeline of two programs run on a text terminal::
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1019
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1020
	$ command1 | command2
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1021
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1022
executes *command1*, using its output as the input for *command2* (commonly called piping, since the "|" character is known as a "pipe").
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1023
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1024
This is equivalent to using two redirects and a temporary file::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1025
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1026
	$ command1 > tempfile
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1027
	$ command2 < tempfile
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1028
	$ rm tempfile
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1029
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1030
A good example for command piping is combining *echo* with another command to achieve something interactive in a non-interactive shell, e.g.::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1031
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1032
	$ echo -e "user\npass" | ftp localhost
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1033
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1034
This runs the ftp client with input user, press return, then pass.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1035
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1036
Redirecting to and from the standard file handles
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1037
--------------------------------------------------
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1038
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1039
In Unix shells derived from the original Bourne shell, the first two actions can be further modified by placing a number (the file descriptor) immediately before the character; this will affect which stream is used for the redirection. The Unix standard I/O streams are:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1040
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1041
+------------+-------------+------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1042
|   Handle   |    Name     |      Description       |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1043
+============+=============+========================+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1044
| 0          |   stdin     |    Standard input      |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1045
+------------+-------------+------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1046
| 1          |   stdout    |    Standard output     |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1047
+------------+-------------+------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1048
| 2          |   stderr    |    Standard error      |
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1049
+------------+-------------+------------------------+
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1050
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1051
For example:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1052
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1053
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1054
	$ command1 2> file1
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1055
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1056
executes *command1*, directing the standard error stream to *file1*.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1057
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1058
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1059
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1060
Another useful capability is to redirect one standard file handle to another. The most popular variation is to merge standard error into standard output so error messages can be processed together with (or alternately to) the usual output. Example:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1061
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1062
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1063
	$ find / -name .profile > results 2>&1
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1064
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1065
will try to find all files named *.profile*. Executed without redirection, it will output hits to *stdout* and errors (e.g. for lack of privilege to traverse protected directories) to *stderr*. If standard output is directed to file results, error messages appear on the console. To see both hits and error messages in file results, merge *stderr* (handle 2) into *stdout* (handle 1) using 2>&1 .
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1066
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1067
It's possible use 2>&1 before ">" but it doesn't work. In fact, when the interpreter reads 2>&1, it doesn't know yet where standard output is redirected and then standard error isn't merged.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1068
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1069
If the merged output is to be piped into another program, the file merge sequence 2>&1 must precede the pipe symbol, thus:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1070
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1071
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1072
	$ find / -name .profile 2>&1 | less
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1073
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1074
A simplified form of the command:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1075
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1076
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1077
	$ command > file 2>&1
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1078
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1079
is:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1080
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1081
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1082
	$ command &>file
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1083
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1084
or:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1085
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1086
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1087
	$command >&file
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1088
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1089
Chained pipelines
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1090
------------------
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1091
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1092
The redirection and piping tokens can be chained together to create complex commands. For example:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1093
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1094
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1095
	$ ls | grep '\.sh' | sort > shlist
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1096
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1097
lists the contents of the current directory, where this output is filtered to only contain lines which contain *.sh*, sort this resultant output lexicographically, and place the final output in *shlist*. This type of construction is used very commonly in shell scripts and batch files.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1098
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1099
Redirect to multiple outputs
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1100
-----------------------------
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1101
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1102
The standard command *tee* can redirect output from a command to several destinations.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1103
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1104
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1105
	$ ls -lrt | tee xyz
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1106
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1107
This directs the file list output to both standard output as well as to the file *xyz*.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1108
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1109
More Text Processing
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1110
====================
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1111
74
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
  1112
grep
7dbeae0fac70 Removed numbering for sections
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 73
diff changeset
  1113
-----
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1114
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1115
*grep* is a command line text search utility originally written for Unix. The name is taken from the first letters in *global / regular expression / print*, a series of instructions for the *ed* text editor. The *grep* command searches files or standard input globally for lines matching a given regular expression, and prints them to the program's standard output.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1116
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1117
Usage
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1118
~~~~~~
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1119
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1120
This is an example of a common *grep* usage:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1121
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1122
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1123
	$ grep apple fruitlist.txt
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1124
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1125
In this case, *grep* prints all lines containing 'apple' from the file *fruitlist.txt*, regardless of word boundaries; therefore lines containing 'pineapple' or 'apples' are also printed. The *grep* command is case sensitive by default, so this example's output does not include lines containing 'Apple' (with a capital A) unless they also contain 'apple'.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1126
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1127
Like most Unix commands, *grep* accepts command line arguments to change this and many other behaviors. For example:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1128
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1129
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1130
	$ grep -i apple fruitlist.txt
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1131
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1132
This prints all lines containing 'apple' regardless of capitalization. The '-i' argument tells *grep* to be case insensitive, or to ignore case.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1133
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1134
To print all lines containing 'apple' as a word ('pineapple' and 'apples' will not match):
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1135
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1136
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1137
	$ grep -w apple fruitlist.txt
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1138
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1139
Regular expressions can be used to match more complicated queries.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1140
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1141
Variations
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1142
+++++++++++
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1143
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1144
There are countless implementations and derivatives of *grep* available for many operating systems. Early variants of *grep* included *egrep* and *fgrep*. The former applies an extended regular expression syntax that was added to Unix after Ken Thompson's original regular expression implementation. The latter searches for any of a list of 'fixed' strings using the Aho-Corasick algorithm. These variants are embodied in most modern *grep* implementations as command-line switches (and standardized as -E and -F in POSIX). In such combined implementations, *grep* may also behave differently depending on the name by which it is invoked, allowing *fgrep*, *egrep*, and *grep* to be links to the same program.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1145
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1146
*pcregrep* is an implementation of *grep* that uses Perl regular expression syntax.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1147
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1148
Other commands contain the word 'grep' to indicate that they search (usually for regular expression matches). The *pgrep* utility, for instance, displays the processes whose names match a given regular expression.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1149
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1150
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1151
Elementary Regex
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1152
=================
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1153
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1154
In computing, regular expressions provide a concise and flexible means for identifying strings of text of interest, such as particular characters, words, or patterns of characters. A regular expression (often shortened to regex or regexp) is written in a formal language that can be interpreted by a regular expression processor, a program that either serves as a parser generator or examines text and identifies parts that match the provided specification.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1155
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1156
Regular expressions are used by many text editors, utilities, and programming languages to search and manipulate text based on patterns. For example, Perl, Ruby and Tcl have a powerful regular expression engine built directly into their syntax. Several utilities provided by Unix distributions—including the editor *ed* and the filter *grep* — were the first to popularize the concept of regular expressions.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1157
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1158
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1159
Regular Expressions are a feature of UNIX. They describe a pattern to match, a sequence of characters, not words, within a line of text. Here is a quick summary of the special characters used in the grep tool and their meaning: 
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1160
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1161
* ^ (Caret)        =    match expression at the start of a line, as in ^A.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1162
* $ (Question)     =    match expression at the end of a line, as in A$.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1163
* \ (Back Slash)   =    turn off the special meaning of the next character, as in \^.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1164
* [ ] (Brackets)   =    match any one of the enclosed characters, as in [aeiou].
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1165
                      Use Hyphen "-" for a range, as in [0-9].
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1166
* [^ ]             =    match any one character except those enclosed in [ ], as in [^0-9].
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1167
* . (Period)       =    match a single character of any value, except end of line.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1168
* * (Asterisk)     =    match zero or more of the preceding character or expression.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1169
* \{x,y\}          =    match x to y occurrences of the preceding.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1170
* \{x\}            =    match exactly x occurrences of the preceding.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1171
* \{x,\}           =    match x or more occurrences of the preceding.
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1172
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1173
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1174
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1175
Here are some examples using grep:
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1176
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1177
*    grep smug files         {search files for lines with 'smug'}
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1178
*    grep '^smug' files      {'smug' at the start of a line}
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1179
*    grep 'smug$' files      {'smug' at the end of a line}
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1180
*    grep '^smug$' files     {lines containing only 'smug'}
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1181
*    grep '\^s' files        {lines starting with '^s', "\" escapes the ^}
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1182
*    grep '[Ss]mug' files    {search for 'Smug' or 'smug'}
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1183
*    grep 'B[oO][bB]' files  {search for BOB, Bob, BOb or BoB }
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1184
*    grep '^$' files         {search for blank lines}
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1185
*   grep '[0-9][0-9]' file  {search for pairs of numeric digits}
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1186
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1187
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1188
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1189
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1190
Lazy quantification
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1191
--------------------
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1192
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1193
The standard quantifiers in regular expressions are greedy, meaning they match as much as they can, only giving back as necessary to match the remainder of the regex. For example, someone new to regexes wishing to find the first instance of an item between < and > symbols in this example:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1194
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1195
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1196
	Another whale explosion occurred on <January 26>, <2004>.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1197
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1198
...would likely come up with the pattern <.*>, or similar. However, this pattern will actually return "<January 26>, <2004>" instead of the "<January 26>" which might be expected, because the `*` quantifier is greedy — it will consume as many characters as possible from the input, and "January 26>, <2004" has more characters than "January 26".
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1199
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
  1200
Though this problem can be avoided in a number of ways (e.g., by specifying the text that is not to be matched: <[^>]*>), modern regular expression tools allow a quantifier to be specified as *lazy* (also known as non-greedy, reluctant, minimal, or ungreedy) by putting a question mark after the quantifier (e.g., <.*?>), or by using a modifier which reverses the greediness of quantifiers (though changing the meaning of the standard quantifiers can be confusing). By using a lazy quantifier, the expression tries the minimal match first. Though in the previous example lazy matching is used to select one of many matching results, in some cases it can also be used to improve performance when greedy matching would require more backtracking.
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1201
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1202
One Liners
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1203
===========
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1204
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1205
A *one-liner* is textual input to the command-line of an operating system shell that performs some function in just one line of input.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1206
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1207
The one liner can be
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1208
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1209
   1. An expression written in the language of the shell.
73
d32a19958ad9 Completed first review and cuts of ULT
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 55
diff changeset
  1210
   2. The invocation of an interpreter together with program source for the interpreter to run.
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1211
   3. The invocation of a compiler together with source to compile and 	  
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1212
      instructions for executing the compiled program.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1213
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1214
Certain dynamic scripting languages such as AWK, sed, and perl have traditionally been adept at expressing one-liners. Specialist shell interpreters such as these Unix shells or the Windows PowerShell, allow for the construction of powerful one-liners.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1215
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1216
The use of the phrase one-liner has been widened to also include program-source for any language that does something useful in one line.
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1217
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1218
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1219
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1220
Here is a one line shell script to show directories:
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1221
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1222
::
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1223
98
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1224
      $grep user * | cut -d":"  -f1|uniq
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1225
678c7c01b5d5 changes to Intorduction to Linux and Text Processing in ULT
amit@thunder
parents: 74
diff changeset
  1226
This returns list of all files which has the word user in it .
55
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1227
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1228
6aa9568b5874 Completed rough draft of first three sessions in module one.
Kadambari Devarajan <kadambari.devarajan@gmail.com>
parents: 44
diff changeset
  1229