LINUX COMMANDS ************************* ------------------------ DIRECTORIES ------------------------ recursively delete a directory structure, rm -rf ------------------------ FILES ------------------------ ls -l ls -ld .* Display File Contents----------------------------------------- cat file display contents of file more file display contents of file one screenfull at a time. view file a read only version of vi. less file similar to, but more powerfull than more. See the man page for more infomation on less. move or rename file x to file y:------------------------------- mv x y move cp x y copy file x to file y copy cp -R * [quelle] [ziel] // mit Unterverzeichnissen rm x delete a file del Ctrl-d end of file (z.b. um SU zu beenden) Ctrl-s output anhalten Ctrl-q weitermachen su - subnutzer FIND FILE------------------------------- locate whereis Give read permissions chmod 744 yourfile Give execute permissions*: chmod 755 yourfile Give Read/write permissions: chmod 766 yourfile to give all permissions: chmod 777 yourfile ------------------------ FIND STUFF ------------------------ find / -name 'mypage.htm' find -name 'file*' find -name 'index.php' -type f -exec grep -il 'iteligentcrm' {} \; finde alle index.php dateien ------------------------ SERVICES ------------------------ ps -ax (all services) ------------------------------------------------ Using tar, gzip, and bzip2 ------------------------------------------------ untar/gzipping a file tar zxvf yourfile.tar.gz" or tar zxvf yourfile.tgz un-tar a .tar tar xvf yourfile.tar". un-gzip a file gzip -d filename.gz". un-bzip2 a file bzip2 -d filename.bz2". tar plus gzip a dir/multiple files cd into the dir of the files you want to tar(warning, this will put ALL files of the current dir you're in into a tar file), type "tar cvf newTarFile.tar * ". Now to gzip the file, type "gzip -9 newTarFile.tar". ------------------------------------------------ Compiling and Installing Software ------------------------------------------------ tar.gz or .tgz untar/gzip the file ("tar zxvf file.tar.gz"). cd into the dir. Most source packages will compile by doing "./configure" then "make" then su to root (type "su" press enter then enter in your root password then press enter) and do "make install". I always like to do "make install > /root/program-version" to keep better track of everything. You should always read the INSTALL file first, but the above instructions usually work fine. If you happen to be compiling and installing libs, be sure to type (as root) "ldconfig" after installing them. src.rpm You must be root and in the same dir as the src.rpm. Type "rpm --rebuild --target i586" (if you have a intel p2 or higher, you can do i686, if you have a 486 or lower do i486 or i386). Now watch for where the actual rpm was placed (look at last few lines on the screen or scroll up a tiny bit). cd into the dir with the new rpm or cp it to where you are at ("cp /path/to/rpm ."). Now do "rpm -Uvh file.rpm". Note for slackware users You can compile source rpms using the above instructions, but instead of installing the rpm, run "rpm2tgz file.rpm" (comes standard with slackware) and install using "installpkg file.tgz". Installing a regular RPM cd into the dir that the rpm you want to install is in. su to root (type "su" press enter, enter in your root password, press enter). Type "rpm -Uvh filename.rpm" and press enter, boom done ;-). ------------------------------------------------ CHOWN / CHMOD ------------------------------------------------ chown - change owner In order to execute the chown ("change owner") command you must login as root user. This command allows you to change the owner of files and directories, as well as group membership. Syntax is quite easy and the recursive function (again with the option -R) works here as well. Let's assume that you have created the directory bobbydata in /usr/local/ and you want to use it as a "normal" user and not as root. However, since you had to create it as root because you, as a normal user, have read only permission for /usr/local, this directory belongs to user root from group root. In order to assign it to user bobby from group user, please enter the following command: chown bobby.user /usr/local/bobbydata or alternatively chown bobby:user /usr/local/bobbydata chmod - change mode The chmod ("change mode") command changes permissions for files and directories. If you have a Windows background, you should first know something about Unix permissions. As we mentioned above, all files and directories belong to an owner, and this in turn belongs to a group. Permissions must be separately defined for the owner, for the group and for all others. An object can be read, written, and executed by these three (owner, group and all others). Now it's turn to explain the somewhat "cryptic" characters from the ls -l output (see above). Just create the subdirectory images in your home directory by entering mkdir images. Then use ls -l to display its contents. The output line for this directory will be something like: drwxr-xr-x 2 bobby user 35 Jul 16 16:00 images/ Let's first consider the initial sequence of characters. The first character implies that we are dealing with a directory (d = directory). The nine following characters are essential because they inform us about permissions. The first three characters represent the owner, the next three the group and the last three all others. r stands for readable, w for writable and x for executable. Program files and directories must be executable. The sequence rwxr-xr-x thus means that bobby, as directory's owner, can read, write and execute it. The rest (group and all others) can read and execute it. In the case of directories, execute means that you can change to them. Defining permissions can be done in two different ways: with flags for the various users and permissions, or by means of the so-called octal number. Symbols: The symbols u, g and a stand for "user", "group" and "all others", and r, w, and x stand for read, write, and executable. Granting and deleting permissions can be done with plus (+) and minus (-). So, if the file bob.pl must be readable for all, the corresponding command reads: chmod a+r bob.pl Please notice that by granting permissions for all others (a), the respective flags will be set not only for a, but also for u and g, i.e. all three positions. However, granting permissions to u or g will only set the flag for the first or second position. When granting permissions to a, the a can be omitted in the command: chmod +r bob.pl ------------------------ POSTGRESQL ------------------------ restart PostgrSQL /etc/init.d/postgresql start # killall -9 nsd --> kills all AOLServers. # init q --> forces "init" to re-read its /etc/inittab configuration file. ------------------------ POUND ------------------------ pound.cfg /usr/local/etc ------------------------ GREP ------------------------ Substract a sub group with GREP Ex.: Show all processes with "nsd" in ps -alW | grep nsd ------------------------ NETWORK ------------------------ netstat -anp –tcp Franks: netstat -lnpt ps -p 1925 -f ------------------------ TEXT BROWSER ------------------------ lynx ------------------------ OPENACS ------------------------ Install OpenACS http://openacs.org/doc/openacs-4/openacs.html ------------------------ AOL Server ------------------------ Getting started with AOL server http://www.informit.com/articles/article.asp?p=18386&seqNum=7 *********************************************************** EMACS *********************************************************** EMACS Reference Card http://old.pubhealth.ku.dk/bsa/software/applications/ Quit: Ctrl-x Ctrl-c I pushed the wrong key. Help!: Ctrl-g LAUNCH/CLOSE************************************** Close Ctrl-x Ctrl-c FILES********************************************* Load a file: Ctrl-x Ctrl-f Load a directory: Ctrl-x Ctrl-f New file: Ctrl-x Ctrl-f Save a file: Ctrl-x Ctrl-s Save all open files: Ctrl-x s Save the file with a new name Ctrl-x Ctrl-w Execute as root: ./foo start foo (allocated in current dir.) foo BUFFERS******************************************* Switch buffers: Ctrl-x b Close buffer: Ctrl-x k Split current buffer Ctrl-x 2 Make current buffer the only one on screen Ctrl-x 1 Switch between the buffers on-screen Ctrl-x o COPY/PASTE**************************************** Set mark: Ctrl-[SPACE] Cut and save text from here to mark: Ctrl-w Cut text from the cursor to the end of the line: Ctrl-k Copy marked text ALT-w Paste saved text: Ctrl-y DELETE**************************************** character (delete, not kill) DEL C-d word M-DEL M-d line (to end of) M-0 C-k C-k sentence C-x DEL M-k sexp M--M-C-k M-C-k kill region C-w copy region to kill ring M-w kill through next occurrence of char M-z char yank back last thing killed C-y replace last yank with previous kill M-y UNDO********************************************** undo an unwanted change Ctrl-x u or Ctrl-_ Directory editor********************************************** M-x dired SEARCH******************************************** C = Control M = Meta = Alt|Esc Basics C-x C-f "find" file i.e. open/create a file in buffer C-x C-s save the file C-x C-w write the text to an alternate name C-x C-v find alternate file C-x i insert file at cursor position C-x b create/switch buffers C-x C-b show buffer list C-x k kill buffer C-z suspend emacs C-X C-c close down emacs Basic movement C-f forward char C-b backward char C-p previous line C-n next line M-f forward one word M-b backward one word C-a beginning of line C-e end of line C-v one page up M-v scroll down one page M-< beginning of text M-> end of text Editing M-n repeat the following command n times C-u repeat the following command 4 times C-u n repeat n times C-d delete a char M-d delete word M-Del delete word backwards C-k kill line C-Space Set beginning mark (for region marking for example) C-W "kill" (delete) the marked region region M-W copy the marked region C-y "yank" (paste) the copied/killed region/line M-y yank earlier text (cycle through kill buffer) C-x C-x exchange cursor and mark C-t transpose two chars M-t transpose two words C-x C-t transpose lines M-u make letters uppercase in word from cursor position to end M-c simply make first letter in word uppercase M-l opposite to M-u Important C-g quit the running/entered command C-x u undo previous action M-x revert-buffer RETURN (insert like this) undo all changes since last save M-x recover-file RETURN Recover text from an autosave-file M-x recover-session RETURN if you edited several files Online-Help C-h c which command does this keystroke invoke C-h k which command does this keystroke invoke and what does it do? C-h l what were my last 100 typed keys C-h w what key-combo does this command have? C-h f what does this function do C-h v what's this variable and what is it's value C-h b show all keycommands for this buffer C-h t start the emacs tutorial C-h i start the info reader C-h C-k start up info reader and go to a certain key-combo point C-h F show the emacs FAQ C-h p show infos about the Elisp package on this machine Search/Replace C-s Search forward C-r search backward C-g return to where search started (if you are still in search mode) M-% query replace Space or y replace this occurence Del or n don't replace . only replace this and exit (replace) , replace and pause (resume with Space or y) ! replace all following occurences ^ back to previous match RETURN or q quit replace Search/Replace with regular expressions Characters to use in regular expressions: ^ beginning of line $ end of line . single char .* group or null of chars \< beginning of a word \> end of a word [] every char inside the backets (for example [a-z] means every small letter) M C-s RETURN search for regular expression forward M C-r RETURN search for regular expression backward M C-s incremental search C-s repeat incremental search M C-r incremental search backwards C-r repeat backwards M-x query-replace-regexp search and replace Window-Commands C-x 2 split window vertically C-x o change to other window C-x 0 delete window C-x 1 close all windows except the one the cursors in C-x ^ enlarge window M-x shrink-window command says it ;-) M C-v scroll other window C-x 4 f find file in other window C-x 4 o change to other window C-x 4 0 kill buffer and window C-x 5 2 make new frame C-x 5 f find file in other frame C-x 5 o change to other frame C-x 5 0 close this frame Bookmark commands C-x r m set a bookmark at current cursor pos C-x r b jump to bookmark M-x bookmark-rename says it M-x bookmark-delete " M-x bookmark-save " C-x r l list bookmarks d mark bookmark for deletion r rename bookmark s save all listed bookmarks f show bookmark the cursor is over m mark bookmarks to be shown in multiple window v show marked bookmarks (or the one the cursor is over) t toggle listing of the corresponding paths w " path to this file x delete marked bookmarks Del ? q quit bookmark list M-x bookmark-write write all bookmarks in given file M-x bookmark-load load bookmark from given file Shell M-x shell starts shell modus C-c C-c same as C-c under unix (stop running job) C-d delete char forward C-c C-d Send EOF C-c C-z suspend job (C-z under unix) M-p show previous commands DIRectory EDitor (dired) C-x d start up dired C (large C) copy d mark for erase D delete right away e or f open file or directory g reread directory structure from file G change group permissions (chgrp) k delete line from listing on screen (don't actually delete) m mark with * n move to next line o open file in other window and go there C-o open file in other window but don't change there P print file q quit dired Q do query-replace in marked files R rename file u remove mark v view file content x delete files marked with D z compress file M-Del remove all marks (whatever kind) ~ mark backup files (name~ files) for deletion # mark auto-save files (#name#) for deletion */ mark directory with * (C-u * removes that mark again) = compare this file with marked file M-= compare this file with it's backup file ! apply shell command to this file M-} change to the next file marked with * od D M-{ " previous " % d mark files described through regular expression for deletion % m " (with *) + create directory > changed to next dir < change to previous dir s toggle between sorting by name or date Maybe into this category also fits this command: M-x speedbar starts up a separate window with a directory view Telnet M-x telnet starts up telnet-modus C-d either delete char or send EOF C-c C-c stop running job (similar to C-c under unix) C-c C-d send EOF C-c C-o clear output of last command C-c C-z suspend execution of command C-c C-u kill line backwards M-p recall previous command Text Works only in text mode M-s center line M-S center paragraph M-x center-region name says Macro-commands C-x ( start macro definition C-x ) end of macro definition C-x e execute last definied macro M-n C-x e execute last defined macro n times M-x name-last-kbd-macro give name to macro (for saving) M-x insert-keyboard-macro save named macro into file M-x load-file load macro M-x macroname execute macroname Programming M C-\ indent region between cursor and mark M-m move to first (non-space) char in this line M-^ attach this line to previous M-; formatize and indent comment C, C++ and Java Modes M-a beginning of statement M-e end of statement M C-a beginning of function M C-e end of function C-c RETURN Set cursor to beginning of function and mark at the end C-c C-q indent the whole function according to indention style C-c C-a toggle modus in which after electric signs (like {}:';./*) emacs does the indention C-c C-d toggle auto hungry mode in which emacs deletes groups of spaces with one del-press C-c C-u go to beginning of this preprocessor statement C-c C-c comment out marked area More general (I guess) M-x outline-minor-mode collapses function definitions in a file to a mere {...} M-x show-subtree If you are in one of the collapsed functions, this un-collapses it In order to achive some of the feats coming up now you have to run etags *.c *.h *.cpp (or what ever ending you source files have) in the source directory M-. (Thats Meta dot) If you are in a function call, this will take you to it's definition M-x tags-search ENTER Searches through all you etaged M-, (Meta comma) jumps to the next occurence for tags-search M-x tags-query-replace yum. This lets you replace some text in all the tagged files GDB (Debugger) M-x gdb starts up gdm in an extra window Version Control C-x v d show all registered files in this dir C-x v = show diff between versions C-x v u remove all changes since last checkin C-x v ~ show certain version in different window C-x v l print log C-x v i mark file for version control add C-x v h insert version control header into file C-x v r check out named snapshot C-x v s create named snapshot C-x v a create changelog file in gnu-style rm p remove a package - df (or df x) Show free space on device x chkdsk ? top view memory status (q to quit) mem man x get a manual page about command x / less x view text file x (note that the more filter works under Linux too!) type x |more echo print something on the screen echo mc Norton Commander for UNIX nc mount to couple a device (e.g. CD-ROM, umount to uncouple) - halt to shutdown - reboot ([ctrl] + [alt] + [del]) to restart [ctrl] + [alt] + [del] ln -s x y Make a symbolic link from x to y ------------------------ X Windows ------------------------ startx to start X-windows [ctrl] + [alt] + [backsp] to quit X during trouble [ctrl] + [alt] + F1 - F6 to switch to text terminal 1 - 6 (in X-windows) xf86Config most primitive setup/configurator for x (in text terminal) Xconfigurator another configurator for X in text terminal xf86Setup an X-Windows configurator for X configX to configure Metro-X server ------------------------ PSQL ------------------------ http://pgsqld.active-venture.com/app-psql.html \a toggle between unaligned and aligned mode \c[onnect] [dbname|- [user]] connect to new database (currently 'booktown') \C table title \copy ... perform SQL COPY with data stream to the client machine \copyright show PostgreSQL usage and distribution terms \d <table> describe table (or view, index, sequence) \d{t|i|s|v} list tables/indices/sequences/views \d{p|S|l} list permissions/system tables/lobjects \da list aggregates \dd [object] list comment for table, type, function, or operator \df list functions \do list operators \dT list data types \e [file] edit the current query buffer or [file] with external editor \echo <text> write text to stdout \encoding <encoding> set client encoding \f <sep> change field separator \g [file] send query to backend (and results in [file] or |pipe) \h [cmd] help on syntax of sql commands, * for all commands \H toggle HTML mode (currently off) \i <file> read and execute queries from <file> \l list all databases \lo_export, \lo_import, \lo_list, \lo_unlink large object operations \o [file] send all query results to [file], or |pipe \p show the content of the current query buffer \pset <opt> set table output <opt> = {format|border|expanded|fieldsep| null|recordsep|tuples_only|title|tableattr|pager} \q quit psql \qecho <text> write text to query output stream (see \o) \r reset (clear) the query buffer \s [file] print history or save it in [file] \set <var> <value> set internal variable \t show only rows (currently off) \T <tags> HTML table tags \unset <var> unset (delete) internal variable \w <file> write current query buffer to a <file> \x toggle expanded output (currently off) \z list table access permissions \! [cmd] shell escape or command * \? for help on psql meta-commands. * \dt to show a list of tables in the database. * \dtS to show a list of system tables. * \du to show a list of database users. * \h for help on SQL commands. * \l to show a list of databases. * \q to quit psql.