Difference between revisions of "Linux Basics"

From JimboWiki
Jump to: navigation, search
(Understanding the Linux Filesystem)
(/sbin/)
Line 82: Line 82:
 
</pre>
 
</pre>
 
====/sbin/====
 
====/sbin/====
Binaries for system administrators.  Again, more in /usr/sbin/
+
Binaries for system administrators.  Like /bin/, ther are more system administrator binaries in /usr/sbin/.  On most distributions, you must use the complete path for these executables:
 +
<pre>
 +
[user@computer ~]# /sbin/mdadm
 +
</pre>
 +
not:
 +
<pre>
 +
[user@computer ~]# mdadm
 +
</pre>
 +
Notice the "#" instead of the "$" denoting that we are executing commands as root - I'll get into this more later.
 +
 
 
====/mnt/ and /media/====
 
====/mnt/ and /media/====
 
This is where removable media is generally mounted.  Because Linux doesn't tell you what device you're working from, you can technically mount a device's partition to any directory on the system, however if the system does it automatically (say in the case of a USB drive or CD-ROM) chances are it's in /mnt/ or /media/
 
This is where removable media is generally mounted.  Because Linux doesn't tell you what device you're working from, you can technically mount a device's partition to any directory on the system, however if the system does it automatically (say in the case of a USB drive or CD-ROM) chances are it's in /mnt/ or /media/

Revision as of 19:15, 1 February 2007


This page is incomplete
More work needs to be done on this page, so if somthing is missing, don't be surprised

This is the first part of the jimbodude.net Linux tutorial. It is meant to introduce Linux people who have a reasonable amount of technical experience but not enough time to spend reading books or doing reasearch on their own. At the end of this document, you should understand what Linux is, how users and files are organized, how to navigate the filesystem, and how to manipulate files. I will not discuss how to install Linux, as that is different for each version of each distribution. See the documentation for the version you plan on using.

What is Linux?

"Linux" generally refers to any operating system using the Linux Kernel. The Linux Kernel is available under the "GNU General Public License" which makes it free for most uses and allows it to be distributed as open source. Linux was developed by Linus Torvalds in 1991. For more information about Linux and its history see Wikipedia:Linux kernel and Wikipedia:Linux.

Simple Overview

Linux was originally developed to be a desktop operating system for "hard core" users. It has since evolved and become available as a server operating system and has emerged into many corporations. Linux provides a huge amount of flexibility for developers because it supports many programming languages and is available on many platforms other than computers. The main goal of the project was to provide a free Unix-like operating system to the masses.

Technical Overview

Linux is a Monolithic kernel. By design, everything running on a Linux system is very modular. For instance, systems do not need to have a GUI. Systems that do generally use some flavor of the X Server. The X Server is controlled separately from the kernel, and any issues with X will not affect the kernel. Also, the X server allows many different displays to run simultaneously. So different users logged in concurrently can have a completely different GUI presented. This is true of many other aspects of Linux software including printing and sound.

The Linux kernel has been ported to many common devices including routers (see DD-WRT for Linksys WRT routers), MP3 players (such as the Apple iPod), phones, and gaming systems (such as Sony PS2, Nintendo GameCube, Microsoft XBox, and XBox 360). Many embedded systems (such as TiVo and older Linksys routers) also use Linux based systems out of the box.

Distributions

The term "Linux" technically only refers to the operating system kernel, but the kernel alone is relatively useless. So people put together more complete software packages which include applications and supporting software. These packages are called distributions. There are so many distributions of Linux available it isn't even funny, and each has its own benefits and disadvantages. I will only cover a few of the major ones here breifly. More information is available from Wikipedia by clicking on the distribution title, and from each distribution's vendor by clicking on their listed website.

Slackware

