Introduction to Linux

Contents:

What Is Linux?

Linux is a free, Unix-like Operating System (fundamental software) thatis developed by a loosely knit team of talented programmers working fromall over the world. Linux works on almost every kind of computer in existance,and provides a robust platform for a wide variety of applications.

Linux was started as a learning project by a computer science student,at the Univeristy of Helsinki, Finland, named Linus Torvalds (hence thename Linux). There were two reasons why Linus created Linux. First, hewanted to learn more about the microprocessor he was studying at the time-- and what better way to learn than by creating an operating system totalk to it? Morever, the second reason was that a failing version of Unix,Minix, didn't have the functionality nor features that Linus wanted. Topurchase it would cost way too much for a starving student, so he startedlinux! [TRANSLATION: Linus wanted to bring Unix to the desktop]

He began the Linux experiment nearly a decade ago and has since graduated,but Linus Torvalds is still in charge of the Linux core today, though manycompanies now exist to help promote and distribute the Linux operatingsystem. Millions of computer science students worldwide use Linux dailyfor their calculations and studies, and many of them, as well as many otherpeople, help Linus to maintain Linux, release new versions, and keep itall working well [TRANSLATION: Many people actually code different partsof the OS themselves and send it in for review, if it passes approval thenit is entered into the next kernel revision.]. Linux is a completely freereimplementation of the POSIX specification, with SYSV and BSD extensions(which means it looks like Unix, but does not come from the same sourcecode base) [TRANSLATION: Linux is a free operating system that mimics theUnix operating system and has similar features and functions], which isavailable in both source code and binary form [TRANSLATION: source codeneeds to be compiled and binary code can be untarred]. Its copyright isowned by Linus Torvalds and other contributors, and is freely redistributableunder the terms of the GNU General Public License (GPL). A copy of theGPL is included with the Linux source; you can also get a copy from ftp://prep.ai.mit.edu/pub/gnu/COPYING.Linux, per se, is only the kernel of the operating system, the part thatcontrols hardware, manages files, separates processes, and so forth. Thereare several combinations of Linux with sets of utilities and applicationsto form a complete operating system. Each of these combinations is calleda distribution of Linux [TRANSLATION: ie: Redhat, Debian, Mandrake, SUSE,Caldera, etc.]. The word Linux, though it in its strictest form refersspecifically to the kernel, is also widely and correctly to refer to anentire operating system built around the Linux kernel [TRANSLATION: thecode that makes the OS work.]. For a list and brief discription of variousdistributions, see http://sunsite.unc.edu/LDP/HOWTO/Distribution-HOWTO.htmlNone of these distributions is ''the official Linux''. Linux is not publicdomain, nor is it `shareware'. It is `free' software, commonly called freewareor Open Source Software[tm] (see http://www.opensource.org/),and you may give away or sell copies, but you must include the source codeor make it available in the same way as any binaries you give or sell.If you distribute any modifications, you are legally bound to distributethe source for those modifications [TRANSLATION: it is ok, for instance,to bring your Redhat CD to your friends house so she can install it onher machine as well]. See the GNU General Public License for details.

It is ported to run on various hardware configurations, like PowerPC,Apple Macintosh, Alpha, Intel i386, and more coming all the time. Withall the volunteers involved with linux over the past 8 years, and morejoining everyday, linux looks to have a bright future in the world of computingfor years and years to come.
Source: linuxnewbie.org
 

Command List

[covered in this guide]
 
Command Description
cp Copy files. Syntax: cp [filename] [destination]
df Display empty disk space
less Show the content of a file. Syntax: less [filename]
ls List files
mkdir Make a directory. Syntax: mkdir [new directory]
more Show the content of a file
mv Move files. Syntax: mv [filename] [destination]
rm Remove files. Syntax: rm [file list]
rmdir Remove an empty directory. Syntax: rmdir [directory]
vi Edit text files

Logging-In

The first thing you need to do when using Linux, is to log-in. After youhave turned on your computer and it has booted up, you will see a promptsimilar to the following:
localhost login:
NOTE: Almost everything in Linux is case sensitive. I.e. the user"John" is a different user to "john"

Type in your user name followed by the enter key. You will the be promptedfor your password:

localhost login: johnpassword:
Type in your password and press the enter key.

NOTE: Your password is not echoed on the screen

You will then, if your user name and password are correct, be logged-inand you will see the following prompt [or similar]:

