George Russell's Quick Linux Reference version 0.1

This is a user reference, not a system administration reference, but in
Linux for a single user, the two are mixed at times.

My email address for corrections etc ;-)
[EMAIL PROTECTED]

Contents
1. Commands - minor subset
  1.1 File commands
  1.2 Useful commands 
2. Shells - some usage tips
  2.1 Scripting
  2.2 Interactive use
3. Applications - useful stuff

Commands
1.1 File operations

copy - cp from to , where from and to are valid filenames or paths
move - mv from to , where from and to are valid filenames or paths
delete, erase - rm filename

*** DANGER ***
deltree - rm -rf directory 
*** END DANGER ***

cd - cd directory (change dir)

dir - ls

(useful switched for ls are -a (show hidden) and and --color (colours
the output depending on the type of file ie green for executable, purple
for images) -l (show permissions))

link - ln -s source destination

(creates a link to a file which acts like that file, but is not a full
copy. I have a file n, which is a link to /opt/netscape/netscape, so I
can start netscape with the command ~/n)

more - less filename

(less, like more or cat, outputs a files contents to screen. Use only on
text files. Use q to quit)

mount - mount mountpoint 

(where mount point is a mount point form /etc/fstab, ie /mnt/cdrom .
This should be all thats needed to access a device. Using a command like
mount -t vfat /dev/hda1 /mnt/dos just shows /etc/fstab is badly setup or
your not using the defauls for once)

unmount - umount mountpoint (it is umount, not unmount for the command)

change file permissions - chmod threedigitnumber filename

(File permissions in unix are awkward to explain.  You can set rights
for read access, write access and execution (ie allowiing the file to be
run as a program) for yourself, others in your group (a group is a group
of users with some access rights in common) and world access rights
(those users not you or in your group) 777 is wide open, insecure,
everybody has all access rights. 666 is read / write access for
everyone. 755 is yourself with all rights, everybody else readonly. man
chmod is highly recommended, better still, a user / sysadmin howto)

locate filename - finds a file and gives its path, by searching a
database (fast) and not the disk itself, like find, which has a worse
syntax anyway.

updatedb - updates the database locate uses. Must be run by root. Is set
to run at midnight automatically, but who runs their machine 24 hours
solid? and totally thrashes the disk while it does.  Peformance goes all
to hell when it runs, especially if you have little memory.

tar -xzvf filename(.tar.gz or .tgz)

(tar is a tape archiver.  Used like pkzip in dos or stuffit in mac. The
x means extract, the z means uncompress using gzip, v (???), f just
precedes the filename)

gzip filename(also bzip2)

(Compress a file. the -d parameter uncompresses, and -9 means tightest,
but slowest, compression. bzip2 compresses better, but is slower.)

halt (see also shutdown)

(Must be run as root.  Kills off all programs, unmounts file systems,
and shuts the computer down to a state where it can be switched off.
shutdown allows a delay before it happens )

1.2 Useful commands.

ps - shows all running tasks on a terminal. Usful switches are -ax
(both, shows all running programs)

top - shows all running processes in a monitor program, updates every
second, allows for sorting by cpu usage , memory usage etc as well as
shoowing uptime, time, and system load. Allows killing of programs.

*** DANGER ***
kill -9 pid  
*** END DANGER ***

kill kills running programs.  the pid is the processes ID number, which
can be found using top or ps. The -9 parameter means kill now,
completely.  Using kill without the parameter can allow for a more
graceful exit.

lpr filename - sends the file to the printer. If setup right, prints
text, images, postscript and pdf files. If not, random jumble of
characters can get printed.

cdplay - does what it says.

startx - starts the X Windowing System, ie Unix's GUI display system. 

setfont - resets the terminal font if X messes the display up

grep keyword filename - search a file for lines containing keyword

wc filename - word count of the file, ie lines, words and letters.

2 Shell Usage

2.1 Scripting

