/ Published in: Bash
                    
                                        
some basic *nix terminal commands
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
# For more details on a command see the man page for the command. For example, to see more information about the command rm, enter the command
man rm
# To display a list of commands related to a topic enter
man -k topic
# or
apropos topic
# Remember: UNIX COMMANDS ARE CASE SENSITIVE!
# |||||||||||| ACCOUNT |||||||||||||||||
passwd # ... set a new password for your account
assets # ... view information on resource use by your account, including connectivity time, cpu use, and disk space. (Availableon C&C systems only.)
# ||||||||||||| DIRECTORIES ||||||||||||||||||
# DO: TO:
# --------------- ---------------------------------------------
pwd # ... find out what your current working directory is
mkdir playdir # ... create a new subdirectory called 'playdir'
rmdir junkdir # ... remove subdirectory 'junkdir' (must be empty of files and subdirectories)
cd /usr/bin # ... change to '/usr/bin' directory
cd .. # ... change to directory one level above current working directory
cd # ... change to home directory for the account you are using
du # ... display the number of disk blocks in use (the total combined size of all files) in each directory and subdirectory.
# |||||||||||||||| FILES |||||||||||||||||||
# DO: TO:
# --------------- ---------------------------------------------
ls # ... list files in the current working directory
ls notes # ... list file in the subdirectory named 'notes'
ls -l # ... list all files in the current working directory, along with each file's permission, owner, size in bytes and date of last modification.
ls -a # ... list files in the current working directory, including dot files (those files with names beginning with a period)
ls -F # ... list files in the current working directory, indicating executable files with an asterisk (*) and subdirectories with a /
find docs -name \\*\.memo -print # ... list all files in the directory 'docs' and any subdirectories of 'docs' with filenames ending in '.memo'. The \ is necessary before the * to insure that is is interpreted as a wild character.
cp file1 file2 # ... copy the file 'file1' to a file named 'file2' (original file remains intact with the same name)
mv oldf newf # ... move the file 'oldfile' to a file named 'newfile' (equivalent to renaming a file)
rm badfile # ... remove the file 'badfile' (the file is permanently removed and cannot be recovered)
rm -i *.c # ... remove all files in the current directory with the suffix '.c' and be asked for confirmation on each file
chmod a+r resul # ... grant read access of the file 'resul' to all users
cat shortfile # ... display the file 'shortfile'
more longfile # ... display the file 'longfile', a screenful at a time
head big # ... display the first ten lines of file 'big'
head -25 big # ... display the first 25 lines of file 'big'
tail big # ... display the last ten lines of file 'big'
tail -25 big # ... display the last 25 lines of file 'big'
grep done tasks # ... display all lines within file 'tasks' containing the string 'done'
# |||||||||||||||||||| JOBS ||||||||||||||||||||||
# DO: TO:
# --------------- ---------------------------------------------
ps # ... list the status of your jobs by process identifier (PID)
ps -aux # ... list the status of all jobs by process identifier (PID)
jobs # ... list the status of all jobs by job number
z # ... suspend the job currently running in the foreground
bg # ... resume the most recently suspended job into the background
bg %2 # ... resume job number 2 in the background
fg %2 # ... resume job number 2 in the foreground
fg %3 # ... bring job number 3, which is running in the background, into the foreground
kill %2 # ... kill job number 2
kill 1234 # ... kill job with PID 1234
# ||||||||||||||||||||| NETWORKING |||||||||||||||||||||
# DO: TO:
# --------------- ---------------------------------------------
ssh becker.u # ... establish an interactive session on computer 'becker'
ftp sun.latin.washington.edu # ... transfer a file to or from computer 'sun.latin.washington.edu'
# |||||||||||| COMMS WITH OTHERS |||||||||||
# DO: TO:
# --------------- ---------------------------------------------
who # ... find out who is logged on to the computer
w # ... find out who is logged on to the computer and what they are doing
finger suzz # ... display information about user 'suzz'
biff y # ... be notified if mail arrives. To turn off notification, enter the command 'biff n'
pine # ... start pine mailer. Pine is an alternative to 'mail' that many people find easier to use than 'mail'
# ||||||||||||||| MISC ||||||||||||||||||
# DO: TO:
# --------------- ---------------------------------------------
cal 6 1990 # ... display a calendar of June, 1990.
date # ... display current date and time
script # ... start recording of all screen interactions
exit # ... stop script recording (text from recorded session will be in a file named typescript )
alias dir ls -Fal # ... alias 'dir' to represent the command 'ls -Fal'
unalias dir # ... remove the alias for 'dir'
alias # ... show all current aliases
# |||||||||||| CONTROL CODES (USED WHEN AT UNIX COMMAND LINE) ||||||||||||
# DO: TO:
# --------------- ---------------------------------------------
u # Delete entire line
w # Delete the preceding word
h # Delete the preceding character
c # Abort the program currently running
z # Suspend the program currently running (use fg or bg to resume the program in the foreground or background, respectively)
# Redirecting and Piping
cc myprog.c > listing # ... run C compiler on 'myprog.c' source file, redirecting compilation messages to a file named 'listing'. The resulting file would NOT include any diagnostic messages.
cc myprog.c >& listing # ... run C compiler on 'myprog.c' source file, redirect compilation messages, including diagnostic messages, into a file named 'listing'.
ps -aux | more # ... list all current jobs on the system, piping the result to more for viewing one screen at a time
cat frog >> rat # ... concatenate the contents of file 'frog' onto the end of file 'rat'
Comments
 Subscribe to comments
                    Subscribe to comments
                
                