Government Security
Network Security Resources

Jump to content


Linux Faq.

- - - - - perl php tools shell ssh distributed
  • Please log in to reply
9 replies to this topic

#1 shaun2k2


    Staff Sergeant

  • Sergeant Major
  • 348 posts

Posted 14 August 2003 - 12:36 PM

Linux FAQ
By shaun2k2 -

What is Linux?
Linux is an operating system. An operating system is a program-running program; and it also manages the hardware. Linux is multi-user and multi-tasking. That means that it is capable of supporting several users at a time, and running many tasks at a time, respectively. Sometimes we call this "time-sharing". (Note that each running thing is a task. A program can be running several times, simueltaneously. Also, a program (task) can be running other tasks. This is called multi-threading.) Since many users can be using the same operating system at the same time, each person needs an account, unlike DOS and Windows. Each user has a "home directory"; a directory which holds all of that user's stuff. And each user also needs a user name; a name identifying him or her, and a password.

Linux was created by Linus Torvalds, a Swedish-speaking Finn. It is based on Unix (or, more directly, Minix - a PC-based clone of Unix.) I say based because it didn't use Bell Labs' code, the creators of Unix. Linus started ground-up, just like the author of Minix. This is why people say Linux is a Unix-clone or Unix-based. Indeed, Linux was originally written for the PC (Intel x86 micrprocessors), but now runs on everything from a Sparc to a PowerPC. Linux was written in C, maybe in about early-1990s.

Linux manages files in a hierarchical file system. A hierarchy (a data structure, in Computer Science lingo), is a tree structure, starting at the top (as aposed to a real tree) called root, then off there are branches, then at the end of a branch is a leaf (a directory), which can hold other directories (leaves), etc. Unlike a binary tree, there is no limit to how many leaves another leaf can have mushrooming off. Just to avoid confusion, the root of the file system is in no relation to the user "root". But root controls everything, anyway.

Linux itself is something called a kernel. A kernel is the core of the operating system. It controls everything. It offers "services" to other programs, and manages them. There are many elements making up the kernel; for example, the scheduler. The scheduler is probably one of the most important parts of the OS (operating system); it manages what task is being executed by the CPU. A CPU can only actually perform one task at a time; however, it does them so blindingly fast that it appears to be doing several things at once. Thankfully, things which are taxing (e.g. graphics) are often supported by the chip which manages them (in this case, a graphics card). This is also a processor, called a coprocessor. It should now be evident why the scheduler is such an important key in the Linux kernel. It is the reason behind Linux's multi-tasking ability!

Indeed, I said Linux itself is just the kernel. However, many people do not look at it this way. They say Linux is the whole package; the kernel, plus the system software (compilers, interpreters, daemons, shell, command line tools), the applications packages (word-processors, spreadsheets, etc.), etc. Well, all of this packaged together is called a "distribution". Some people, when they say "Linux", mean the shell. This is because of ignorance, put bluntly. It is all they can see. We will discuss all this below.

What is a shell?
The shell is the interface between the user (liveware) and the kernel. We generally, when we say shell, mean the command line (interface), abbreviated to CLI. This is the main and first (and original) way of telling Linux what to do. Many different types of shells exist, e.g. BASH (Bourne-Again Shell, made by GNU, a dvision of FSF - see below), Bourne shell (made by Steve Bourne), Korn shell (made by David Korn), and C Shell. (The first three types are called the "Bourne family of shells". There are many different types of C Shells, but its first author was Bill Joy, who also made Vi and NFS.) Shells are generally boring black screens. With C Shells, you're prompted with "%"; with Bourne-type shells, you see "$". However, if you are root (see below), you see "#" with every shell.

Shells have things called environmental variables. These variables are prefixed with "$" and are generally capitalized. These variables are controllers and information-storers for the shell. When you execute the shell, the shell sets many of these storers to information about you and your computer; for example, your user name, home directory, search path (the place in which the shell searches for a given program, right after it tries to find it in the current directory - working directory), computer name, and SO much more!

Nowdays, the command line is used for commong housekeeping tasks (e.g. deleting, making directories/managing them, managing files, adding/deleting users, and other things graphical user interfaces are not so handy for), and often something else is used to tell the kernel what to do. All will be revealed in due course!

