diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ca1ea57..314b308 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,9 +12,12 @@ Stick to the following format: * If you added several questions and you would like to know how many questions are there you can use the script "count_questions.sh" in scripts directory. - ## What to avoid * Avoid adding installation questions. Those are the worst type of questions... * Don't copy questions and answers from other sources. They probably worked hard for adding them. * If you add new images, make sure they are free and can be used. + +## Before submitting the pull request + +You can test your changes locally with the script `run_ci.sh` in scripts directory. diff --git a/README.md b/README.md index b632c35..c17bbb7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ :information_source:  This repository contains questions on various DevOps and SRE related topics -:bar_chart:  There are currently **714** questions +:bar_chart:  There are currently **720** questions :books:  To learn more about DevOps check the resources in [DevOpsBit.com](https://devopsbit.com) @@ -1678,7 +1678,7 @@ Re-install the OS IS NOT the right answer :) What is sudo? How do you set it up?
-#### Random and Strange :) +#### Random and perhaps useless :)
Give 5 commands which are two letters long
@@ -1686,6 +1686,12 @@ Re-install the OS IS NOT the right answer :) ls, wc, dd, df, du, ps, ip, cp, cd ...
+
+What a double dash (--) mean?
+ +It's used in commands to mark the end of commands options. One common example is when used with git to discard local changes: `git checkout -- some_file` +
+ #### Commands
@@ -1699,10 +1705,45 @@ ls, wc, dd, df, du, ps, ip, cp, cd ... #### :star: Advanced +#### System Calls + +
+Explain the fork system call
+ +fork() is used for creating a new process. It does so by cloning the calling process but the child process has its own PID and any memory locks, I/O operations and semaphores are not inherited. +
+ +
+Explain the exec system call
+
+ +
+What are the differences between exec() and fork()?
+
+ +
+Why do we need the wait system call?
+ +wait() is used by a parent process to wait for the child process to finish execution. +If wait is not used by a parent process then a child process might become a zombie process. +
+
What happens when you execute ls?. Provide a detailed answer
+#### Linux Filesystem & Files + +
+How to create a file of a certain size?
+ +There are a couple of ways to do that: + + * dd if=/dev/urandom of=new_file.txt bs=2MB count=1 + * truncate -s 2M new_file.txt + * fallocate -l 2097152 new_file.txt +
+
Can you describe how processes are being created?
@@ -1759,37 +1800,6 @@ Another common way to task this questions is "what part of the tcp header does t What are cgroups?
-
-How to create a file of a certain size?
- -There are a couple of ways to do that: - - * dd if=/dev/urandom of=new_file.txt bs=2MB count=1 - * truncate -s 2M new_file.txt - * fallocate -l 2097152 new_file.txt -
- -
-Explain the fork system call
- -fork() is used for creating a new process. -
- -
-Explain the fork system call
-
- -
-What are the differences between exec() and fork()?
-
- -
-Why do we need the wait system call?
- -wait() is used by a parent process to wait for the child process to finish execution. -If wait is not used by a parent process then a child process might become a zombie process. -
-
Explain Process Descriptor and Task Structure
@@ -1825,14 +1835,7 @@ There are many ways to answer that. For those who look for simplicity, the book "responsible for making it easy to run programs (even allowing you to seemingly run many at the same time), allowing programs to share memory, enabling programs to interact with devices, and other fun stuff like that" -
-If you had to design an API for processes in an operating system, what would this API look like?
- -* Create - allow to create new processes -* Delete - allow to remove/destroy processes -* State - allow to check the state of the process, whether it's running, stopped, waiting, etc. -* Stop - allow to stop a running process -
+#### Processes
Can you explain what is a process?
@@ -1840,6 +1843,17 @@ There are many ways to answer that. For those who look for simplicity, the book A process is a running program. A program is one or more instructions and the program (or process) is executed by the operating system.
+
+If you had to design an API for processes in an operating system, what would this API look like?
+ +It would support the following: + +* Create - allow to create new processes +* Delete - allow to remove/destroy processes +* State - allow to check the state of the process, whether it's running, stopped, waiting, etc. +* Stop - allow to stop a running process +
+
How a process is created?
@@ -1867,6 +1881,12 @@ False. It was true in the past but today's operating systems perform lazy loadin * Blocked - it's waiting for some operation to complete. For example I/O disk request
+#### Concurrency + +
+Explain what is Semaphore and what its role in operating systems
+
+ ## Virtualization @@ -2629,7 +2649,6 @@ def find_triplets_sum_to_zero(li): 7. In python **Everything** is an object. There are many other characteristics but these are the main ones that every python programmer should know. - ``` @@ -2650,13 +2669,13 @@ The immutable data types are: Tuple Frozenset -You can usually use the function hash() to check an object mutability, if it is hashable it is immutable, although this does not always work as intended as user defined objects might be mutable and hashable +You can usually use the function hash() to check an object mutability. If an object is hashable, it is immutable (although this does not always work as intended as user defined objects might be mutable and hashable).
In Python, functions are first-class objects. What does it mean?
-In general, first class objects in programming languages are objects which can assigned to variable, used as a return value and can be used as arguments or parameters.
+In general, first class objects in programming languages are objects which can be assigned to variable, used as a return value and can be used as arguments or parameters.
In python you can treat functions this way. Let's say we have the following function ``` @@ -2667,6 +2686,10 @@ def my_function(): You can then assign a function to a variables like this `x = my_function` or you can return functions as return values like this `return my_function`
+
+Explain expressions and statements
+
+
What is PEP8? Give an example of 3 style guidelines
@@ -2822,25 +2845,19 @@ Generally, every compiling process have a two steps.
-What // is used for?
+Explain Exception Handling and how to use it in Python
-Write a program which will revert a string (e.g. pizza -> azzip)
+Explain what is GIL
+
-``` -Shortest way is str[::-1] but not the most efficient. +
+What is Lambda? How is it used?
+
-"Classic" way: - -foo = '' - -for char in 'pizza': - foo = char + foo - ->> 'azzip' - -``` +
+What // is used for?
@@ -2957,7 +2974,7 @@ def is_unique4(l:list) -> bool: [Solution](coding/python/binary_search.py)
-##### Files +#### Files
How to write to a file?
@@ -2976,6 +2993,10 @@ with open('file.txt', 'w') as file: Sum all the integers in a given file
+
+Can you write a function which will print all the file in a given directory? including sub-directories
+
+ #### Regex
@@ -3002,10 +3023,6 @@ sorted(x, key=lambda l: l[1]) ```
-
-Can you write a function which will print all the file in a given directory? including sub-directories
-
-
You have the following list: [{'name': 'Mario', 'food': ['mushrooms', 'goombas']}, {'name': 'Luigi', 'food': ['mushrooms', 'turtles']}] Extract all type of foods. Final output should be: {'mushrooms', 'goombas', 'turtles'}
@@ -3027,18 +3044,26 @@ def get_food(brothers_menu) -> set: # One liner way (Using list comprehension) set([food for bro in x for food in bro['food']]) ``` -
What is List Comprehension? Is it better than a typical loop? Why? Can you demonstrate how to use it?
-
-How to reverse a string?
+#### Practical -Shortest way is: my_string[::-1] but it doesn't mean it's the most efficient one.
-Cassic way is: +
+How to reverse a string? (e.g. pizza -> azzip)
+ +Shortest way is: + +``` +my_string[::-1] +``` + +But it doesn't mean it's the most efficient one.
+ +The Classic way is: ``` def reverse_string(string): temp = "" @@ -3064,10 +3089,6 @@ def reverse_string(string): How do you handle argument parsing in Python?
-
-Explain what is GIL
-
-
What is an iterator?
@@ -3092,6 +3113,14 @@ def reverse_string(string): How to combine list of strings into one string with spaces between the strings
+
+You have the following list of nested lists: [['Mario', 90], ['Geralt', 82], ['Gordon', 88]] How to sort the list by the numbers in the nested lists?
+ +One way is: + +the_list.sort(key=lambda x: x[1]) +
+
Explain the following: * zip() @@ -3101,6 +3130,8 @@ def reverse_string(string):
How do you debug Python code?
+ +pdb :D
@@ -3238,7 +3269,7 @@ What would be the result of is_int(2) and is_int(False)? ##### Flask
-You wrote you have experience with Django/Flask. Can you describe what is Django/Flask and how you used it? Why Flask and not Djano? (or vice versa)
+You wrote you have experience with Django/Flask. Can you describe what is Django/Flask and how you have used it? Why Flask and not Djano? (or vice versa)
@@ -3660,6 +3691,12 @@ gitattributes allow you to define attributes per pathname or path pattern.
You can use it for example to control endlines in files. In Windows and Unix based systems, you have different characters for new lines (\r\n and \n accordingly). So using gitattributes we can align it for both Windows and Unix with `* text=auto` in .gitattributes for anyone working with git. This is way, if you use the Git project in Windows you'll get \r\n and if you are using Unix or Linux, you'll get \n.
+
+How do you discard local file changes?
+ +You can use `git checkout -- ` +
+ #### :star: Advanced