Vous êtes sur la page 1sur 5

Basic Unix Commands

http://faculty.plattsburgh.edu/jan.plaza/computing/help/commands.html

Basic UNIX/Linux commands


Custom commands available on departmental Linux computers but not on Linux systems elsewhere have descriptions marked by an *asterisk. Notice that for some standard Unix/Linux commands, friendlier versions have been implemented; on departmental Linux computers the names of such custom commands end with a period. -----------------------------------------------------------------------------INTERACTIVE FEATURES TAB UPARROW CTRL-C CTRL-D CTRL-D CTRL-D Command completion !!! USEFUL !!! Command history !!! USEFUL !!! Interrupt/kill current process. (at the beginning of the input line) end input. (in the middle of the input line) end input.

-----------------------------------------------------------------------------WILDCARDS AND DIRECTORIES USED IN COMMANDS * ? ~ ~abcde001 .. . / Example: ls ~/files/csc221/*.txt -----------------------------------------------------------------------------REDIRECTIONS AND PIPES COMMAND COMMAND COMMAND COMMAND COMMAND COMMAND COMMAND COMMAND < FILE > FILE >> FILE 2> FILE 2>> FILE > FILE1 2> FILE2 >& FILE >>& FILE Take input from FILE instead of from the keybaord. Put output of COMMAND to FILE Append the output of COMMAND to FILE Put error messages of COMMAND to FILE. Append error messages of COMMAND to FILE. Put output and error messages in separate files. Put output and error messages in the same FILE. Append output and error messages of COMMAND to FILE. Output of COMMAND1 becomes input for COMMAND2. See the output of COMMAND page by page. See the output lines of COMMAND sorted and page by page. Replaces any string of characters in a file name except the initial dot. Replaces any single character in a file name except the initial dot. The home directory of the current user. The home directory of the user abcde001. The parent directory. The present directory. The root directory

COMMAND1 | COMMAND2 COMMAND | more COMMAND | sort | more

-----------------------------------------------------------------------------ONLINE HELP h COMMAND --help | more COMMAND -h | more whatis COMMAND man COMMAND info COMMAND xman apropos KEYWORD | more *Custom help. Basic help on a Unix COMMAND (for most commands). Basic help on a Unix COMMAND (for some commands). One-line information on COMMAND. Display the UNIX manual page on COMMAND. Info help on COMMAND. Browser for Unix manual pages (under X-windows). Find man pages relevant to COMMAND.

1 of 5

8/16/2013 8:51 AM

Basic Unix Commands

http://faculty.plattsburgh.edu/jan.plaza/computing/help/commands.html

help COMMAND perldoc

Help on a bash built-in COMMAND. Perl documentation.

-----------------------------------------------------------------------------FILES AND DIRECTORIES ls ls ls ls ls ls ls List contents of current directory. List contents of current directory in a long form. Same as ls but .* files are displayed as well. Combination of ls -a and ls -l List contents of DIRECTORY (specified by a path). List contents of SUBDIRECTORY. Check whether FILE exists (or what FILES exist). Display absolute path to present working directory. Create DIRECTORY (i.e. a folder) Change to your home directory. Change to the parent directory. Change to SUBDIRECTORY. Change to DIRECTORY (specified by a path). Change to the directory you were in previously. *Same as cd followed by ls Copy FILE to NEWFILE. Copy DIR and all its contents to NEWDIR. *Same as cp -r but preserving file attributes. Rename FILE to new NAME. Rename directory DIR to new NAME. Move FILE into existing directory DIR. *Swap contents of FILE1 and FILE2. Create symbolic LINK (i.e. shortcut) to existing FILE. Displays your disk quota. *Displays your disk quota and current disk usage. Remove FILE(S). Remove empty DIRECTORY. Remove DIRECTORY and its entire contents. Same as rm -r but without asking for confirmations. *Remove non-essential files, interactively *Remove non-essential files, without interaction. *Move FILE to ~/junk instead of removing it. *Search current dir and its subdirs for FILE(S). Update modification date/time of FILE. Find out the type of FILE. Compress or expand files. Compress or expand files. Compress or expand files. Archive a directory into a file, or expand such a file. *Pack DIRECTORY into archive file *.tgz *Unpack *.tgz archive into a directory.

-l -a -al DIRECTORY SUBDIRECTORY FILE(S)

pwd mkdir DIRECTORY cd cd .. cd SUBDIRECTORY cd DIRECTORY cd cd. ARGUMENTS cp FILE NEWFILE cp -r DIR NEWDIR cp. ARGUMENTS mv FILE NAME mv DIR NAME mv FILE DIR swap FILE1 FILE2 ln -s FILE LINK quota quota. rm FILE(S) rmdir DIRECTORY rm -r DIRECTORY rm -rf DIRECTORY clean clean -f junk FILE find. FILE(S) touch FILE file FILE gzip zip compress tar targz DIRECTORY untargz ARCHIVE.tgz

-----------------------------------------------------------------------------TEXT FILES more FILE Display contents of FILE, page by page.

2 of 5

8/16/2013 8:51 AM

Basic Unix Commands

http://faculty.plattsburgh.edu/jan.plaza/computing/help/commands.html

less FILE cat FILE head FILE tail FILE pico FILE nano FILE kwrite FILE gedit FILE kate FILE emacs FILE vim FILE aspell -c FILE ispell FILE cat FILE1 FILE2 > NEW cat FILE1 >> FILE2 sort FILE > NEWFILE grep STRING FILE(S) grep. STRING FILE(S) wc FILE(S) diff FILE1 FILE2 | more filter FILE NEWFILE COMMAND | cut -b 1-9,15 COMMAND | uniq

Display Display Display Display Edit Edit Edit Edit Edit Edit Edit

contents of FILE, page by page. a file. (For very short files.) first lines of FILE. last lines of FILE. using using using using using using using a a a a a a a user-friendly editor. user-friendly editor. user-friendly editor under X user-friendly editor under X user-friendly editor under X powerful editor. powerful editor with cryptic

FILE FILE FILE FILE FILE FILE FILE

windows. windows. windows. syntax.

Check spelling in text-file FILE. *Check spelling in text-file FILE. Append FILE1 and FILE2 creating new file NEW. Append FILE1 at the end of FILE2. Sort lines of FILE alphabetically and put them in NEWFILE. Display lines of FILE(S) which contain STRING. *Similar to that above, but better. Count characters, words and lines in FILE(S). Show differences between two versions of a file. *Filter out strange characters from FILE. Remove sections from each line. Omit repeated lines.

-----------------------------------------------------------------------------PRINTING lpr FILE lprint1 FILE lprint2 FILE In Hawk153B or Redcay 141A, print FILE from a workstation. *Print text-file on local printer; see help printing *Print text-file on local printer; see help printing

-----------------------------------------------------------------------------PROGRAMMING LANGUAGES python python3 idle idle3 cc -g -Wall -o FILE FILE.c gcc -g -Wall -o FILE FILE.c c++ -g -Wall -o FIL FIL.cxx g++ -g -Wall -o FIL FIL.cxx gdb EXECUTABLE make FILE m c-work javac CLASSNAME.java java CLASSNAME javadoc CLASSNAME.java appletviewer CLASSNAME scheme lisp Listener of Python 2.x programming language. *Listener of Python 3.x programming language. IDE for Ptyhon 2.x. *IDE for Ptyhon 3.x. Compile C source FILE.c into executable FILE. Compile C source FILE.c into executable FILE. Compile C++ source FIL.cxx into executable FIL. Compile C++ source FIL.cxx into executable FIL. Start debugging a C/C++ program. Compile and link C/C++ files specified in makefile *Same as make but directs messages to a log file. *Repeatedly edit-compile-run a C program. Compile a Java program. Run a Java program. Create an html documentation file for CLASSNAME. Run an applet. *Listener of Scheme programming language. *Listener of LISP programming language.

3 of 5

8/16/2013 8:51 AM

Basic Unix Commands

http://faculty.plattsburgh.edu/jan.plaza/computing/help/commands.html

prolog

*Listener of Prolog programming language.

-----------------------------------------------------------------------------INTERNET lynx firefox konqueror BROWSER BROWSER FILE.html BROWSER FILE.pdf mutt pine ssh HOST sftp HOST rsync ARGUMENTS Web browser (for text-based terminals). Web browser. Web browser. Browse the Internet (with one of the browsers above. Display a local html file. Display a local pdf file. Text-based e-mail manager. Text-based e-mail manager (on some systems). Open interactive session on HOST using secure shell. Open sftp (secure file transfer) connection to HOST. Synchronize directories on local and remote host.

-----------------------------------------------------------------------------UNDER X-WINDOWS libreoffice soffice acroread FILE.pdf epdfviewer FILE.pdf okular FILE xterm konsole xcalc xclock xeyes LibreOffice productiveity suite OpenOffice productivity suite Display pdf FILE.pdf Display pdf FILE.pdf Display FILE (pdf, postscript, ...) A shell window A better shell window A calculator A clock They watch you work and report to the Boss :-)

-----------------------------------------------------------------------------RESET xfwm4 Ctrl-Alt-Backspace clear xrefresh reset setup-account Reset the windows manager on Lab and MiniLab computers. Restart the X-server. (You may need to do that twice.) Clear shell window. Refresh X-windows. *Reset session. *Set up or reset your account (Dr. Plaza's customizations)

-----------------------------------------------------------------------------MISCELLANEOUS exit logout svn date Exit from any shell. Exit from the login shell and terminate session. Version control system. Display date and time.

-----------------------------------------------------------------------------COURSEWORK IN DR. PLAZA'S COURSES Commands and directory names related to csc219 have 219 as a suffix. By changing the suffix you will obtain commands for other courses. ls cd cp cp $csc319 $csc319 $csc319/FILE . -r $csc319/SUBDIR . *List files related to csc319. *change into instructor's public directory for csc319. *Copy FILE related to csc319 to the current directory *Copy SUBDIR of csc319 to the current directory.

4 of 5

8/16/2013 8:51 AM

Basic Unix Commands

http://faculty.plattsburgh.edu/jan.plaza/computing/help/commands.html

submit grades

*Submit a directory with files for an assignment. *See your grades. Used in some courses only.

-----------------------------------------------------------------------------PROCESS CONTROL Notes: A process is a run of a program; One program can be used to create many concurrent processes. A job may consist of several processes with pipes and redirections. Processes are managed by the kernel. Jobs are managed by the shell. CTRL-Z fg bg JOB ps ps. jobs kill PROCESS ctrl-C kill -9 PROCESS kill. PROCESS COMMAND & Suspend current foreground process. Bring job suspended by CTRL-Z to the foreground. Restart suspended JOb in the background. List processes. *List processes. List current jobs (A job may involve many processes). Kill PROCESS (however some processes may resist). Kill the foreground process (but it may resist). Kill PROCESS (no process can resist.) *Kill PROCESS; same as kill -9. Run COMMAND in the background.

-----------------------------------------------------------------------------ENVIRONMENT VARIABLES IN BASH env | sort | more echo $VARIABLE unset VARIABLE export VARIABLE=VALUE List all the environment variables with values. List the value of VARIABLE. Remove VARIABLE. Create environment variable VARIABLE and set to VALUE.

------------------------------------------------------------------------------

5 of 5

8/16/2013 8:51 AM

Vous aimerez peut-être aussi