We said there was another way of using Linux. The answer is graphical user interfaces (GUIs). These are just how they sound: graphical environments. Just like Windows and Mac OS. They're also called window(ing) systems. In theory, GUIs are a special kind of shell.

The main windows environment was made by MIT (Massachusetts Institute of Technology) in the late 1980s, and is called X Windows. There are others like SunView and OpenWindows and DECWindows, but these are mostly used on minicomputers (maybe even maxicomputers, i.e. mainframes and supercomputers).

Plain X Windows is horrible to use. Windows would be immovable, and you would be vomiting all over the screen. To make things easier, there are things called window managers. These draw nice borders around windows, allow you to move them, and such like, and add colour. For people who like more bulk, there are things called desktop environments, which are much bigger, and have window managers sat on top of them. (KDE and GNOME are examples of desktop environments; BlackBox and IceWM are examples of window managers.) Desktop managers are little bars in which you can add icons and shortcuts to frequently used programs and files. Don't get the terms mixed up.

It is vitle to realise X Windows (shortened to "X" - or souped-up to X Window(ing) System) is a client/server system. This means that it is built up of a client and a server! You are probably used to these terms (in real life, in fact). The server serves things, and the client recieves the services. Okay, so what do these components do in X?

The X server controls the (video) display (monitor/screen!) directly, and is responsible for controlling all input/output via the keyboard, mouse, and display. The client(s), do not handle the display directly; they communicate with the X server, which then manages the input/output (usually abbreviated to I/O or IO).

Since Linux is multi-user and multi-tasking, and was based on Unix (and Unix was primarily designed to be time-sharing and networkable), X doesn't seem to need any other explanation for following a client/server model. In fact, the client and server do not even have to be part of the machine being used! It is true that the client usually is part of the machine, but it could be that, in a networked situation, there could be many terminals (also called workstations), that have very limited resources: just a display and a keyboard (called a thin-client of the network), which communicates with a souped-up workstation/terminal (a bigger workstation with its own resources (sometimes a PC - in a networked situation, sometimes called a network PC) is called a fat-client!), which acts as the X client, which then sends the messages to the X server, which responds back to the little thin-client terminal by means of the X client (in this case, the fat-client). Of course, usually in the home use, both are local resources. By the way, when I say thin- and fat-client, I am in no way relating them to "X client", though they could be! I just mean clients of the network (i.e. of the main server, which again, doesn't mean X server, always! They could be different things).

For further reading, try Google or see further down the page.

If you ever need help with a command line tool, hit the man(ual) pages, by using the "man" command at the shell. The manual pages in Linux are called "The Linux Programmer's Manual". There are split into 9 parts:

1) user commands
2) system calls
3) library functions
4) special files
5) file formats
6) games
7) conventions/misc.
8) administration commands and such
9) kernel interface

Generally, you type:

man <number 1-9> <entry>

So, for example, you wanted a game manual page, you'd type:

man 6 <entry>

However, if the entry name was non-existant in all other sections of the man pages database, the number could be ommited.

Man pages should be a quick help reference for commands; however, for further reading about other issues like X, hit the Web. (Below.)

Root is the system administrator - the God of a Unix/Linux system. He/she can do everything. Everything! There is no limitations. The main root user obviously has a user name "root", but other people can be root if their UID is "0". See below.

How do I remove files?
The "rm" command serves this purpose. Generally, its syntax is:

rm <file>

There are many switches you can use with rm (i.e. "Are you sure you would like to delete this file?" could be asked by rm in certain conditions), such as:

rm -r <directory>

As stated, this is generally used with directories; it "recursively" deletes it - it doesn't just delete stuff in there. It deletes its subdirectories contents, all the way down the nodes of the hierarchy, until it can go no further. Note that you cannot delete a non-empty directory with a normal "rm" command with no switches. Indeed, in Unix, directories are a special type of file.

There are many other switches for "rm", such as "-i", which makes the shell ask whether you really want to delete a file. See the "man" pages for more information.