Slackware (http://www.slackware.com/) is one of the earliest distributions. It was released in 1993. It is meant to contain only the most stable open source programs available and be as simple as possible. By simple, I do not mean simple to operate. The developers leave out many features that could hinder performance or create configuration problems. Software is organized in packages, but there is a pretty serious lack of package management tools. For instance, there is no way to determine if all an application's dependancies are installed. Packages are stored in simple tarballs, which is consistent with the minimalist attitude of Slackware. Technical people don't seem to think this is an issue, but the average user should beware.

Red Hat and Red Hat Enterprise

Probably one of the most famous distributions is Red Hat (http://www.redhat.com/). Red Hat 1.0 was released near the end of 1994. It has always been targeted at the server market. It includes a built in installer called Anaconda and the ability to script installation using kickstart. Software is organized in RPM packages which allow for fairly easy program installation and dependency checking. Red Hat now also uses yum to extend its package management. yum was inspired by Debian's apt which allows the user to run a single simple command to downlod, resolve dependancies for, and install packages. Red Hat Linux used to be available for free; the company made its money by selling service contracts and gauranteed uptime. Around 2003, Red Hat renamed its product from Red Hat Linux to Red Hat Enterprise and stopped distributing it for free.

Fedora Core

Fedora Core (http://www.fedoralinux.org/) is a project sponsored by Red Hat and based on Red Hat Linux. The project was started as Red Hat stopped allowing free distribution of their software. The idea is Fedora Core will be a completly open-source, general purpose operating system for home and recreational use, and Red Hat Enterprise is stable enough to be sold for profit to corporations. Everything in Fedora Core is pretty much the same as Red Hat, except more "cutting edge" and recreationally targeted technologies are available, and it is slightly less stable. This is the distribution I most commonly use.

Yellow Dog

Yellow Dog (http://www.yellowdoglinux.com) originonlly used Red Hat as a starting point, and now bases itself on Fedora Core. It was released in 1999 for PowerPC architecture and currently supports Macs, some IBM servers, and partially Sony Play Station 3. However, some apple hardware (such as AirPort cards) do not generally function properly without kernel modification. As a Red Hat/Fedora spin-off, Yellow Dog uses RPM package management. Yellow Dog costs between $30 and $90 depending on which package is chosen.

Debian

Debian Linux (http://debian.org) is most known for its strict policies on package quality and dependency structure. It was origionally announced in late 1993, but its first stable release wasn't released until 1996. Calling it a Linux distribution is a little misleading, as the project simultaneously develops on multiple kernels, however their only official releases use the Linux kernel exclusively. Debian is famous for its package management using the apt tool (Advanced Packaging Tool), which allows users to simply run a single command to downlowd, resolve dependancies for, and install a package. Debian boasts over 15,000 pre-compiled packages, all kept in multiple, clearly labled versions.

Ubuntu

Ubuntu (http://www.ubuntu.com/) is a Debian based distribution focused on ease of use for the user. As such, many consider it a good distribution for Linux beginners to start with. It began in 2004 as a fork in the Debian project, but soon became its own entity. Ubuntu, like Debian, uses free software. Ubuntu developers generally try not to provide more than one package that does the same thing, unlike Fedora and Debian.

SUSE

SUSE (http://www.opensuse.org) originated in 1992 as a German translation of Slackware. It was one of the first distributions to feature the X server (GUI management) and TCP/IP networking. SUSE is currently owned by Novell, who has released their fomerly proprietary rpm-based package update tool Yet Another Setup Tool (YaST2) to the public under GPL. YaST2 also manages disk partitions, system setup, network and firewall configuration, user administration, and much more. SUSE comes packaged with the ability to read and resize NTFS (Windows post-2000) partitions and supports drivers for winmodems and softmodems common in low-end or space confined systems. Several version of SUSE are available depending on the anticipated use of the software.

Knoppix

Knoppix (http://www.knopper.net/knoppix) is a Debian based bootable CD distribution. In other words no installation is required. Once the system is booted with the Knoppix CD or DVD in the drive, the linux kernel and all Knoppix additions decompres to a RAM drive and the operating system starts. Tools on the disc range from movie players to web browsers to file system recovery tools. Knoppix is good for saving your commonly corrupted Windows partions, just playing with Linux with no risk, or scaring the pants of your buddy when he goes to the store and finds his computer running linux when he gets back.

Why Linux?

Technical

Cost and Availability

Development

Security

Compared to Microsoft Windows

Compared to Other UNIX Based OSs

Using Linux

If you're just looking at a Linux GUI, things don't appear much different from Microsoft Windows, but under the hood there's a whole different story.

How to Connect to a Linux Machine

I will use the term connect very loosely to mean anything you do to the computer before you can make the computer do what you want. So don't think I'm only talking about remote connections here, I will discuss both remote and local (physical) connections.

The first thing to realize about Linux is that it is designed in a way that you can access any part of the system from anywhere if you conigure it correctly. We won't cover conviguration in this tutorial, but probably in a later one. For now, I'm going to assume you are connecting to a properly configured machine - like your school or work. If everything is set up right, you can pull up a GUI or shell over the Internet without much effort.

Shell and SSH

The shell is the most basic connection you can make to a Linux machine. Many new users are scared of shells, but don't worry, it's not nearly as bad as it seems. You might not believe it now, but once you get the hang of it working from the shell is usually more efficient and easier.

That said, if you're sitting at a machine and there is any sort of graphic on the display you're not logging into a shell, but if you're connecting remotely by SSH or there is only grey or green text on the screen you are. If you're connecting remotely you're going to need an SSH client like putty (http://www.chiark.greenend.org.uk/~sgtatham/putty/). Putty is nice because there's generally no installation - very simple - but has a lot of features (like port tunneling) that I won't discuss here. Simply type in the host name you want to connect to and hit connect.

Whether connecting remotely or locally, you will need to enter a username and password. You will then be presented with something like this:

This station is for interactive use

[user@computer ~]$

This means that the system is ready to start taking commands. The '~' is where the current working directory is displayed. You will usually start out in your home directory, which is denoted by '~'. The '$' means that you are not root user. It turns to a '#' when you are. I will discuss root user, directory structure, and commands later in this article.

X Server (locally)

Sit down, type in username and password, done. Just like accessing the shell locally, except prettier. You may have an oppertunity to change your desktop environment; this will have no effect on how you log in, but as you would guess, the GUI will be completely different depending on which environment you choose.

X Server (remotely)

VNC Server

Understanding the Linux Filesystem

If you are not used to *nix operating systems, the first difference you will probably notice is the file system. The base of the file system exists at "/" (pronounced "root directory"), not "My Computer" or "C:\". because of this, there is no notion of what physical drive you are working from. You will see why this is an advantage in a later tutorial. You will also notice that there are objects in directories that are not files or subdirectories. There are symbolic links and pointers to devices and all kinds of other things. We'll get to those later, for now, there are several important directories in "/" that you might want to know about. I won't cover them all, and those I cover will not have much depth in their explaination, so for more detailed information and history see Wikipedia:Filesystem Hierarchy Standard.

/home/

Each user has a home directory. By default, a user's home directory is /home/username. The home directory of the user you are logged in as is often refered to simply as '~'. Lots of things are stored in a user's home directory including personal program preferences, application logs, shell logs, and whatever they decide to put there. Usually, a user's home directory is inaccessable to all other users (except root, but we'll get to that).

/root/

This is the root user's home directory. We'll talk about why root is special later. You will have no need to go in this directory at this point.

/etc/

This is where system wide configuration is stored. I'll talk more about specific files in here in a later tutorial.

/usr/

User sharable read-only data, such as some program files and source code. You will see many of the same directory names as the root filesystem in here.

/dev/

Pointers to all system devices

/bin/

Almost all the executable files are in here. There are also some in /usr/bin/. Anything in this directory can be run without citing a path to the executable. For example, the following 2 commands do the same thing:

[user@computer ~]$ cp hi.txt bye.txt

[user@computer ~]$ /bin/cp hi.txt bye.txt

/sbin/

Binaries for system administrators. Like /bin/, ther are more system administrator binaries in /usr/sbin/. On most distributions, you must use the complete path for these executables:

[user@computer ~]# /sbin/mdadm

not:

[user@computer ~]# mdadm

Notice the "#" instead of the "$" denoting that we are executing commands as root - I'll get into this more later.

/mnt/ and /media/

This is where removable media is generally mounted. Because Linux doesn't tell you what device you're working from, you can technically mount a device's partition to any directory on the system, however if the system does it automatically (say in the case of a USB drive or CD-ROM) chances are it's in /mnt/ or /media/

Understanding Users

Normal Users

System Users

"root" User

Properties of Users

Important Commands

Navigating the Filesystem

Manipulating Files

Text Editors

Emacs
vim
Graphical Editors

About Commands

Where they live, how they execute, how to execute commands in the current directory, etc.

Conclusion

See Also