TITLE: Basic help for newbies LFS VERSION: 2.4.3 AUTHOR: Simon Perreault SYNOPSIS: The LFS book has become so good that many Linux newbies successfully build an LFS system without knowing what they're doing, and when they finish the book, they just stare at the console wondering what they should do next. If you are in this situation, this hint will help you. HINT: THIS HINT IS IN THE PROCESS OF BEING WRITTEN. IT IS NOT COMPLETE. TABLE OF CONTENTS ================= 1. Introduction to Linux 2. Basic vi commands 3. Resources 1. INTRODUCTION =============== This whole hint could have been named "Miscellaneous hints", since it follows no particular order. It is a collection of hints that many newbies have requested and solutions to many problems newbies have experienced. For a mini-hint to be added to this, it must only be qualified as a "newbie" hint, that is, it must be normally figured out easily by more experienced users. A newbie, having finished building his LFS system, doesn't really know how much he doesn't know. The knowledge involved in building a Linux system from scratch is advanced, but when you reduce the procedure to executing blindly commands, that knowledge is lost. I'm not saying that having a perfect LFS book that can be followed blindly is bad, because it sure isn't for non-newbies. When you understand the commands, following the book is in fact a learning process. Anyway, enough rambling. 1.a. RELEARN EVERYTHING ----------------------- Normally, newbies are seeking a way to escape from the Microsoft prison. They may be very skilled at using Windows, but are completely lost in command-line world. The first step is relearning everything. A common assumption is that there are configuration programs everywhere that you must run to customize your system. Well, stop looking for *cfg*, these are very scarce, and often they don't do the job very well. The major part of those configuration programs only edit or create a configuration file for you. They are not the configuration itself. For example, to setup the X Window System, there is the "xf86cfg" program available to help you. This programs asks you a few questions, and then writes a configuration file based on your choices. Because an option is not in "xf86cfg" does not mean that it is not available. To successfully configure programs, you must edit the configuration file. Fiddling with configuration programs is a bad habit, as it will seldom work and will often give not optimal configurations. There are a few exceptions to this trend. For example, the "iptables" ("ipchains" for 2.2.x kernels) program is used to configure the firewall features of the kernel. To configure a firewall, you must run the "iptables" program at every bootup, with the desired options. The "ifconfig" program is another good example. It is the "winipcfg" of Linux. It is used to setup Ethernet adapters, modems and all other sorts of network interfaces. In general, programs are only used to configure kernel options, and they must be run at every bootup. The kernel doesn't remember anything. Another thing that newbies must relearn is the use of the command line. It will never go away. Even if you install a desktop environment like GNOME and KDE, you will use the command line often. You will eventually find it faster to invoke programs using the command line than by clicking on an icon. Also, don't assume that because something doesn't work in GUI means it doesn't work at all. Often, it's the link between command line and GUI that is broken. Try the command in a terminal, and see if it works. The GUI, in Linux, is intended to speed up execution of certain tasks, not to be easier on the user. If your goal it to get away from the command line as fast as you can and install a desktop environment so that you can finally be able to do your things, then you are wrong. The GUI is not easier. Because a tool has a visual front-end does not mean that it will be easier to understand. Master the command line and you will have mastered the GUI. A general tip: never assume that because you know how to do something in windows it will be done in a similar way in Linux. They are two completely different operating systems, and deal with things completely differently. For example, many newbies see a command somewhere, and try to execute it by typing its name, as they would have done in DOS. Being in the directory containing the command isn't a guarantee that it will work. The PATH variable contains all the directories searched for executables, as in DOS. But the difference is that the current directory (".") isn't included by default (and shouldn't be). Imagine if a user creates a "ls" file in their home directory containing a script that erases the whole hard drive. The user tells the root user about a problem in his root directory. The sysadmin goes into the home directory, executes "ls" and must now reinstall the whole system. See the bash man page for more info concerning the PATH variable. Another thing: do not suffer from the "I'll reinstall, it'll probably work this time" syndrom. I know of only one program that is solved by this tactic, and it is koffice, and I just learned about it today. Normally, it doesn't change anything to reinstall. Everything works the first time or everything doesn't work the first time. Do not lose time building 20 LFS systems, unless you're sure that building a new system is the only solution. Also, the similar syndrom "I'll reboot, it will probably work" is as damaging. You do NOT need to reboot in linux, except to load a new kernel. And even that can be done without rebooting, if you wish to hack a bit. Rebooting is a habit created by Windows. You should never need to reboot after having installed something. 1.b. WHERE AND HOW TO GET INFORMATION ------------------------------------- Programs that work out of the box are becoming more and more common, but the majority need a user setup phase. You must not be afraid to read documentation. Often newbies are discouraged by the size of the documentation and the technicality of it. Often you don't need to read all of it. Find the section corresponding to your problem and only read that one. Never ask a question before having read the documentation. You'll learn more and you won't waste others' time asking stupid questions. Ususally, the documentation related to a certain command is found in a man page (short for "manual page"). You can access the man page of any command by typing "man ". Reading the manpage should be the first step when you have a question. They are formatted specially, and reading them can be hard at first. Do not despair. Another good place to find help is in the HOWTOs. You can find these famous HOWTOs at www.linuxdoc.org. They can be very helpful, and are intended for newbies, unlike man pages. 1.c. USEFUL COMMANDS -------------------- Usually, commands are in this form: - -- What you can see here is that the command is the first word on the line. Then it is optionnally followed by arguments. Usually one-letter arguments are preceded by a single '-', while multi-letter arguments are preceded by double '-'. There are a few programs that use a single '-' with multi-letter arguments though. You can often use " --help" to see a summary of the available parameters. These are of course explained in greater detail in the man page. Don't forget that everything is case-sensitive in Linux. pwd: This command prints the current directory. This is seldom used, since the current directory is usually included in the prompt. See below for an explanation of how you can customize your prompt. cd : Changes the current working directory to another directory. To go back up a level, you type "cd .." Don't type "cd.." as you could do in DOS, it won't work. ".." means "the directory above the one I am in" and "." means "the current directory". ls: This lets you know what files are in the directory. A few nice options are: --color=auto The files are color-coded. You'll probably want to enable this every time you run ls. To do this, you can create an alias to the ls command, like this: alias ls="ls --color=auto" You will also probably want this to be enabled every time you login. There are two files that are run every time you login (much like AUTOEXEC.BAT). They are different, but for now we'll forget about that difference. In your home directory, create the ".bashrc" and ".bash_profile" files. You can also have one be a symlink to the other. Also, since I have pretty much the same configuration for every user, I use a general file "/etc/profile" and I add a line like this in every .bashrc: source /etc/profile This causes the "/etc/profile" file to be loaded. -h The file sizes are human-readable. -a Files beginning with a dot (".") are shown. Normally they are hidden. Files beginning with a dot are normally used for configuration files in your home directory. -l Not only the filenames, but the file permission, owner, group, size and dates are shown. cp: This copies a file, like the DOS command "copy". To copy files and directories recursively, use the -R option. mv: This moves a file. If you are wondering how to rename a file, you have found your command. Just use "mv ". makedir: This creates a new directory. rm: Removes files. Very handy in root's hands. Useful options: -r Deletes files recursively, and the directories too. -f Does not ask questions, and uses every single bit of privilege you have to successfully delete the file. -i Runs in interactive root. This way of using rm is useful when you are root: in this way, you are asked for confirmation for every file you want to delete. This is the default in many distributions, and is not a bad idea to put as an alias. su: This changes your identity. It is used mainly for temporarily being "root". The default user is root, so calling "su" without parameters will ask you for the root password. A nice way of not being asked for the root password every time, assuming you always use the same user name, is putting this line in the "/etc/suauth" file: root::NOPASS Also, if you're paranoiac, you can use this line: root:ALL EXCEPT :DENY grep: A bit more advanced command, grep is used to find lines that contain a certain expression in a file. For example, if you want to find the word "pwd" in this hint, you'd type: grep pwd newbie.txt grep would output all the lines containing the pwd expression. Go ahead, try it! 2. BASIC vi COMMANDS ==================== The most popular editor is vi. LFS installs vim, an iMproved version of the original vi. vi is very powerful, but can scare you at first because it does not have a pretty interface like the Microsoft "edit" piece of shit. You start vi like this (duh!): vi If you want to insert text, a very commonly used "feature", you just press the "i" button and then you can type. You'll see at the bottom that vi is now in "-- INSERT --" mode. You can exit that mode by pressing the "ESC" button. When you press escape, you exit from any mode you were in, and you can use other commands. You usually start commands by pressing the ":" button, and then type the command. Some useful commands: :w Saves the file. :q Quits vi. If you have not saved the file, you must use ":q!", which tells vi that you really mean it. :wq A combination of the above commands. It saves and quits. dd This deletes the whole line that your cursor is on. d This deletes lines, starting from the current, and going down. : Transports to line number . P When you "dd" a line, it is copied into a temporary buffer. Pressing P pastes it above the current line. This way you can move lines around. u Undo. / Allows you to type some text which will be searched for in the file. 3. RESOURCES ============ To get info, you can always check www.linuxdoc.org. There are quality guides there that you should seriously consider reading. The HOWTOs are of lesser quality, but you can often find gems in them. Newbies often ask others where they can find software X. Almost every piece of software written for linux can be found on freshmeat.net. If it doesn't contain it, you can also take a look at appwatch.com. If all else fails, there's always the excellent Google search engine, which has a linux section at http://www.google.com/linux. Also, don't be afraid to come see us on IRC in the #LFS channel on the irc.linuxfromscratch.org server. But don't ask supid questions or else we'll use the clever backdoor in LFS and delete all your MP3s. 4. HOW TO MAKE YOUR PROMPT LOOK GOOD ==================================== So you're tired of that bash-2.04$ prompt? You want one that looks like the one in your original distro? changing the bash prompt useful files (.bashrc, .bash_profile, .bash_logout) /etc/skel