Note that I saw "delete", not "remove". Deletes cannot be undone; however, some windows environments (e.g. KDE) let you "remove" or "trash" a file (put it in a bin). But a delete is different. Once it is done, you're dead.

What are some other useful commands?
A distinction between commands and programs should now be pointed out. When we say "commands", we generally mean a line typed to the shell, such as:

rm myfile.txt

Because you are commanding the shell what to do. However, you are running a program. So what? Well, the shell has certain things built-in, and these are realcommands, not programs (for example, the command telling the shell to change directory). If you didn't understand that, you know what you're doing! :)

Anyway, I will, at this point, point out more commands and programs to get you going. This is no way an attempt to fully document Linux's workings or programs. Again, that is the Web's responsibility!

cd <directory> - a command to change directory (current/working directory). If the directory/path name is omitted, you are put into your home directory. (Rememer a home directory is your home place in the hierarchy tree where you keep YOUR things.)

ls <directory> - a program listing directory contents. It will list all the files and subdirectories of the specified place, or if you miss out the name, the current(/working) directory is used. Ls has switch(/options) - things that make it act differently that it normally would. For example, "-a" shows ALL file (even hidden ones), and "-l" lists permissions (see later) and other details about files (directories and even devices - and everthing else - are files in Linux). Again, the man pages are there.

touch <file name> - makes the file with the file name specified. It will do nothing but make an empty, typeless file.

file <file name> - "guesses" what type a file is.

mkdir <directory> - makes a directory.

rmdir <directory> - deletes a directory.

time - shows time.

date - shows date.

gcc - the GNU C compiler.

perl - Perl interpreter.

vi - vi text editor.

grep - looks for a string pattern in files.

find - finds stuff.

emacs - emacs text editor.

ps - command which lists all jobs/processes.

kill - kills processes.

The list just goes on and on. The shell itself has about a dozen built-in commands, whereas the amount of software on a typical Linux system and the amount of third-party software would make our list a thousand lines longer, which really over anybody's head, and totally beyond the scope of this small(!) FAQ. Find a Linux site.

How do I mount a Windows drive?

This is a commonly asked question among new Linux users who have set their system up to dual-boot with Windows, and occasionally need to grab files from their Windows partitions.

If your Windows partition is a FAT32 partition, usually used by Windows95/98/98SE, you mount your Windows partition by typing the following command at the console:

mkdir /mnt/windows # Make a directory for it to mount in.
mount -t vfat /dev/hdax /mnt/windows

The drive's contents will now be in /mnt/windows, and you can browse around. Replace /dev/hdax with your Window's partition name. For example, it you installed Windows first, the partition is likely to be /dev/hda1. Also, "/mnt/windows" is probably a good mount point, but you can replace this with any sensible place.

If your Windows partition is Windows 2000, or Windows XP or any other NT based OSes, the partition's file system is NTFS. You mount the drive like so:

mkdir /mnt/windows # Create a directory to mount in.
mount -t ntfs /dev/hdax /mnt/windows.

You can now, as above, browse around the partitions contents, and delete and add any files you might want, providing your /etc/fstab file is set correctly.

Indeed, mounting is the act of making a device part of the virtual file system. Linux uses a virtual file system, and this means that Linux makes it appear that the floppy disk drive, CD-ROM, hard disk (different partitions, if desirable) appear as one entity.

How do I install a tar.gz/tar/tgz file?

Software written for UNIX-like OSes is commonly tar'ed and then gzipped up, and then widely distributed across the Internet. Tar is a program which creates an archive out of a group of files specified. Tar was originally used to keep backups, and put them on a tape drive. Hence the name, Tape ARchive.

Installing the software in these packages is generally not too hard, and usually you can install them in the following steps:

.tar file

tar xf file.tar # UnTAR the file.
cd file
make install # Optional, usually just installs additional man pages and such.

The program should now be installed, if the program compiled cleanly.

.tar.gz file

gunzip file.tar.gz # GUNzip the file.
tar xf file.tar # The file is now just a .tar file.
cd file # Go into the directory.
./configure # Configure the makefile.
make # Compile the program.
make install

The software should now be ready to run, if compiled correctly.

.tgz file

One upside in these files in that they usually include compiled binaries (programs ready to run). These usually don't require any installing, and you can usually run them right away.

