Presentation is loading. Please wait.

Presentation is loading. Please wait.

Www.ischool.drexel.edu INFO 320 Server Technology I Week 4 Basic Unix commands 1INFO 320 week 4.

Similar presentations


Presentation on theme: "Www.ischool.drexel.edu INFO 320 Server Technology I Week 4 Basic Unix commands 1INFO 320 week 4."— Presentation transcript:

1 www.ischool.drexel.edu INFO 320 Server Technology I Week 4 Basic Unix commands 1INFO 320 week 4

2 www.ischool.drexel.edu Overview Now we’re focusing more on practical concerns about how Linux/UNIX works –Booting –Managing Services –Users and Groups –Permissions But first a brief digression about scheduling and memory speeds 2INFO 320 week 4

3 www.ischool.drexel.edu Installation addendum I recently got a new system, and was very good to set it up right –Make sure the system works out of the box –Test RAM and hard disk – no errors –Install one component at a time, and check for errors for each before adding the next In doing so, I found a surprising increase in RAM speed just from doing an upgrade 3INFO 320 week 4

4 www.ischool.drexel.edu Memory and speed Recall that a major part of an OS’s job is to manage processes, and where they run As a refinement of the earlier slide about memory speeds, here are examples of speed to access various levels of memory –They are for a 2.132 GHz four-core Intel Xeon E5506 processor with 4 MB cache and DDR3 800 MHz RAM, before and after a 4 GB RAM upgrade 4INFO 320 week 4

5 www.ischool.drexel.edu Memory and speed (memtest86+ v2.11) TypeAmountSpeed (MB/s) L1 cache32 kB71,079 L2 cache256 kB28,057 L3 cache4096 kB19,563 RAM (2 GB)2039 MB5,213 RAM (6 GB)6135 MB8,703 5INFO 320 week 4

6 www.ischool.drexel.edu Memory and speed In contrast, a 2002-era 2 GHz (1993 MHz) Pentium 4 processor with 1 GB of RAM (200-266 MHz DDR SDRAM) got the results on the next slide (same test) –So how much of a factor is CPU clock speed in system performance? –Is 800 MHz RAM four times faster than 200 MHz RAM? Why or why not? 6INFO 320 week 4

7 www.ischool.drexel.edu Memory and speed (same test) TypeAmountSpeed (MB/s) L1 cache8 kB14,439 L2 cache512 kB12,611 L3 cachenone- RAM (1 GB)1022 MB797 7INFO 320 week 4

8 www.ischool.drexel.edu Booting From (Frisch, 2002), (Petersen, 2009) and (Rankin, 2009) 8INFO 320 week 4

9 www.ischool.drexel.edu Bootstrapping The process of bringing a computer to life and preparing it for use is formally known as bootstrapping –As in ‘picking yourself up by your bootstraps’ –This is usually abbreviated to booting We won’t go into huge detail, but an overview of the process is in order 9INFO 320 week 4

10 www.ischool.drexel.edu Booting overview Power on (or command to reboot) ROM finds boot device, loads boot program Boot program loads kernel into memory Kernel makes sure hardware is happy, runs init program 10INFO 320 week 4

11 www.ischool.drexel.edu Booting overview 11INFO 320 week 4

12 www.ischool.drexel.edu Start booting The process of booting varies from one flavor of UNIX/Linux to another, and is also hardware-dependent –We’ll focus on Linux on PC’s Booting starts with permanent instructions executed when the system powers up –Their location can be called ROM, ROS, firmware, or CMOS/nvram (a list of terms is at the end of these notes) 12INFO 320 week 4

13 www.ischool.drexel.edu Booting Several kinds of devices could be used for booting (examples?) –The ROM (BIOS) program chooses in which order they are checked –It finds the boot device, loads the boot program, and hands control to it On PC’s, ROM loads the master boot program from the master boot record (MBR), at the start of the C: drive 13INFO 320 week 4

14 www.ischool.drexel.edu Master boot programs On a Windows system, the master boot program could be a simple DOS program On Linux systems, lilo or GRUB can be the master boot program –Then based on input from the user, it knows which kernel to boot –GRUB’s configuration file is at /boot/grub/menu.lst 14INFO 320 week 4

15 www.ischool.drexel.edu GRUB If you want to change the GRUB configuration use the tool update-grub instead of editing the config file For more GRUB information install –sudo apt-get install grub-doc Can use the HTML reader w3m –w3m /usr/share/doc/grub-doc/html/grub.html 15INFO 320 week 4

