1
Introducción al Sistema Operativo LINUX
Pedro Corcuera
- Dpto. Matemática Aplicada y
Ciencias de la Computación Universidad de Cantabria
corcuerp@unican.es
Introduccin al Sistema Operativo LINUX Pedro Corcuera Dpto. - - PowerPoint PPT Presentation
Introduccin al Sistema Operativo LINUX Pedro Corcuera Dpto. Matemtica Aplicada y Ciencias de la Computacin Universidad de Cantabria corcuerp@unican.es 1 ndice General Introduccin Estructura e instalacin Interfaz
1
Ciencias de la Computación Universidad de Cantabria
corcuerp@unican.es
Linux
2
Linux
3
Linux
4
Linux
5
Linux
6
Linux
7
Linux
8
Linux
9
Linux
10
Linux
11
Linux
12
Linux
13
Linux
14
Linux
15
Linux
16
Linux
17
Linux
18
Linux
19
Windows Linux Partition Disk1 /dev/sda1 Filesystem type NTFS/FAT32 EXT3/EXT4/XFS... Mounting Parameters DriveLetter MountPoint Base Folder where OS is stored C drive /
Linux
20
Linux
21
Linux
22
Linux
23
Linux
24
Linux
25
Linux
26
Linux
27
Linux
28
Linux
29
Linux
30
Linux
31
Linux
32
Linux
33
Linux
34
Linux
35
Linux
36
Linux
37
Linux
38
Linux
39
Command Usage cat Used for viewing files that are not very long; it does not provide any scroll- back. tac Used to look at a file backwards, starting with the last line. less Used to view larger files because it is a paging program; it pauses at each screenful of text, provides scroll-back capabilities, and lets you search and navigate within the file. Note: Use / to search for a pattern in the forward direction and ? for a pattern in the backward direction. tail Used to print the last 10 lines of a file by default. You can change the number
instead of the default. head The opposite of tail; by default it prints the first 10 lines of a file.
Linux
40
Linux
41
Linux
42
Linux
43
Linux
44
Linux
45
Command Usage gzip The most frequently used Linux compression utility bzip2 Produces files significantly smaller than those produced by gzip xz The most space efficient compression utility used in Linux zip Is often required to examine and decompress archives from
Linux
46
Command Usage $ tar xvf mydir.tar Extract all the files in mydir.tar into the mydir directory $ tar zcvf mydir.tar.gz mydir Create the archive and compress with gzip $ tar jcvf mydir.tar.bz2 mydir Create the archive and compress with bz2 $ tar Jcvf mydir.tar.xz mydir Create the archive and compress with xz $ tar xvf mydir.tar.gz Extract all the files in mydir.tar.gz into the mydir directory. Note you do not have to tell tar it is in gzip format.
Linux
47
Linux
48
Linux
49
Linux
50
Linux
51
Linux
52
Linux
53
Linux
54
Command Usage chown Used to change user ownership of a file or directory chgrp Used to change group ownership chmod Used to change the permissions on the file which can be done separately for owner, group and the rest of the world (often named as
Linux
55
Linux
56
Linux
57
Linux
58
Linux
59
Linux
60
Linux
61
Linux
62
Linux
63
Linux
64
Linux
65
Linux
66
Linux
67
In this example, the system is able to locate the file /etc/passwd and returns a value of 0 to indicate success; the return value is always stored in the $? environment variable.
Linux
68
Character Description # Used to add a comment, except when used as \#, or as #! when starting a script. \ Used at the end of a line to indicate continuation on to the next line ; Used to interpret what follows as a new command $ Indicates what follows is a variable
Linux
69
Linux
70
Linux
71
Linux
72
Linux
73
Linux
74
Linux
75
The output of the command "uname –r" becomes the argument for the cd command.
Linux
76
Linux
77
Linux
78
Linux
79
Linux
80
Linux
81
Linux
82
Linux
83
Linux
84
if TEST-COMMANDS; then CONSEQUENT-COMMANDS; fi
if condition then statements else statements fi
Linux
85
Linux
86
Condition Meaning
Check if the file exists.
Check if the file is a directory.
Check if the file is a regular file (i.e., not a symbolic link, device node, directory, etc.)
Check if the file is of non-zero size.
Check if the file has sgid set.
Check if the file has suid set.
Check if the file is readable.
Check if the file is writable.
Check if the file is executable.
Linux
87
Linux
88
Linux
89
Linux
90
Linux
91
Operator Operation Meaning && AND The action will be performed only if both the conditions evaluate to true. || OR The action will be performed if any one of the conditions evaluate to true. ! NOT The action will be performed only if the condition evaluates to false.
Linux
92
Linux
93
Linux
94
case expression in pattern1) execute commands;; pattern2) execute commands;; pattern3) execute commands;; pattern4) execute commands;; *) execute some default commands \
esac
Linux
95
#!/bin/bash # prompt user to enter a character read charac case "$charac" in "a"|"A") echo "You have typed a vowel!";; "a"|"A") echo "You have typed a vowel!";; "a"|"A") echo "You have typed a vowel!";; "a"|"A") echo "You have typed a vowel!";; "a"|"A") echo "You have typed a vowel!";; *) "You have typed a consonant";; esac exit 0
Linux
96
Linux
97
Linux
98
Linux
99
Linux
100
File stream Description File Descriptor stdin Standard Input, by default the keyboard/terminal for programs run from the command line stdout Standard output, by default the screen for programs run from the command line 1 stderr Standard error, where output error messages are shown or saved 2
Linux
101
Linux
102
Linux
103
Linux
104
Linux
105
Linux
106
Linux
107
Linux
108
Process Type Description Example Interactive Processes Need to be started by a user, either at a command line or through a graphical interface such as an icon or a menu selection. bash, firefox, top Batch Processes Automatic processes which are scheduled from and then disconnected from the terminal. These tasks are queued and work on a FIFO (First In, First Out) basis. updatedb Daemons Server processes that run continuously. Many are launched during system startup and then wait for a user or system request indicating that their service is required. httpd, xinetd, sshd Threads Lightweight processes. These are tasks that run under the umbrella
scheduled and run by the system on an individual basis. An individual thread can end without terminating the whole process and a process can create new threads at any time. Many non-trivial programs are multi-threaded. gnome-terminal, firefox Kernel Threads Kernel tasks that users neither start nor terminate and have little control over. These may perform actions like moving a thread from
are completed. kswapd0, migration, ksoftirqd
Linux
109
Linux
110
Linux
111
all: hello.exe hello.exe: hello.o g++ -o hello.exe hello.o hello.o: hello.cpp g++ -c hello.cpp clean: rm hello.o hello.exe
$ make
Linux
112
Linux
113