Simple scripts are simply a text file, set as executable (chmod 755
filename), with the first line stating what shell is to interpret the
script, followed by commands. ie
--- script starts here  cut below---
#!/bin/sh
# #'s are comment delimiters, and are not treated as commands
# ! is supposed to be in the 1st line
# sh is the standard scripting shell, 
# even if you use bash, zsh, tcsh interactively
echo 'hello world' 
echo 'good bye'    
--- end of script cut above ---

Anything more complex is programming, and not for this quick reference.

2.2 Interactive use.

command1 ; command2 ; command3 ; <enter> 

(This runs the list of commands in sequence.)

command1 && command2 && command3 <enter>

(Runs the commands in sequence, but if one command fails, no further
commands in the list are executed.)

command1 > filename

(Redirects the output of command1 to the file filename)

command1 >> filename

(as above, but adds the output to the end of the file filename, not
overwriting the file)

comand1 | command2

(sends the output of command1 to be the input of command2. For example,
"less filename | patch -p0" sends the contents of a file to the patch
command.)

cd ~ 

(Go to your home directory. Same as cd on its own.)

pwd 

(print working directory)

./command

(Run the command in the current directory, not the command in the system
path.)

command &

(Run the command in the background, Useful for Xterms, wher you want to
start a GUI program and keep usingf the terminal)

Tab Completion. I could for example, in bash, type
cd /ho 
and press tab. Bash would complete the path for me to
cd /home
If there are multiple possibilities, bash won't expand it until its
clear which one is meant.

Wildcarding. for example
cd /ho*/grr*/Des*
is a valid path, because bash expands it to 
cd /home/grrussel/Desktop
and you can use 
rm *xyzzy* 
to delete all files with xyzzy in the name


Command line history. Press the up cursor key to see the last command.
Use up or down to navigate list.  left and right move cursor through the
command, andallow for editing etc.

3 Applications

mc (see also git (GNU Interactive Tools))

(The midnight commander, a console based file manager. Does ftp,
fileviewing, opens archives for browsing, has an internal editor which
is easy to use. Be sure to select the use of the internal editor in the
configuration menu, otherwise you get vi)

*** DANGER ***
vi (also vim, elvis, gvim)

(The standard unix lightweight editor. What you get in rescue disks.
Press i to insert text. Press the escape key to enter command mode, and
to 
give commands in command mode, : followed by the command.
For example, the important ones
:w 
writes the currently edited file
:q
exits vi. Many newbies just kill vi - they don't know the :q command,
and its so muchmore satisfying (once the file is saved, anyway)
Command mode is dangerous. Think about what your pressing after you've
pressed escape.  dd means delete the entire line. x means delete current
character. there are so many commands, that the keyboard probably has no
unused keys. Bad stuff happens if you forget to i before randomly
pecking away at the keyboard)

*** END DANGER ***

emacs (also xemacs)

(The standard heavyweight unix editor.
EightMegabytesAndConstantlySwapping, or just a meaningless five letter
acronym. Not a modal editor, like vi. So no need to switch between
insert mode and command mode.
Save a file.
ctrl-x ctrl-s
Exit
ctrl-x ctrl-c
)

pico

( a very simple and limited editor)

nedit

(a powerul but simple editor for X)

lynx

( a console based web browser. Excellent for html help files or
documentation)

wvdial

(a ppp setup and connection tool. Asks for phone number, username at
isp, andisp passwrd, and the rest is worked out by wvdial.)

man command

(display the help file for the command.  man pages are terse, and not
very helpful)

man -k keyword

(also apropos . Searches man pages for pages whose (titles?) contain the
keyword)

info

(The GNU equivalent of man. Early hypertext. Use a GUI info browser in
preference to info itself)

----------------------------
End of Reference.
blimey, that got long. Share and enjoy. Mail any corrections. 
HTH
George Russell
-- 
One Ring to rule them all, One Ring to find them, 
One Ring to bring them all and in the Darkness bind them,
In the Land of Mordor where the shadows lie.

Reply via email to