Presentation is loading. Please wait.

Presentation is loading. Please wait.

LIS508 using Debian GNU/Linux Thomas Krichel 2010-01-10.

Similar presentations


Presentation on theme: "LIS508 using Debian GNU/Linux Thomas Krichel 2010-01-10."— Presentation transcript:

1 LIS508 using Debian GNU/Linux Thomas Krichel 2010-01-10

2 ssh The main protocol we use to communicate with the server is the secure shell “ssh”. The server has to have ssh server software installed. Any rented server will have this. Otherwise run “aptitude install openssh- server”

3 installing putty Go to your favorite search engine to search for putty. If you have administrator rights install the installer version. Since you have already installed winscp, you should have no further problems.

4 putty options In the window/translation choose UTF-8, always. Find out what the size of your screen for the font that you are using, and save that in your session. For wotan, the port is 22, ssh. You can choose to disable the annoying bell.

5 how is ssh secure ssh uses public key cryptography. It can cope with serveral crytographic algorithm. The most common one is rsa. In public key cryptography, you have two keys. One is the private key. The second is the public key.

6 private key Using the private key, I can decrypt a message that has been encrypted using my public key. Somebody can check that I am who I claim to be because by keeping the private key private, I am the only one who can decrypt it.

7 authorizing keys If you want to give your friend access to an account, you can ask her for her public key. You will then authorize the public key by storing it in a file with authorized keys. When an somebody comes along and pretends to be your friend you can challenge her to decode a message encoded with your friends public key.

8 public key Using the public key, I can encrypt a message and send it to you. Once the message is encrypted, I can not decode it any more. The public key can not be used to decode a message. This is the reason why the encryption key can be made public.

9 communication with the server Assume we are using a Microsoft Windows client. For file editing and manipulation, we use putty. For file transfer, we use winscp. Both are available on the web.

10 password authentication When we login to a machine, we give a password for the user that we login as. This a common form of authenticiation. The idea is that we keep the password secret.

11 key authenticatiton ssh uses public key This a common form of authenticiation. The idea is that we keep the password secret.

12 key creation “ssh-keygen” is the command to use to create a key. Answer all questions with the key. “cd.ssh” and “ls -l” shows you the contents of the directory.ssh created in the first step. The file “id_rsa.pub” has your public key.

13 authorized_keys In.ssh, you can maintain a file “authorized_keys” that contains the public keys of all users you authorize to access the account, one line per user. “cp id_rsa.pub authorized_keys” will authorize yourself. Then “ssh user@wotan” will allow you to login again as you on wotan. You can also create a public key with putty.

14 issuing commands While you are logged in, you talk to the computer by issuing commands. Your commands are read by command line interpreter. The command line interpreter is called a shell. You are using the Bourne Again Shell, bash.

15 bash features bash allows to browse the command history with the up/down arrow keys. bash allows to edit commands with the left/right arrow keys. You can complete command and file names with. bash comes with a language of commands that allows to write batch files. “exit” is the command to leave the shell.

16 environment variables These are variables used by the shell. Two important ones are –$HOME your home directory –$PATH the location where bash will search for executable files. echo $HOME will show you your home directory. “env” is a command that can be used to see all environment variables.

17 bash initialization Files that start with a dot are hidden. They are only seen with “ls -a”..bashrc is a file written in bash language that is run every time bash is started..bash_profile or.profile is run when the shell is started at login. You can customize these files.

18 files, directories and links Files are continuous chunks data on disks that are required for software applications. Directories are files that contain other files. Microsoft calls them folders. In UNIX, the directory separator is “/” The top directory is “/” on its own.

19 home directory When you first log in to wotan you are placed in your home directory /home/username “cd” is the command that gets you back to the home directory. The home directory is also abbreviated as “~“ cd ~user gets you to the home of user user. “cd ~” does what?

20 ~/public_html The web server on wotan will map requests to http://wotan.liu.edu/~user to show the file ~user/public_html/index.html The web server will map requests to http://wotan.liu.edu/~user/file to show the file ~user/public_html/file The server will do this by virtue of a configuration option.

