Unix System Overview Flashcards

1
Q

what is an operating system?

A

the software that controls the hardware resourses of the computer. and provides an environment under which programs can run. (generally called the kernel).
In broad sense, an operating system is the kernel and all the other software that makes a computer useful.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the interface to the kernel?

A

It is a layer of software called the Systems calls.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Libraries used for in this?

A

contains common functions which are built on top of the system call interface.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the shell?

A

it is a special application that provides an interface for running other applications.
is a command line interperater that reads user input and executes commands

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does “other software “ refer to when talking operating systems?

A

software includes: system utilities, applications , shells, libraries of common functions, ect.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

give an example of an operating system that uses Linux

A

GNU/Linux operating system (commonly referenced as Linux).

Linux is the kernel used by the GNU operating system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What would you find if you look at our entry in the password file?

A
login name
encrypted password,
numeric user ID (205)
numeric group ID (105)
a comment field
home directory
shell program
(*note: newer systems have moved encrypted password to a Different file.)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is an interactive shell?

A

the user input to a shell is normally from the terminal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a shell script?

A

A file from which commands will be entered in to run.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the only 2 chars that cannont appear in a filename?

A

slash character (/) and the null character

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

how many filenames are automatically created whenever a new directory is created?

A

Two.
current directory
and the parent directory.
(fun fact: in the root directory the dot-dot is the same as dot)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

describe C preprocessor

A

Macro processor automatically used by C compiler to transform ur program before compilation. (ablility for inclusion of header files, macro expansions, and line conditional compilation, system files )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

describe modifier “const”

A

can make types or pointers read only/ cant change without casting (const) away.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

difference between const and static

A

static variable can be change anywhere within its scope. but can only be used within what the function it is in.
so if you call a static global variable then can be used anywhere in that file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

describe pointer

A

a datatype in C and is an address of some place in memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

list 4 things pointers can point to in C

A

global variables
local variables
functions
dynamically allocated memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

describe what this means:

pointers and arrays are same concept in C

A

arrays use pointer
but not all pointers are arrays
*note: int *dp
dp[cnt] == *(dp+cnt)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

where does your file system start?

A

everything starts in root directory whose name is the single char /.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

what does function stat and fstat return?

A

it returns a structure of information containing all the attributes of a file. such as type of file, directory size of file, owner of file, permissions for file, last modified

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

what are names in a directory called?

A

filenames

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

what is it called when a pathname begins with a slash?

A

absolute pathname

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

what is it called when a pathname does not begin with a slash?

A

relative pathname

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

what does relative pathname refer to?

A

refers to files relative to the current directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

what command is used to compile a c file into an exicutable

A

cc programName.c