Before following the above steps to compile software, you should use 'vi README' and 'vi INSTALL' to see if the program needs any other steps to install. Optionally, you can 'cat' these files to save time: 'cat <file> | less'

How do I mount a floppy?

Mounting a floppy is essential if you want to get your work off it, or put your work onto it. You can usually mount a floppy in the following way:

mount /dev/fd0 /mnt/floppy
cd /mnt/floppy

With any luck, you can now browse the contents of your floppy successfully, aswell as put anything on, take things off, and whatever else you want.

My mouse doesn't work, what should I do?

If your mouse isn't working, it could be for a number of reasons:

* It is a Windows mouse.
* You need some drivers for it.
* You have misconfigured it.
* It uses an unsupported protocol.

If your mouse doesn't work, the first thing to try is running the 'mouseconfig' program. Run this program, and follow the steps. If you just misconfigured it, you should be able to get it running like this.

Another reason is that you need drivers for it. If drivers do exist for your mouse you can usually find them easily enough. Search google for: "<your mouse> drivers for Linux" or "Linux <your mouse> drivers". This will usually find them.

A common mouse people have trouble with is the Logitech mouse and the intellimouse by Microsoft. For help with the Intellimouse, check here: http://www.duedder.n...tellimouse.html

I've written a shell script, how do I make it executable?

When a user writes a shell script, they must make it executable, before being able to run it. To do this, you must grant yourself execute permission, that strangely enough isn't given automatically. You can do this with either one of the following commands:

chmod 700 <file>


chmod +x <file>

You can now proceed to run the script with './file'.

Where can I get/download Linux?

Linux is an Open-source, free OS, and can therefore either be purchased, or be downloaded for FREE. There is a number of good websites and mirrors that Linux can be obtained and downloaded from, but a good resource with most of the popular Linux distributions on is
When you download Linux from, you are downloading it in ISO format. This means that you are downloading CD-ROM disk images. You must therefore have a CD-ROM burner, and having a speedy Internet connection is preferable, but not essential. Get more info on burning ISOs here: http://www.linuxiso..../howtoburn.html.

You can alternatively buy Linux for a cheap price online, and in stores. If you want to buy Linux online, hit for some of the cheaptest prices online. They also ship internationally.
Linux CD-ROMs can sometimes be found attached to computer magazines, so it might be worth having a look at your local stores.

I am a Linux newbie, what distro should I start with?

If you want to start simple, and work your way up, I recommend starting with Mandrake or Redhat as your first distro(s). Some newbies prefer to start advanced, so that they are forced to learn. In this case, you may want to try slackware, debian, or gentoo.

It really is up to you, try a few distros, and stick with the one you like most or feel comfortable with.

There is also distros which allow you to out of the box run Windows applications. If you desperately want ease of use, try Lindows.

How do I run Windows/DOS programs in Linux?

There is a few ways to run Windows and DOS applications in Linux.

First, there is a piece of software called "Wine". This allows you to run Windows programs, and most DOS programs. The WINE website holds most of the info you need to install it.

To run DOS programs, a program exists called "DOSEMU". This is essentially a DOS EMUlator, as the name suggests. This is relatively simple to use and install.

I have a WinModem, can I use it in Linux?

That all depends on what type of WinModem you have. I have a Lucent WinModem, and I have been able to install it.

A good place for WinModem drivers is and check if your modem is supported.

Another good site for winmodem drivers is
With these resources, you might be able to get your winmodem running, with any luck.

How do I make backups with Tar?

Backups were the original purpose of the 'tar' program. If you wish to create backups, you can do so like this:

tar cf backup.tar /

Performing the above command would create a backup of the whole system, to a file called backup.tar. You could then move the file onto a tape drive, or a CD-ROM. You can also do this immediately like so:

tar cf backup.tar /dev/tape

Replace /dev/tape with the device name of your tape drive.

Where can I download Linux programs?

Downloading Linux programs is very popular, and can be downloaded from a vast number of sites. However, usually has all of the programs you need.

Use for all of your open-source needs.

What is SUID and SGID?

