Mason Firewall
 
Search:

Home    Articles    Authors    Links    Useful Tips    Polls       
Browsing Issue # 2  
Monthly Notifications


Issue 2 Articles
Sshhh, somebody might hear you!
Linux Network Basics, Graphical Network Configuration.
A crash course introduction to linux.
Uses of AUTOLOAD - Perl
Interview with Linsight masterminds: David Whitinger and E.J. Wells
Can You Handle The Traffic ? - Part 2
Recovering Deleted Files with "mc"
Notes from the Linux Biz Expo (Chicago)

Latest Tips
Adding the hostname to the XTERM titlebar - dead simple!
Build RPMs as a User
Netstat - What is it good for ?

P o l l  Q u e s t i o n
What is your favorite text editor?

vi / vim
emacs / xemacs
pico
mcedit / nedit
joe
jove
cat > filename
other

   [ Results ]


Feedback

 
Setting Up
by: David Blackman
(New)    Print Edition

A crash course introduction to linux.

We've got a lot to cover, so let's get moving. Just so you know, when I write something in caps, like FILE_NAME, it means that's where you should put the actual file name, or <command> means substitute with the real command you're interested in.

First off, if you're at what appears to be a graphical login screen, get out! You can do this by pressing Crtl-Alt-F1, today we'll be working on the console. You should see something like this:

zaphod login:

Now type your username and password. If you only have a root account, we need to add another user so you can't kill your system in the first 5 minutes. The root user has complete power of the system, root can delete or modify or run any file on the system. You'll spend most of your time as a normal user, so let's add one. Pick a name for your account, less then or equal to 8 characters. (Everything after and including the # is a comment, don't type it).

$adduser blackmad # the syntax is adduser <username>

Now answer the questions it asks you, including what you want the password to be. Logout (either hit Crtl-D or type logout (enter)), and log back in as the user you just created. If you want to change your password, just type 'passwd' at the prompt. If you're root and want to change another user's password, type 'passwd' followed by the username who's password you want to change.

Now for some dry theory. Linux only has one 'drive', /, which is called the root directory. If you'd like, you can think of this as "My Computer" from windows 9X. All your removable media, and all your hard drive partitions will be mounted in a directory relative to '/', also, your device (more on these at another time) will be in /dev, and information about your system in /proc.

A little bit about what you can and can't do in Linux. You can develop applications, use a GUI that looks like windows or macOS or something entirely different, you can host a website, you can mount CDs, play games and lots more. The main thing you can't do is run windows executables, you can try using a program called WINE, but not all windows programs will run correctly with this, and many features are still unimplemented.

We're going to run through some basic Linux commands, and then work on mounting a CDROM.

ls - the equivalent of 'dir' in dos, lists the files in a directory
 

ls list files in current directory
ls -l long listing of files
ls -a list all files
ls /SOME_DIR /SOME_DIR list files in /SOME_DIR

Those are just a few of the dozens of command line switches for ls, they can be mixed and match like so:

ls -al /home Long listing of *all* files in /home

I'm now going to tell you the two most important things you'll ever learn in linux. To find out more about a command you usually have two options

man <command>

This will give you the manual page for the command, and usually a very detailed explanation of all the flag

<command> --help OR <command> -h

Generally this will print a shortened help for <command>

Some other useful commands:


cd 
change directory

pwd 
print working directory

cp FROM_FILE TO_FILE 
copy FROM_FILE to TO_FILE

mv 
FROM_FILE TO_FILE move FROM_FILE to TO_FILE - Be Careful! Look at the manpage first!

rm FILE 
removes FILE, be very careful!

mkdir DIR
make directory DIR

less FILE 
view FILE, cannot edit FILE.

you can give 'rm' multiple files to delete, and if you want to delete a directory you'd do

rm -rf DIRECTORY/

This will remove all files and try to force as many deletions as it can.

if you give 'cp' more then two arguments, the last must be a directory, because it will copy all the other arguments to that directory.

if you want to copy a directory you need to do

'cp -r directory/ to_directory/'
(-r for recursive)

You can now see your files, remove them, copy them, move them, and move around your files.

Now you'll want to edit something, modern Linux distros come with many editors, all of them will let you edit a file by giving them the file you want to edit as the first argument. Here are a few editors and very brief descriptions.

emacs very powerful editor, but easy to use, you can immediately start editing with it.
vi old and cumbersome editor, but very lightweight, has a steep learning curve
pico, ae, joe, jed all small editors that you can try and see if you like, all have on screen help

This lesson feels a little rushed, don't worry, we'll go through a sample system interaction at the end of this month's column, But now we're going to explore how to mount and unmount CDROMs and floppies!

First off, you'll need to be root to mount media. Linux has an odd way of naming hardware, your IDE devices are as follows:

/dev/hda Primary Master
/dev/hdb Primary Slave
/dev/hdc Secondary Master
/dev/hdd Secondary Slave

Your scsi devices will be on