21 changing directory, listing files “cd directory” changes into the directory directory the current directory is “.” its parent directory is “..” “ls” lists files

22 users and groups “root” is the user name of the superuser. The superuser has all privileges. There are other physical users, i.e. persons using the machine There are users that are virtual, usually created to run a daemon. For example, the web sever in run by a user www-data. Arbitrary users can be put together in groups.

23 permission model Permission of files are given –to the owner of the file –to the group of the file –and to the rest of the world A group is a grouping of users. Unix allows to define any number of groups and make users a member of it. The rest of the world are all other users who have access to the system. That includes www-data!

24 listing files “ls” lists files “ls -l” make a long listing. It contains –elementary type and permissions (see next slide)‏ –owner –group –size –date –name

25 first element in ls -l Type indicator –d means directory –l means link –- means ordinary file 3 letters for permission of owner 3 letters for permission of group 3 letters for permission of rest of the world r means read, w means write, x means execute Directories need to be executable to get in them.

26 change permission: chmod usage: chmod permission file file is a file permission is three numbers, first for owner, 2 nd for group and 3 rd rest of the world. Each number is sum of –4 for read- 2 for write –1 for execute - 0 for no permission Example: chmod 764 file

27 general structure of commands commandname –flag --option Where commandname is a name of a command flag can be a letter Several letters set several flags at the same time An option can also be expressed with - - and a word, this is more user-friendly than flags.

28 example command: ls ls lists files ls -l makes a long listing ls -a lists all files, not only regular files but some hidden files as well –all files that start with a dot are hidden ls -la lists all files is long listing ls --all is the same as ls -a. --all is known as a long listing.

29 copying and removing files cp file copyfile copies file file to file copyfile. If copyfile is a directory, it copies into the directory. mv file movedfile moves file file to file movedfile. If movedfile is a directory, it moves into the directory. rm file removes file, there is no recycling bin!!

30 directories and files mkdir directory makes a directory rmdir directory removes an empty directory rm -r directory removes a directory and all its files more file –Pages contents of file, no way back less file –Pages contents of file, “u” to go back, “q” to quit

31 soft links A link is a file that contain the address of another file. Microsoft call it a shortcut. A soft link can be created with the command ln -s file link_to_file where file is a file that is already there and link_to_file is the link.

32 file transfer You can use winscp to upload and download files to wotan. If uploaded files in the web directory remain invisible, that is most likely a problem with permission. Refer back to permissions. chmod 644 * will put it right for the files chmod 755. (yes with a dot) will put it right for the current directory * is a wildcard for all files. rm -r * is a command to avoid.

33 editing There are a plethora of editors available. For the neophyte, nano works best. nano file edits the file file. nano -w switches off line wrapping. nano shows the commands available at the bottom of the screen. Note that ^letter, where letter is a letter, means pressing CONTROL and the letter letter at the same time.

34 emacs This is another editor that is incredibly rich and complex. Written by Richard M. Stallman, of GNU and GPL fame. Get an emacs cheat sheet of the web before you start it. Or look at next slide.

35 emacs commands (here ^ stands for the control character)‏ ^x^s saves buffer ^x^c exits emacs ^g escapes out of a troublesome situation control+space sets the mark ^w removes until the mark (cut)‏ ^y pastes

36 common emacs/bash commands ^k kills until the end of the line or removes empty line ^y yank what has been killed (paste)‏ ^a get to the beginning of the line ^e get to the end of the line These commands also work in the shell.

37 emacs modes Just like people get into different moods, emacs gets into different modes. One mode that will split your pants is the PHP mode. Then look how emacs checks for completion of parenthesis, braces, brackets, and the ; and use the tab character to indent.

38 copy and paste Putty allows to copy and paste text between windows and wotan. On the windows machine, it uses the windows approach to copy and paste On wotan machine, –you copy by highlighting with the mouse’ left button –you paste using the middle button –if you don't have a middle button, use left and right together

