1/65
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No study sessions yet.
When matching filenames in the shell, the ____________________ symbol will match any single character.
?
When matching filenames using regular expressions, the ____________________ symbol will match any single character.
.
In shell, executables can be called without supplying an absolute path or a relative path because of the _____________ environment variable.
$PATH
What is stored in the $HOME environment variable
the path to the user's home dir
how do I cd into the home directory?
cd ~
How do I cd into the root directory?
cd /
The environment variable _________________ stores the exit status of the most recently run executable.
$?
What environment variable do I use to get the PID of a shell program?
$$
What environment variable do I use to get the number of variables of a shell program?
$#
Which type of quoting suppresses expansion of variables?
single quotes
What type of quotes are used for command substitution?
back ticks ``
/usr/bin is a directory on our systems that contain ____________
are available to a normal user
What will this command do to the permissions of an executable +rx?
adds read and execute permissions to all user groups
What are the different user groups for a program?
owner, group, others
What will this command do to the permissions of an executable 777?
adds read, write and execute permissions to all user groups
What mode will set permissions for the owner and group to just read and execute, and restrict others to just read?
554
In a shell script, the ________________ line specifies the executable that should interpret the script.
Shabang, #!
What is the environment variable for the name of a bash script?
$0
What is the meaning of true in bash?
0
The _____ is a special directory used to resolve relative paths to the current working directory, while _____ is a special directory used to resolve relative paths to the previous directory.
./ and ../
Write a shell expansion that matches all files in the local directory that begin with "cs".
cd*
Write a shell expansion that matches all files that are located in smithb's home directory ending in ".sh".
~/smithb/*.sh
Write a regular expression that matches lines containing "catinthehat.txt".
catinthehat\.txt
Write a shell expansion that matches all files that are named "file" followed by any single character followed by ".txt".
file?.txt
Write a regular expression that matches lines that start with "proj4" and end with ".c".
^proj4.*\.c$
Write a shell expansion that matches all files ending in ".thm".
*.thm
The Linux ps command give you information about ______________________________.
currently running processes
In shell, the special character _________________ can be used to redirect standard output from the command that precedes it to standard input of the command that follows it.
|, pipe
In shell, special characters like < and > can be used to ________________________ standard input and output streams.
redirect
What key combination will save a copy of the current file without exiting while in control mode?
w
What key combination will delete the current line while in control mode?
dd
What are the shell commands to get the current date, current working directory and the user ID?
date
pwd
id -u
what is the function to open a file for system calls?
int fd = open(path, O_RDONLY);
What is the function to read from a file using system calls?
ssize_t read(int fd, void *buf, size_t count);
What is the function to write to a file using system calls?
ssize_t write(int fd, const void *buf, size_t count);
What is the function to open a file using stdio?
FILE fopen(const char path, const char *mode);
What is the read mode for opening a file using stdio?
"r"
What is the function to close a file using stdio?
fclose
What function should I use if I want to get to a certain spot in a file and start reading/writing to there? (head, tail)
fseek
What function should I use if I want to interpret flags from running a program?
getopt
How do I specify that there is an argument with the flag with getopt?
Put a colon before the flag, for example :x means that there is an argument after the flag. Use optarg to get the argument
What is the function to get the exit status of a child?
WEXITSTATUS
What is the function to check if a child process is finished given the PID?
waitpid(pid, status, 0);
WIFEXITED(&status)
What is the function to create a thread?
int pthread_create(pthread_t , const pthread_abr_t , void ()(void ), void );
What is the function to initialize a semaphore?
sem_init(&semaphore)
what does semwait do?
it will check if semaphore is unlocked...if not it will wait until it is opened (lock)
what does sem_post do?
it increments the value in the semaphore struct...basically showing that its done with executing (open)
Threads have a ______ memory/system model?
shared
What is a race condition?
A race condition is when multiple threads access a shared resource and one of them increments it but the other thread doesn't realize
What number is the write side of a pipe?
fd[1]
What number is the read side of a pipe?
fd[0]
sh shell name?
Bourne Shell
csh
C shell
What is a directory I could write output to and not care?
/dev/null
Use $(( )) for simple arithmetic and let for unary operations. (T/F)
true
Zombie process
A child process that is waiting to return its exit status to its parent (defunct)
Developers of UNIX
Denis Ritchie, Ken Thompson, Brian Kernighan
Regex that matches any 5 letter sequence that repeats at least once
grep -E "([a-zA-Z]{5}).*\1" file_name
Vim move cursor to beginning of file
gg
Vim: get editor to move cursor to end of current line
$
Vim: undo last change to file
u
Developer of Linux
Linus Torvalds
Anchor to beginning for regex
^
Anchor to end for regex
$
What is the syntax for a makefile recipe?
MUST have a tab
____ is a system call that can be used to determine if a string corresponds to a file or a directory.
stat