Help - Search - Members - Calendar
Full Version: Command Line Help Please
I'm along time Windows user and I'm just now taking a look at linux os. Dos anyone know where I could learn command line basics or have some tips for me

Also i highly recommend just getting a book. The Linux Pocket Guide is great. Its about the size of a Z so you pack it along with your beast. A desk reference is pretty good. I like the O'Reilly books a lot.

Good luck!
QUOTE(Chazz @ Dec 20 2004, 07:49 PM)

The following is a good starting point for all kind of Linux. It is the most updated link site to Linux on the internet:
I'm typing this straight through, free thought -- so bear with me.

The old days of unix were based around non-graphical interfaces.
The basic philosophy of unix is/was "do one thing and do it well"
.. and in this regard, a calendar program is a calendar program and
not also a word processor, etc. Many (most old?) programs in unix
can be used as "filters" which means that the read input and produce
output. This is vastly different from running a program and interacting
with it via a mouse, etc.

Unix now has guis -- in fact, so many that even that is overly complicated
and broken due to fragmentation -- but at least there is a choice.

Shells are the same way. A shell is probably similar to the dos command
"window" ("cmd.exe" in later windows). Within this shell, you issue commands.
With widows, if these commands are in a file (file.bat) -- they are called a batch
file. In unix, they're called a "shell script" ... but, in fact, what you type at
the shell is really a script -- in a sense -- you're just doing it interactively.
More or less, if you put the (non gui) commands that you used in the shell
into a file -- you could then run that file to do those commands (aha!!! power
of unix!)

So, although you could probably do many things with guis that you can do with command line -- once you become familiar with more basic unix programs (ie: filters, etc) -- you probably can out produce a gui user.

In windows, to work faster you click faster -- with unix, to work faster you work smarter.

Old[er] unixes had a shell called "bourne shell" ("sh" is "/bin/sh") -- new[er]
systems come with many shells like ksh, csh, tcsh, zsk and linux is fond of
bash (the gnu "born again shell). I'm a long time tcsh user, but I've recently
decided to act upon my long time wish to switch to zsh.

Most scripts are written in sh due to hopes of cross platform use/compatibility.
bash is similar enough to sh that you might see the two mixed when dealing with linux boxes.

So, what can you do with a shell? "cd" is change directory. same as dos -- but unlike dos, you have to put a space after the command. In unix, the command is typically the first word and everything else up to a point are options for that program. For instace "ls" (for LiSt files) ... and then there is "ls -l" for a "longer" listing. Not all unix commands are as easy to remember (ie: espeically with linux!), but the basic ones are fairly easy and standard... cd, ls, rm, man, etc.

cd /usr/bin
ls a*
pick a command
"man command"
such as
ls l*
man ls

in the manual pages, you decipher them by reading the synopsis and then looking to see if there is an "examples" section (I personally think that all man(ual) pages should have an examples section -- and it seems that those pages that do have this section are actually better manual pages, regardless).
It may seem confusing with all the syntax... the []s and |s and stuff -- but this is just the unix way of saying some combination of things. For instance, the program ls has just about every letter as an option. Unix is case sensitive so an option of "e" is not the same as "E" ... also, in unix, most options are
prefixed with a hyphen (a "-" char) vs the dos forward slash ("/").

Unix is particular about syntax -- spaces and punctuation. For instance, a
simicolon (";") is typically used to separate commands. ie: cal; cal -- will run
the program "cal" two times.

Finally, the pipe character ("|") is pretty universally used to connect programs. How does this work? Well, remember, (many/most good/old?) unix programs may work as a filter ... so you can take the output of one program and use it -- ie "pass it" -- to another program as input.

run program 1
program 1 writes to output file a
program 1 finishes
run program 2 that reads from file a
program 2 finishes

program1 | program2

Unlike dos, unix doesn't make a temporary file behind the scenes that you
don't see.

Ok, so now you have some idea of a shell -- but which one? depends on what
you want to do -- you can program in /bin/sh, but I wouldn't recommend running
it as an interactive shell. My recommendation is that if you are going to be using linux a lot, perhaps starting with the "bash" shell is best.

You can certainly search on the net (and see posts above) that list where to find some information on shells. If you have specific questions, feel free to ask them here.

Some quick commands from a DOS user. smile.gif

ls = dir
cd .. = cd.. (cd / = cd\)
pwd = lists the current working directory, was that even in DOS?
chmod = attrib
shutdown (mostly the same, just add "now" to the end and /r = -h)
rm = del
cat = type

Hope that helps.