16 www.ischool.drexel.edu Booting The boot program loads the kernel into memory (RAM), and passes control to it –The boot program also checks RAM, looks for key peripherals, might detect new devices The kernel has many names, unix (System V), vmunix (BSD), hp-ux (HP-UX), vmlinux or vmlinuz (Linux) 16INFO 320 week 4

17 www.ischool.drexel.edu Kernel In Linux the kernel is now modular*, to accommodate all the different kinds of file systems, RAID, encryption, etc. possible –The initrd (initialized RAM disk) file is loaded with the kernel –It decompressed initramfs, which is a RAM filesystem for the kernel to use until it mounts the disk-based root filesystem * It was ‘monolithic’- just load everything right away 17INFO 320 week 4

18 www.ischool.drexel.edu Booting Then the kernel has control –It initializes itself, runs hardware diagnostics, installs drivers, might test the CPU –Then the kernel runs the first program, init Init is usually* PID 1, found in /sbin/init It is the parent of all other Unix processes and shells Init controls if the system will be booted into multiuser mode or single user mode * Try ps –ef and see for yourself! 18INFO 320 week 4

19 www.ischool.drexel.edu Multiuser mode The normal boot process goes into multiuser mode –Init verifies the integrity of the filesystems using the fsck utility –Mount local disks –Designate paging areas –Clean up filesystems – check quotas, save recovery files, delete /tmp files 19INFO 320 week 4

20 www.ischool.drexel.edu Multiuser mode –Start server daemons for printing, email, cron jobs, etc. –Start networking daemons, mount remote disks –Enable user logins with agetty process These are accomplished via a lot of services scripts (next section) Now a user can log into the system 20INFO 320 week 4

21 www.ischool.drexel.edu Single user mode Single user mode (also called service mode or maintenance mode) is used for exclusive access to the system –Often for admin or maintenance functions –Could enter it if file system problems occur that fsck can’t fix Init runs a Bourne shell ( /bin/sh ) as root user; often has limited filesystems loaded 21INFO 320 week 4

22 www.ischool.drexel.edu Managing Services 22INFO 320 week 4

23 www.ischool.drexel.edu Services The init daemon manages the startup of services in most traditional System V- based UNIX systems Ubuntu has recently switched to a tool called Upstart for the same purposeUpstart To understand their role, we need to look at run levels 23INFO 320 week 4

24 www.ischool.drexel.edu Run Levels Services are set up in different run levels from 0 to 6 –Runlevel 0 powerdown state, ready to shut off –Runlevel 1 single user mode –Runlevel 2 normal multiuser mode –Runlevels 3 to 5 are other multiuser modes –Runlevel 6 shutdown and reboot state –Runlevel s or S, single user mode 24INFO 320 week 4

25 www.ischool.drexel.edu Run Levels There are other special purpose run levels, such as a, b, c, and q To see your current run level try –who -r The default run level for Ubuntu is 2, per /etc/inittab (not used in Desktop) The telinit utility can be used to change run level interactively 25INFO 320 week 4

26 www.ischool.drexel.edu Run Levels Other key service resources include: –The /etc/init.d directory has startup scripts for every service Most accept start or stop as arguments –Directories /etc/rc0.d through /etc/rc6.d have init scripts for each runlevel These scripts Start, Kill (stop), or Disable (ignore) each service in numeric order 26INFO 320 week 4

27 www.ischool.drexel.edu Run Levels –The directory /etc/rcS.d has startup scripts that are applied before going to a particular run level So a typical startup would run –Init looks to inittab to find the desired run level (let’s say 2) –Then run the S (start) flagged services in /etc/rcS.d –Then run the services in /etc/rc2.d 27INFO 320 week 4

28 www.ischool.drexel.edu Run Levels The init daemon keeps running in case there’s a change in run level Services can be manually started or stopped by commanding their scripts –sudo /etc/init.d/networking start –sudo /etc/init.d/networking stop –Use no argument (e.g. start, stop ) to see the available ones 28INFO 320 week 4

29 www.ischool.drexel.edu xinetd A legacy program for starting and stopping Internet services is xinetd (eXtended InterNET Daemon) –The services it controls are in the directory /etc/xinetd.d –All are disabled by default; enable them by editing their config file, e.g. /etc/xinetd.d/echo –Then reload xinetd to activate them sudo service xinetd reload 29INFO 320 week 4

