Welcome to Unix - PowerPoint PPT Presentation

1 / 71
About This Presentation
Title:

Welcome to Unix

Description:

netscape, outlook, eudora, and others can get at your mail using POP or IMAP. ... IMAP only reads headers, but leaves mail how it is on the server. ... – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 72
Provided by: snapNl
Category:

less

Transcript and Presenter's Notes

Title: Welcome to Unix


1
Welcome to Unix
  • Crafted by the CSUA at Berkeley
  • http//csua.berkeley.edu
  • Presented 8/29/2002

2
Redistribution
  • The authors (nor anyone else) provides no
    warranty or claim of accuracy of this document.
    Use at your own risk.
  • You may use this document in whole or part
    according to the terms of the GPL. See
    http//www.gnu.org/copyleft/gpl.html for details.

3
Outline
  • I. getting help
  • II. the file system
  • III. the shell
  • IV. safe computer sex
  • V. email options
  • VI. and lesser editors
  • VII. input and output redirection
  • VIII.printing
  • IX. process management
  • X. X

4
What is it and where do you get it?
  • An operating system used on everything from
    servers to embedded systems.
  • To you, probably a prompt
  • gt type stuff here
  • You get a temporary account when you take a CS
    class. Get a (more) permanent account from the
    OCF or CSUA. Or buy a Mac.

5
If you know only one thing, know how to RTFM.
  • gtman command
  • gives you help on that command.
  • gtapropos keyword
  • tells you all man pages that contain keyword.

6
How to get help.
  • Come to the CSUA office, 343 Soda.
  • HKN is next door the CSUA.
  • Go to the OCF in the MLK Heller Lounge when
    someone is holding staff hours.
  • Post your question to a newsgroup (like your
    class newsgroup).
  • Hit the man pages/web first !

7
Outline
  • I. getting help
  • II. the file system
  • III. the shell
  • IV. safe computer sex
  • V. email options
  • VI. and lesser editors
  • VII. input and output redirection
  • VIII.printing
  • IX. process management
  • X. X

8
Files and DirectoriesNaming something gives you
power over it.
9
Absolute Addressing
10
Addressing relative to your home dir.
11
Addressing relative to your current dir.
12
File system commands
  • pwd - report your current directory
  • cd ltto wheregt - change your current directory
  • ls ltdirectorygt -list contents of directory
  • cp ltold filegt ltnew filegt - copy
  • mv ltold filegt ltnew filegt - move (or rename)
  • rm ltfilegt -delete a file
  • mkdir ltnew directory namegt -make a directory
  • rmdir ltdirectorygt -remove an empty directory

13
getting recursive
  • remove a directory and its contents
  • rm -r ltdirectorygt
  • copy a directory and its contents
  • cp -r ltdirectorygt

14
File permissions.
  • There are 3 kinds of people in the world you
    (user), your friends (group) and everyone else
    (other).
  • Each sort of person may or may not be able to
    read, write, or execute a file.
  • gtls -l .forward
  • -rw-r--r-- 1 darin csua 23 Jan 23 2002
    .forward
  • gtls -l .cshrc.local
  • -rwxr-xr-- 1 darin csua 2988 May 19 0048
    .cshrc.local

15
executing
  • executing a file means running it as a program.
  • executing a directory means setting your
    current directory to it using cd.

16
Changing File Permissions
  • make a file readable to your friends
  • chmod gr ltfilenamegt
  • change who owns a file
  • chown ltusergt ltfilenamegt
  • change to which group the file belongs
  • chgrp ltgroupgt ltfilenamegt

17
touch
  • look at the full listing again
  • gtls -l .forward
  • -rw-r--r-- 1 darin csua 23 Jan 23 2002
    .forward
  • Each file has a date stamp of when it was
    modified.
  • Use touch to set the timestamp to the current
    clock.
  • touch ltfilenamegt
  • Touch creates the file if it didnt exist
    beforehand.
  • You can only touch a file to which you can write.

18
Symbolic Links
  • use ln -s ltold filegt ltsecond namegt to create a
    symbolic link to a file.
  • gtls -l .forward
  • -rw-r--r-- 1 darin csua .forward
  • lrwxr-xr-x 1 darin csua .forward.link_at_ -gt
    .forward
  • The first l tells you that its a symbolic
    link.
  • Symbolic links can be used as if it were its
    target.

19
Outline
  • I. getting help
  • II. the file system
  • III. the shell
  • IV. safe computer sex
  • V. email options
  • VI. and lesser editors
  • VII. input and output redirection
  • VIII.printing
  • IX. process management
  • X. X

20
whats a shell?
  • The shell is the program that
  • runs when you log in. It prints
  • the prompt and reads what you
  • type, invokes programs, etc.
  • your window to the Unix world.
  • use chsh ltnew shellgt to change your shell

