Presentation is loading. Please wait.

Presentation is loading. Please wait.

Welcome to Unix. Redistribution The authors (nor anyone else) provides no warranty or claim of accuracy of this document. Use at your own risk. You may.

Similar presentations


Presentation on theme: "Welcome to Unix. Redistribution The authors (nor anyone else) provides no warranty or claim of accuracy of this document. Use at your own risk. You may."— Presentation transcript:

1 Welcome to Unix

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 for details.

3 Outline I. getting help II. the file system III. the shell V. 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. Most of the Network users first login to Unix machine before they really access to routers and switches

5 Where do you get Help ~>man command gives you help on that command. tells you all man pages that contain keyword. Of course.. Google or Wiki

6 Outline I. getting help II. the file system III. the shell V. options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X

7 Files and Directories: Naming something gives you power over it.

8 Absolute Addressing

9 Addressing relative to your home dir.

10 Addressing relative to your current dir.

11 File system commands pwd - report your current directory cd - change your current directory ls -list contents of directory cp - copy mv - move (or rename) rm -delete a file mkdir -make a directory rmdir -remove an empty directory

12 getting recursive remove a directory and its contents: rm -r copy a directory and its contents: cp -r

13 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. >ls -l.forward -rw-r--r-- 1 darin csua 23 Jan forward Chown >ls -l.cshrc.local -rwxr-xr-- 1 darin csua 2988 May 19 00:48.cshrc.local*

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

15 Changing File Permissions make a file readable to your friends: chmod g+r change who owns a file: chown change to which group the file belongs: chgrp

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

17 Symbolic Links use ln -s to create a symbolic link to a file. >ls -l.forward* -rw-r--r-- 1 darin csua.forward drwxr-xr-x 1 darin ->.forward The first l tells you that its a symbolic link. Symbolic links can be used as if it were its target.

18 Outline I. getting help II. the file system III. the shell V. options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X

19 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 to change your shell

20 File Globbing some commands can work on many files at once: ~> rm file1 file2 file27 Use * to match any number of unknown characters ~> rm file* Use ? to match one unknown character. ~> rm file??

21 (un)aliasing create shortcuts for yourself ~>alias ll ls -la Use alias with no arguments to discover current aliases ~>alias rmrm -i llls -la Type unalias rm to remove alias.

22 shell variables, echo (tcsh) ~>setenv BOB joe (tcsh) ~>printenv BOB joe (tcsh) ~>echo $BOB joe

23 PATH: a very important shell variable >echo $PATH /home/d/da/darin/bin:/opt/local/bin:/opt/local/bin/pbmutil s:/usr/bin:/usr/sbin:/opt/SUNWspro/bin:/usr/ccs/bin:/op t/local/X11/bin:/usr/dt/bin:/usr/openwin/bin:/opt/local /gnu/bin:/opt/local/games/bin:/usr/ucb:./ If a program (like ls) is in one directory found in your path, then typing it ( ~>ls ) will execute it. Otherwise you can type the full absolute address to execute a program ( ~>/usr/bin/ls )

24 finding things in your PATH. Type which to find the location of the program which would be run when you type. If you dont remember if it was chgrp or chgroup, type ch to get a list of commands that starts with ch. when all else fails, use find to find a file. ~>find -name *.doc

25 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

26 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 to run the script. If the first line of your script looks like #! then you can make the script executable. When it executes, it uses to interpret the contents of the script.

27 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.

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

29 Outline I. getting help II. the file system III. the shell V. options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X

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

31 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.

32 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.

33 using secure copy: scp copy local to remote scp copy remote to local scp

34 Outline I. getting help II. the file system III. the shell V. options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X

35 the program mail mail: useful for sending: >mail Subject: hello Cc: hi there this is a message.

36 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.

37 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 . ALWAYS use SSL (encryption).

38 Outline I. getting help II. the file system III. the shell V. options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X

39 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

40 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

41 Outline I. getting help II. the file system III. the shell V. options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X

42 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

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

44 > vers >> By default, who >f will overwrite the file f. Use who >>f to append to f rather than overwriting it.

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

46 The output of one program can be the input to another. who | sort >file1 The output of who is sorted and shown on your terminal screen.

47 grep grep shows only those lines containing its search pattern. To see all lines in a file containing bob: grep Dropped Packet file2

48 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 < file1

49 Outline I. getting help II. the file system III. the shell V. options VI. and lesser editors VII. input and output redirection VIII. process management IX.Other Useful commands

50 how to print a.ps file syntax: lp -D example: lp -Dlw330 myfile.ps

51 How to check the printers queue. syntax: lpq -P example: lpq -Plw330

52 Outline I. getting help II. the file system III. the shell V. options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X

53 To start a process in the background, use &. example: big_program > output & big_program will not have input!

54 managing jobs To suspend the currently active program, use. To return to the program you just suspended, type fg To put the program you just suspended in the background, type bg

55 To see a list of your programs running, type ps. >ps -eaf PID TTY TIME CMD 866 pts/1 00:00:00 tcsh 872 pts/1 00:00:00 ps

56 use kill to end a process >ps PID TTY TIME CMD 866 pts/1 00:00:00 tcsh 874 pts/1 00:00:00 cat 875 pts/1 00:00:00 ps >kill 874 [1] Terminated cat

57 kill -9 If kill doesnt end your process, use kill -9


Download ppt "Welcome to Unix. Redistribution The authors (nor anyone else) provides no warranty or claim of accuracy of this document. Use at your own risk. You may."

Similar presentations


Ads by Google