Explore

Loading

Thursday, February 16, 2012

Unix Commands


Modifiers
Print Command Line :p
Substitute Command Line :[g]s/l/r/
3.2 Aliases
alias Command alias name 'definition'
definition can contain escaped history substitution event
and
word designators as placeholders for command-line arguments.
3.3. Variable Substitution
Creating a Variable set var
Assigning a Value set var = value
Expressing a Value $var
Displaying a Value echo $var
value is a single word, an expression in quotes, or an
expression that results in a single word after variable,
filename and command substitution takes place.
Assigning a List set var = (list)
list is a space-separated list of words, or an expression that
results in a space-separated list.
Selecting the n'th Item $var[n]
Selecting all Items $var
Selecting a Range $var[x-y]
Item Count $#var
3.4 foreach Lists
Start foreach Loop foreach var (list)
foreach prompts for commands to repeat for each item in
list (with >), until you type end. Within the loop, $var
stands for the current item in list.
3.5. Command Substitution
Replace Command with its Output on Command Line ``
3.6 Job Control
Run Command in the Background &
Stop Foreground Job CTRL-Z
List of Background Jobs jobs
Bring Job Forward %[n]
Resume Job in Background %[n] &
4. Processes
Listing ps [-[ef]]
Terminating kill [-9] PID
Timing time command
time is a number up to 4 digits. script is the name of a file
containing the command line(s) to perform.
5. Users
Seeing Who is Logged In who
w
Seeing Your User Name whoami

Wednesday, February 15, 2012

Unix commands


2.3. Searching with grep
grep Command grep "pattern" filename
command | grep "pattern"
Search Patterns
beginning of line ^
end of line $
any single character .
single character in list or range []
character not in list or range [^]
zero or more of preceding char. or pattern *
zero or more of any character .*
escapes special meaning \
3. C-Shell Features.
3.1 History Substitution
Repeat Previous Command !!
Commands Beginning with str !str
Commands Containing str !?str[?]
All Arguments to Prev. Command !*
Word Designators
All Arguments :*
Last Argument :$
First Argument :^
n'th Argument :n

Unix commands for redirection,pipes,filters


2.1. Command-line Special Characters
Quotes and Escape
Join Words ""
Suppress Filename, Variable Substitution ''
Escape Character \
Separation, Continuation
Command Separation ;
Command-Line Continuation (at end of line) \
2.2. I/O Redirection and Pipes
Standard Output >
(overwrite if exists) >!
Appending to Standard Output >>
Standard Input <
Standard Error and Output >&
Standard Error Separately
( command > output ) >& errorfile
Pipes/ Pipelines command | filter [ | filter]
Filters
Word/Line Count wc [-l]
Last n Lines tail [-n]
Sort lines sort [-n]
Multicolumn Output pr -t
List Spelling Errors ispell

Unix commands-displaying files with less,directory access


1.4. Displaying a File with less
Run less less filename
Next line RETURN
Next Page SPACE
Previous line k
Previous Page b
1.5. Directories
Change Directory cd directory
Make New Directory mkdir directory
Remove Directory rmdir directory
Print Working (Show Current) Directory pwd

Tuesday, February 14, 2012

Unix Commands

1. Files

1.1. Filename Substitution
Wild Cards ? *
Character Class (c is any single character) [c…]
Range [c-c]
Home Directory ~
Home Directory of Another User ~user
List Files in Current Directory ls [-l]
List Hidden Files ls -[l]a
1.2. File Manipulation
Display File Contents cat filename
Copy cp source destination
Move (Rename) mv oldname newname
Remove (Delete) rm filename
Create or Modify file pico filename
1.3. File Properties
Seeing Permissions ls -l filename
Changing Permissions chmod nnn filename
chmod c=p…[,c=p…] filename
n, a digit from 0 to 7, sets the access level for the user
(owner), group, and others (public), respectively. c is one of:
uuser; ggroup, oothers, or aall. p is one of: rread
access, wwrite access, or xexecute access.
Setting Default Permissions umask ugo
ugo is a (3-digit) number. Each digit restricts the default
permissions for the user, group, and others, respectively.
Changing Modification Time touch filename
Making Links ln [-s] oldname newname
Seeing File Types ls -F