<p>CS 350 Spring 2002 2/17/02</p><p>A summary of some useful UNIX commands:</p><p>The following are useful UNIX commands with suggested or sample flags. Run the “man” command against these commands for full meaning (the items in <...> are arguments, all file names and directory names may need to be prefixed by a path name to uniquely identify them: man <cmd> ... gives detailed on-line help on command “cmd”. Cmd may be any UNIX command or the name of a system or standard library call. For example: man mv, man fork, or man printf chmod xyz <file>, where x, y, and z are octal numbers whose three bit encoding represents the permissions “read”, “write”, “execute” for the file. x is the permissions for you the owner of the file and would be private to all others. y is the permissions for a workgroup you define (default is you have no work group). z is permissions you grant to the outside world. Suggested permissions are 600 for a file you may want to change and keep private, 400 for a file you want to be read-only and to keep private, and 700 for an executable file you want to keep private and modifiable or erasable. Examples: If you want a file to be read-write for yourself and private use: chmod 600 <filename>. If you want to share a file as read-only with the outside world and make if read-write for yourself use: chmod 644 <filename>. If you want a file to be executable and read-only and also private, use: chmod 500 <filename> pwd ... gives current directory tree cp <file1> <file2> ... copies file1 to file1 cat <file1> ... displays (dumps) file1 to screen - no pausing</p><p><command> | more ... displays the output of the command one page at a time or more <file1> ... Displays file1 on screen one page at a time For both uses of more: space bar for next page, enter key for next line mv <file1> <file2> ... moves or renames file1 to file2 rm <file1> ... erases file1 rm -rf <directory> will remove a directory tree starting with <directory>. the "-r" tells rm to go through all subdirectories, "-f" tells it not to ask for prompts. CAREFUL: this will zap out <directory> and all of its subdirectories - even if the directory has files in it. mkdir <dirname> ... creates directory dirname rmdir <dirname> ... removes directory dirname ... must be empty cd <dirname> ... change current directory to dirname ls -l -d -a ... lists files and directories (like dir in dos) All flags are optional -l ... gives full information (long) -d ... lists directories without giving contents -a ... lists “all” files including “hidden files” beginning with a dot You can also add a name or partial name with wild card “*” in it after the flags. logout ... logs user off session passwd ... allows user to change password ps -aef ... list processes (includes pid and names) kill <pid> ...... kills or removes process id “pid.” will ask the process to exit ... use the ps command to get the process id’s currently running kill -9 <pid> ...unconditionally kills or removes process id “pid.” without the processes consent ctrl-z ... interrupts a process ... may be continue the process by typing fg gcc -o<file1> <file1.c> ... compiles the C source file into executable file1 cc -o<file1> <file1.c> ... compiles the C source file into executable file1 g++ -o<file1> <file1.c> ... compiles the C source file into executable file1 ... in each case above the -o option is optional. If left out the executable will be a.out be default. ipcs … list all the system processor communication resources “loaned” out to the account. ipcrm -s semaphore id ipcrm -m shared memory id ipcrm -q msgqid</p><p>How to get rid of suspended or hung processes: First list all processes running under your user id (my_user_id), for example bf12345 ps -eaf | grep my_user_id examine the list for the hung process, suppose it is: 16309 now do: kill -9 16309 editors: pico <filename> emacs <filename> vi <filename> ... this one is un-intuitive!</p><p>Check out Barnes and Noble at the Town-Square mall for books on UNIX and C/C++. I found “UNIX Made Easy”, by Lurnix (Osborne, McGraw-Hill publ.) useful. There must be a book called “UNIX for Dummies” out there. An excellent book on C is: “The C Programming Language” by Kernighan and Ritchie (Prentice Hall). As I mentioned an excellent book on both C and UNIX is “An Introduction to ANSI C on UNIX”, by Paul Wang, Wadsworth Publishing Co.</p>
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages2 Page
-
File Size-