39 man man is the manual lookup command You usually say “man command” if you want to have an overview over the command. man -k keyword looks up the man pages on the computer for pages with the keyword keyword. I don't find this very effictive ;-(

40 echo echo is a command to desplay a line of text. Example: echo foo

41 cat This is a program that displays the contents of a file. Use like “cat file” to display the contents of the file file.

42 more This is a paging utility. It is mostly used as part of a pipe. You take the output of a command and pipe it to the input of the next command Example “cat longfile | more” | is the piping operator.

43 less This is a paging utility. It does more than more. You can use the command “u” to go up. You must use the command “q” to leave the page.

44 du du is a command to look at disk usage. du -s makes a summary, rather than listing the usage of every. The size is give in kilobytes. A kilobyte is 1024 bytes, not 1000 bytes.

45 ln -s ln -s origin target makes a link from a target file target to an original file origin. Then when you access target you get the same contents as in origin. This concept is knows as a shortcut in Microsoft windows.

46 ssh ssh user@host logs you in as user user on the host host. host can be a DNS name or an IP address. If you don't have you public keys in the remote account's.ssh/autorized_keys file, you will be prompted for a password.

47 slogin slogin is a bit of a synonym for ssh. I use it often “slogin host -l user”.

48 scp This copies files from one host to another. You can use it has complicated as “scp user1@host1:file1 user2@host2:file2. But often one of the users is the current user on thee current host. In that case the user@host: bit can be left out. If you don't have permissions via keys you will be prompted for passwords.

49 date date says what time it is. This depends on the locale, as set of conventions to deal with language issues.

50 find find finds file in a directory. This is a very important and powerful command. Example: “find. -type f -name '*.deb'” finds all regular files ending with “deb” The most powerful feature is “-exec command \;” that executes a command on the files found. Each file is represented by {}

51 find examples find ~/public_html -name '*.html' -exec cp {} {}.org find ~/public_html -name '*.css' -exec cat {} >> /tmp/master.css

52 output and error In programs that ran on the shell, there are two concepts, the output and the error. The output is what is written by the command in normal operation, e.g. a list of files for ls. The output is often empty, for example for the cp command. The error of a command is what is reported when an error occurs. Example “cp foo bar” will generate an error when there is no file foo.

53 output redirection The redirect the output of a command to a file, use > or >> Example “echo foo > /tmp/foo.file” When you use “>” the file will be created anew. When you use “>>” the output will be appended to an existing file, if any.

54 error redirection The redirect the output of a command to a file, use “2>” or “2>>” Example “cp foo 2> /tmp/error.file” When you use “2>” the file will be created anew. When you use “2>>” the error will be appended to an existing file, if any.

55 pipes The piping operator | connects the output of one command to the input of another. Example: echo “hi thomas” | mutt krichel@openlib.org

56 grep grep is a very important utility to look up a pattern in a file, as in “grep pattern file”. Pattern is often just a string of what we want to find. But in the pattern, the following will have special meaning: ( ) \ +. ? * []. grep -r finds the pattern recursively.

57 sort and uniq sort sorts entries in it's inputExample: “last | cut -f 1 | sort” gives you a sorted list of last users. uniq gives uniq values in an sorted list. The list has to be sorted first. Example “last | cut -f 1 | sort | uniq”

58 crontab files /etc/crontab is the system wide crontab. /etc/cron.d, /etc/cron.monthly, /etc/cron.daily, /etc/cron.weekly have more cron examples for your viewing pleasure. Output and error from a crontab entry is sent by local mail to the user. This is one reason of having mail at least set up locally, i.e. from the machine to users on the same machine.

59 crontab entries You can create a file that contains commands you want to schedule regularly, and the schedule The file cantains lines of the form minutes hour day_of_month month day_of_week. There day_of_week ranges form 0 to 6 with 0 being Sunday. Save this in a file say etc/crontab.

60 http://openlib.org/home/krichel Thank you for your attention! Please switch off machines before leaving!


Download ppt "LIS508 using Debian GNU/Linux Thomas Krichel 2010-01-10."

Similar presentations


Ads by Google