1 .\" Copyright (c) 2002 Andries Brouwer <aeb@cwi.nl>
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .TH INTRO 1 2002-08-06 "Linux" "Linux Programmer's Manual"
25 intro \- Introduction to user commands
27 Linux is a flavour of Unix, and as a first approximation
28 all user commands under Unix work precisely the same under
29 Linux (and FreeBSD and lots of other Unix-like systems).
31 Under Linux there are GUIs (graphical user interfaces), where you
32 can point and click and drag, and hopefully get work done without
33 first reading lots of documentation. The traditional Unix environment
34 is a CLI (command line interface), where you type commands to
35 tell the computer what to do. That is faster and more powerful,
36 but requires finding out what the commands are.
37 Below a bare minimum, to get started.
39 In order to start working, you probably first have to login,
40 that is, give your username and password. See also
46 (command interpreter) for you.
47 In case of a graphical login, you get a screen with menus or icons
48 and a mouse click will start a shell in a window. See also
51 One types commands to the
53 the command interpreter. It is not built-in, but is just a program
54 and you can change your shell. Everybody has her own favourite one.
55 The standard one is called
64 A session might go like
68 .BI "knuth login: " aeb
69 .BI "Password: " ********
71 Tue Aug 6 23:50:44 CEST 2002
85 drwxrwxr-x 2 aeb 1024 Aug 6 23:51 bin
86 -rw-rw-r-- 1 aeb 37 Aug 6 23:52 tel
90 .BI "% " "cp tel tel2"
93 drwxr-xr-x 2 aeb 1024 Aug 6 23:51 bin
94 -rw-r--r-- 1 aeb 37 Aug 6 23:52 tel
95 -rw-r--r-- 1 aeb 37 Aug 6 23:53 tel2
96 .BI "% " "mv tel tel1"
99 drwxr-xr-x 2 aeb 1024 Aug 6 23:51 bin
100 -rw-r--r-- 1 aeb 37 Aug 6 23:52 tel1
101 -rw-r--r-- 1 aeb 37 Aug 6 23:53 tel2
102 .BI "% " "diff tel1 tel2"
104 .BI "% " "grep maja tel2"
109 and here typing Control-D ended the session.
112 here was the command prompt \(em it is the shell's way of indicating
113 that it is ready for the next command. The prompt can be customized
114 in lots of ways, and one might include stuff like user name,
115 machine name, current directory, time, etc.
116 An assignment PS1="What next, master? "
117 would change the prompt as indicated.
119 We see that there are commands
121 (that gives date and time), and
123 (that gives a calendar).
127 lists the contents of the current directory \(em it tells you what
128 files you have. With a \-l option it gives a long listing,
129 that includes the owner and size and date of the file, and the
130 permissions people have for reading and/or changing the file.
131 For example, the file "tel" here is 37 bytes long, owned by aeb
132 and the owner can read and write it, others can only read it.
133 Owner and permissions can be changed by the commands
140 will show the contents of a file.
141 (The name is from "concatenate and print": all files given as
142 parameters are concatenated and sent to "standard output", here
143 the terminal screen.)
147 (from "copy") will copy a file.
148 On the other hand, the command
150 (from "move") only renames it.
154 lists the differences between two files.
155 Here there was no output because there were no differences.
159 (from "remove") deletes the file, and be careful! it is gone.
160 No wastepaper basket or anything. Deleted means lost.
164 (from "g/re/p") finds occurrences of a string in one or more files.
165 Here it finds Maja's telephone number.
166 .SS "Path names and the current directory"
167 Files live in a large tree, the file hierarchy.
170 describing the path from the root of the tree (which is called /)
171 to the file. For example, such a full path name might be /home/aeb/tel.
172 Always using full path names would be inconvenient, and the name
173 of a file in the current directory may be abbreviated by only giving
174 the last component. That is why "/home/aeb/tel" can be abbreviated
175 to "tel" when the current directory is "/home/aeb".
179 prints the current directory.
183 changes the current directory.
184 Try "cd /" and "pwd" and "cd" and "pwd".
188 makes a new directory.
192 removes a directory if it is empty, and complains otherwise.
196 (with a rather baroque syntax) will find files with given name
197 or other properties. For example, "find . \-name tel" would find
198 the file "tel" starting in the present directory (which is called ".").
199 And "find / \-name tel" would do the same, but starting at the root
200 of the tree. Large searches on a multi-GB disk will be time-consuming,
201 and it may be better to use
203 .SS "Disks and Filesystems"
206 will attach the filesystem found on some disk (or floppy, or CDROM or so)
207 to the big filesystem hierarchy. And
212 will tell you how much of your disk is still free.
214 On a Unix system many user and system processes run simultaneously.
215 The one you are talking to runs in the
221 will show you which processes are active and what numbers these
225 allows you to get rid of them. Without option this is a friendly
226 request: please go away. And "kill \-9" followed by the number
227 of the process is an immediate kill.
228 Foreground processes can often be killed by typing Control-C.
229 .SS "Getting information"
230 There are thousands of commands, each with many options.
231 Traditionally commands are documented on
233 (like this one), so that the command "man kill" will document
234 the use of the command "kill" (and "man man" document the command "man").
237 sends the text through some
241 Hit the space bar to get the next page, hit q to quit.
243 In documentation it is customary to refer to man pages
244 by giving the name and section number, as in
246 Man pages are terse, and allow you to find quickly some forgotten
247 detail. For newcomers an introductory text with more examples
248 and explanations is useful.
250 A lot of GNU/FSF software is provided with info files. Type "info info"
251 for an introduction on the use of the program "info".
253 Special topics are often treated in HOWTOs. Look in
254 .I /usr/share/doc/howto/en
255 and use a browser if you find HTML files there.
257 .\" Actual examples? Separate section for each of cat, cp, ...?
258 .\" gzip, bzip2, tar, rpm