Attached is version 0.2 of my Quick Linux reference. 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.
George Russell's Quick Linux Reference version 0.2 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.0 root and normal use 1.1 File commands 1.2 Useful commands 2. Shells - some usage tips 2.0 What is a shell 2.1 Scripting 2.2 Interactive use 3. Applications - useful stuff 4. Credits - those who contribute and correct Commands 1.0 Root and Normal Usage In DOS and Windows, normal users can do anything with the operating system. Anyone can use any command, even dangerous ones, like fdisk, and format, and delete any file, even important ones in c:\windows\system In Unix and Linux, normal users are restricted in the commands which they can execute and the access rights which they have to files. Unlimited access is granted to only to the super-user, root, which is usually the System Administrator. On a single user linux system, you are your own administrator. It is unwise to run as the root user all the time - its better to create a normal user account for yourself. Always using the root account is likely to bite you when you make a mistake, and its a security risk as well. Only use root when administering the system, or installing programs, or shutting the system down. You have been warned. Commandline switches are preceded by - and not / as in DOS. Usually - precedes the short version of the switch, and -- precedes the long switch. e.g. -h and --help have the same result. 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 rename ==> use mv as above ==> mv oldname newname *** DANGER *** This is a recursive forced delete. No queries. No mercy. In the root directory, has aboutthe same effect as formatting c: There will be total data loss. Check the commandline for typos, and think twice. deltree ==> rm -rf directory *** END DANGER *** cd ==> cd directory (change dir) dir ==> ls (useful switches 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) Under Unix and Linux, hidden files are those whose filenames begin with a . character.) link ==> ln -s realname linkname and call it a symbolic link (or symlink for short), not just a link (creates a symbolic link or symlink 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, type ==> 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 Unlike DOS and Windows, Unix has a unified filesystem. What this means is that each device is treated as a directory, and there is root directory, from which all other devices, filesystems, and folders are subdirectories. There are no drive letters, but there are some common points. A rough equivalence table. DOS name Linux Device Name Common Mount Point / Linux Directory a: ==> /dev/fd0 ==> /mnt/floppy, /floppy d: ==> /dev/cdrom ==> /mnt/cdrom, /cdrom The table which maps Linux device names to Linux mount points is the /etc/fstab file. Modifying this is definitely system administration. Note that you can allow a user to a add / remove devices and filesystems. Removing a floppy disc, without unmounting the disk, is likely to corrupt the disc. Its contents may be lost. 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 defaults for once. For the record, mount allows you to spoecify a device, a mountpoint, a filesystem, and the degree of access e.g. read / write, read only, and no execution of programs. "man mount" for further details. Each of the directories in the root directory has a special purpose. /bin ==> holds binaries of small system utilities /boot ==> holds kernel images to boot the system /dev ==> shows the devices linux makes available /etc ==> system wide configuration files /home ==> Where users store their files, each with their own subdirectory /lib ==> system libraries /lost+found ==> used by the disk repair tool, fsck /mnt ==> subdirectories for mounting devices and filesystems /opt ==> optional. Holds programs which are to be kept seperated. /proc ==> Gives information on the kernel as files /root ==> The home directory of the root user /sbin ==> system utilities, used to maintain the system. /tmp ==> holds temporary files /usr ==> where programs are installed /var ==> for variable data, such as log files. In Unix and Linux, the directory seperator is / and not, as in DOS \ 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 means verbose, 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. gunzip also unzips. Its a symlink to gzip . There is also bunzip2, the equivalent for bzip2) halt (see also shutdown) halt serves on a Linux system the role equivalent to the Start-ShutDown dequence in Windows. It stops (kills, in Linux/Unix terminology) all programs running in the background; closes open files; makes sure all hard drives have been updated from temporary, cache storage; and generally makes the system ready to be turned 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.0 What is a shell? A unix shell is the unix is a program which provides the command line interface. Its equivalent in DOS is command.com, but Unix shells such as sh, ash, bash, tcsh, zsh, csh (and many more) are more flexible and powerful, implemented with multitasking in mind. Its possible to have multiple shells available, by using the alt-(F1-F6) keys to switch between them, and logging in multiple times. 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. The DOS equivalent is the batch language with the .bat file extension. Unix shell scripting is more powerful and more complex. 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 using 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 Wildcarding works in a different fashion to that of DOS. Be aware of this, and cautious in your use of * 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, and allow 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, and isp 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) 4 Contributers Ray Olszewski ---------------------------- End of Reference. Please mail any corrections / suggestions to me [EMAIL PROTECTED]
