Remove lfs-uefi.txt symlink
[linux_from_scratch_hints.git] / PREVIOUS_FORMAT / newbie.txt
blobc39479aba9615a8f8331725ea0f7a82834c35932
1 TITLE:          Basic help for newbies
2 LFS VERSION:    All
3 AUTHOR:         Nathan Ladd (nathanladd@yahoo.com),
4                 (original author) Simon Perreault <nomis80@videotron.ca>
6 SYNOPSIS:
7         The LFS book has become so good that many Linux newbies successfully
8 build an LFS system without knowing what they're doing, and when they finish
9 the book, they just stare at the console wondering what they should do next.
10 If you are in this situation, this hint will help you.
12 HINT:
13 THIS HINT IS IN THE PROCESS OF BEING WRITTEN. IT IS NOT COMPLETE.
15 TABLE OF CONTENTS
16 =================
18 Changelog
19 1. Introduction to Linux
20 2. Basic vi commands
21 3. Resources
24 Changelog
25 9/29/02 [Nathan Ladd]: Changed wording in a few paragraphs
26 9/29/02 [Nathan Ladd]: Added 'moving to lfs from distro' section
27 9/29/02 [Nathan Ladd]: Added 'building packages' section
28 9/29/02 [Nathan Ladd]: Replaced 'Making your prompt look good' with more
29         general 'customizing your system' section.
32 1. INTRODUCTION
33 ===============
35 This whole hint could have been named "Miscellaneous hints", since it follows no
36 particular order. It is a collection of hints that many newbies have requested
37 and solutions to many problems newbies have experienced. For a mini-hint to be
38 added to this, it must only be qualified as a "newbie" hint, that is, it must be
39 normally figured out easily by more experienced users.
41 A newbie, having just finished building his LFS system, doesn't realize just how
42 much he doesn't know. The knowledge involved in building a Linux system from
43 scratch is advanced, but when you reduce the procedure to executing blindly
44 commands, that knowledge is lost. I'm not saying that having a perfect LFS book
45 that can be followed blindly is bad, because it sure isn't for non-newbies. When
46 you understand the commands, following the book is in fact a learning process.
48 Finally, one last note: the goal here is for you to learn to use LFS without
49 anyone else ever having to know that you're a "n00b," so keep that in mind when
50 you consider asking for support on irc or lfs-support (don't EVER post for
51 support on lfs-dev).  You're goal is not just to have a great system, it is to
52 be self sufficient in administering that system.
55 1.a. MOVING FROM WINDOWS TO LFS
56 -------------------------------
58 Normally, Linux newbies are seeking a way to escape from the Microsoft prison.
59 They may be very skilled at using Windows, but are completely lost in the
60 command-line interface (CLI) world. The first step is relearning everything.
62 A common assumption is that there are configuration programs everywhere that you
63 must run to customize your system. Well, stop looking for *cfg*, these are very
64 scarce, and often they don't do the job very well. The major part of those
65 configuration programs only edit or create a configuration file for you. They
66 are not the configuration itself. For example, to setup the X Window System,
67 there is the "xf86cfg" program available to help you. This programs asks you a
68 few questions, and then writes a configuration file based on your choices.
69 Because an option is not in "xf86cfg" does not mean that it is not available. To
70 successfully configure programs, you must edit the configuration file. Fiddling
71 with configuration programs is a bad habit, as it will seldom work and will
72 often give not optimal configurations.
74 There are a few exceptions to this trend. For example, the "iptables"
75 ("ipchains" for 2.2.x kernels) program is used to configure the firewall
76 features of the kernel. To configure a firewall, you must run the "iptables"
77 program at every bootup, with the desired options. The "ifconfig" program is
78 another good example. It is the "winipcfg" of Linux. It is used to setup
79 Ethernet adapters, modems and all other sorts of network interfaces. In general,
80 programs are only used to configure kernel options, and they must be run at
81 every bootup. The kernel doesn't remember anything.
83 Another thing that newbies must relearn is the use of the command line. It will
84 never go away. Even if you install a desktop environment like GNOME and KDE, you
85 will use the command line often. You will eventually find it faster to invoke
86 programs using the command line than by clicking on an icon. Also, don't assume
87 that because something doesn't work in GUI means it doesn't work at all. Often,
88 it's the link between command line and GUI that is broken. Try the command in a
89 terminal, and see if it works.
91 In Linux, especially less dumbed down variants such as Debian and, of course,
92 LFS, the GUI is built on top of the core OS, and is not actually the OS itself.
93 As a newbie, your goal should not be to get away from the command line as fast
94 as possible and then install a desktop environment. You must gain competence at
95 the CLI first and foremost; LFS is about gaining mastery of your system, not
96 having your system master you. After you can work on the command line
97 comfortably, then you'll have gained mastery over any GUI.
99 A general tip: never assume that because you know how to do something in windows
100 it will be done in a similar way in Linux. They are two completely different
101 operating systems, and deal with things completely differently. For example,
102 many newbies see a command somewhere, and try to execute it by typing its name,
103 as they would have done in DOS. Being in the directory containing the command
104 isn't a guarantee that it will work. The PATH variable contains all the
105 directories searched for executables, as in DOS. But the difference is that the
106 current directory (".") isn't included by default (and shouldn't be). Imagine if
107 a user creates a "ls" file in their home directory containing a script that
108 erases the whole hard drive. The user tells the root user about a problem in his
109 root directory. The sysadmin goes into the home directory, executes "ls" and
110 must now reinstall the whole system. See the bash man page for more info
111 concerning the PATH variable.
113 Another thing: do not suffer from the "I'll reinstall, it'll probably work this
114 time" syndrom. I know of only one program that is solved by this tactic, and it
115 is koffice, and I just learned about it today. Normally, it doesn't change
116 anything to reinstall. Everything works the first time or everything doesn't
117 work the first time. Do not lose time building 20 LFS systems, unless you're
118 sure that building a new system is the only solution. Also, the similar syndrom
119 "I'll reboot, it will probably work" is as damaging. You do NOT need to reboot
120 in linux, except to load a new kernel. And even that can be done without
121 rebooting, if you wish to hack a bit. Rebooting is a habit created by Windows.
122 You should never need to reboot after having installed something.
125 1.b. MOVING FROM A DISTRO TO LFS
126 --------------------------------
128 Many Linux distros are becoming almost as easy as Windows to use.  They often
129 boot into a full-blown desktop environment by default, and as such being able
130 to use a newer, more dumbed-down distro such as Mandrake or Lycoris no longer
131 guarantees that you are qualified to handle an LFS system.  Now that you have
132 a working LFS system, it is time to play around with it.  Go ahead and read the
133 previous section if you haven't, as modern distros often emulate Windows'
134 behavior, and carry with them similar problems that one encounters when booting
135 into a CLI.
137 Learn to use basic Unix commands to move around the filesystem (avoid rm for
138 now ;) and learn how to use vim to edit configuration files.  Also, gone are
139 bloated help programs, wizards, and tutorials--you've more than likely had to
140 edit XF86Config before at least once.  There's going to be a lot of that coming
141 your way in the future.  Don't worry, you'll get better.  The key here is to
142 make sure that you learn to figure things out for yourself--sort of like if you
143 were to learn the basics of French, then move to Paris.  You'll be "speaking"
144 Linux in no time.
146 Man pages and google are your friends.  I repeat: man pages and google are your
147 friends.  Use them all the time, because what ever your problem is, man pages
148 and google usually have the answer.  Basically, if you learn the commands in 
149 section 1.d, read the vim section and start editing your config files by hand,
150 and you go to man and google for your problems, there's a good chance no one
151 will ever have to know that you're a "n00b."
154 1.c. WHERE AND HOW TO GET INFORMATION
155 -------------------------------------
157 Programs that work out of the box are becoming more and more common, but the
158 majority need a user setup phase. You must not be afraid to read documentation.
159 Often newbies are discouraged by the size of the documentation and the
160 technicality of it. Often you don't need to read all of it. Find the section
161 corresponding to your problem and only read that one. Never ask a question
162 before having read the documentation. You'll learn more and you won't waste
163 others' time asking stupid questions.
165 Ususally, the documentation related to a certain command is found in a man page
166 (short for "manual page"). You can access the man page of any command by typing
167 "man <command name>". Reading the manpage should be the first step when you have
168 a question. They are formatted specially, and reading them can be hard at first.
169 Do not despair.
171 Another good place to find help is in the HOWTOs. You can find these famous
172 HOWTOs at www.linuxdoc.org. They can be very helpful, and are intended for
173 newbies, unlike man pages.  Also, learn to use google to find answers to your
174 problems.  A lot of the time the links google returns will be references to
175 mailing list archives and threads.  These can either be gold mines or dead
176 ends, learn to use your best judgement.
179 1.d. USEFUL COMMANDS
180 --------------------
182 Usually, commands are in this form:
183         <command> -<one-letter argument> --<multi-letter argument> <target>
184 What you can see here is that the command is the first word on the line. Then it
185 is optionnally followed by arguments. Usually one-letter arguments are preceded
186 by a single '-', while multi-letter arguments are preceded by double '-'. There
187 are a few programs that use a single '-' with multi-letter arguments though. You
188 can often use "<command> --help" to see a summary of the available parameters.
189 These are of course explained in greater detail in the man page. Don't forget
190 that everything is case-sensitive in Linux.
192 pwd:
193         This command prints the current directory. This is seldom used, since
194         the current directory is usually included in the prompt. See below for
195         an explanation of how you can customize your prompt.
197 cd <directory>:
198         Changes the current working directory to another directory. To go back
199         up a level, you type "cd .." Don't type "cd.." as you could do in DOS,
200         it won't work. ".." means "the directory above the one I am in" and "."
201         means "the current directory".
204         This lets you know what files are in the directory. A few nice options
205         are:
206         --color=auto
207                 The files are color-coded. You'll probably want to enable this
208                 every time you run ls. To do this, you can create an alias to
209                 the ls command, like this:
210                         alias ls="ls --color=auto"
211                 You will also probably want this to be enabled every time you
212                 login. There are two files that are run every time you login
213                 (much like AUTOEXEC.BAT). They are different, but for now we'll
214                 forget about that difference. In your home directory, create the
215                 ".bashrc" and ".bash_profile" files. You can also have one be a
216                 symlink to the other. Also, since I have pretty much the same
217                 configuration for every user, I use a general file
218                 "/etc/profile" and I add a line like this in every .bashrc:
219                         source /etc/profile
220                 This causes the "/etc/profile" file to be loaded.
221         -h
222                 The file sizes are human-readable.
223         -a
224                 Files beginning with a dot (".") are shown. Normally they are
225                 hidden. Files beginning with a dot are normally used for
226                 configuration files in your home directory.
227         -l
228                 Not only the filenames, but the file permission, owner, group,
229                 size and dates are shown.
232         This copies a file, like the DOS command "copy". To copy files and
233         directories recursively, use the -R option.
236         This moves a file. If you are wondering how to rename a file, you have
237         found your command. Just use "mv <old_filename> <new_filename>".
239 mkdir:
240         This creates a new directory.
243         Removes files. Very handy in root's hands. Useful options:
244         -r
245                 Deletes files recursively, and the directories too.
246         -f
247                 Does not ask questions, and uses every single bit of privilege
248                 you have to successfully delete the file.
249         -i
250                 Runs in interactive root. This way of using rm is useful when
251                 you are root: in this way, you are asked for confirmation for
252                 every file you want to delete. This is the default in many
253                 distributions, and is not a bad idea to put as an alias.
256         This changes your identity. It is used mainly for temporarily being
257         "root". The default user is root, so calling "su" without parameters
258         will ask you for the root password. A nice way of not being asked for
259         the root password every time, assuming you always use the same user
260         name, is putting this line in the "/etc/suauth" file:
261                 root:<the name of the user you use to su>:NOPASS
262         Also, if you're paranoiac, you can use this line:
263                 root:ALL EXCEPT <the name of the user you use to su>:DENY
265 grep:
266         A bit more advanced command, grep is used to find lines that contain a
267         certain expression in a file. For example, if you want to find the word
268         "pwd" in this hint, you'd type:
269                 grep pwd newbie.txt
270         grep would output all the lines containing the pwd expression. Go ahead,
271         try it!
274 2. BASIC vi COMMANDS
275 ====================
277 The most popular editor is vi. LFS installs vim, an iMproved version of the
278 original vi. vi is very powerful, but can scare you at first because it does not
279 have a pretty interface like the Microsoft "edit" piece of shit.
281 You start vi like this (duh!):
282         vi <file>
284 If you want to insert text, a very commonly used "feature", you just press the
285 "i" button and then you can type. You'll see at the bottom that vi is now in
286 "-- INSERT --" mode. You can exit that mode by pressing the "ESC" button. When
287 you press escape, you exit from any mode you were in, and you can use other
288 commands. You usually start commands by pressing the ":" button, and then type
289 the command. Some useful commands:
292         Saves the file.
295         Quits vi. If you have not saved the file, you must use ":q!", which
296         tells vi that you really mean it.
299         A combination of the above commands. It saves and quits.
302         This deletes the whole line that your cursor is on.
304 <number>d
305         This deletes <number> lines, starting from the current, and going down.
307 :<number>
308         Transports to line number <number>.
311         When you "dd" a line, it is copied into a temporary buffer. Pressing P
312         pastes it above the current line. This way you can move lines around.
315         Undo.
318         Allows you to type some text which will be searched for in the file.
321 3. BUILDING PACKAGES
322 ====================
324 Generally, package building takes the following form:
326 ./configure && make && make install
328 Numerous options can be appended to ./configure and make.  One such blip is the
329 PREFX= option, which is used heavily in LFS and BLFS (see RESOURCES).  It lets
330 you configure where you want the package to go.  There are tons of options to
331 use, so check the packages README files before you have a go at installing them.
332 Also, check out the Software Building Howto at www.linuxdoc.org.
334 When you are told to apply a patch, you are being asked to apply a set of
335 changes to the source tree in order to (presumably) build the package onto LFS
336 properly.  There are a lot of options to patch, so check out the man page.  If
337 you just want to apply the thing and get on with it, cd into the top of the
338 source tree and type:
340 patch -Np1 -i whatever_the_patch_is.patch
342 When packages fail to build, you have a great opportunity to search google and
343 find out if the same problem has happened to others.  If not, and you feel the
344 need to resort to getting a person to donate time to you, describe the problem
345 to the best of your ability.  Since chances are you might come off as a newbie,
346 let the console output do the talking, and paste the last 20-ish lines of
347 output for them.  Then tell them if you've done anything unusual (especially if
348 you've deviated from the book or a howto in any way).
351 4. CUSTOMIZING YOUR SYSTEM
352 ==========================
354 The /etc directory contains all of your configuration files.  In the first part
355 of the BLFS book (see RESOURCES), there are some tips on customizing your login
356 and input device.  There are also a number of hints that describe how to work
357 with all sorts of files in the /etc directory, such as /etc/inittab and
358 /etc/issue.
360 Make sure you've learned the basics of, and feel comfortable with using, vi(m).
361 If you chose to install a different editor, make sure you can use that well.
362 Text editors are novelties in Windows, and are seldom used in modern distros
363 since GUI configuration tools are preferred.
365 Many /etc config files have their own manpage.  Be sure to check them out.
366 Google will likely return sample files, explanations of files, and helpful tips
367 for these files.  Don't be afraid to get your hands wet and poke around; just
368 be wary of the more critical files such as /etc/inittab.  Learning by doing is
369 what LFS is all about!
371 The following files are covered in the BLFS book
372 /etc/issue      Customizes your login prompt
373                 Your login prompt is what gets displayed before you type in
374                 your user name/pass.
375 /etc/profile    LFS (and all Linux distros) use bash as the shell (like
376                 COMMAND.COM in DOS).  This file customizes bash.
377 /etc/inputrc    The keys you press like control, alt, backspace, etc., all get
378                 interpreted by the shell according to this file.
379 /etc/vimrc      This is the configuration file for vim, your friendly UNIX text
380                 editor.
383 /etc/inittab    The program init handles booting and shutting down.  When the
384                 kernel is finished loading, it always looks for and runs a
385                 program called init.  init runs bootscripts and then starts
386                 virtual consoles that in turn use the /etc/issue file to
387                 display a login prompt.
389                 inittab can be configured to use more than six consoles, and
390                 you can even run console applications in their own terminal!
391                 There is a great hint for this file.
392 /etc/rc.d/*     The bootscripts go here; there is an excellent explanation of
393                 how they work in the LFS book.
394 /etc/X11/       Your X configuration file will sit here.  There are other
395   XF86Config    config files that live in this directory for things like font
396                 rendering.  Be sure to check relevant manpages.
399 5. RESOURCES
400 ============
402 To get info, you can always check www.linuxdoc.org. There are quality guides
403 there that you should seriously consider reading. The HOWTOs are of lesser
404 quality, but you can often find gems in them.
406 Newbies often ask others where they can find software X. Almost every piece of
407 software written for linux can be found on freshmeat.net. If it doesn't contain
408 it, you can also take a look at appwatch.com.  Also, check to see if there's a
409 hint.  Finally, Beyond Linux from Scratch book, hosted at
410         http://beyond.linuxfromscratch.org
411 is a huge help for people who want to put new packages on top of the stock LFS
412 distribution.  Be warned, however, that there are also copious amounts of
413 copy-n-pasting in BLFS, so graduate from "newbie" status before you install a
414 fancy GUI.
416 If all else fails, there's always that excellent Google search engine, which
417 has a linux section at http://www.google.com/linux (you have been using it,
418 haven't you?)
420 Also, IF ALL ELSE FAILS, don't be afraid to come see us on IRC in the #LFS
421 channel on the irc.linuxfromscratch.org server. But don't ask supid questions
422 or else we'll use the clever backdoor in LFS and delete all your MP3s ;)