localhost%~:
To quickly log-out you can press Ctrl-D or type log-out at theprompt

Changing your password:

To change your password, type passwd at the prompt. You will beprompted for your old password and then for your new password twice

Getting Help

There is an extensive help system in Linux which consists of a series ofmanual pages.
To access it, type man [command] where [command] is the commandyou want help on.
E.g.: man passwd will give you the manual page on the passwdcommand

If you are not sure on what command you want help with, you can searchthe keyword index which consists of all the commands in the system.
To search the index type man -k [keyword] where [keyword]is the keyword you are looking for
E.g.: man -k password will give you a list of all the manualpages with the word "password" in it

The main console commands

Commands usually follow the following format
command  modifiers  arguments
command: what you want to execute
modifiers: the different options for the command [usually precededwith a minus sign]
arguments: specifies what to do with the command
Running a Process in the Background
A process may be run in the background by typing the character '&'after the command name on the command line. For example, to run the programfoo in the background, type foo& at the command prompt. By runninga program in the background, you are not giving up control of the commandline and can therefore multitask.

Changing directories

To see what directory you are in, type pwd [print working directory]
To change directories you need to use the cd command:
cd
Moves to your home directory

cd ..
Moves up one directory

cd -
Moves to the previous directory

cd /usr/docs
Moves to the /usr/docs directory

cd ../usr/docs
Moves up one directory and then into usr/docs

Listing Files

To get a list of files in the current directory, you use the ls command:
ls
Lists the files in the current directory

ls -a
Lists all files as well as hidden ones

ls -l
Lists files with all their details [access rights, last modified etc.]

ls -r
This will recursively list all directories encountered

ls -f
This will show the type of file. The following suffixes after the nametell you what type of file it is:

/ -> directory
* -> executable file
@ -> symbolic link
ls | less
Pipe (pass) the listing of the current directory to the less program,allowing you to scroll up and down a long listing. [The | character iscalled a "pipe".]

Less Keys:

Down cursor = Down 1 line
Up cursor   = Up 1 line
Spacebar    = Down 1 screen
b           =Back up 1 screen
q           =Quit
h           =Activate help screen
ls [directory]
Where [directory] is the directory where you want to get the file listfrom

Copying Files

To copy a file, you use the cp command
cp [source] [destination]

cp -r a b
Copy the entire contents of directory a into directory b. [the r isfor recursion]

cp a.txt backup
Copy the file a.txt across to the directory backup.

cp a.txt backup/a_bk.txt
Copy the file a.txt across to the directory backup and rename it a_bk.txtat the same time. If the file backup/a_bk.txt already existed then it willbe overwritten without warning.

cp -i a.txt backup/a_bk.txt
The same as above but asks for confirmation before overwriting an existingfile.

cp a b c d
In the above, every parameter but the last - are the files to copy,and the last parameter - is the directory to copy the files too.

Moving or Renaming Files

To do this you use the mv command. mv is a clever littlecommand that will either move a file , or rename it

Moving a file

mv [file] [directory] where [file] is the file youwant to move, and [directory] is the directory you want to move the fileto
Renaming a file
mv [oldfilename] [newfilename] where [oldfilename]is the old file name and [new filename] is the new file name

Deleting files

To delete a file you use the rm command
rm file.txt
Deletes the file named file.txt

rm a b c
Deletes the three files a,b,c

rm -i a b c
Deletes the three files a,b,c, but asks for confirmation

rm *.txt
Deletes all files ending in .txt

rm -rf work
Deletes the directory work and all sub directories/files in it [thef modifier, means force]

Creating and removing directories

To create a directory, you use the mkdir command:
mkdir [directory] where [directory] is your new directoryname
To remove a directory, you use the rmdir command
rmdir [directory] where [directory] is the directoryyou want to delete
Note: rmdir will not remove a directory ifit is not empty, i.e. it contains files and/or other directories

View a files contents

To view a files contents, you use the more command:
more [filename] where [filename] is the name of thefile you wish to view
It will scroll through the file one page at a time. Press spacebarto scroll down
Or you can use the less command:
less [filename] basically the same as the morecommand

Archiving and Compression

Archiving
To archive files and directories you use the tar command
Example:
To make a archive from a directory called work you need todo the following:
tar -cvf work.tar work
The general format of the tar command:
tar - [options]f [tar file] [source]
where [options] are the options, [tar file] is the destination whereyou want the files to be archived [usually ends in .tar]. [source] arethe files of directories that you want archived.
The common options: [you need to specify one of these]
 
