1INTRO(1) Linux User's Manual INTRO(1)
2
3
4
6 intro - Introduction to user commands
7
9 Section 1 of the manual describes user commands and tools, for example,
10 file manipulation tools, shells, compilers, web browsers, file and
11 image viewers and editors, and so on.
12
13 All commands yield a status value on termination. This value can be
14 tested (e.g., in most shells the variable $? contains the status of
15 the last executed command) to see whether the command completed suc‐
16 cessfully. A zero exit status is conventionally used to indicate suc‐
17 cess, and a non-zero status means that the command was unsuccessful.
18 (Details of the exit status can be found in wait(2).) A non-zero exit
19 status can be in the range 1 to 255, and some commands use different
20 non-zero status values to indicate the reason why the command failed.
21
23 Linux is a flavor of Unix, and as a first approximation all user com‐
24 mands under Unix work precisely the same under Linux (and FreeBSD and
25 lots of other Unix-like systems).
26
27 Under Linux there are GUIs (graphical user interfaces), where you can
28 point and click and drag, and hopefully get work done without first
29 reading lots of documentation. The traditional Unix environment is a
30 CLI (command line interface), where you type commands to tell the com‐
31 puter what to do. That is faster and more powerful, but requires find‐
32 ing out what the commands are. Below a bare minimum, to get started.
33
34 Login
35 In order to start working, you probably first have to login, that is,
36 give your username and password. See also login(1). The program login
37 now starts a shell (command interpreter) for you. In case of a graphi‐
38 cal login, you get a screen with menus or icons and a mouse click will
39 start a shell in a window. See also xterm(1).
40
41 The shell
42 One types commands to the shell, the command interpreter. It is not
43 built-in, but is just a program and you can change your shell. Every‐
44 body has her own favorite one. The standard one is called sh. See
45 also ash(1), bash(1), csh(1), zsh(1), chsh(1).
46
47 A session might go like
48
49 knuth login: aeb
50 Password: ********
51 % date
52 Tue Aug 6 23:50:44 CEST 2002
53 % cal
54 August 2002
55 Su Mo Tu We Th Fr Sa
56 1 2 3
57 4 5 6 7 8 9 10
58 11 12 13 14 15 16 17
59 18 19 20 21 22 23 24
60 25 26 27 28 29 30 31
61
62 % ls
63 bin tel
64 % ls -l
65 total 2
66 drwxrwxr-x 2 aeb 1024 Aug 6 23:51 bin
67 -rw-rw-r-- 1 aeb 37 Aug 6 23:52 tel
68 % cat tel
69 maja 0501-1136285
70 peter 0136-7399214
71 % cp tel tel2
72 % ls -l
73 total 3
74 drwxr-xr-x 2 aeb 1024 Aug 6 23:51 bin
75 -rw-r--r-- 1 aeb 37 Aug 6 23:52 tel
76 -rw-r--r-- 1 aeb 37 Aug 6 23:53 tel2
77 % mv tel tel1
78 % ls -l
79 total 3
80 drwxr-xr-x 2 aeb 1024 Aug 6 23:51 bin
81 -rw-r--r-- 1 aeb 37 Aug 6 23:52 tel1
82 -rw-r--r-- 1 aeb 37 Aug 6 23:53 tel2
83 % diff tel1 tel2
84 % rm tel1
85 % grep maja tel2
86 maja 0501-1136285
87 %
88 and here typing Control-D ended the session. The % here was the com‐
89 mand prompt — it is the shell's way of indicating that it is ready for
90 the next command. The prompt can be customized in lots of ways, and
91 one might include stuff like username, machine name, current directory,
92 time, etc. An assignment PS1="What next, master? " would change the
93 prompt as indicated.
94
95 We see that there are commands date (that gives date and time), and cal
96 (that gives a calendar).
97
98 The command ls lists the contents of the current directory — it tells
99 you what files you have. With a -l option it gives a long listing,
100 that includes the owner and size and date of the file, and the permis‐
101 sions people have for reading and/or changing the file. For example,
102 the file "tel" here is 37 bytes long, owned by aeb and the owner can
103 read and write it, others can only read it. Owner and permissions can
104 be changed by the commands chown and chmod.
105
106 The command cat will show the contents of a file. (The name is from
107 "concatenate and print": all files given as parameters are concatenated
108 and sent to "standard output", here the terminal screen.)
109
110 The command cp (from "copy") will copy a file. On the other hand, the
111 command mv (from "move") only renames it.
112
113 The command diff lists the differences between two files. Here there
114 was no output because there were no differences.
115
116 The command rm (from "remove") deletes the file, and be careful! it is
117 gone. No wastepaper basket or anything. Deleted means lost.
118
119 The command grep (from "g/re/p") finds occurrences of a string in one
120 or more files. Here it finds Maja's telephone number.
121
122 Pathnames and the current directory
123 Files live in a large tree, the file hierarchy. Each has a pathname
124 describing the path from the root of the tree (which is called /) to
125 the file. For example, such a full pathname might be /home/aeb/tel.
126 Always using full pathnames would be inconvenient, and the name of a
127 file in the current directory may be abbreviated by only giving the
128 last component. That is why "/home/aeb/tel" can be abbreviated to
129 "tel" when the current directory is "/home/aeb".
130
131 The command pwd prints the current directory.
132
133 The command cd changes the current directory. Try "cd /" and "pwd" and
134 "cd" and "pwd".
135
136 Directories
137 The command mkdir makes a new directory.
138
139 The command rmdir removes a directory if it is empty, and complains
140 otherwise.
141
142 The command find (with a rather baroque syntax) will find files with
143 given name or other properties. For example, "find . -name tel" would
144 find the file "tel" starting in the present directory (which is called
145 "."). And "find / -name tel" would do the same, but starting at the
146 root of the tree. Large searches on a multi-GB disk will be time-con‐
147 suming, and it may be better to use locate(1).
148
149 Disks and Filesystems
150 The command mount will attach the file system found on some disk (or
151 floppy, or CDROM or so) to the big file system hierarchy. And umount
152 detaches it again. The command df will tell you how much of your disk
153 is still free.
154
155 Processes
156 On a Unix system many user and system processes run simultaneously.
157 The one you are talking to runs in the foreground, the others in the
158 background. The command ps will show you which processes are active
159 and what numbers these processes have. The command kill allows you to
160 get rid of them. Without option this is a friendly request: please go
161 away. And "kill -9" followed by the number of the process is an imme‐
162 diate kill. Foreground processes can often be killed by typing Con‐
163 trol-C.
164
165 Getting information
166 There are thousands of commands, each with many options. Traditionally
167 commands are documented on man pages, (like this one), so that the com‐
168 mand "man kill" will document the use of the command "kill" (and "man
169 man" document the command "man"). The program man sends the text
170 through some pager, usually less. Hit the space bar to get the next
171 page, hit q to quit.
172
173 In documentation it is customary to refer to man pages by giving the
174 name and section number, as in man(1). Man pages are terse, and allow
175 you to find quickly some forgotten detail. For newcomers an introduc‐
176 tory text with more examples and explanations is useful.
177
178 A lot of GNU/FSF software is provided with info files. Type "info
179 info" for an introduction on the use of the program "info".
180
181 Special topics are often treated in HOWTOs. Look in
182 /usr/share/doc/howto/en and use a browser if you find HTML files there.
183
185 standards(7)
186
188 This page is part of release 3.22 of the Linux man-pages project. A
189 description of the project, and information about reporting bugs, can
190 be found at http://www.kernel.org/doc/man-pages/.
191
192
193
194Linux 2007-11-15 INTRO(1)