gcc for GNU C complilation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
what is working directory
the directory from which all relative pathnames are interpreted.
26
how can a process change its working directory
by using the chdir fucntion
27
describe what this pathname tells | /usr/lib/lint
is an absolute pathname that refers to the file or directory lint in the directory lib, in the Root directory usr
28
what is our working directory when we log in?
it is set to our home directory.
29
where is our home directory obtained?
it is obtained from our entry in the password file
30
describe file descriptors
small positive nums that kernel uses to identify the files being accessed by a particular process.. all open files are referred to by file descriptors
31
what 3 descriptors does shell open whenever a new program is run?
standard input 0 (buffered), standard output 1 (buffered), standard error 2 (unbuffered)
32
unbuffered I/O is provided by functions...
open, read, write, lseek, and close. these functions all work with file descriptors
33
describe a program
is an executable file residing on disk in a directory. program is read into memory and is executed by kernel as a result of 1 of 6 exec functions.
34
describe process
an executing instance of a program. every process is given a unique process ID always positive number
35
what is getpid()
function that returns the process ID
36
describe ps command
it is process status command and provides info about current running process (PID, TIME, TTY, CMD)
37
describe fork()
creates a new process. parent and newly created process child. returns 0 for child. and returns the PID of the child process to the fork() of parent.
38
describe execlp()
called by child process to execute comand read from standard input. this replaces the child process with the new program file.
39
what does "spawning a new process" mean
when fork used followed by exec.
40
describe getuid()
returns user id (numeric value that identifies us to the system. assigned by the system adminastrator when our login name is assigned)of calling process
41
describe getgid()
returns the group id of the calling process
42
describe getpid()
returns the process ID of the calling process
43
what is system calls?
request to os, typically a trap instruction, often an assembly wrapper, return values (return info about system call) or error number
44
char *strerror(int errnum)
returns pointer to message string
45
void perror(const char *msg)
produces an error message on the standard error based on value of errno.
46
describe signals
a technique used to notify process that some condition has occurred. 3 typical choices when dealing with signals. ignore signal, defualt action occur, and catching
47
chmod()
changes file mode bits
48
describe system call
function that invokes appropriate kernal service
49
what is difference between system calls and library functions
we can replace library functions (user process), if desired where as the system calls (kernel) usaully cant be replaced
50
describe open()
``` a file is opened or created by calling this function. 3 flags: read only (0) O_RDONLY write only (1) O_WRONLY read and right (2) O_RDWR ```
51
describe creat()
new file can also be created by creat() function | returns file descriptor opened for write-only of OK, error -1.
52
describe int close(int fd)
an open file is closed by calling this function. returns 0 if OK returns -1 if error when process terminates all open files are closed automatically by kernel
53
describe lseek(int fd, off_t offset, int whence)
an open files offset can be set explicitly by calling lseek returns new location of file pointer. whence: SEEK_SET - offset bytes from start of file SEEK_CUR - offset bytes from current location SEEK_END - offset bytes from end of the file
54
read(int fd, void *buf, size_t nbytes)
returns num of bytes read, 0 if end of file, -1 for error Data is read from open file with this function starts at files current offset and incremented by num of offset read
55
write(int fd, const void *buf, size_t nbytes)
returns num of bytes written if ok, -1 for error data is written to an open file with the write function starts at files current offset increments by num of bytes actually written
56
dup(int fd) | dup2(int fd, int fd2)
ducliates an existing file descriptor
57
int fnctl(int fd, int cmd)
manipulates fd, can change properties of a file that is already open.
58
int ioctl(int d, request, *argptr)
manipulates underlying device parameters, catchall fro i/o operations. used when anything cant be expressed using one of the other functions we know of.
59
name 7 file types
``` regular file directory file character special file block special file symbolic link fifo socket (network) ```
60
disk
| partition 1 | partition 2 | ..... |
61
single partition
| file system 1 | file system 2 | file system | ... |
62
single file system
| boot | super | inodes | data blocks |
63
describe boot
bootstrap program
64
describe super
contains info about partition
65
describe inodes
one per real file
66
data blocks
both files and directories
67
file system blocks
usually power of 2
68
directory:
| name, inode # | name, inode # | ... | each entry in directory is a link inode contains num of links file (inode and data) in not deleted until like count is 0
69
describe inode
``` owner, group, permissions file type num of links size, num of blocks times (accessed modified status_change) ```
70
describe access to data blocks
``` n data block pointer (disk address) - inode -> data block 1 - indirect block - inode -> pointer block -> data block 1 - 3 level indirect block - inode -> ptr block -> ptr block -> ptr block -> data block ```
71
int stat(const char *path, struct stat *sb)
return inf about files no premissions required. | reterive info about file pointed to by pathname
72
int lstat(const char *path, struct stat *sb)
return inf about files no premissions required. reterive info about file pointed to by pathname except if pathname is a symbolic linke then return info about link itself, not the file that it refers to
73
int fstat(int fd, struct stat *sb)
return inf about files no premissions required. reterive info about file pointed to by pathname except file is specified by file descriptor
74
int access(const char *path, int mode)
checks whether colling process can access the file pathname.
75
int chmod(const char *path, mode_t mode)
system calls change the permissions of a file specified whose pathname is given in pathname
76
int chown(const char *pathname, uid_t owner, gid_t group);
changes the ownership of the file specified by pathname
77
int truncate(const char *path, off_t length);
functions cause the regular file named by path to be truncated to a size of precisely length bytes
78
int link(const char *oldpath, const char *newpath);
creates a new link to an existing file, works only on files in the same file system. need write permissions
79
if sicky bit is off or on how does affect unlink()
if off you dont have to own file to unlink if on then must own file either way must have execute permission
80
``` symbolic links int symlink(const char *target, const char *linkpath); ```
not a hard link unlink removes only stored name creates a symbolic linke "linkpath" which contains the string target.
81
describe macro
fragment of code which is given a name.
82
what is the man pages?
man is the system's manual pager. the section no. are as follow: 1: executable programs or shell commands 2: system calls (functions provided by kernels) 3: Library calls (functions within program libraries) 4: Special files (usually found in /dev) 5: File formats and conventions 7: miscellaneous (including macro packages) 8: system administration commands (usually only for root) 9: Kernel routines
83
formats: %[flags][fieldwidth][.precision][modifier]conv | what kind of flags can be added in outputted formats?
``` flags: - Left justify + Always sign the number 0 zero padded (space) blank space for + ```
84
what does printf() return?
it tells you how many characters were printed