Wednesday, February 13, 2008

Learn easy - linux commands

TIP 1:
All of these commands should work from your command prompt (regardless which shell you're using). Just in case some folks were not aware, you MUST press enter to invoke the command

TIP 2:
For this summary, please note that the EX: stands for example and is not part of the command. Commands are denoted in courier type font.

TIP 3:
If you need help understanding what the options are, or how to use a command, try adding this to the end of your command: --help

For example, for better understanding of the df command's options, type:
df --help

Command Summary Use
Use cd to change directories Type cd followed by the name of a directory to access that directory.
Keep in mind that you are always in a directory and allowed access to any directories hierarchically above or below. Ex:
cd games

If the directory games is not located hierarchically below the current directory, then the complete path must be written out. Ex:
cd /usr/games

To move up one directory, use the shortcut command. Ex:
cd ..
Use clear to clear the command prompt Type clear to clean up your command prompt window.
This is especially helpful when you are typing lots of commands and need a clean window to help you focus.Ex:
clear

This is also useful when you are getting ready to type a rather long command and do not wish to become confused by other details on the screen.
Use date to set your server's date and time Type date followed by the two digit month, the two digit date, the two digit time, and two digit minutes. The syntax is easy enough and resembles this: MMDDhhmm
This command is helpful but must be used when superuser or logged in as root. Otherwise you will get an "Operation not permitted" reply.As root user you can use the command such as:
date 11081300

The above command will set the server date and time to the 11th month (November), the 8th day, at 1:00pm.
Use df to check disk space Typing df provides a very quick check of your file system disk space.
Type df -h to get a more easily readable version of the output. Notice that this command will include all applicable storage such as your hard disk/s (hda, hdb etc.) and your server SWAP file (shm). To list disk space including filesystem type:
df -h -T
Use finger to see who's on the system Typing finger allows you to see who else is on the system or get detailed information about a person who has access to the system.
Type finger followed by the name of a user's account to get information about that user. Or, type finger and press enter to see who's on the system and what they are doing. Ex:
finger johndoe
Use logout to quit using the system Yep, you guessed it, typing logout will log your account out of the system.
Type logout at the prompt to disconnect from your Linux machine or to logout a particular user session from the system. Keep in mind that although rudimentary, leaving your critical account logged on may be a security concern. We always recommend promptly using logout when you are finished using your root account! Ex:
logout
Use ls to list files and directories Type ls to see a list of the files and directories located in the current directory. If you’re in the directory named games and you type ls, a list will appear that contains files in the games directory and sub-directories in the games directory. Examples:
ls Mail
ls /usr/bin

Type ls -alt to see a list of all files (including .rc files) and all directories located in the current directory. The listing will include detailed, often useful information. Examples:
ls -alt
ls -alt /usr/bin
If the screen flies by and you miss seeing a number of files, try using the |more at the end like:
ls -alt |more

* In Bash (Linux shell) often the abbreviated command L is available. To get a verbose listing of files and directories you could therefore simply type: l

Use man to pull up information about a Linux command Type man followed by a command to get detailed information about how to use the command. Ex:
man ls

Type man -k followed by a word to list all of the commands and descriptions that contain the word you specified. Ex:
man -k finger
Use more to read the contents of a file Type more followed by the name of a text file to read the file’s contents. Why do we exmphasize using this on a "text" file? Because most other types of files will look like garbage! Ex:
more testfile.txt
Use nano to start a text editor Typing nano will start a basic text editor on most Linux systems.
Type nano followed by the filename you wish to edit. This basic editor is quick and easy to use for beginners. However, it is very important that you also learn about other text editors available on Linux and UNIX systems. Click on this link to learn about others like emacs, vi, and pico. Ex:
nano /etc/security/access.conf
Use passwd to change your current password Type passwd and press enter. You'll see the message Changing password for yourname.
At the Old password: prompt, type in your old password .
Then, at the Enter new password: prompt, type in your new password .
The system double checks your new password. Beside the Verify: prompt, type the new password and press again.

Create a secure password that combines parts of words and numbers. For instance, your dog's name may be Rufus. He may have been born in 1980. Create a password that uses parts of both the name and date of birth, such as 80rufuS. Note the use of at least one capital letter. This is a fairly secure password and easy to remember.
Use pwd to list the name of your current directory Type pwd and hit enter. You'll see the full name of the directory you are currently in. This is your directory path and is very handy. This is especially handy when you forget which directory you’ve changed to and are trying to run other commands.
Although there are a large number of Linux implementations, you will find a lot of similarities in the different
distributions, if only because every Linux machine is a box with building blocks that you may put together
following your own needs and views. Installing the system is only the beginning of a longterm relationship.
Just when you think you have a nice running system, Linux will stimulate your imagination and creativeness,
and the more you realize what power the system can give you, the more you will try to redefine its limits.
Linux may appear different depending on the distribution, your hardware and personal taste, but the
fundamentals on which all graphical and other interfaces are built, remain the same. The Linux system is
based on GNU tools (Gnu's Not UNIX), which provide a set of standard ways to handle and use the system.
All GNU tools are open source, so they can be installed on any system. Most distributions offer pre−compiled
packages of most common tools, such as RPM packages on RedHat and dpkg packages on Debian, so you
needn't be a programmer to install a package on your system. However, if you are and like doing things
yourself, you will enjoy Linux all the better, since most distributions come with a complete set of
development tools, allowing installation of new software purely from source code. This setup also allows you
to install software even if it does not exist in a pre−packaged form suitable for your system.
A list of common GNU software:
· Bash: The GNU shell
· GCC: The GNU C Compiler
· GDB: The GNU Debugger
· Findutils: to search and find files
· Fontutils: to convert fonts from one format to another or make new fonts
· The Gimp: GNU Image Manipulation Program
· Gnome: the GNU desktop environment
· Emacs: a very powerful editor
· Ghostscript and Ghostview: interpreter and graphical frontend for PostScript files.
· GNU Photo: software for interaction with digital cameras
Octave: a programming language, primarily intended to perform numerical computations and image
processing.
·
· GNU SQL: relational database system
· Radius: a remote authentication and accounting server

Does Linux have a future?

1.3. Does Linux have a future?
1.3.1. Open Source
The idea behind Open Source software is rather simple: when programmers can read, distribute and change
code, the code will mature. People can adapt it, fix it, debug it, and they can do it at a speed that dwarfs the
performance of software developers at conventional companies. This software will be more flexible and of a
better quality than software that has been developed using the conventional channels, because more people
have tested it in more different conditions than the closed software developer ever can.
The Open Source initiative started to make this clear to the commercial world, and very slowly, commercial
vendors are starting to see the point. While lots of academics and technical people have already been
convinced for 20 years now that this is the way to go, commercial vendors needed applications like the
Internet to make them realize they can profit from Open Source. Now Linux has grown past the stage where it
was almost exclusively an academic system, useful only to a handful of people with a technical background.
Now Linux provides more than the operating system: there is an entire infrastructure supporting the chain of
effort of creating an operating system, of making and testing programs for it, of bringing everything to the
users, of supplying maintenance, updates and support and customizations, etcetera. Today, Linux is ready to
accept the challenge of a fast−changing world

intro for beginners

This language was especially developed for creating the UNIX system. Using this new technique, it was much
easier to develop an operating system that could run on many different types of hardware.
The software vendors were quick to adapt, since they could sell ten times more software almost effortlessly.
Weird new situations came in existence: imagine for instance computers from different vendors
communicating in the same network, or users working on different systems without the need for extra
education to use another computer. UNIX did a great deal to help users become compatible with different
systems.
Throughout the next couple of decades the development of UNIX continued. More things became possible to
do and more hardware and software vendors added support for UNIX to their products.
UNIX was initially found only in very large environments with mainframes and minicomputers (note that a
PC is a "micro" computer). You had to work at a university, for the government or for large financial
corporations in order to get your hands on a UNIX system.
But smaller computers were being developed, and by the end of the 80's, many people had home computers.
By that time, there were several versions of UNIX available for the PC architecture, but none of them were
truly free.
1.1.2. Linus and Linux
Linus Torvalds, a young man studying computer science at the university of Helsinki, thought it would be a
good idea to have some sort of freely available academic version of UNIX, and promptly started to code.
He started to ask questions, looking for answers and solutions that would help him get UNIX on his PC.
Below is one of his first posts in comp.os.minix, dating from 1991:
From: torvalds@klaava.Helsinki.FI (Linus Benedict Torvalds)
Newsgroups: comp.os.minix
Subject: Gcc−1.40 and a posix−question
Message−ID: <1991jul3.100050.9886@klaava.helsinki.fi>
Date: 3 Jul 91 10:00:50 GMT
Hello netlanders,
Due to a project I'm working on (in minix), I'm interested in the posix
standard definition. Could somebody please point me to a (preferably)
machine−readable format of the latest posix rules? Ftp−sites would be
nice.
From the start, it was Linus' goal to have a free system that was completely compliant with the original UNIX.
That is why he asked for POSIX standards, POSIX still being the standard for UNIX.
In those days plug−and−play wasn't invented yet, but so many people were interested in having a UNIX
system of their own, that this was only a small obstacle. New drivers became available for all kinds of new
hardware, at a continuously rising speed. Almost as soon as a new piece of hardware became available,
someone bought it and submitted it to the Linux test, as the system was gradually being called, releasing more
free code for an ever wider range of hardware. These coders didn't stop at their PC's; every piece of hardware
they could find was useful for Linux.
Back then, those people were called "nerds" or "freaks", but it didn't matter to them, as long as the supported
hardware list grew longer and longer. Thanks to these people, Linux is now not only ideal to run on new PC's,
but is also the system of choice for old and exotic hardware that would be useless if Linux didn't exis

What is Linux?

What is Linux?
We will start with an overview of how Linux became the operating system it is today. We
will discuss past and future development and take a closer look at the advantages and
disadvantages of this system. We will talk about distributions, about Open Source in general
and try to explain a little something about GNU.
This chapter answers questions like:
¨ What is Linux?
¨ Where and how did Linux start?
¨ Isn't Linux that system where everything is done in text mode?
¨ Does Linux have a future or is it just hype?
¨ What are the advantages of using Linux?
¨ What are the disadvantages?
¨ What kinds of Linux are there and how do I choose the one that fits me?
¨ What are the Open Source and GNU movements?
1.1. History
1.1.1. UNIX
In order to understand the popularity of Linux, we need to travel back in time, about 30 years ago...
Imagine computers as big as houses, even stadiums. While the sizes of those computers posed substantial
problems, there was one thing that made this even worse: every computer had a different operating system.
Software was always customized to serve a specific purpose, and software for one given system didn't run on
another system. Being able to work with one system didn't automatically mean that you could work with
another. It was difficult, both for the users and the system administrators.
Computers were extremely expensive then, and sacrifices had to be made even after the original purchase just
to get the users to understand how they worked. The total cost of IT was enormous.
Technologically the world was not quite that advanced, so they had to live with the size for another decade. In
1969, a team of developers in the Bell Labs laboratories started working on a solution for the software
problem, to address these compatibility issues. They developed a new operating system, which was
1. Simple and elegant.
2. Written in the C programming language instead of in assembly code.
3. Able to recycle code.
The Bell Labs developers named their project "UNIX."
The code recycling features were very important. Until then, all commercially available computer systems
were written in a code specifically developed for one system. UNIX on the other hand needed only a small
piece of that special code, which is now commonly named the kernel. This kernel is the only piece of code
that needs to be adapted for every specific system and forms the base of the UNIX system. The operating
system and all other functions were built around this kernel and written in a higher programming language, C.