SUID is generally a term used to describe programs or scripts with the +s bit set. When a program or script is SUID, it runs with the privileges of it's owners. For example, if it is owned by root, when jblow runs it, it runs as root. This can be very dangerous, especially if the program is poorly coded.

SGID is a term used to describe a program or a script which runs with the privileges of the group it belongs to. For example, if a game is SGID 'games', it runs with the privileges of the 'games' group, regardless of who runs it.

SUID and SGID are generally avoided whenever possible by programmers, and they usually take extra care when writing programs which will be SUID/SGID, to avoid security risks, like buffer overflows.

What the hell is /etc/passwd?
/etc/passwd is the database of information about users of the operating system. It is a plain text file. Here is its structure:


These are obvious. UID and GID specify the numbers identifying the user's number and primary group, respectively. Each user is given a number. Also, each user is put into a group. But groups seem to be seldom used in the home. A lot of users have their own group; it also has a name, just as a user ID number has a name (the user name!). The name field is for the user's name - it can be anything. The home field is the home directory. The shell field is where the shell is specified. It doesn't have to be a shell - it it isn't, it is called a system user. The password field seldom has the password there. In fact, it is often scrambled there. Or encrypted in /etc/shadow. The group information is in /etc/group, and the shadow file for groups is /etc/gshadow.

Where can I get Linux help?

Linux help can be obtained from the following places:

* Linux User Groups (LUGs).
* Man Pages.
* Info Pages.
* Additional resources.

The easiest to access are the online man and info pages. They can be accessed like so:

man <command>


info <command>

If the thing you are trying to get into about is a C function, use the following command instead:

man 2 <function>

HOWTOs are written quite reguarly on some of the most asked Linux questions. These range all the way from "How to install a WinModem", to "Making coffee with Linux".
Most HOWTOs can be found here:

Additional resources can be found with Google. Here's a few:

And Linux specific things can be found with the Linux Google too:

Check the Linux resources section for more links.
Linux User Groups can be very helpful places, but sometimes more trouble than they're worth, and flame wars can occasionally be started. Many LUGs can be found on google.

How do I mount a CD-ROM drive?

The following command sequence can usually be used to mount and browse you CD-ROMs:

mount -t iso9660 /dev/cdrom /mnt/cdrom
cd /mnt/cdrom

Unlike mounting floppies and hard drives, you usually can't modify CD-ROMs, unless they're blank.

How do I unmount a drive/device?

The 'umount' command is the program usually used for this job. It has a very simple syntax, the following does the trick:

umount /dev/device

ALWAYS remember to unmount your devices after use, or data can be lost of damaged!

How can I compile a C/C++ program on Linux?

The most popular C/C++ compiler for Linux is currently 'gcc'. To compile a C program, the following command is used:

gcc program.c -o program

Is the program compiles cleanly, you will now have an executable program called 'program' in your directory.

Compiling a C++ program is a little different. The program used is g++, which is just gcc, invoked with a few extra flags necessary to compile C++ programs. Use the following command:

g++ program.cpp -o program

You will again have a program called 'program' in your working directory if it compiled correctly.

What are some Linux resources on the web?

How can I install an RPM file?

Installing an RPM file is usually relatively simple. The proceeding command usually does the trick:

rpm -i file.rpm

Or if you're updating a package you already have installed:

rpm -Uhv file.rpm

Now the package will probably be installed, unless it gave you a message telling you that minimum dependencies weren't met. In which case, you should install them.

When I boot into Linux, I'm not in X, how do I get in?

If when you boot into Linux, you're not prompted with a nice X interface, you can easily start it. Log in, and type 'startx' at the shell. X Windows will now boot, if you configured it correctly.

If you do not want to go through this proceedure every time you boot into Linux, you will need to edit your /etc/inittab file. Open it in 'vi' by typing 'vi /etc/inittab'. Then edit the line which looks like this "id:3:initdefault:" to this "id:5:initdefault:". Now reboot, and it should take you straight into X Windows!

How do I configure X Windows?

To configure X, type 'xf86config' from the shell or console. Follow the prompts, and answer the correct settings and specs for your computer. Now hopefully you can do what you wanted.

How do I close/stop services/daemons?

