Download presentation
Presentation is loading. Please wait.
Published byCaitlin Sutton Modified over 9 years ago
1
Fall 2011 Nassau Community College ITE153 – Operating Systems 1 Session 4 More Hands-on Commands
2
Files and Directories Unit Objectives: By the end of this unit, you will be able to: Describe the format for filenames Use commands to: determine and display file contents copy and move files link files remove files Make, copy and remove directories Use wildcards Fall 2011 Nassau Community College ITE153 – Operating Systems 2
3
Filenames There is no specified format for filenames in UNIX Filenames (including directory names) can consist of: Up to 255 characters Any character except: & ; | * ? ‘ “ ` [ ] { } ( ) $ ^ # / \ Examples: myfiles UNIX4.you You+Me Dir2 hare_2_day Fall 2011 Nassau Community College ITE153 – Operating Systems 3
4
Basic File Commands
5
The file Command Reports the type of file. Some classifications include: Plain text commands, text directory executable data commands, text ASCII text empty c programtext Format: file filename(s) $ file myfiles myfiles: Directory $ file /dev/tty10 /dev/tty10: character special Fall 2011 Nassau Community College ITE153 – Operating Systems 5
6
Displaying File Contents The cat, pg, and more commands display the contents of a file. $ cat filename(s) Displays the named files Does not page! $ pg filename(s) $ more filename(s) Displays the named files one screen at a time Fall 2011 Nassau Community College ITE153 – Operating Systems 6
7
head and tail head -n filename Displays the first ten lines of a file (with no option) Using -n, you can specify the number of lines $ head -25 fileA tail -n -r filename Displays the last ten lines of a file (with no options) Using -n, you can specify the number of lines Using -r, you can display the lines in reverse order $ tail -15 -r fileA Fall 2011 Nassau Community College ITE153 – Operating Systems 7
8
Copying Files Copy a specified file and creates a new file. cp f1 f2 (f1 is an existing file) Copy a list of files to a specified directory. cp f1 f2 f3 DIR1 (f1, f2, & f3 are existing files) Fall 2011 Nassau Community College ITE153 – Operating Systems 8
9
Moving Files Move (rename) a specified file in the current directory. mv f1 f2 (f1 is an existing file) Moves a list of files to a specified directory. mv f1 f2 f3 DIR1 (f1, f2, & f3 are existing files) Fall 2011 9 Nassau Community College ITE153 – Operating Systems
10
Linking Files Link two files ln f1 f2 (f1 is an existing file) Examples: $ ln fileC XXX $ ln fileB myfiles/archive Fall 2011 Nassau Community College ITE153 – Operating Systems 10
11
Removing Files Remove one or more files rm f1 rm f1 f2 f3 f4 Examples: $ rm fileC fileB $ rm myfiles/fileB myfiles/fileC Be very careful! rm –i (interactive) rm –r (recursive) Fall 2011 Nassau Community College ITE153 – Operating Systems 11
12
Making & Removing Directories Make one or more directories mkdir Dir1 mkdir Dir2 Dir3 Dir4 Remove one or more directories rmdir Dir1 rmdir Dir2 Dir3 Dir4 Fall 2011 Nassau Community College ITE153 – Operating Systems 12
13
Copying Directories Copy a directory and its subdirectories to a new location in the filesystem cp -r Dir1 Dir2 (Dir1 and Dir2 are existing directories) Fall 2011 Nassau Community College ITE153 – Operating Systems 13
14
Using Wildcards Wildcards are used for filename generation Used to make shorthand references to files and directories. Interpreted by the shell Also called metacharacters Fall 2011 Nassau Community College ITE153 – Operating Systems 14
15
Exercises Fall 2011 Nassau Community College ITE153 – Operating Systems 15
16
Session 3 Fall 2011 Nassau Community College ITE153 – Operating Systems 16 Memory Management
17
(a) A part of memory with five processes and three holes. The tick marks show the memory allocation units. The shaded regions (0 in the bitmap) are free. (b) The corresponding bitmap. (c) The same information as a list. Memory Management with Bitmaps Fall 2011 Nassau Community College ITE153 – Operating Systems 17
18
Memory allocation changes as processes come into memory and leave it. The shaded regions are unused memory. Swapping (1) Fall 2011 Nassau Community College ITE153 – Operating Systems 18
19
The position and function of the MMU – shown as being a part of the CPU chip (it commonly is nowadays). Logically it could be a separate chip, was in years gone by. Virtual Memory – Paging (1) Fall 2011 Nassau Community College ITE153 – Operating Systems 19
20
Relation between virtual addresses and physical memory addresses given by page table. Paging (2) Fall 2011 Nassau Community College ITE153 – Operating Systems 20
21
Page fault handling with an external pager. Separation of Policy and Mechanism (2) Fall 2011 Nassau Community College ITE153 – Operating Systems 21
22
Protection on the Pentium. Segmentation with Paging: The Pentium (5) Fall 2011 Nassau Community College ITE153 – Operating Systems 22
23
Try to get into Task Manager Fall 2011 Nassau Community College ITE153 – Operating Systems 23
24
Session 4 Fall 2011 Nassau Community College ITE153 – Operating Systems 24 Memory Management Commands
25
Information About CPU & Memory On Linux there are two handy commands: Information about CPU cat /proc/cpuinfo Information about Memory cat /proc/meminfo You can also use the command: free or free -m or free –g Also try (usually for FreeBSD): sysctl -a | less or dmesg | grep -i CPU Fall 2011 Nassau Community College ITE153 – Operating Systems 25
26
Find Out About My System Information about the system uname –a gives something like this: Linux papacosta 2.6.38-11-generic-pae #48-Ubuntu SMP Fri Jul 29 20:51:21 UTC 2011 i686 i686 i386 GNU/Linux Here are some parameters: uname –r kernel release uname –p processor name uname –i hardware platform uname –o operating system Fall 2011 Nassau Community College ITE153 – Operating Systems 26
27
Hands-on Fall 2011 Nassau Community College ITE153 – Operating Systems 27
28
top command The top program provides a dynamic real-time view of a running system i.e. actual process activity. By default, it displays the most CPU-intensive tasks running on the server and updates the list every five seconds. Fall 2011 Nassau Community College ITE153 – Operating Systems 28 Tasks: 226 total, 1 running, 222 sleeping, 0 stopped, 3 zombie Cpu(s): 4.0%us, 4.3%sy, 0.3%ni, 91.4%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 4119148k total, 3982628k used, 136520k free, 27036k buffers Swap: 9823712k total, 354952k used, 9468760k free, 280452k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 5703 papacost 20 0 2358m 2.1g 2.0g S 14 52.4 621:52.12 VirtualBox 25677 papacost 20 0 567m 74m 16m S 4 1.8 13:25.37 banshee 2126 papacost 20 0 534m 87m 16m S 4 2.2 103:50.75 compiz 1194 root 20 0 106m 56m 8488 S 3 1.4 178:01.98 Xorg 3947 papacost 20 0 457m 59m 12m S 2 1.5 174:09.74 chromium-browse 2125 papacost 9 -11 224m 10m 8964 S 2 0.3 53:17.21 pulseaudio 2143 papacost 20 0 536m 54m 9272 S 1 1.4 5:00.63 nautilus 2392 papacost 20 0 305m 59m 5228 S 1 1.5 3:29.50 unity-panel-ser 3828 papacost 20 0 173m 58m 17m S 1 1.5 1:28.35 chromium-browse 26318 papacost 20 0 209m 11m 8172 S 1 0.3 0:06.14 gnome-terminal
29
w - Find Out Who Is Logged on And What They Are Doing w command displays information about the users currently on the machine, and their processes. w 15:01:31 up 5 days, 5:21, 3 users, load average: 0.08, 0.12, 0.13 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT papacost tty7 :0 Fri09 5days 2:58m 1.24s gnome-session - papacost pts/0 :0 Tue20 23:09 0.47s 0.47s bash papacost pts/1 :0 14:26 0.00s 0.33s 6.33s gnome-terminal Fall 2011 Nassau Community College ITE153 – Operating Systems 29
30
uptime - Tell How Long The System Has Been Running The uptime command can be used to see how long the server has been running. The current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes. uptime yields: 15:05:39 up 5 days, 5:25, 3 users, load average: 0.12, 0.11, 0.13 Fall 2011 Nassau Community College ITE153 – Operating Systems 30
31
vmstat - System Activity, Hardware and System Information The command vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity. vmstat procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 0 0 354300 139928 28592 261692 0 0 16 13 20 8 3 3 92 1 Fall 2011 Nassau Community College ITE153 – Operating Systems 31
32
Hands-on Fall 2011 Nassau Community College ITE153 – Operating Systems 32
33
Important URLs 20 Linux System Monitoring Tools Every SysAdmin Should Know Handy monitoring commands 20 Linux System Monitoring Tools Every SysAdmin Should Know Linux command to gathers up information about a Linux system Some basic commands Linux command to gathers up information about a Linux system Graphical Monitoring Under Ubuntu Contrast this to the tolls under Windows Graphical Monitoring Under Ubuntu Fall 2011 Nassau Community College ITE153 – Operating Systems 33
34
Homework Review the Slides Keep Practicing Commands Try to get into Task Manager on Windows Compare to what you have learned on Linux Fall 2011 Nassau Community College ITE153 – Operating Systems 34
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.