21
File Globbing
  • some commands can work on many files at once
  • gt rm file1 file2 file27
  • Use to match any number of unknown characters
  • gt rm file
  • Use ? to match one unknown character.
  • gt rm file?

22
(un)aliasing
  • create shortcuts for yourself
  • gtalias ll ls -la
  • Use alias with no arguments to discover current
    aliases
  • gtalias
  • rm rm -i
  • ll ls -la
  • Type unalias rm to remove alias.

23
shell variables, echo
  • (tcsh) gtsetenv BOB joe
  • (tcsh) gtprintenv BOB
  • joe
  • (tcsh) gtecho BOB
  • joe

24
PATH a very important shell variable
  • gtecho PATH
  • /home/d/da/darin/bin/opt/local/bin/opt/local/bin
    /pbmutils/usr/bin/usr/sbin/opt/SUNWspro/bin/us
    r/ccs/bin/opt/local/X11/bin/usr/dt/bin/usr/open
    win/bin/opt/local/gnu/bin/opt/local/games/bin/u
    sr/ucb./
  • If a program (like ls) is in one directory found
    in your path, then typing it (gtls ltentergt) will
    execute it.
  • Otherwise you can type the full absolute address
    to execute a program (gt/usr/bin/ls ltentergt)

25
finding things in your PATH.
  • Type which ltcommandgt to find the location of
    the program which would be run when you type
    ltcommandgt.
  • If you dont remember if it was chgrp or chgroup,
    type chltcontrol-dgt to get a list of commands
    that starts with ch.
  • when all else fails, use find to find a file.
  • gtfind ltstart dirgt -name .doc

26
Other useful pre-defined shell variables
  • HOST what computer youre logged into
  • PAGER program used display man pages
  • PWD current directory
  • GROUP what group youre in
  • USER your login

27
Shell scripts.
  • If you have a bunch of commands youd like to
    automate, you can put them on separate lines of a
    file. Then type source ltfilegt to run the
    script.
  • If the first line of your script looks like
  • !ltprogram namegt
  • then you can make the script executable. When it
    executes, it uses ltprogram namegt to interpret the
    contents of the script.

28
Login scripts
  • Most people have a script that executes when they
    log in. It is commonly used to set up ones PATH
    and aliases.
  • Ask someone to help you start your own login
    script.

29
screen is your friend
  • You can use the program screen to run several
    shells from one window.
  • create a new shell by pressing ltctrl-agt c
  • switch shells by pressing ltctrl-agt ltnumbergt
  • use ltctrl-agt d to detach a session and come
    back to it later.

30
Outline
  • I. getting help
  • II. the file system
  • III. the shell
  • IV. safe computer sex
  • V. email options
  • VI. and lesser editors
  • VII. input and output redirection
  • VIII.printing
  • IX. process management
  • X. X

31
Your Options
  • Abstinence
  • (switch majors, unplug your computer)
  • monogamy
  • (use only one computer, do not use network)
  • protection
  • (also known as encryption)

32
What not to use.
  • telnet, ftp, rlogin
  • all your data (including your password) is
    transmitted plain text over the network.
  • from library machines you can use the java ssh
    client from a web browser.

33
using ssh keys
  • use ssh-keygen to generate a public/private set
    of keys. You keep the private key and append the
    public key to authorized_keys.
  • You can now log in using either your password or
    the private key file.

34
using secure copy scp
  • copy local to remote
  • scp ltsource filegt user_at_machineltpathgt
  • copy remote to local
  • scp user_at_machineltpathgt ltsource filegt

35
Outline
  • I. getting help
  • II. the file system
  • III. the shell
  • IV. safe computer sex
  • V. email options
  • VI. and lesser editors
  • VII. input and output redirection
  • VIII.printing
  • IX. process management
  • X. X

36
the program mail
  • mail useful for sending
  • gtmail darin_at_csua
  • Subject hello
  • Cc
  • hi there
  • this is a message
  • .

37
other console based options
  • elm - quick and simple, easy to use, but doesnt
    handle attachments very well.
  • pine - more complete. the standard
  • mutt - most modern/complex.

38
accessing mail remotely
  • netscape, outlook, eudora, and others can get at
    your mail using POP or IMAP.
  • POP takes the messages off the server to your
    local computer.
  • IMAP only reads headers, but leaves mail how it
    is on the server. Works well if you wish to use
    console based email.
  • ALWAYS use SSL (encryption).

39
Outline
  • I. getting help
  • II. the file system
  • III. the shell
  • IV. safe computer sex
  • V. email options
  • VI. and lesser editors
  • VII. input and output redirection
  • VIII.printing
  • IX. process management
  • X. X

40
vi
  • is an editor available on all decent Unix
    systems. Developed at Berkeley.
  • Has two modes command and insert. In insert
    mode you can type normally.
  • Press escape to get into command mode. In
    command mode each letter is a command.
  • hjkl ? ????

