"Learning Linux isn't easy, but its power and customizability make it worth the effort" - Linus Torvalds
1.1 What is Linux?
Linux is a powerful multi-tasking multi-user Operating System, based on Unix, that comes with a huge collection of free
software. This includes a free Web Server, free c/c++ development tools, a free implementation of the X Window System, and much more. It
runs on a wide range of hardware, including intel (3456)86, DEC Alpha, Sun Sparc, M68000 (Atari,Amiga), MIPS and PowerPC. It is estimated
that between 10 and 20 million people worldwide are using Linux.
The term 'Linux' itself generally refers to one of two things, depending on the context. Either it refers to just the Linux
kernel itself, originally developed by Linus Torvalds (and named after him), or it is used to refer to an entire system running Linux as
it's kernel - although technically most programs running on the system aren't 'Linux' programs as such, as most will also compile and run on
other Unix systems (and sometimes on Windows.)
Editor's Note Jul 2020: A significant functional subset of Linux is now also available running natively on modern Windows 10 systems, in the form of the Windows Subsystem for Linux.
1.2 What can you do with Linux?
Here is a brief list of some of the uses of linux:
Personal home/work desktop system (including Internet access, read email, browse web with Netscape or Lynx etc.)
Development workstation - typically Linux comes with C/C++
compilers (such as gcc/g++), makefiles, IDE's (e.g. KDevelop), as well as tools such
as git, subversion, CVS for managing large multi-developer projects.
Office Tasks and Word Processing There are free Microsoft Office alternatives like LibreOffice that include word processing, spreadsheet functionality and more.
Multi-user Unix/NT server. Network serving includes nfs,
samba (Windows networking) and Netware, as well as DHCP/WINS
server capabilities. Also dial-in access.
Internet/Intranet server (including web, ftp, telnet,
netware services, NT file and print share services, sql, appletalk,
email server and more.) It is estimated that between 20 and 30 percent
of Web servers on the Internet are running Linux.
Router Linux can turn "obsolete" hardware such as
a disk-less 486 into a cheap router to connect LAN's. (For more
information on how to do this, see the Linux Router Project at linuxrouter.org [now defunct].)
Database server, using either a free SQL server (mysql or
postgresql), or something commercial like Oracle.
Media server Use media center software like Kodi to serve home entertainment (e.g. movies) to a TV/monitor or other devices in your home.
Graphics creation/photo editing - there is a free (source
code available) Adobe Photoshop-like program called GIMP (GNU Image
Manipulation Program, gimp.org) which has many
powerful features such as scripting.
3D graphics modeling/rendering Applications like Blender (which is free) allow you to do 3D graphics modeling and software rendering.
Linux has been growing fairly steadily since
it's creation in 1991, and shows no signs of slowing down.
1.3 What does Linux cost?
Linux is free. It costs about the price of printing
and distributing a CD, but since it's free you may lend someone else's
Linux CD to install it, or use one CD to install Linux onto multiple machines.
You can also download it off the Internet,
or install it off a network over an NFS connection. Factors like this
make it difficult to estimate the number of users of Linux.
1.4 How can it be free? Surely if it's free it must be junk?
Not really. For a variety of reasons, OpenSource software
is often of a very high standard. There are pros and cons though to both
proprietary and open models of software development. One advantage of
the open approach is that there are a great many more programmers who can
spot bugs in the code. One of the disadvantages is that projects sometimes stagnate -
if the creator of the project no longer has time to maintain a project, or moves on
to other things, then sometimes a project can remain relatively "stagnant" for quite a long time
before somebody else takes over, as happened with the GIMP. Of course, commercial software
often also stagnates, but normally for completely different reasons (e.g. not enough
competition.) An advantage of the open approach, for end users, is that it is far far harder
for the software to have hidden "trojans" - a lot of commercial software has in recent years
been found to have hidden functionality that uploads personal information about its users to
the company, for example. Another user disadvantage of the proprietary approach is that vendors
often keep standards closed, so that instead of retaining users through the development of quality
products, they retain users through product lock-in. A good example is the Microsoft Word format -
since there are no viable commercial alternatives, users are often forced into an endless upgrade
cycle, shelling out money for new versions simply to be able to continue to work with and exchange
documents they already have.
Very much more can be written on this subject. In fact, very much more *has*
been written on the subject, so I'm going to stop here and give a link
to a long rather well-known document on this topic titled "The
Cathedral and the Bazaar" by OpenSource advocate Eric
1.5 History of Linux
Linux was originally created as a college project by
a student names Linus Torvalds at Helsinki University in Finland. He
began work on Linux in July 1991, and opened the source for
collaborative development of the kernel over the Internet. Since that
time, Linux has grown at a dizzying pace, being used all over the
world by (estimated to be) millions of people, and being developed by
thousands of people spread across the globe. The kernel itself (the
core of the system) is hacked on by about 1 or 2 hundred people
actively, and probably over a thousand have actually made
contributions to it.
1.6 Free Software
GNU, Copyleft, OpenSource, Free Software Foundation, Richard
Stallman. (Mention other free unixes, such as FreeBSD.)
1.7 Linux "Distributions"
Different "flavours" blah blah blah.
1.8 Compared to Microsoft Windows, for the end-user?
Although each new version of Linux becomes far easier
to install and use, Linux is still not as easy to use as Windows for
the computer novice. However, with a bit of knowledge, you can get more out of Linux than you generally can with Windows.
1.10 Why don't you hear about Linux? There must be something wrong with it. One mostly hears about Microsoft Windows.
Linux is not created/backed by a multi-billion dollar
corporation that can afford to spend many millions on heaps and heaps
of advertising/brainwashing campaigns, adverts designed to make you
feel good etc.
1.11 What other options are there?
There are literally dozens of systems around. Here are some of the major options:
There is another "free Unix" called BSD. There are
three varieties, NetBSD, OpenBSD and FreeBSD. [FIXME: get URL] FreeBSD
is used on some very large web servers, for example www.yahoo.com. BSD
was also used to help create special effects for the movie 'The
Another option for the desktop is BeOS, the multimedia OS. [BeOS is now defunct, but is semi-resurrected in the form of Haiku OS »]
And, of course, theres always the Mac.
1.12 Can Linux run games?
Yes, as long as the producers of games support Linux. Many new games,
such as 'Civilization: Call to Power' and Quake3 run on Linux. The percentage of new games
that will run on Linux is likely to increase quite a bit in the next few years.
1.13 Can Linux co-exist with Windows? Can I run my DOS/Windows applications on Linux?
Linux can happily co-exist with Windows on a system,
but both cannot run at the same time. You will be able to
see and use your Windows disk partitions from Linux, but not vice-versa - the only
support I know of for reading a Linux filesystem (in this case ext2)
under Windows is a read-only utility called fsdext2. [Update 2020: There are several other options available now for viewing ext2 filesystems on Windows]
There is some (limitted) support for running DOS/Windows applications
within Linux. For DOS programs, there is a DOS emulator which works fairly well (and can apparently
even run Windows 3.1.) There is also a large project that has been steadily developing for
many years now called WINE (Windows Emulator, or Wine Is Not an Emulator, any of the two).
This project has resulted to date in moderate success in running a number of Windows applications.
Other similar programs to wine include Sun's WABI, and Willows 'twin'.
1.14 Can I run Linux applications on Windows?
Hmm .. I'm not sure what all the options are here. There are X
clients that allow you to run your applications on a Unix server, but
have all graphical input/output on a Windows client running an X
client. Also MS claims Windows NT is Posix compliant .. that may mean
that most Posix Unix apps *should* compile and run on NT, but that
probably won't make X apps run. Unless an X client is running? Not
sure about that.
[Update 2020] Windows 10 contains Microsoft's "Windows Subsystem for Linux" which can compile and run text-based applications, and you can get it working for some X applications. There are also layers like Cygwin that may work for your situation.
Unix and Linux have very powerful command-line interfaces - mastering the command-line can get
you very far, and is extremely useful for tasks such as low-bandwidth remote administration, automating tasks with shell
However, recent new GUI projects such as KDE and GNOME give Linux a powerful windowed user interface.
Although the X Window System itself has been around a while now, these new GUI's go very far towards creating intuitive,
standardized interfaces for applications. Combined with the network interface that comes along with the X Window
System, this makes Linux powerful in both command line and GUI.
Software for Linux
There has always been quite a lot of software available for Linux. However, the past few years has
seen an explosion in the amount of software available. You can now get applications for Linux ranging from Wordperfect
to SAP to GIMP to Quake3 to huge databases, with more companies jumping on the bandwagon daily.
A categorical list of Unix/Linux software is available at http://freshmeat.net/,
along with software announcements.
Linux runs on PC's (from a 386 and upwards) as well as various other system architectures,
such as ARM, DEC Alpha, Sun Sparc, M68000, MIPS and PowerPC.
Why does Linux perform better then Windows?
[David 2020 context note: This paragraph was relevant in the 1990s, but modern Windows systems are not as bad anymore, and these days 64-bit is also a norm.] One reason is that Linux is entirely 32-bit (on an x86
platform), whereas Windows95/98 spends a good deal of it's time in
16-bit code. Swopping the processor between 32-bit and 16-bit modes is
relatively slow, so the more such swops Windoze makes, the slower it
gets. This also makes Linux more stable than Windows9X.
There are probably a number of other reasons, such as methods
of multitasking, memory management etc.
What's wrong with Linux?
There are a few areas in which Linux is currently weak.
One particular area is user-friendliness. Despite all the recent progress made,
Linux still does not have the level of standardization for software interfaces (e.g. standard keyboard
shortcuts) that Windows has.
However, Linux is relatively new, and Linux is
growing fast and furiously. There are thousands of people out there working
to make Linux better.
Because there are a wide variety of distros, different distros also have slightly different ways of doing things, so if you're following instructions on how to do something or how to troubleshoot an issue, the instructions often don't work precisely or need to be adapted depending on your distro, or version etc.
There have also been some what may be viewed by some as design regressions, e.g. 'systemd'.
For the end-user, there are generally two main ways
of interacting with a Linux (or Unix) system - the commandline
console, and X (the X Window System). The commandline is a text-mode
system that gives you a prompt where you can type in commands (like a
DOS prompt.) The X Window System (combined with a "window
manager", more later) provide a Graphical User Interface (GUI,
pronounced 'gooey') for programs; this is similar to Microsoft
Windows, or the Apple Macintosh interface. For people with an aversion
to command-line interfaces (why?), Linux can be configured quite
easily to start up in X.
The commandline and 'shells' [NOVICE]
You may think that the commandline seems like a step
backwards in computing in these "modern GUI days"; but
taking a little bit of time (possibly less than an hour) to learn the
basics of getting around on the commandline is very likely to take
even the novice user a very long way in learning to use the system,
even if he/she very soon ends up spending most of his/her time in X.
A Linux commandline prompt is provided by a program called a
'shell'. This is similar to command.com in DOS, only there is a
greater variety of shells under Linux, each with slightly different
functionality. 'bash' (Bourne Again Shell') is a nice shell to begin
with, and is the default one with a RedHat Linux install. Later on I
will describe how to switch which shell you use.
Tab filename completion: For most shells, when typing a
command at the prompt, you can type the first couple of characters of
a filename and press TAB; the rest of the filename will be filled
in. If there is more than one possible file with those starting
characters, the 'bash' shell will show you a list of available
files. Naturally this works with program names and file names, as
programs are just files.
Command history: Most shells maintain a list of your last
several hundred recently typed in commands. You can move through these
by using the up and down arrow keys.
Login names, passwords, 'root', home directories [EVERYONE/ADMIN]
With Linux each user on the system gets a login name and a
password. Different users have varying amounts of power over what
they can and can't do on a system, what files they can modify
etc. Loosely, there are two main categories of user: (1) "normal
users" and (2) "super users".
Normal user logins have restrictions on what they can and
can't do to the system, to prevent a situation where any user can
destroy important system files etc. (Sidenote: A common
complaint from people who manage large numbers of Windows desktops is
that of programs corrupting themselves by, for example, deleting
important DLL's; and fancy "features" of the currently beta
MS Office 2000 include "smart" auto-recovery by checking on
startup and re-installing missing DLL's etc from the program
CD-ROM. In Unix, this sort of "smart" garbage would not
have been necessary in the first place, since ordinary users could
not delete important files even if they wanted to. In my opinion,
trying to sell such features is a gyp, since the market for them is
an artificial market created by poor design. The same goes for disk
defragmentation software, antivirus utilities, and "crash-guard"
software. The "features" of these types of software all centre around
fixing the symptoms caused by an underlying design problem, rather
than fixing the problem at its source.)
The user with login name 'root' is a super user on a
Unix/Linux system, and can do virtually anything, including
accidentally wipe out every file on the system, along with other
users home directories. For this reason the system administrator
should only log in as 'root' when he/she has serious system
configuration to do, or has to install new applications. Get into the
habit of avoiding using 'root' - don't make the mistake of waiting
until you've accidentally deleted everything on the system.
Each user gets a 'home directory', which is their own
personal subdirectory and disk space where they can put their files
in. File and directory 'permission' bits can be set on files and
directories to control which other users on the system may see which
files of yours. This is very handy if you want to keep your personal
files away from prying eyes on a home system that others use. The
exception to this is the root user, who can see any file he/she
wants. Make sure you have an ethical administrator.
user groups: (explanation of user groups ..)
If you are the only user who will work on a system, then you may
consider using 'root' as your login for general use. This sometimes
makes life easier, especially for a newbie, since some services
sometimes have to be explicitly set up to allow ordinary users to use
them (for example the DOS emulator, DOSEMU). Bear in mind that (a)
this is definitely out if you're administering a multi-user system
such as a company network, and (b) using root opens you up to a whole
bunch of risks, such as accidentally wiping out important system
files; and, if the majority of Linux users used 'root' for their
logins, Linux could become susceptible to viruses. Currently I do not
know of a single virus for Linux, and avoiding 'root' makes it nearly
impossible for viruses to spread.
For systems with limited disk space, user 'quotas' can be set to
limit the amount of space each user can take up.
Use the 'adduser' program to add users, or if you're
using RedHat you can use the Control Panel's user configuration
manager in X. (You must have root 'rights', which normally means
having logged in as the super user, or more commonly having used
su (substitute user) to switch to root - more on 'su' later.)
For the more macho, you can also add users by directly typing
entries into the /etc/passwd file. Make sure you know what you
File naming is case-sensitive on Unix/Linux. This means
that 'Readme.txt' and 'readme.txt' would be
considered two different files.
DOS uses backslash '\' to separate directory names (eg
'C:\WINDOWS\'). Unix uses a forward slash '/' (eg '/usr/X11R6/bin/').
Permissions: If you 'ls -la', the left-most column will
have 10 characters, looking something like '-rwx-r-xr-x'. Here
is a brief overview of what these characters mean:
Column 1 indicates the type of file. The most
common types are: '-', a normal file; 'l', a link to another file;
and 'd', a directory.
The next 9 columns are divided into three groups of three,
indicating permission for 'user', 'group' and
'other' respectively. Each group has permissions 'rwx', for
read, write and execute. (Read and write are self-explanatory;
execute controls whether or not a user may execute that file
(presuming the file is a program), or in the case of a directory,
whether or not a user may change into a directory.)
Columns 2-4: rwx user permissions. This controls
what the owner of a file may do to it.
Columns 5-7: rwx group permissions. These control
what members of the 'user group' to which the file belongs may do to
Columns 8-9: rwx permissions for everyone else (known as
"other" or "world".).
There are no 'drive letters' on Unix (such as 'C:' and 'A:' on
DOS.) Unix filesystems have only one single directory tree, rooted at
'/', and all 'drives' fall into subdirectories of this single rooted
filesystem. So the top-level directory would be just '/' (sort of like
C:\ in DOS), and any other 'drives' (such as the cdrom drive) would
fall into subdirectories, which you can choose (eg /cdrom or
/mnt/cdrom are typical places to find the cdrom files.) (I 'mount' my
DOS drives C:, D: and E: under the directories /c, /d and /e
Every subdirectory has two 'special directories', "." and
".."; these refer to "the current directory" and "this
directories parent directory" respectively.
Filenames beginning with a fullstop (".") are considered
by convention to be hidden files. 'ls -l' or 'ls' won't show
them, but 'ls -la' will. (Sidenote: There is a Windows
Explorer bug in Windows 95 that stops you from creating new files or
folders with names beginning with a "." - if you try, it gives you a
message box telling you you must type a filename!)
[MOSTLY ADMIN]: The commands mount and umount are
used to add and remove filesystems from the filesystem hierarchy. For
example, if /dev/hda1 is my Windows partition, I can 'mount' it into
/c by typing 'mount -t vfat /dev/hda1 /c'; '/c' here would be what is
called the 'mount point', and this directory must already
exist. 'umount /c' would unmount the filesystem from /c. It will not
unmount if it is in use by any programs. This is the standard way to
view cdrom's; you can mount the CDROM by inserting a disk and typing
'mount -t iso9660 /dev/cdrom /cdrom'. The file '/etc/fstab' contains
a list of filesystems that will automatically be mounted when the
system boots. If such an entry exists in /etc/fstab, then the above
commands can normally be shortened to just 'mount /c' and 'mount
[MOSTLY ADMIN]: It is possible to set up 'automount' daemons that
will automatically mount cdrom's, floppies etc into the filesystem
when they are required.
There are several 'standard' subdirectories which are typically
found on all Unix/Linux systems, with mostly subtle differences
between systems. They are as follows:
/etc: System configuration files for the local machine.
/dev: Special "device" files that are used to access hardware devices on the local machine. Eg, /dev/fd0 would be a file corresponding to your floppy drive; /dev/audio would be your sound card output.
/var: Files that change and store information pertinent to the current state of the system; log files are typically found here for example (in /var/log).
/bin: Fundamental executable files that are needed to boot up the system are stored here, such as 'mount'.
/sbin: Fundamental Super-user (eg root) executables.
/home: Users' home directories are stored under here, eg '/home/dave'.
/root: This is the super-users home directory.
/usr/bin: Binaries (executables); contains most user commands
/usr/sbin: Super-user binaries.
/usr/lib: Libraries for programs/packages.
/usr/local: Locally installed applications, libs etc.
/proc: The files in this directory aren't real files on the disk; they are 'pseudo-files' that can be read to obtain various bits of information pertaining to the system.
/tmp: Temporary directory. Normally any user can write to this directory.
/lib: Fundamental libaries (shared .so and static .a).
There are others as well. There is a published "standard" for the
directory hierarchy, which is actually more of a recommendation than a
standard. It is called fhs (filesystem hierarchy standard);
detailed information about it can be found at http://www.pathname.com/fhs/.
Getting around on the commandline [NOVICE]
cd: change directory. Just typing 'cd' should change to your home directory.
ls: list contents of directory (like DOS DIR)
ls -la: list all files, long (detailed) format; equivalent to 'DIR /A' in DOS.
mv: move or rename files (MOVE,REN in DOS)
rm: remove files/directories (DEL in DOS) (use with caution)
mkdir: make directory (MKDIR,MD in DOS)
mkdirhier: make a directory tree (eg mkdirhier /blob/flob/glob)
rmdir: remove directory (RD in DOS)
pwd: print working directory (shows you current directory) (CD,enter in DOS)
chmod: change permission bits, to change who may/may not read/write to a given file or directory. (ATTRIB in DOS)
chown: change file 'owner'; on a Unix filesystem each file is "owned" by a specific user.
chgrp: change file 'group'; users belong to 'groups'. This changes the 'group' associated with a file.
You can specify multiple commands to execute at the command line by separating them with semicolons.
Some more commands [NOVICE]
df: Summarize free disk space.
du: Summarize disk usage, eg amount of space taken up by a directory.
echo: Whatever string you give this, it echoes. 'echo Windows sucks' will dump the string 'Windows sucks' to the console. (Technically, the output goes to 'stdout' -> more about that later). 'echo' also exists in DOS.
cat: 'Cat' (concatenate) the contents of listed file(s) to stdout. (Dumps file contents to screen, typically.)
sort: Sort whatever input you give it, line by line.
more: Displays files to the screen, pausing after each pagefull of information. (Like DOS 'type | more' command combo)
less: Does 'more or less' (no pun intended) the same as the 'more' command.
Finding help on Linux [EVERYONE]
Linux comes with truckloads of documentation. Much of
the documentation is far more detailed and more technical than the
'click on the File menu with the left mouse button' type help you get
in Windows, which almost seems designed to try to keep users ignorant
about their system.
The tricky part about Linux is *finding* the
documentation you need. The first command you'll need to know is
'man' command - short for 'manual' - to get a 'man
page'. This is the "help" command in Unix. E.g. 'man X' will
give you quite a good basic overview of the X Window System. 'man ls'
will tell you anything you need to know about the ls command. 'man
printf' will give you man page info on the 'c' language printf
routine. 'man -k keyword' will search the man pages for the given
keyword. Man pages are divided into 'sections', to give multiple man
pages per command, e.g. there are two different 'printf' man
pages. 'man 4 commandname' will give you section 4's man page for
commandname. You will normally see the section name in brackets after
the command name in a man page, such as strings(1). Man pages
are displayed by default through the program 'less'; a few main
keyboard shortcuts for this: 'q': quit. 'SPACE': page down. 'b' page
up. 'Enter': move one line down. 'g': top of man page. 'G': bottom of
man page. There are X GUI viewers for man pages, if the command-line
aint your thang.
'whatis' command to get a one-line description of a
command. You may have to create the 'whatis' database initially, or
every now and again if you install new stuff. Use
'[/usr]/sbin/makewhatis' to do this. 'apropos' search
the whatis database. A default RedHat install is set up to use crond
(a process scheduler) to (re)create the whatis pages once a week; but
this fails if your system is off at the designated time (see
/etc/crontab). This may seem silly for a desktop OS, but remember that
Linux was originally designed as a server OS, so this was designed
with the idea that the machine would be up 24/7.
There is lots of documentation in /usr/doc. Also see
[TIP] Avoid asking other people for help unless you're
stuck and you've properly read the documentation first. There is
nothing worse than someone who keeps asking you questions just because
he is too lazy to read the documentation. If you ask questions without
reading the manual first, you might get a reply 'RTFM': 'Read The
Flipping Manual'. The exception to this is if you personally know
someone who doesnt seem to mind answering all your questions.
[TIP] An archive of all newsgroup posts ever is kept at http://www.dejanews.com/ - before
asking on the newsgroups, do a quick power-search there for keywords
related to your problem. You can quite often find the solution to your
problem already in the archives. (Sidenote: Dejanews is powered by
Accessing DOS disks [EVERYONE]
[Editors note 2020, this paragraph should be updated to discuss FAT32, NTFS support etc.]
It is possible to use the normal commands such as
'mount' and 'umount' to manipulate files on floppy disks; however, if
the floppy disks are DOS disks, then it is normally far more
convenient to use a set of commands known collectively as
'mtools'. Mostly, these are commands that are clones of DOS
commands, but with 'm' added to the front of the name; and usually you
have to replace '\' with '/' when specifying files. Some of these
commands are 'mcopy', 'mcd', 'mdir', and 'mdel'.
Process management: [EVERYONE]
Linux is multitasking; that is, it can run many
programs concurrently. Each program that runs exists as a
"process", and each process has associated with it a
unique ID number (called the PID, or 'process ID') that can be used to
manipulate processes. Processes can start other processes; then the
started process will be the 'child process' of its 'parent
process'. Here are a few commands to help you manage your processes.
ps: List processes. Used to list programs
running on the system. 'ps' on its own lists your current shells
processes. 'ps ax' lists all the processes on the system. 'ps f' lists
processes hierarchically. 'ps u' displays the user names of the owners
of processes. 'ps ufax' for all of the above.
kill: This is used to kill running
processes. Only the superuser can kill other peoples processes. 'kill
-KILL [pid]' will destroy the process with ID number [pid]; eg 'kill
-KILL 3456'. 'ps' can be used to obtain the process ID number. 'kill'
is also used to send signals other than "kill" to processes; use 'kill
-l' to obtain a list of available signals.
killall: This kills all processes that have a
given name. For example, if you wanted to kill all instances of
'netscape' that are running, you could type 'killall netscape'.
nice,renice: These are used to modify the
priority of processes. The priority value sets how much CPU time a
top: Display a constantly updating list of
running processes, sorted (by default) by how much CPU time each one
is taking. This program can also be used to do things like renicing
More advanced (but not difficult) commandline stuff [INTERMEDIATE]
Wildcards: Use of wildards (* and ?) work slightly
differently internally to those in DOS, and understanding how they
work in Linux will facilitate your use of them. Wildcard expansion is
done by the shell, when you type in a command, and not by the command
you typed. For example, if you type 'ls *.txt', the shell (such
as bash) would *first* find all files ending in .txt in the current
directory, and then expand the command before running it, for example,
it may produce: 'ls readme.txt phonebook.txt', and then run that. This
process is known as 'globbing'. Try stuff like 'echo *' as an
alternative to 'ls' to get a feel for this.
Redirecting output: The text that a command outputs (eg
'ls') doesn't have to go to the console (command-line); it can be (1)
dumped into a text file, (2) appended to the contents of an existing
text file or (3) given to another program as that programs input. To
redirect the output of 'ls' into a text file, type 'ls >
textfilename'. Note that this will overwrite the contents of
'textfilename'. You can append to the end of that file by typing
'ls >> textfilename'. (Note that these work in DOS
Redirecting input: In any unix/Linux program that asks for
input from the keyboard, that input can be given from a file
instead. This is known as 'redirecting input' and the syntax looks
like this: 'ls < textfilename'. The contents of
'textfilename' will appear to 'ls' be keyboard input. (Note that this
is a bad example, because ls doesn't take any keyboard input anyway.)
(This also works in DOS)
Redirecting output into another program (piping): The
output of one program can be used as input to another program. This
makes use of the symbol called a 'pipe', found above the '\' on the
keyboard, which looks like this: '|'. I can run 'ls' and then 'pipe'
the output of 'ls' into the 'sort' program, like this: 'ls |
sort'. This should sort the output of 'ls' and display
that. (A slightly more limited form of this also works in DOS). There
is no practical limit to the number of times you can redirect output;
if the output of 'ls' fills too much to see on one page I can 'pipe'
it through 'more': 'ls | more' or 'ls |
sort | more'. This is a simple but very powerful concept,
as you will no doubt begin to see.
Some slightly more advanced commands [INTERMEDIATE(?)]
grep: Stands for 'global regular expression
parser'. At it's most basic, this is simply a program that searches
for strings inside files. This is a simplification: it actually
searches for what is called a 'regular expression'. A 'regular
expression' allows you to more advanced searches than just for
strings, by using a special specifying format. 'grep' also works with
input redirected from other programs. If I generate a long-format
listing of files using 'ls -la', I can search that listing for
specific strings by piping the output into 'grep'. Try 'ls -la | grep
"ofi"', and you should get only the 'ls' listings that
contain the string 'ofi'. An example of a more advanced regular
expression is "^d". The "^" character means
'beginning of line'. So I can list all sub-directories in the current
directory by using 'ls -la | grep "^d"'.
su: 'substitute user'; while working as one
user, you can "become" another user on the system. The
default behaviour of 'su' is to try become root (requires password)
.. this is useful if, for example, you're working under your regular
username, and need to do something administrative like install an
application in /usr/bin; then you can quickly 'become' root with su,
and use 'exit' to return afterwards.
sed: stream editor ... blah blah
/sbin/ifconfig: Network interface configuration utility, used to add/remove network interfaces, gateways etc. [On new systems, this may have been replaced by the 'ip' command]
/sbin/route: Manipulate the IP routing table. That is, tell the system where to send network packets for the various network interfaces etc.
Editing text files [EVERYONE]
There is a large variety of text editors available
for Linux. The most commonly used ones tend to be the most obscure for
some reason :)
These days, there are a wide variety of user-friendly graphical text editors in Linux.
Sometimes, you need to edit text files when in a terminal - below are some of the major options for doing so.
If you try run one of these and it's not installed, you should usually be able to install it using the package manager of your distro.
In the '90s I mainly used emacs, joe and vi/vim, but these days I mainly use nano.
Terminal-based Text Editors
nano: Reasonably user-friendly terminal-based text editor. Ctrl+g for Help. Ctrl+x to exit. It will prompt to save any unsaved changes.
joe: 'Joseph's Own Editor'. This one is reasonably
friendly. Here is a quick summary of common keyboard shortcuts for
Ctrl+K,H Turn on/off a help window at the top of the editing screen that contains a list of the most commonly used keyboard shortcuts.
Ctrl+u Page up.
Ctrl+v Page down.
Ctrl+a Go to beginning of line.
Ctrl+e Go to end of line.
Ctrl+k,u Go to beginning of document.
Ctrl+k,v Go to end of document.
Ctrl+k,e Open a file for editing. Pressing TAB here gives you a list of files to choose from.
Ctrl+k,d Save current file. Allows you to choose a different name.
Ctrl+k,x Save current file and exit.
Ctrl+k,f Find text.
Ctrl+l Find next.
emacs: Extensible Macro something-or-other. What I'm using to type this document.
Ctrl+h,t Emacs tutorial.
Alt+v Page up.
Ctrl+v Page down.
Ctrl+a Go to beginning of line.
Ctrl+e Go to end of line.
Home Go to beginning of document.
End Go to end of document.
Ctrl+x,Ctrl+f Open a file for editing.
Ctrl+x,Ctrl+s Save current file.
Ctrl+x,Ctrl+w Save current file as.
Ctrl+g Cancel any command. (eg, try Ctrl+s, then Ctrl+g.)
Ctrl+s Find text; find next.
vi / vim: The text editor most likely to be found on any Unix system. Like emacs, it is powerful, but somewhat obscure. It is not user-friendly. My strategy on 'vi' is to just know how to do basics like edit, save and quit, in case I find myself on e.g. old Unix systems that don't have more user-friendly alternatives available (or in a situation like git's default branch merge opening a vi text editor to edit the comment), but not to use it for day-to-day editing.
i go into insert mode to insert characters in document
Esc exit 'insert mode'
d delete character (when not in insert mode)
Esc, :wq save and quit
Esc, :q! quit without saving
Hmm .. more coming.
There are various other text editors, many of them which run in X,
and many of them far more friendly than the above ones. Some examples
are 'cooledit' and 'kedit'.
Scripting [INTERMEDIATE - ADVANCED]
Hmmm .. scripting ... awk .. shell scripting .. Tcl/Tk
.. etc. Large topic this.
Linux source code, re-compiling the kernel etc. [ADVANCED]
You don't have to recompile the kernel to use Linux, as I have heard some people claim. A few years ago, you often had to recompile to (say) get support for your soundcard, but these days Linux distributions such as RedHat seem to be set up with almost everything you could need in a kernel or as kernel modules.
That said, there are definite benefits to recompiling a kernel; such as getting the latest optimisation features (and sometimes bugs) in a newer gcc, or recompiling an optimised kernel for your specific architecture, or generating an extremely streamlined, efficient kernel with the minimal services required. So for the power-user, the option is there, and it isn't very difficult either.
You should be able to find the source code in /usr/src under 'linux' or 'linux-2.0.34' or whatever. A safe bet is to 'cd /usr/src/linux' and type 'make menuconfig' (after reading the README, of course.)
Here is a basic summary of the process of recompiling the kernel: (This is just a summary, read the actual
README. I assume you know a bit about lilo and make etc. If you don't, then
I doubt you're the sort of user who would be recompiling their kernel anyway)
cd /usr/src/linux (change to linux source directory.)
make menuconfig (select what you want in the kernel, and available as kernel modules.)
make clean; make dep (something like this; when you exit 'make menuconfig' it will tell you.)
make zImage (Compile the kernel. Places the kernel image file in ./arch/i386/boot)
make modules; make modules_install (Compiles kernel modules, places them in /lib/modules/"kernelversion")
cp arch/i386/boot/zImage /boot/vmlinuz2.0.34 (Copy the kernel image file into the /boot directory under the name 'vmlinuz' with the version number attached. The actual filename can be anything you want, but that is the "standard" way of doing things.)
joe /etc/lilo.conf (Use joe/vi/emacs/editor-of-your-preference to edit the LILO boot manager configuration file. Add a new entry (typically by copying an existing one and modifying it) for your new kernel image. Leave the previous one there, in case there are problems with the new one, so that you can still boot the old one.)
/sbin/lilo (Run lilo to update the MBR (master boot record) with the new information.)
"You must now restart your computer for the changes to take effect" .. hehe .. ctrl+alt+del, and enter the label you gave for your kernel at the LILO: prompt. You should keep a boot disk handy in case something goes wrong.
Linux configuration [INTERMEDIATE - ADVANCED]
Generally, the directory /etc contains system configuration stuff, useful to root.
/etc/profile: a script executed for each login to the system. (Note that xterms must be run with '-ls' to tell them to process this file.) This file can be used to set paths, aliases and various environment variables, such as CLASSPATH or MOZILLA_HOME.
/etc/motd: 'message of the day': a file all user's see when they log in.
/etc/HOSTNAME: Set to the network name of the current system (used even if you're not on a network.) This could contain www.linux.org (if thats who you are), or for a computer not on the Internet, this could be something simple like 'amethyst' or 'darkstar'.
/etc/exports: A list of directories to make available via NFS over the network.
/etc/fstab: 'File system table': A table of filesystems to mount into the root filesystem at boot-time; for example if you have a dual-boot Windows/Linux PC you could add your FAT filesystems here. Swap partitions are also set up in this file.
/etc/hosts: A list of hosts on the LAN or WAN, and their IP addresses.
/etc/ld.so.conf: A list of directories to look for shared libraries in. You should run /sbin/ldconfig after changing this. Be careful when adding entries here, you can really mess things up.
/etc/lilo.conf: LILO boot manager configuration file. You should always remember to re-run 'lilo' after changing this file.
/etc/passwd: The password file. This contains a list of users on the system, their passwords, home directories and shells, what group they belong to etc.
/etc/shadow: Sometimes, for added security, passwords are 'shadowed'. The passwd file will contain a special character in place of the password that tells the system to look in /etc/shadow for the password.
/etc/group: A list of groups on the system and their group ID's.
/etc/rc.d/: This is a directory containing startup/initialization scripts for system services, ranging from gpm (console mouse utility) to the web server daemon.
Redhat comes with a neato program called 'setup' that can be used to very easily set up several major things, including what startup scripts in /etc/rc.d/ to start up, sound configuration stuff, X configuration stuff etc.
A program called 'linuxconf' can also make your life easier, as well as the RedHat control panel.
X Window System quickstart info [EVERYONE]
My X section is a tad sparse at the moment ...
'xf86config' is a text program that helps you configure your X Window system, by asking you a bunch of questions and then generating a '/etc/XF86config' file. This has to some extent been superceded by the friendlier RedHat X Configurator.
setup: RedHat's setup utility, making xf86config unnecessary; does better graphics card autodetection, is friendlier etc.
'startx' on the command line to run X
Ctrl+Alt+Backspace: quick-exit the X Window System
Ctrl+Alt+('+' or '-'): switch actual (not virtual) screen resolution
X always starts in 8-bit color mode (256 colors). How to change that:
Run X with the commandline 'startx -- -bpp n' where 'n' is 16 or 24 or 32 or whatever color depth you want.
To change the *default* color depth, edit the /etc/XF86Config (or /etc/X11/XF86Config) and add the line 'DefaultColorDepth 16' to the relevant 'screen'(?) section.
Booting up straight into the X Window System
Once you have X nicely and stably set up you might like to make your system start up by default in X, like MS Windoze does. For this, use the 'X Display Manager', 'xdm'. 'xdm' will present a simple graphical 'login/password' screen. Then any user (for example your sister or whatever on a home machine) just needs to type in their login name/password and X will load up their particular configuration/window manager/menus etc. Thanks to the design of Linux you can let other members of your family use the machine without worrying about them being able to delete your files, or even be able to *look* at your files (hehe).
(setting default runlevel from 3 to 5 in /etc/inittab=proper way?)
Setting up an X server for clients over a network.
Changing X configuration
/your/home/directory/.xinitrc (change windows manager etc here)
/your/home/directory/.xsession (Xsession?) (startup xterms etc, i think)
Linux Documentation Project (Linux installation and getting started guide. Pretty comprehensive; includes: introduction to Linux, how to install Linux, a Linux tutorial, system administration, the X Window System and networking.)
http://www.linuxfocus.org/ Online magazine, multilingual, excellent high-quality articles ranging from beginner topics to advanced topics.
Alt+F1: Access the K panel main menu (like Ctrl+ESC in Windows/Explorer)
Alt+F2: Run command (a bit like Start/Run in Windows)
Alt+F3: Access current apps "system" menu (like Alt+SPACE in Windows)
Alt+F4: Close current app; same as Windows
Ctrl+ESC: Access task manager (like Ctrl+ESC in Windows/Progman)
Enabling syntax highlighting: Add line
"(global-font-lock-mode 1)" to $HOME/.emacs (This syntax
highlighting only works in X. For syntax highlighted emacs on the
console, try jed instead of emacs.
Background/foreground colors in emacs: Modify
$HOME/.Xdefaults .. add line "emacs*Background:
MidnightBlue", replacing MidnightBlue with the color of your
choice --- color names are found in /usr/X11R6/lib/X11/rgb.txt.
Changing auto-indent C/C++ coding style: Add line
"(c-set-style "gnu")" to your ~/.emacs file, replacing 'gnu'
with the name of the style of your choice. (Use Ctrl+H,M in c mode to
get more help on this, plus available styles etc. I use
Select all and auto-indent: Ctrl-x h; meta Ctrl-\ (same
thing in vi would be ":1,$!indent", meaning run lines 1 to
last-line through the indent program
[INTERMEDIATE] Set hard disk auto power down timeout: hdparm -S 144
/dev/hda (12 minutes, hard disk a) See 'man hdparm' for details. I
put this line in /etc/rc.d/rc.local to set it every time
the PC boots.
[ADVANCED]Adding swap files on the fly The
"standard" way of setting up swap space for Linux is
to use a partition as the swap device. An ordinary file can however be
used (although it will probably be a bit slower than a raw partition,
but is useful if, for example, you suddenly need some extra swapspace,
like when you might be simultaneously running several Netscape
sessions, some ftp sessions, GIMP, a dozen emacs sessions, KDE, wine,
a DOSEmu box, xdoom, StarOffice word processor, and a large project is
compiling in the background while x11amp plays mp3's.) The new
partition file can be created and added to the system via a few quick
commands on the command line, without restarting your computer
(duh). The process is detailed in man mkswap, but here is a
dd if=/dev/zero of=/swapfile bs=1024 count=8192 This creates an 8M
file (8192 * blocksize 1024) called /swapfile.
mkswap /swapfile 8192 This sets the file up for use as a swap
sync Flush any filesystem caches. (Why?)
swapon /swapfile Voila, the swapfile is happily in use by the
system. No restarts necessary. You can have several swapfiles; not sure what
the limits are.
[INTERMEDIATE][TIP]More than 64MB RAM Due to a BIOS limitation, Linux (kernel 2.0 series) won't automatically find more than 64 MB of RAM on PC's (the 2.1 series apparently has this fixed.) In the meantime, you can get around this by adding the line append="mem=128M" to your linux partitions bootup info section in /etc/lilo.conf (and of course re-running 'lilo'.)