Unixintro
Unixintro
Rob Funk
<[email protected]>
University Technology Services
Workstation Support
http://wks.uts.ohio-state.edu/
• text processing
• system resources
• printing
• vi editor
• shell programming
• Unix command summary tables
• Conciseness
• Everything is a file
• File system has places, processes have life
Programs
Kernel
Hardware
System Calls
• To reset:
• setenv TERM terminaltype (C-shell)
• may need to unsetenv TERMCAP
Do:
• make sure nobody is looking over your shoulder when
you are entering your password.
• change your password often
• choose a password you can remember
Don’t:
• use a word (or words) in any language
• use a proper name
• use information in your wallet
• use information commonly known about you
• use control characters
• write your password anywhere
• EVER give your password to anybody
ˆC interrupt
ˆD can log a user off; frequently disabled
logout leave the system
exit leave the shell
ˆS pause display
ˆQ restart display
ˆC cancel operation
ˆU cancel line
ˆD signal end of file
ˆV treat following control character as normal
character
ls [options] [argument]
r read permission
w write permission
x execute permission
- no permission
s and t also seen in special cases
r = 4
w = 2
x = 1
Total: 7
chmod 7 7 7 filename
user group others
gives user, group, and others r, w, x permissions
umask mask
• set in startup files for the account
• masks out permissions
• umask numbers added to desired permission number
equals 7
more
less page through a text file
pg
df [options] [directory]
% df -k /
du [options] [directory] % du
% du directory
% du -s directory
% du -k directory
ps [options]
% ps
% ps -ef
% ps auxw
who [am i]
% who
lists all users currently on system
% who am i
reports information on command user
% whoami
reports username of command user
which command
will report the name of the file that will be executed
when the command is invoked
• full path name
hostname
reports the name of the machine the user is logged into
uname [options]
has additional options to print info about system
hardware and software
System V:
lp [options] filename
lpstat [options]
cancel [requestID] [printer]
% compress logins.*
% zcat beauty.Z | head
% uncompress logins.*.Z
-c create an archive
-t table of contents list
-x extract from archive
-f file archive file is named file
-v verbose
-i ignore case
-v display only lines that dont match
-n display line number with the line where
match was found
echo $SHELL
• Korn (ksh)
• Bourne-Again Shell (bash)
• Z Shell (zsh)
DISPLAY
EDITOR
PAGER
PATH
TERM
PS1 (sh)
prompt (csh)
others as needed
• set path
• define functions
• set terminal parameters (stty)
PATH=/usr/bin:/usr/ucb:/usr/local/bin:.
export PATH
PS1="{ ‘hostname‘ ‘whoami‘ } "
ls() { /bin/ls -sbF "$@"; }
ll() { ls -al "$@"; }
stty erase ˆH
eval ‘tset -Q -s -m ’:?xterm’‘
umask 077
• noclobber
• ignoreeof
• history
• alias
# .login
stty erase ˆH
set noglob
eval ‘tset -Q -s -m ’:?xterm’ ‘
unset noglob
#aliases
alias h history
alias ls "/usr/bin/ls -sbF"
alias ll ls -al
alias cd ’cd \!*;pwd’
umask 077
% history nn
prints last nn commands
% !!
repeats the last command
% !nn
repeats the command numbered nn
% !string
repeats latest command starting with string
• chsh
• passwd -e /usr/local/bin/tcsh
The new shell must be the full path name for the shell on the
system
Frequently standard shells:
Bourne: /bin/sh
Korn: /bin/ksh
C: /bin/csh
To discard stderr:
$ command 2 > /dev/null
(/dev/null is a “black hole” for bits)
; command separator
& run the command in the background
&& run the following command only if previous
command completes successfully
|| run the following command only if previous
command did not complete successfully
() grouping — commands within parentheses
are executed in a subshell
cw change word
[n] cw change next [n] word(s)
c$ change from cursor to end of line
˜ change case of character
J joins current line and next line
u undo the last command just done
-i ignore case
-v display only lines that dont match
-n display line number with the line where
match was found
grep ’regexp’ file
Regular expressions:
• allow pattern matching on text
• combine normal and special characters (metacharacters)
-f filelist
filelist is a file which contains a list of files to
examine
-h don’t follow symbolic links (SVR4)
-L follow symbolic links (BSD)
% file *
-n numeric order
-u unique; omit multiple copies
-f fold upper case to lower case
-d dictionary order (ignore punctuation)
-b ignore leading blanks
wc [options] file
Options:
-c count bytes
-m count characters (SVR4)
-l count lines
-w count words
% wc userlist
#!
Include full path to interpreter (shell)
• #!/bin/sh
• #!/bin/csh -f
• if [ . . . ]; then
...
fi
• case $variable in . . . esac
• for variable in . . .
do . . . done
Check sh man page for details, also look at examples.