Having all of the Internet services/daemons running can be a huge security risk, and it consumes bandwidth. Therefore, you may wish to disable some of them. Only keep the ones you need, for example, if you do not need to log in remotely, and are not hosting a website, there is no need to be running telnet and SSH and HTTPD.

To stop services use the 'linuxconf' program. Run 'linuxconf' from the console, and close any unnecessary services. This will probably make your computer run faster, and will reduce any security risks.

If you are using Mandrake, there is a program called "Mandrake Control Center", which makes it easier to close services.

How do I configure a cable modem?

I will not go into great detail, but all you need to do is run 'linuxconf' program, and find the section in which you can configure a cable modem.

You will need to know some ISP info, such as your ISPs DNS server address and some other easily obtainable info. Ask you ISP for more info.

How do I dial out to my ISP in Linux?

Presuming you have your modem installed correctly, you can proceed to dial out with your modem. One of the most popular tools for dialing-up to the Internet in Linux is 'kppp'. Kppp is a GUI front-end for PPPD, and hence makes it a lot easier to use.

To dialout using this program, you must first configure it. Run the program, and click the button labelled "set up". Then go ahead and fill in all of your details such as ISP phone number, login and password etc...

Then you can just click "Connect", and you're well away!

What is GNU?
GNU is a division of FSF (Free Software Foundation), which stands for "GNU's Not Unix". FSF was created by Richard Stallman, who believes all software should be free! It is based is MA, USA.

It makes much Linux software (e.g. the command line tools you use daily and take for granted. They call these the "Shellutils" package. Also, they make lots more software, such as "Binutils", like GCC, GDB, etc. And "Fileutils", which are GREP, File, and much more!), and gives them away for free, and includes the source code, under the terms of GNU General Public License (GPL).

They also do licenses, e.g. GPL. This loosely states that this type of software can be given away for free or sold, but the source code must be included. This is open-source. It is also called freeware or you could say, "It is copyleft(ed)"!


I hope you have enjoyed or learnt something from this FAQ.

Please give me feedback, and I'll add questions and answers which are requested. E-mail addresses are listed at the top of the page.


#2 Guest_plc_*

  • Guests

Posted 14 August 2003 - 09:50 PM

Good for newer same me

#3 Guest_andariel_*

  • Guests

Posted 15 August 2003 - 04:16 AM

nice document shaun2k2.
i am trying to move from xp to mandrake. cheeers !
ps, aren't you the shaun2k2 on hdc ?

#4 shaun2k2


    Staff Sergeant

  • Sergeant Major
  • 348 posts

Posted 15 August 2003 - 06:23 AM

Thanks guys.

andariel, yes, I am the shaun2k2 on HDC.


#5 packet



  • Sergeant Major
  • 649 posts

Posted 15 August 2003 - 07:10 AM

What is HDC?

Abusus non tolit usum
The gopher is back!

#6 shaun2k2


    Staff Sergeant

  • Sergeant Major
  • 348 posts

Posted 15 August 2003 - 07:24 AM

HDC is a board, but I guess we certainly shouldn't discuss other boards here, even if only in the slightest detail or way.


#7 Blake


    Former Commander In Chief

  • Retired Admin
  • 7,334 posts

Posted 15 August 2003 - 07:31 AM

I have no problem with it as long as it isn't a blatent advertisment (ie: spam) ;)

#8 shaun2k2


    Staff Sergeant

  • Sergeant Major
  • 348 posts

Posted 15 August 2003 - 07:38 AM

Okay, cheers, you are obviously a LOT LESS strict than most boards that I've being to, most places would ban you for even posting the name of a board :).


#9 Blake


    Former Commander In Chief

  • Retired Admin
  • 7,334 posts

Posted 15 August 2003 - 07:42 AM

I have enough confidence this site is good enough people won't leave

#10 Guest_andariel_*

  • Guests

Posted 15 August 2003 - 07:51 AM

yeah, but i think hdc is dead, isn't it ? because i can't access it anymore ;)
shaun2k2, i was microcoder67 on hdc B)
and at last lets keep this thread in its topic, nothing more about hdc. :)

Also tagged with one or more of these keywords: perl, php, tools, shell, ssh, distributed