30 www.ischool.drexel.edu Upstart Upstart was designed to handle interactive running and stopping of services, beyond what the run level concept can do –Init only changes services when you boot, reboot, or change run level –But some services, like networking, could change during a session 30INFO 320 week 4

31 www.ischool.drexel.edu Upstart Upstart is event-driven Actions (such as starting or stopping services) can be taken based on events that occur –Events could include startup, shutdown, changing runlevel, plugging in a network cable, removing a flash drive, etc. 31INFO 320 week 4

32 www.ischool.drexel.edu Upstart Upstart scripts are in /etc/event.d Get a list of all Upstart jobs with –sudo initctl list The default Upstart runlevel is in –/etc/event.d/rc-default –Look for the command telinit 2 –Replaces the inittab file 32INFO 320 week 4

33 www.ischool.drexel.edu Rebooting and shutting down The boot command can be used to manually reboot, or use reboot The –s qualifier can boot into single user mode –boot -s To shut down from a command line use halt or shutdown –The latter has many configuration options 33INFO 320 week 4

34 www.ischool.drexel.edu Users and Groups 34INFO 320 week 4

35 www.ischool.drexel.edu Users Ok, now we have a running system, we need to define users, and assign them to groups In the Desktop GNOME interface, users and groups are managed from –System > Administration > Users and Groups 35INFO 320 week 4

36 www.ischool.drexel.edu Users From the command line add a user withadd a user –sudo adduser To set or reset a password use –sudo passwd Remove a user with deluserRemove a user –sudo deluser –It can also remove their files and home directory, or remove them from a group 36INFO 320 week 4

37 www.ischool.drexel.edu Groups The addgroup command creates a new group –sudo addgroup Conversely, delgroup removes a group –sudo delgroup –The group must have no users for whom it is their primary group 37INFO 320 week 4

38 www.ischool.drexel.edu Other stray commands The who command tells who is logged into the system For keyword-based help, use –man –k keyword Or –apropos keyword If you can’t find a command, use whereis –whereis commandname 38INFO 320 week 4

39 www.ischool.drexel.edu Permissions 39INFO 320 week 4

40 www.ischool.drexel.edu Permissions Permissions apply to files, directories, and links Their basis is the right to read, write, and execute –Read is only that –Write includes create, modify or delete –Execute is in the sense of running a script or application 40INFO 320 week 4

41 www.ischool.drexel.edu Permissions In a full listing ( ls –l ) the permissions for each entry are shown In order, they pertain to the User, their Group members, and Other (anyone else) For each of those categories, read (r), write (w) and execute (x) –So what does rwxr-xr-- mean? –What’s wrong with r-xrwxrwx ? 41INFO 320 week 4

42 www.ischool.drexel.edu Changing permissions The read, write, and execute can be given numeric values of 4, 2, and 1 respectively and are added for each type of user –So the example rwxr-xr-- becomes what numbers? To change permissions, chmod is used chmod –The value of permissions can be done numerically (like above) or with code letters 42INFO 320 week 4

43 www.ischool.drexel.edu Changing permissions The numeric format might look like –chmod 751 filename Whereas the text format might say –chmod u+rw filename –Meaning the user (u) adds (+) read and write (rw) permissions to filename –Before the operator, u g o a mean user, group, other, or all users A plus operator adds permissions, - removes them 43INFO 320 week 4

44 www.ischool.drexel.edu Files and ownership Files have group membership –By default it’s the group of their creator –chgrp can be used to modify the group associated with them Also chown can change the owner and/or group membership of a file chown –chown glenn:prof filename –Assigns owner=glenn and group=prof to filename 44INFO 320 week 4

45 www.ischool.drexel.edu Terms CMOS = complementary metal oxide semiconductor GRUB = GNU GRand Unified Bootloader lilo = Linux Loader MBR = master boot record, sector 0 on C: drive Nvram = non-volatile random access memory RAM = random access memory ROM = read only memory ROS = read only storage xinetd = eXtended InterNET Daemon 45INFO 320 week 4

46 www.ischool.drexel.edu References The Official Ubuntu Book, by Benjamin Mako Hill et al, Prentice Hall 2007. ISBN 0132354136 Index of Ubuntu community HowTo pages https://help.ubuntu.com/community/TitleIn dex https://help.ubuntu.com/community/TitleIn dex 46INFO 320 week 4


Download ppt "Www.ischool.drexel.edu INFO 320 Server Technology I Week 4 Basic Unix commands 1INFO 320 week 4."

Similar presentations


Ads by Google