Sponsored Links
|
Basic Unix Commands
INTERACTIVE FEATURES TAB Command completion (not supported by certain shells) UPARROW Command history (not supported by certain shells) CTRL-C Interrupt current process. CTRL-D If a program/command waits for input, end input. WILDCARDS AND DIRECTORIES USED IN COMMANDS * 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. ~abcde123 The home directory of the user abcde123. .. The parent directory. . The present directory. / The root directory Example: ls ~/csc219/*.txt REDIRECTIONS AND PIPES COMMAND < FILE COMMAND will take input from FILE. COMMAND > FILE Put output of COMMAND to FILE COMMAND >> FILE Append the output of COMMAND to FILE COMMAND 2> FILE Put error messages of COMMAND to FILE. COMMAND 2>> FILE Append error messages of COMMAND to FILE. COMMAND > FILE1 2> FILE2 Put output and error messages in separate files. COMMAND >& FILE Put output and error messages in the same FILE. COMMAND >>& FILE Append output and error messages of COMMAND to FILE. COMMAND1 | COMMAND2 Output of COMMAND1 becomes input for COMMAND2. COMMAND | more See the output of COMMAND page by page. COMMAND | sort | more See the output lines of COMMAND sorted and page by page. ONLINE HELP COMMAND --help | more Basic help on a Unix COMMAND (for most commands). COMMAND -h | more Basic help on a Unix COMMAND (for some commands). whatis COMMAND One-line information on COMMAND. man COMMAND Display the UNIX manual page on COMMAND. info COMMAND Info help on COMMAND. xman Browser for Unix manual pages (under X-windows). apropos KEYWORD | more Find man pages relevant to COMMAND. help COMMAND Help on a bash built-in COMMAND. perldoc Perl documentation. FILES AND DIRECTORIES ls List contents of current directory. ls -l List contents of current directory in a long form. ls -a Same as ls but .* files are displayed as well. ls -al Combination of ls -a and ls -l ls DIRECTORY List contents of DIRECTORY (specified by a path). ls SUBDIRECTORY List contents of SUBDIRECTORY. ls FILE(S) Check whether FILE exists (or what FILES exist). pwd Display absolute path to present working directory. mkdir DIRECTORY Create DIRECTORY (i.e. a folder) cd Change to your home directory. cd .. Change to the parent directory. cd SUBDIRECTORY Change to SUBDIRECTORY. cd DIRECTORY Change to DIRECTORY (specified by a path). cp FILE NEWFILE Copy FILE to NEWFILE. cp -r DIR NEWDIR Copy DIR and all its contents to NEWDIR. mv FILE NAME Rename FILE to new NAME. mv DIR NAME Rename directory DIR to new NAME. mv FILE DIR Move FILE into existing directory DIR. ln -s FILE LINK Create symbolic LINK (i.e. shortcut) to existing FILE. quota Displays your disk quota. rm FILE(S) Remove FILE(S). rmdir DIRECTORY Remove empty DIRECTORY. rm -r DIRECTORY Remove DIRECTORY and its entire contents. rm -rf DIRECTORY Same as rm -r but without asking for confirmations. FILE(S). touch FILE Update modification date/time of FILE. file FILE Find out the type of FILE. gzip Compress or expand files. zip Compress or expand files. compress Compress or expand files. tar Archive a directory into a file, or expand such a file. TEXT FILES more FILE Display contents of FILE, page by page. less FILE Display contents of FILE, page by page. cat FILE Display a file. (For very short files.) head FILE Display first lines of FILE. tail FILE Display last lines of FILE. pico FILE Edit FILE using a user-friendly editor. nano FILE Edit FILE using a user-friendly editor. kwrite FILE Edit FILE using a user-friendly editor under X windows. gedit FILE Edit FILE using a user-friendly editor under X windows. emacs FILE Edit FILE using a powerful editor. vim FILE Edit FILE using a powerful editor with cryptic syntax. aspell -c FILE Check spelling in text-file FILE. cat FILE1 FILE2 > NEW Append FILE1 and FILE2 creating new file NEW. cat FILE1 >> FILE2 Append FILE1 at the end of FILE2. sort FILE > NEWFILE Sort lines of FILE alphabetically and put them in NEWFILE. grep STRING FILE(S) Display lines of FILE(S) which contain STRING. wc FILE(S) Count characters, words and lines in FILE(S). diff FILE1 FILE2 | more Show differences between two versions of a file. COMMAND | cut -b 1-9,15 Remove sections from each line. COMMAND | uniq Omit repeated lines. PROGRAMMING LANGUAGES javac CLASSNAME.java Compile a Java program. java CLASSNAME Run a Java program. javadoc CLASSNAME.java Create an html documentation file for CLASSNAME. appletviewer CLASSNAME Run an applet. python Listener of Python programming language. cc -g -Wall -o FILE FILE.c Compile C source FILE.c into executable FILE. gcc -g -Wall -o FILE FILE.c Compile C source FILE.c into executable FILE. c++ -g -Wall -o FIL FIL.cxx Compile C++ source FIL.cxx into executable FIL. g++ -g -Wall -o FIL FIL.cxx Compile C++ source FIL.cxx into executable FIL. gdb EXECUTABLE Start debugging a C/C++ program. make FILE Compile and link C/C++ files specified in makefile INTERNET lynx Web browser (for text-based terminals). firefox Web browser. konqueror Web browser. BROWSER Browse the Internet. BROWSER FILE.html Display a local html file. BROWSER FILE.pdf Display a local pdf file. mutt Text-based e-mail manager. pine Text-based e-mail manager (on some systems). ssh HOST Open interactive session on HOST using secure shell. sftp HOST Open sftp (secure file transfer) connection to HOST. rsync ARGUMENTS Synchronize directories on local and remote host. 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 a shell.
CTRL-Z Suspend current foreground process.
fg Bring job suspended by CTRL-Z to the foreground.
bg JOB Restart suspended Job in the background.
ps List processes.
ps -ef Complete list processes.
jobs List current jobs (A job may involve many processes).
kill PROCESS Kill PROCESS (however some processes may resist).
ctrl-C Kill the foreground process (but it may resist).
kill -9 PROCESS Kill PROCESS (no process can resist.)
COMMAND & Run COMMAND in the background.
ENVIRONMENT VARIABLES IN BASH env | sort | more List all the environment variables with values. echo $VARIABLE List the value of VARIABLE. unset VARIABLE Remove VARIABLE. export VARIABLE=VALUE Create environment variable VARIABLE and set to VALUE. MISCELLANEOUS exit Exit from any shell. logout Exit from the login shell and terminate session. svn Version control system. xterm A shell window under X-windows. xcalc A calculator under X-windows. xclock A clock under X windows. xeyes They watch you work and report to the Boss :-) date Display date and time. clear Clear shell window. xrefresh Refresh X-windows. Source: faculty.plattsburgh.edu
|
