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