Option Description
c Create a new archive
x Extract files from the archive
t List the files in the archive
There are a lot more, type man tar for more information
Other options
 
Option Description
f Use the archive file [supply the file name after the option]
v Verbosely list files processed
z Gzip or Gunzip the archive
There are a lot more, type man tar for more information
Compression
To compress files, so that they take up less space, you use thegzip command
Gzipped files usually end in .gz
To compress a file, type the following:
gzip [file name]
where [file name] is the name of the file you want to compress
To uncompress a file, type the following:
gzip -d [file name]
where [file name] is the name of the gzipped file you want to uncompress

VI [text editor]

The vi (pronounced vee-eye) editor was developed by the University of California- Berkleley. While vi is a very complex editor (virtually every key onthe keyboard has a function), it is the one editor that you can be surewill be installed on a machine. Whith that said, it is a good idea to atleast have a working knowledge of vi.

To put yourself into command mode <Esc needs to be pressed.This will allow you to execute the following commands.
 
Running vi
vi [filename] opens [filename] in vi. If the file does not exist ci creates it. 
Entering Text
i Start inserting at the cursor position. All characters typed will beinserted until <Esc is pressed. 
a Start appending text after the cursor position. All characters typedare inserted until <Esc is pressed. 
Moving Cursor
h, j, k, l Moves cursor, left, down, up, and right. The arrow keys *may* workon some systems. 
$ Move cursor to the end of the current line.
:1 Go to line 1. Entering another number in place of 1 will bring youto that line instead.
:$ Go to ther last line.
Other Commands
dd Delete the line the cursor is on.
x Delete the character the cursor is on.
p, P Paste the last deleted text at or after the cursor position
u Undo the previous command.
U Undo changes to the current line.
J Join the following line to the end of the current line. 
<control - L Re-paint your screen. 
? help
Saving and Exiting
:q! Abandon ALL changes and exit vi.
:w save and return to vi
ZZ
:wq
save all changes and exists vi.

source: http://alt.ben.edu/faculty/rmeeker/linux_manual/vi.html

Other commands

Free Space:
To find out how much disk space you have left on your hard drive andother mounted drives, type df

The X Windows System [or just X]

There are a few basic principles and terms you should familiarize yourselfwith to make using X much more straightforward. These terms will appearover and over again in the manual pages and help files, which it is suggestedthat you consult whenever necessary.

The screen is your whole ''desktop'', and the words may be usedinterchangeably. Technically it means the primary video display you viewX with, and you can have more than one screen, in fact you can have morethan one computer running off a single X server. This is beyond the scopeof this humble document, but you should be aware of the distinction.

The root window is the background of your screen. It is referredto a window in name alone, it does not behave like any other window, butrather you run your applications on the root window, or put a picture onit, or just a solid color.

The window manager is the main interface between the X Windowsystem and the user. Without the window manager, the system would be ratherdifficult to use, and would certainly not be a very productive tool. Thewindow manager provides such functionality as window borders, menus, icons,virtual desktops, button bars, tool bars, and allows the user to customizeit at will, often adding to its functionality in the process.

The pointer is the arrow or indicator of any given shape whichrepresents the location your mouse (or other pointing device) correspondsto on the screen. The pointer often changes to give you contextual feedbackas to what will happen when you use the mouse at that point on the screen.

The window is a frame in which any given application resideswhich is ''managed'' by the window manager. This includes pretty much anythingexcept the so-called root window. Even windows which do not appear to haveframes, titles, or normal borders of any kind are being managed by yourwindow manger. The active window is the window you are currentlyusing, the window that will receive text when you type, and is traditionallydenoted by the fact that your mouse cursor is pointing at it, though thisis not always the case. The active window is said to have ''focus,'' therest of the windows on your display being ''unfocused.''

Menus and icons behave in X similar to the way they behavein other windowing systems, and the same general principles apply. Windowswith text only are called terminal emulators, an example would bexterm,and these basically emulate a console text-only display, but let you multiplexand use more than one at a time, and have many other advantages availabledue to their being used in X.
Source: http://linuxcentral.com/linux/LDP/HOWTO/XWindow-User-HOWTO-2.html

Starting X

After you have logged in, type startx at the prompt. X shouldthen load.

Usefull Links

http://alabanza.com/kabacoff/Inter-Links/guides.html
http://www.linuxdot.org/nlm/
http://www.linuxnewbie.org/