/dev/sr#
for some scsi CDR's,
/dev/scd#
for other CDs,
/dev/sg#
for things the kernel can't comprehend (like scanners), but for now we'll look at
/dev/hdX
and
/dev/scd#
. When I say X, I mean substitute with a letter, and # means substiture with a number, starting at zero and going up.

If you know where your CDs are, great! You can skip this, otherwise, read on. We're now going to search through the kernel messages for our CDs, it's not as bad as it sounds.

dmesg | grep -i CD

Here's What I get:

hdc: CD-ROM 45X/A, ATAPI CDROM drive
hdd: CREATIVE CD-RW RW4224E, ATAPI CDROM drive
Vendor: E-IDE Model: CD-ROM 45X/A Rev: 30
Type: CD-ROM ANSI SCSI revision: 02
Detected scsi CD-ROM sr0 at scsi0, channel 0, id 0, lun 0
Vendor: CREATIVE Model: CD-RW RW4224E Rev: 1.36
Type: CD-ROM ANSI SCSI revision: 02
Detected scsi CD-ROM sr1 at scsi0, channel 0, id 1, lun 0
scsi : detected 2 SCSI cdroms 1 SCSI disk total.
sr0: scsi3-mmc drive: 0x/20x xa/form2 cdda tray
Uniform CDROM driver Revision: 2.56
sr1: scsi3-mmc drive: 24x/24x writer cd/rw xa/form2 cdda tray

Here's what's important

hdc: CD-ROM 45X/A, ATAPI CDROM drive
hdd: CREATIVE CD-RW RW4224E, ATAPI CDROM drive
sr0: scsi3-mmc drive: 0x/20x xa/form2 cdda tray
sr1: scsi3-mmc drive: 24x/24x writer cd/rw xa/form2 cdda tray

You see why? Because we have our /dev entries listed. Your floppy drives will have the entries /dev/fd#, with /dev/fd0 being the first floppy (a: in windows), most modern computers only have one floppy, so you shouldn't worry to much about it, but your second floppy (b: in windows), would be /dev/fd1.

Here's the outline of the mount command

mount -t FILESYSTEM /dev/DEVICE /MOUNTPOINT

Complex, no? No. generally you won't need the -t option, the kernel should be able to autodetect what filesystem is on the media, but here's the most common:

msdos MSDOS filesystem, used on almost all floppies
vfat FAT32 filesystem, used in win9X
hfs Mac filesystem
iso9660 CDROM filesystem

Then MOUNTPOINT is simply the directory where you want to mount the media, convention says mount floppies in /floppy and cdroms in /cdrom, you can mount wherever you want, just make sure the directory exists.

So to mount my CDROM which is my Secondary Master in /cdrom, I'd do:

mount -t iso9660 /dev/hdc /cdrom

Now I can ls /cdrom and cp files from it (but not to it, linux can't make your CDROMs into CDRs it's not that cool!).

Before you can take out your CD or floppy, you need to UNMOUNT it! Now make sure you're not in the directory you're trying to unmount from, and do:

umount /MOUNTPOINT

So to umount my CD I'd do this:

umount /cdrom

I think that's enough for a crash course in Linux, before you go, I have two parting pieces of advice:

First piece of advice: ~/ is an abbreviation for your home directory (if you're root it's /root, otherwise for every USER it's /home/USER)

so:

"cp /vmlinuz ~/"
will copy the file vmlinuz, in the root directory, to my home directory.

Second piece of advice: RTFM (Read the Fine Manual) check out www.linuxdoc.org, look at "Installation and Getting Started Guide" and "The Linux Users' Guide" as well as any HOWTO's that look interesting. Also, explore /usr/doc, look at the files in there, use less to look at them, or zless if the files end in .gz

And now for a brief refresh

$cd ~/ # change to my home directory

$mkdir test #make a directory, in the current directory, called test

$su # become superuser

Password: (The prompt often changes from $ to # when you become root)

#mkdir /my_cd_mountpoint #make a directory my_cd_mountpoint

#mount -t iso9660 /dev/hdc /my_cd_mountpoint #mount my cd

#Crtl-D #logout

$cd /my_cd_mountpoint #change my current directory

$ls #list files

file1 file2 file3 

$cp file1 file2 ~/test #copy file1 and file2 to the my home's test di

$cd ~ # I want to unmount the CD, so I leave the directory

$su #become superuser

Password: (The prompt often changes from $ to # when becoming root)

#umount /my_cd_mountpoint #unmount the CD

#rmdir /my_cd_mountpoint #delete the directory

#Crtl-D #logout

$less ~/test/file1 #View "file1" in the directory test in my home directory

$rm -rf ~/test #delete the directory test in my home directory

$Ctrl-D #logout

Other Articles by David Blackman

So You're Crazy?
Configuring X

0.4.0 Copyright to all articles belong to their respective authors.
Everything else © 2024 LinuxMonth.com
Linux is a trademark of Linus Torvalds.
Powered by Apache, mod_perl and Embperl.