home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 8 / CDACTUAL8.iso / docs / mini / dos2linu / text0000.txt < prev   
Encoding:
Text File  |  1996-07-11  |  30.0 KB  |  778 lines

  1.  
  2. Section 0: Introduction
  3.  
  4. 0.1: Is Linux Right for You?
  5.  
  6. There is no such thing as "the best computer" or "the best operating 
  7. system": it all depends on what you have to do. For instance, I don't like 
  8. the Mac (sacrilege! ;-): it's surely easy to use, but to do some things I 
  9. prefer the PC by far. (Try the equivalent of dir/s/w >lst on a Mac!) Yet, 
  10. to many folks the Mac is simply "the best" computer. Likewise, I don't 
  11. believe that Linux is "the best" os: it is undoubtedly superior to, say, 
  12. Win 95, but many might prefer the latter.
  13.  
  14. Un*x is aimed at programmers/scientists, while Mac & Win are aimed at 
  15. nontechnical users. Therefore, you are going to benefit immensely from 
  16. Linux if what you need are compilers, network, and scientific sw in 
  17. general, and if you don't mind fiddling around and fixing things yourself: 
  18. in a word, if you like hacking. You'll hate Linux if you want everything to 
  19. work out of the box, if you need mostly commercial sw, and if you feel lost 
  20. typing in commands.
  21.  
  22. It's up to you. Remember that Linux and DOS/Windows can coexist on the same 
  23. machine, anyway.
  24.  
  25. 0.2: It is. Tell Me More
  26.  
  27. You installed Linux on the PC. You gave yourself an account following the 
  28. installation instructions (if this is not the case, see Section 6.1) and 
  29. Linux is running. Somebody told you that all the programs you needed were 
  30. there, and all you have to do is login and go. You've just entered your 
  31. name and password, and now you are looking at the screen thinking: "Well, 
  32. now what?"
  33.  
  34. Now, don't despair. You're almost ready to do the same things you used to 
  35. do with DOS, and many more. If you were running DOS instead of Linux, you 
  36. would be doing some of the following tasks:
  37.  
  38. 1. executing programs and creating, copying, viewing, deleting, renaming 
  39. files;
  40. 2. CD'ing, MD'ing, RD'ing, and DIR'ring your directories;
  41. 3. formatting floppies and copying files from/to them;
  42. 4. mending your AUTOEXEC.BAT and CONFIG.SYS;
  43. 5. writing your own .BAT files and/or QBASIC programs;
  44. 6. the remaining 1%.
  45.  
  46. You'll be glad to know that these tasks can be accomplished under Linux in 
  47. a fashion similar to DOS. Under DOS, the average user uses very few of the 
  48. 100+ commands available: the same, up to a point, can be said for Linux. 
  49. Incidentally, if you don't know the DOS commands for the tasks in the list, 
  50. drop out now: I won't be explaining what such things as a directory or the 
  51. PATH variable are.
  52.  
  53. A few things to point out before going on:
  54.  
  55. 1) unlike DOS, Linux has built-in security mechanisms. When you turn the PC 
  56. on and fire up Linux, you have to "log in", that is make yourself known to 
  57. the system; this is because Un*x is a multi-user os. Besides, the normal 
  58. user doesn't really own the system; at login time, only the user whose 
  59. login name is "root" has the power. (This guy's the system administrator. 
  60. If you work on your own PC, you'll be root.) Files and directories have 
  61. permissions associated to them, and therefore some cannot be accessed by 
  62. the normal user. DOS, on the other hand, will let you wipe out the entire 
  63. contents of your hard disk;
  64.  
  65. 2) once you have finished working, you *must not* switch off your PC! 
  66. Instead, you must follow the correct shutdown procedure (press CTRL-ALT-
  67. DEL, wait for the system to fix its innards and tell you everything is OK, 
  68. then switch off the PC). Anyway, Linux is such a reliable os that it is 
  69. *extremely* unlikely that an ill-behaved application will ever hang your 
  70. machine - you'll never need to reset.
  71.  
  72. 3) you are strongly encouraged to experiment, play, try by yourself: it 
  73. surely won't hurt. You can get some help typing at the prompt ($ is the 
  74. standard prompt, # is the prompt for root):
  75.     $ help
  76. (pretty logical), or get info about a command typing
  77.     $ man <command>
  78. which, if you have installed the man pages, will invoke the manual ("man") 
  79. page associated to <command>. You may also try
  80.     $ apropos <command>
  81. or
  82.     $ whatis <command>
  83.  
  84. 4) conventions:
  85. a) <...> means something that must be specified, while [...] something 
  86. optional. Example:
  87.     $ tar -tf <file.tar> [> redir_file]
  88. file.tar must be indicated, but redirection to redir_file is optional.
  89. b) from now on "RMP" means "read the man pages for further information".
  90.  
  91. You are now ready to refer to the following sections.
  92.  
  93.  
  94. Section 1: Working with Files
  95.  
  96. 1.1. Files: Preliminary Notions
  97.  
  98. Linux has a file system - meaning by that "the structure of directories and 
  99. files in them" - very similar to that of DOS. Files have filenames that 
  100. obey special rules, are stored in directories, some are executable, and 
  101. among these most have command switches. Moreover, you can use wildcard 
  102. characters, redirection, and piping. There are only a few minor 
  103. differences.
  104.  
  105. - First difference: under DOS, file names are in the so-called 8.3 form; 
  106. e.g. NOTENOUG.TXT. Under Linux we can do better. If you installed Linux 
  107. using a filesystem (you needn't know what it means now) like ext2 or 
  108. umsdos, you can use longer filenames, and with more than one dot in them: 
  109. for example, This_is.a.VERY_long.filename. Please note that I used both 
  110. upper case and lower case characters. In fact...
  111.  
  112. - Second difference: upper case and lower case characters are different. 
  113. Therefore, FILENAME.tar.gz and filename.tar.gz are two different files. The 
  114. same holds true for commands: if you issue the command ls (the same as DIR 
  115. under DOS) you'll get a list of files in your directory, but if you enter 
  116. LS you'll get an error message.
  117.  
  118. - Third difference: if you start a filename with a period, the file will be 
  119. considered as hidden. Example: the file .I.am.a.hidden.file won't show up 
  120. after an ls command.
  121.  
  122. - Fourth difference: there are no compulsory exensions like .COM and .EXE 
  123. for programs, or .BAT for batch files. Executable files are marked by a 
  124. star * at the end of their name when you issue the ls -F command. For 
  125. example:
  126.     $ ls -F
  127.     letter_to_Joe  Cindy.jpg  cjpg*  I_am_a_dir/  my_1st_script*
  128. The files cjpg* and my_1st_script* are executable - "programs". Under DOS, 
  129. files ending in .BAK represent backup files; under Linux, such files are 
  130. those ending with a tilde ~.
  131.  
  132. - Fifth difference: DOS program switches are obtained with /switch, while 
  133. under Linux with -switch. Example: dir /s becomes ls -R. Note that many DOS 
  134. programs, like PKZIP or ARJ, use Un*x-style switches.
  135.  
  136. 1.2. Files: Translating Commands from DOS to Linux
  137.  
  138. On the left, the DOS commands; on the right, their Linux counterpart.
  139.  
  140. COPY:   cp
  141. DEL:    rm
  142. REN:    mv
  143. TYPE:   more, less, cat
  144.  
  145. Redirection and plumbing operators: < > >> |
  146. Wildcards: * ?
  147. nul:    /dev/null
  148. prn, lst:       /dev/lp0; lpr
  149.  
  150. - EXAMPLES -
  151.  
  152. DOS                                     Linux
  153.  
  154. C:\GUIDO>copy joe.txt joe.doc           $ cp joe.txt joe.doc
  155. C:\GUIDO>copy *.* total                 $ cat * > total
  156. C:\GUIDO>copy fractals.doc prn          $ cat fractals.doc | lpr
  157. C:\GUIDO>del temp                       $ rm temp
  158. C:\GUIDO>del *.bak                      $ rm *~
  159. C:\GUIDO>ren paper.txt paper.asc        $ mv paper.txt paper.asc
  160. C:\GUIDO>type letter.txt                $ more letter.txt
  161. C:\GUIDO>type letter.txt                $ less letter.txt
  162. C:\GUIDO>type letter.txt > nul          $ cat letter.txt >/dev/null
  163.     n/a                             $ more *.txt *.asc
  164.     n/a                             $ cat section*.txt
  165.  
  166. Notes:
  167.  
  168. 1) * is smarter under Linux:
  169. - * matches all files except the hidden ones; .* matches all hidden files; 
  170. *.* matches only those ending with . plus other characters;
  171. - p*r matches both peter and piper; *c* matches both picked and peck;
  172. 2) when using more, press <space> to read through the file, 'q' or CTRL-C 
  173. to exit. less is more inuitive and lets you use the arrow keys;
  174. 3) there is no UNDELETE, so *think twice* before deleting anything;
  175. 4) in addition to DOS's < > >>, Linux has 2> to redirect error messages 
  176. (stderr);
  177. 6) Linux has another wildcard: the []. Use:
  178. - [abc]* matches files starting with a, b, c;
  179. - [I-N]* matches files starting with I, J, K, L, M, N.
  180. 7) there is no DOS-like RENAME; that is, ren *.xxx *.yyy won't work. 
  181.  
  182. 1.3. Executing Programs: Multitasking and Sessions
  183.  
  184. To run a program, type in its name as you would do under DOS. If the 
  185. directory (Section 2) where the program is stored is included in the PATH 
  186. (Section 4), the program will start. Exception: unlike DOS, under Linux a 
  187. program located in the current directory won't run unless the directory is 
  188. included in the PATH. Escamotage: being <prog> your program, type ./<prog>.
  189.  
  190. This is what the typical command line looks like:
  191.     $ command -s1 -s2 ... -sn par1 par2 ... parn <input >output
  192. where -s1, ..., -sn are the program switches, par1, ..., parn are the 
  193. program parameters. It is possible to issue several commands on the command 
  194. line:
  195.     $ command1 ; command2 ; ... ; commandn
  196. That's all about running programs, but it's easy to go a step beyond. One 
  197. of the main reasons for using Linux is that it is a multitasking os - it 
  198. can run several programs (from now on, processes) at the same time. You can 
  199. launch processes in background and continue working straight away. 
  200. Moreover, Linux lets you have several sessions: it's like having many 
  201. computers to work on at once!
  202.  
  203. - To switch to session 1..8:
  204.     $ <ALT-F1> ... <ALT-F8>.
  205. - To start a new session without leaving the current one:
  206.     $ su - <loginname>
  207. Example:
  208.     $ su - root
  209. This is useful, for one, when you need to mount a disk (Section 3): only 
  210. root can do that.
  211. - To end a session:
  212.     $ exit
  213. - To launch a process in foreground:
  214.     $ progname [-switches] [parameters] [<input] [>output]
  215. - To launch a process in background, add an ampersend (&) at the end of the 
  216. line:
  217.     $ progname [-switches] [parameters] [<input] [>output] &
  218. - To see how many processes there are:
  219.     $ ps
  220. This will output a list of processes currently running. Each one is 
  221. identified by a PID, a number.
  222. - To kill a process:
  223.     $ kill <PID>
  224. You may need to kill a process when you don't know how to quit it the right 
  225. way... ;-). Sometimes, a process will only be killed by either one of the 
  226. following:
  227.     $ kill -15 <PID>
  228.     $ kill -9 <PID>                 
  229. In addition to this, the shell (the equivalent of COMMAND.COM; most folks 
  230. use a shell called bash) allows you to stop or temporarily suspend a 
  231. process, send a process to background, and bring a process from background 
  232. to foreground. In this context, processes are called "jobs".
  233. - To see how many jobs there are:
  234.     $ jobs
  235. here jobs are identified by the numbers the shell gives them, not by their 
  236. PID.
  237. - To stop a process running in foreground:
  238.     $ <CTRL-C>
  239. (it doesn't always work)
  240. - To suspend a process running in foreground:
  241.     $ <CTRL-Z>
  242. (ditto)
  243. - To send a suspended process into background:
  244.     $ bg <job>
  245. - To bring a process to foreground:
  246.     $ fg <job>
  247. - Again, to kill a process:
  248.     $ kill %<job>
  249. where <job> may be 1, 2, 3, ...  Using these commands you can format a 
  250. disk, zip a bunch of files, compile a program, and unzip an archive all at 
  251. the same time, and still have the prompt at your disposal. Try this with 
  252. DOS! And try with Windows, just to see the difference in performance. 
  253.  
  254.  
  255. Section 2: Using Directories
  256.  
  257. 2.1. Directories: Preliminary Notions
  258.  
  259. We have seen the differences between files under DOS and Linux. As for 
  260. directories, under DOS the root directory is \, under Linux / is. 
  261. Similarly, nested directories are separated by \ under DOS, by / under 
  262. Linux. Example of file paths:
  263.     DOS:    \PROGRAMS\C++\SOURCES\HELLO.CPP
  264.     Linux:  /home/guido/papers/geology/mid_eocene.tex
  265. As usual, .. is the parent directory, . is the current directory. Remember 
  266. that the system won't let you cd, rd, or md everywhere you want. Every user 
  267. starts from his or her own directory called home, given by the system 
  268. administrator; for instance, on my PC my home dir is /home/guido.
  269.  
  270. 2.2. Translating Commands from DOS to Linux
  271.  
  272. DIR:    ls, find, du
  273. CD:     cd, pwd
  274. MD:     mkdir
  275. RD:     rmdir
  276.  
  277. - EXAMPLES -
  278.  
  279. DOS                                     Linux
  280.  
  281. C:\GUIDO>dir                            $ ls
  282. C:\GUIDO>dir file.txt                   $ ls file.txt
  283. C:\GUIDO>dir *.h *.c                    $ ls *.h *.c
  284. C:\GUIDO>dir/p                          $ ls | more
  285. C:\GUIDO>dir \*.tmp /s                  $ find / -name "*.tmp"
  286. C:\GUIDO>cd                             $ pwd
  287.     n/a - see note                  $ cd
  288.     n/a - see note                  $ cd ~
  289.     n/a - see note                  $ cd ~/temp
  290. C:\GUIDO>cd \other                      $ cd /other
  291. C:\GUIDO>cd ..\temp\trash               $ cd ../temp/trash
  292. C:\GUIDO>md newprogs                    $ mkdir newprogs
  293. C:\GUIDO>md \progs\turbo                $ mkdir /progs/turbo
  294. C:\GUIDO>rd newprogs                    $ rmdir newprogs
  295. C:\GUIDO>rd \progs\turbo                $ rmdir /progs/turbo
  296.  
  297. Note: the character ~ is a shortcut for the name of your home directory. 
  298. The commands cd or cd ~ will take you to your home directory from wherever 
  299. you are; the command cd ~/tmp will take you to /home/your_home/tmp. Got 
  300. the hang of it?
  301.  
  302.  
  303. Section 3: Floppies, Hard Disks, and the Like
  304.  
  305. 3.1. Using a floppy disk
  306.  
  307. You have never thought about it, but the DOS command FORMAT A: does a lot 
  308. more work than it seems. In fact, when you issue the command FORMAT it 
  309. will:
  310. 1) physically format the disk;
  311. 2) create the A:\ directory (= create a filesystem);
  312. 3) make the disk available to the user (= mount the disk).
  313.  
  314. These three steps are addressed separately under Linux. It is possible to 
  315. prepare and use floppies in MS-DOS format, though other formats are 
  316. available; the most common is perhaps ext2. Here is how to prepare a disk 
  317. (you'll need to start a session as root):
  318.  
  319. - To format a standard 1,44 Meg floppy disk (A:):
  320.     # fdformat /dev/fd0H1440
  321. - To create a filesystem:
  322.     # mkfs -t ext2 -c /dev/fd0H1440
  323. or
  324.     # mformat a:
  325. to create an MS-DOS filesystem.
  326.  
  327. Beore using the disk, you must mount it.
  328. - To mount the disk:
  329.     # mount -t ext2 /dev/fd0 /mnt
  330. or
  331.     # mount -t msdos /dev/fd0 /mnt
  332.  
  333. Now you can address the files in the floppy. When you've finished, before 
  334. extracting the disk you must unmount it. (*very important!*)
  335. - To unmount the disk:
  336.     # umount /mnt
  337. Now you can extract the disk. Obviously, you have to fdformat and mkfs only 
  338. unformatted disks, not previously used ones. If you want to use drive B:, 
  339. refer to fd1H1440 and fd1 instead of fd0H1440 and fd0 in the examples 
  340. above.
  341.  
  342. All you used to do with A: or B: is now done using /mnt instead. Examples:
  343.  
  344. DOS                             Linux
  345.  
  346. C:\GUIDO>dir a:                 $ ls /mnt
  347. C:\GUIDO>copy a:*.* \docs\temp  $ cp /mnt/* /docs/temp
  348. C:\GUIDO>copy *.zip a:\zip      $ cp *.zip /mnt/zip
  349. C:\GUIDO>a:                     $ cd /mnt
  350. A:\>                            /mnt$
  351.  
  352. Needless to say, what holds for floppies holds for whatever device you can 
  353. think of; for instance, you may want to mount another hard disk or a CD-ROM 
  354. drive. Have a look at the list of devices in directory /dev. Here's how to 
  355. mount the CD-ROM:
  356.     # mount -t iso9660 /dev/cdrom /cdrom
  357.  
  358.  
  359. Section 4: Tayloring the System
  360.  
  361. 4.1. System Initialization Files
  362.  
  363. Two important files under DOS are AUTOEXEC.BAT and CONFIG.SYS, which are 
  364. used at boot time to initialise the system, set some environment variables 
  365. like PATH and FILES, and possibly launch a program or batch file.
  366.  
  367. Under Linux there are several initialisation files, some of which you had 
  368. better not tamper with until you know exactly what you are doing. I'll tell 
  369. you what the most important are, anyway:
  370.  
  371. FILES                           NOTES
  372.  
  373. /etc/inittab                    don't touch for now!
  374. /etc/rc.d/*                     ditto
  375.  
  376. If all you need is setting the PATH and other environment variables, or you 
  377. want to change the login messages or automatically launch a program after 
  378. the login, have a look at the following files:
  379.  
  380. FILES                           NOTES
  381.  
  382. /etc/issue                      sets pre-login message
  383. /etc/motd                       sets post-login message
  384. /etc/profile                    sets PATH and other variables, etc.
  385. /home/your_home/.profile        does whatever you want
  386.  
  387. If the latter file exists (note that it is a hidden file), it will be read 
  388. after the login and the commands in it will be executed.
  389.  
  390. Example - look at this .profile:
  391.  
  392.     # I am a comment
  393.     echo Environment:
  394.     printenv | more   # equivalent of command SET under DOS
  395.     alias d='ls -l'   # easy to understand what an alias is
  396.     alias up='cd ..'
  397.     echo "I remind you that the path is "$PATH
  398.     echo "Have a good day, "$LOGNAME
  399.  
  400. PATH and LOGNAME, you guessed right, are environment variables.
  401.  
  402. 4.2. Program Initialization Files
  403.  
  404. Under Linux, virtually everything can be tailored to your needs. Most 
  405. programs have one or more initialization files you can fiddle with, often 
  406. as a .prognamerc in your home dir. The first ones you'll want to modify 
  407. are:
  408.  
  409. .xinitrc: used by startx to initialize X Window System.
  410. .fvwmrc: used by the window manager fvwm. A sample can be found in:
  411. /usr/lib/X11/fvwm/system.fvwmrc
  412. .xfm/*: used by xfm, a file manager for X.
  413. .Xdefault: used by rxvt, a terminal emulator for X.
  414.  
  415. For all of these and the others you'll come across sooner or later, RMP.
  416.  
  417.  
  418. Section 5: A Bit of Programming
  419.  
  420. 5.1. Writing Scripts: .BAT Files on Steroids
  421.  
  422. If you used .BAT files to create shortcuts of long command lines (I did a 
  423. lot), this goal can be attained by inserting appropriate alias lines (see 
  424. example above) in profile or .profile. But if your .BATs were more 
  425. complicated, then you'll love the scripting language made available by the 
  426. shell: it's as powerful as Qbasic, if not more. It has variables, 
  427. structures like while, for, case, if... then... else, and lots of other 
  428. features: it can be a good alternative to a "real" programming language.
  429.  
  430. To write a script - the equivalent of a .BAT file under DOS - all you have 
  431. to do is write a standard ASCII file containing the instructions, save it, 
  432. then make it executable with the command
  433.     $ chgmod u+x <scriptfile>
  434. To execute it, type in its name.
  435.  
  436. A word of warning. The system editor is called vi, it's rather difficult to 
  437. use, and I'm sure you'll find it lousy. I'm not going to explain how to use 
  438. it, because I myself can't find my way around in it yet; see Matt Welsh's 
  439. "Linux installation... ", page 109. You had better get hold of another 
  440. editor like joe or emacs for X. Suffice it here to say that:
  441. - to insert some text, type i then your text;
  442. - to quit vi whithout saving, type ESC then :q!
  443. - to save and quit, type ESC then :wq
  444.  
  445. Writing scripts under Linux is such a vast subject it would require a book 
  446. by itself, and I will not delve into the subject any further. I'll just 
  447. give you a few (hopefully) useful examples from which you can extract some 
  448. basic rules.
  449.  
  450. EXAMPLE 1: first_script
  451.  
  452.     #!/bin/sh
  453.     # I am a comment
  454.     # don't change the first line - it's got to be there
  455.     echo "Today is `date`"
  456.     echo "My name is "$0
  457.     echo "You gave me the following "$#" parameters: "$*
  458.     echo "First parameter is "$1
  459.     echo "Have you grasped the trick?"
  460.  
  461. EXAMPLE 2: 2exe
  462.  
  463.     #!/bin/sh
  464.     echo "making "$1" executable... "
  465.     chmod u+x $1
  466.  
  467. EXAMPLE 3: backup
  468.  
  469.     #!/bin/sh
  470.     echo "Copying files in ~/bak... "
  471.     for name in $*
  472.     do
  473.       cp ${name} ~/bak
  474.     done
  475.  
  476. EXAMPLE 4: fmta
  477.  
  478.     #!/bin/sh
  479.     echo "I remind you that only root can format disks"
  480.     fdformat /dev/fd0H1440
  481.     mkfs -t ext2 -c /dev/fd0H1440
  482.     echo "disk formatted."
  483.  
  484. EXAMPLE 5: mnta
  485.  
  486.     #!/bin/sh
  487.     echo "I remind you that only root can mount disks"
  488.     mount -t msdos /dev/fd0 /mnt
  489.     echo "don't forget to umount when you've done."
  490.  
  491. 5.2. C for Yourself
  492.  
  493. You're not expecting to find GW/Qbasic under Linux, are you? Under Un*x, 
  494. the system language is C, love it or hate it. Lots of other languages 
  495. (FORTRAN, Pascal, Lisp, Basic... but not Turbo Pascal, helas) are also 
  496. available.
  497.  
  498. Taken for granted that you know C, here are a couple of guidelines for 
  499. those of you who have been pampered by Turbo C++ or one of its DOS 
  500. brothers. Linux's C compiler is called gcc and lacks all the bells and 
  501. whistles that usually accompany its DOS counterparts: no IDE, on-line help, 
  502. integrated debugger, etc. It's just a rough command-line compiler, very 
  503. powerful and efficient. To compile your standard hello.c you'll do:
  504.     $ gcc hello.c
  505. which will create an executable file called a.out. To give the executable a 
  506. different name, do
  507.     $ gcc -o hola hello.c
  508. To link a program with a library, add the switch -l<arg>. For example, to 
  509. link the math library do
  510.     $ gcc -o mathprog mathprog.c -lm
  511. (The -l<arg> switch forces gcc to link the library /usr/lib/lib<arg>.a; so 
  512. -lm links /usr/lib/libm.a).
  513.  
  514. All this is good for small programs. But when your prog is made of several 
  515. source files, you'll need to use the utility make. Let's suppose you have 
  516. written an expression parser: its source file is called parser.c and 
  517. #includes two header files, parser.h and xy.h. Then you want to use the 
  518. routines in parser.c in a program, say, calc.c, which in turn #includes 
  519. parser.h. What a mess! What do you have to do to compile calc.c? 
  520.  
  521. You'll have to write a so-called makefile, which tells the compiler the 
  522. dependencies between sources and objects files. In our example:
  523.  
  524.     #  This is makefile, used to compile calc.c
  525.     #  Press the <TAB> key at appropriate positions!
  526.  
  527.     calc: calc.o parser.o
  528.     <TAB>gcc -o calc calc.o parser.o -lm
  529.     # calc depends on two object files: calc.o and parser.o
  530.  
  531.     calc.o: calc.c parser.h
  532.     <TAB>gcc -c calc.c
  533.     # calc.o depends on two source files
  534.  
  535.     parser.o:  parser.c parser.h xy.h
  536.     <TAB>gcc -c parser.c
  537.     # parser.o depends on three source files
  538.  
  539.     # end of makefile.
  540.  
  541. Save this file as makefile and then type
  542.     $ make
  543. to compile your program; alternatively, save it as calc.mak and then type
  544.     $ make -f calc.mak
  545. And of course, RMP.
  546.  
  547. In addition to all this, remember that you can invoke some help about the C 
  548. functions, which are covered by man pages; for example,
  549.     $ man printf
  550.  
  551.  
  552. Section 6: The Remaining 1%
  553.  
  554. 6.1. Unroot Yourself
  555.  
  556. It's a very bad idea to login as root to do everyday work; such account is 
  557. dangerous and should be used for system administration only. To give 
  558. yourself a new account, login as root and issue the command
  559.     # adduser
  560. entering then the information the system will ask you. (Enter <RET> to the 
  561. questions you don't understand; default values will be used.)
  562.  
  563. 6.2. Making Virtual Memory
  564.  
  565. Although Linux can theoretically run with only 2 megs of RAM, the more you 
  566. have, the more you can do. X Window System won't run unless you have at 
  567. least 8 megs. To create an additional 8 megs of virtual memory, type as 
  568. root:            
  569.     # dd if=/dev/zero of=/swapfile bs=1024 count=8192
  570.     # mkswap /swapfile 8192
  571.     # sync
  572.     # swapon /swapfile
  573. Add the last line in /etc/rc.d/rc.local to make the swapfile available the 
  574. next time you boot.
  575.  
  576. 6.3. Using tar & gzip
  577.  
  578. Under Un*x there are some widely used applications to archive and compress 
  579. files. tar is used to make archives - it's like PKZIP but doesn't compress, 
  580. it only archives. To make a new archive:
  581.     $ tar -cvf <archive_name.tar> <file> [file...]
  582. To extract files from an archive:
  583.     $ tar -xpvf <archive_name.tar> [file...]
  584. To list the contents of an archive:
  585.     $ tar -tf <archive_name.tar> | less
  586. You can compress files using compress, which is obsolete and shouldn't be 
  587. used any more, or gzip:
  588.     $ compress <file>
  589. or:
  590.     $ gzip <file>
  591. that creates a compressed file with extension .Z (compress) or .gz (gzip). 
  592. These programs can compress only one file at a time. To decompress, use
  593.     $ compress -d <file>
  594. or
  595.     $ gzip -d <file>
  596. RMP.
  597.  
  598. The arj, zip and unzip (PK??ZIP compatible) utilities are also available. 
  599. Files with extension .tar.gz or .tgz (archived with tar, then compressed 
  600. with gzip) are as common in the Un*x world as .ZIP files are under DOS. 
  601. Here's how to list the contents of a .tar.gz archive:
  602.     $ gzip -dc <file.tar.gz> | tar tf - | less
  603.  
  604. 6.4. Installing Applications
  605.  
  606. Most Linux applications are distributed as .tar.gz archives, specifically 
  607. prepared so that they can be decompressed from / typing the following 
  608. command:
  609.     # gzip -dc <file.tar.gz> | tar xvf -
  610. The files will be decompressed in the right directory, which will be 
  611. created on the fly. Great, isn't it? Users of the Slackware distribution 
  612. (and perhaps other distributions - I don't know) have a user-friendly 
  613. pkgtool program, though.
  614.  
  615. Others packages have their own installation instructions; read the 
  616. documentation. Besides, some packages are distributed as C or C++ source 
  617. files, which you'll have to compile to create the binaries. In most cases, 
  618. all you have to do is issue
  619.     # make
  620. Obviously, you'll need the gcc compiler, included in most distributions. 
  621. And remember that installing packages is root's work.
  622.  
  623. 6.5. Tips You Can't Do Without
  624.  
  625. Command completion: pressing <TAB> when issuing a command will complete the 
  626. command line for you. Example: you have to type gcc this_is_a_long_name.c; 
  627. typing in gcc thi<TAB> will suffice. (If you have other files that start 
  628. with the same characters, type enough characters to resolve any ambiguity.)
  629.  
  630. Backscrolling: pressing SHIFT + PAG UP (the grey key) allows you to 
  631. backscroll a few pages, depending on how much video memory you have. 
  632. Moreover, if you issue the command
  633.     $ script <script_file>
  634. everything that appears on screen until you issue the command exit will be 
  635. copied to the file script_file, which you can examine later on.
  636.  
  637. Resetting the screen: if you happen to more or cat a binary file, your 
  638. screen may end up full of garbage. To fix things, blind type
  639.     $ reset
  640. or this sequence of characters: echo CTRL-V ESC c RETURN.
  641.  
  642. Messages from the kernel: have a look at /var/adm/messages as root to see 
  643. what the kernel has to tell you, including bootup messages.
  644.  
  645. 6.6. Useful Programs
  646.  
  647. First of all, where to find them. Since you all know how to surf the Net 
  648. and how to use archie and ftp, I'll just give you three of the most 
  649. important addresses for Linux: sunsite.unc.edu, TSX-11.mit.edu, and 
  650. nic.funet.fi. Please use your nearest mirror.
  651.  
  652. at allows you to run programs at a specified date and time;
  653.  
  654. delete-undelete do what their name means;
  655.  
  656. df gives you info about the hard disk(s);
  657.  
  658. dosemu allows you to run several (not all) DOS programs - including Windows 
  659. 3.x, with a bit of fiddling;
  660.  
  661. file <filename> tells you what a file is (ASCII text, executable, archive, 
  662. etc.);
  663.  
  664. find (see section 2.2) is one of the most powerful and useful commands. It 
  665. can be used to find files that match several characteristics and perform 
  666. actions on them. General use of find is:
  667.     $ find <directory> <expression>
  668. where <expression> includes search criteria and actions. Examples:
  669.     $ find . -type l -exec ls -l {} \;
  670. finds all the files that are symbolic links and show what they point to.
  671.     $ find / -name "*.old" -ok rm {} \;
  672. finds all the files matching the pattern and deletes them, asking for your 
  673. permission first.
  674.     $ find . -perm 755
  675. finds all the files whose permissions match 755 (executable).
  676.     $ find . -user root
  677. finds all the files that belong to root.
  678. Lots of possibilities here - RMP.
  679.  
  680. grep finds text patterns within files. For example,
  681.     $ grep -l "geology" *.tex
  682. lists the files *.tex that contain the word "geology". RMP;
  683.  
  684. gzexe compresses executable binaries keeping them executable;
  685.  
  686. joe is an excellent editor. Invoking it by typing jstar you'll get the same 
  687. key bindings as WordStar and its offspring, including the DOS editor;
  688.  
  689. lpr <file> prints a file in background. To check the status of the printing 
  690. queue, use lpq;
  691.  
  692. mc is a very useful file manager;
  693.  
  694. pine is a nice e-mailing program;
  695.  
  696. sudo allows users to perform some of root's tasks (e.g. formatting and 
  697. mounting disks; RMP)
  698.  
  699. uname -a gives you info about your system;
  700.  
  701. zcat and zless are useful for viewing gzipped text files without ungzipping 
  702. them. Possible use:
  703.     $ zless textfile.gz
  704.     $ zcat textfile.gz | lpr
  705.  
  706. 6.6. Common Extensions and Related Programs
  707.  
  708. You may come across scores of file extensions. Excluding the more exotic 
  709. ones (i.e. fonts, etc.), here's a list of who's what:
  710.  
  711. .1 ... .8: man pages. Get man.
  712. .arj: archive made with arj.
  713. .dvi: output file produced by TeX (see below). xdvi to visualize it; dvips 
  714. to turn it into a postscript .ps file.
  715. .gif: graphic file. Get seejpeg or xpaint.
  716. .gz: archive made with gzip.
  717. .info: info file (sort of alternative to man pages). Get info.
  718. .jpg,.jpeg: graphic file. Get seejpeg.
  719. .ps: postscript file. To visualize it get gs and, optionally, ghostview. 
  720. (great!)
  721. .tgz,.tar.gz: archive made with tar and compressed with gzip.
  722. .tex: text file to submit to TeX, a powerful typesetting program. Get the 
  723. package tex, available in many distributions.
  724. .texi: texinfo file (cp. .info). Get texinfo.
  725. .xbm,.xpm,.xwd: graphic file. Get xpaint.
  726. .zip: archive made with zip. Get zip and unzip.
  727. .Z: archive made with compress.
  728.  
  729.  
  730. The End, for Now
  731.  
  732. Congratulations! You have now grasped a little bit of Un*x and are ready to 
  733. start working. Remember that your knowledge of the system is still 
  734. positively limited, and that you are expected to do more practice with 
  735. Linux to use it comfortably. But if all you had to do was get a bunch of 
  736. applications and start working with them, I bet that what I included here 
  737. is enough: by now I don't know much  more, yet I manage to work with Linux 
  738. every day!
  739.  
  740. I'm sure you'll enjoy using Linux and will keep learning more about it - 
  741. everybody does. I bet, too, that you'll never go back to DOS! I hope I made 
  742. myself understood and did a good service to my 3 or 4 readers.
  743.  
  744.  
  745. Disclaimer
  746.  
  747. "From DOS to Linux - Quick!" was written by Guido Gonzato, 
  748. <Guido@ibogfs.cineca.it>, April 1996. Many thanks to Matt Welsh, the author 
  749. of "Linux Installation and Getting Started", to Ian Jackson, the author of 
  750. "Linux frequently asked questions with answers", to Giuseppe Zanetti, the 
  751. author of "Linux - Il sistema operativo FREE SOFTWARE per personal computer 
  752. 386/486", to all the folks who emailed me suggestions, and especially to 
  753. Linus Torvalds and GNU who gave us Linux.
  754.  
  755. This document is provided "as is". I put great effort into writing it as 
  756. accurately as I could, but you use the information contained in it at your 
  757. own risk. In no event shall I be liable for any damages resulting from the 
  758. use of this work.
  759.  
  760. This document can be freely distributed as long as:
  761.  
  762. - it is distributed in its entirety, including this disclaimer and 
  763. permission notice;
  764. - no money is charged for it;
  765. - it is not modified in any way without my permission.
  766.  
  767. Translations, prints, re-editings, or extractions from this document must 
  768. be approved by me before being distributed. For any requests, suggestions, 
  769. flames, etc., feel free to contact me. If you don't have e-mail access, my 
  770. snail-mail address is:
  771.  
  772. Guido Gonzato - Via Monte Ortigara 19/a, 37127 Verona - Italy
  773.  
  774. Enjoy life!
  775.  
  776.                  Guido   =8-)
  777.  
  778.