41
pico - the pine composer
  • the simplest visual editor available on most Unix
    systems.
  • all possible commands displayed at bottom of
    screen. (control-somethings)
  • no real surprises

42
emacs
  • Always has one major mode running, potentially
    several minor modes.
  • stands for editing macros - designed by and for
    lisp programmers.

43
Outline
  • I. getting help
  • II. the file system
  • III. the shell
  • IV. safe computer sex
  • V. email options
  • VI. and lesser editors
  • VII. input and output redirection
  • VIII.printing
  • IX. process management
  • X. X

44
STD
  • All terminal programs have
  • standard output, which is usually your screen
  • standard input, which is usually your keyboard
  • standard error, which is also the screen

45
redirect output to a file with gt
  • If you type who at the prompt, you will get a
    list of who is logged into the system.
  • If you type who gtf, a file named f will be
    created and the standard output of who will be
    placed in that file instead of to your screen.

46
gt vers gtgt
  • By default, who gtf will overwrite the file f.
  • Use who gtgtf to append to f rather than
    overwriting it.

47
redirecting input from a file with lt
  • The program sort will sort its standard input and
    then print it on standard out.
  • To sort the lines of file1 and display
  • sort lt file1
  • To sort the lines of file1 and save in file2
  • sort lt file1 gt file2

48
The output of one program can be the input to
another.
  • who sort
  • The output of who is sorted and shown on your
    terminal screen.

49
grep
  • grep shows only those lines containing its search
    pattern.
  • To see all lines in a file containing bob
  • grep bob lt file1

50
The cat command
  • the arguments to cat are concatenated together
    and displayed on stdout. To view a file
  • cat file1
  • if no arguments, cat puts on stdout whatever you
    type on stdin, so this does the same thing
  • cat lt file1

51
Outline
  • I. getting help
  • II. the file system
  • III. the shell
  • IV. safe computer sex
  • V. email options
  • VI. and lesser editors
  • VII. input and output redirection
  • VIII.printing
  • IX. process management
  • X. X

52
printers have stupid names
  • The printers downstairs are named lw274.
  • The printer in 330 is called lw330.

53
how to print a .ps file
  • syntax
  • lp -Dltprintergt ltfilenamegt
  • example
  • lp -Dlw330 myfile.ps

54
how to print a .pdf file
  • convert it to .ps first!!!
  • use the pdf2ps utility program.
  • pdf2ps input.pdf output.ps

55
how to print other file types
  • Convert them to .ps first!!!
  • The program a2ps (anything to .ps) works most of
    the time.

56
How to check the printers queue.
  • syntax
  • lpq -Pltprinter_namegt
  • example
  • lpq -Plw330

57
How to cancel your print job.
  • Type cancel.

58
Outline
  • I. getting help
  • II. the file system
  • III. the shell
  • IV. safe computer sex
  • V. email options
  • VI. and lesser editors
  • VII. input and output redirection
  • VIII.printing
  • IX. process management
  • X. X

59
To start a process in the background, use .
  • example
  • big_program gt output
  • big_program will not have input!

60
managing jobs
  • To suspend the currently active program, use
    ltcontrol-zgt.
  • To return to the program you just suspended, type
    fg
  • To put the program you just suspended in the
    background, type bg

61
To see a list of your programs running, type ps.
  • gtps
  • PID TTY TIME CMD
  • 866 pts/1 000000 tcsh
  • 872 pts/1 000000 ps

62
use kill to end a process
  • gtps
  • PID TTY TIME CMD
  • 866 pts/1 000000 tcsh
  • 874 pts/1 000000 cat
  • 875 pts/1 000000 ps
  • gtkill 874
  • 1 Terminated cat

63
kill -9
  • If kill ltPIDgt doesnt end your process, use
    kill -9 ltPIDgt

64
Outline
  • I. getting help
  • II. the file system
  • III. the shell
  • IV. safe computer sex
  • V. email options
  • VI. and lesser editors
  • VII. input and output redirection
  • VIII.printing
  • IX. process management
  • X. X

65
cutting and pasting
  • Highlight some text in any window.
  • Hit the middle mouse button in another window.
  • The highlighted text appears.
  • There is no saving to the clipboard step as in
    Microsofts Windows or MacOS.

66
Changing your fonts.
  • ltcontrol-leftclickgt in xterm
  • edit --gtpreferences --gt fonts in netscape.

67
Changing your window manager.
  • Your /.xsession gets run when you log into X
    windows, the last line sets which window manager
    you are going to use.
  • You probably want someone to set up your X
    configuration for you the first time.

68
Using X windows at home on a MS-Windows machine.
  • You need to get a program called a program called
    an Xserver. Exceed works well and is free for
    academic use.
  • You must allow X-forwarding through your ssh
    client. Putty is good for this.

69
(No Transcript)
70
(No Transcript)
71
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com