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