Linux Administration/ Engineering
What is Linux and how does it differ from other operating systems? Discuss some of the key features of Linux.
Linux is a free, open-source operating system whereas window is a commercial software. Linux has access to the source code and alters the code based on the user. One key feature of Linux is although it facilitates a Graphical user interface, which is a nice way of saying clickable/interactive buttons, color and images, Linux is well know for being a command line-based operating system, meaning everything that can be done on the operating system can be done exclusively from the command prompt, or terminal (Linux).
What is the role of the Linux Kernel in the operating system and what are some of its key functions?
Linux uses the kernel, which manages hardware and system resources and communicates with the hardware. The kernel has 4 main jobs: 1.memory management: monitors how much memory is being used to store what and where, 2.process management: determine which process can use the central processing unit (CPU), 3.device drivers: mediate/interpret between hardware and software, and system calls and 4.security: receive requests for service from processes.
Describe the basic components of a Linux system, including the file system, processes, and permission management.
The Linux system consists of several components, most important would be the kernel, then on top of the kernel we have shells which are user interface which accepts user inputs and transfers them into the kernel, on top of the shell, we have terminals( can be multiple) which are channels allowing users to log on to the kernel locally or across a network.
On each terminal we have the Linux filesystem, which is a collection of directories, files, special files, configuration files, links, sockets, named pipes etc. all of these have to be in an organized layout in order to manage them, which form a tree-like structure known as MS-DOS (disk operating system). Examples of the filesystem is /root- administrative users’ home directory, or /etc/- most important system configuration files, like a control panel in windows.
Use mkdir to create directories and subdirectories, mv to move files, directories and folders, cp to copy files, directories, and folders. Use rm and rmdir to remove files and directories respectively. Processes can be viewed with the ps, or top(more detailed- shows cpu, memory details), pstree (shows the relationship between processes) command, to show the processed(PID), the parent process ID(PPID- process that started this process), nice number, terminal(terminal to which the process is connected), and username. Not every command starts a single process, some initiate a series of processes. There are several types of processes, interactive ( initialized and controlled the terminal session), automatic process (or batch process are not controlled by the terminal, rather they are tasks that are queue into a spooler area where they are executed first in first out basis), and daemons (server processes that run continuously, initiate at startup).
Permission management is a vital part of any Linux system. The right permission can make a significant difference in whether you are able to read a .txt file or run/execute a .sh(executable) file, or write to/ modify any general file, directory or subdirectory. Easiest way to view permissions is with the ls -l command. When a file/folder/directory is created, that user name and primary group becomes the owner and group owner of the file/directory/folder. We can use whoami command to see who the current user is, and chown command to change ownership of a file/directory/folder, similar to the chgrp to chage group ownership. Similar to ownership we have permissions, which are Read (being able to view the contents of the file/folder/directory), Write (modify the contents of the file/folder/directory and Execute (run the file (or folder/directory)), and can be changed with chmod command. All this information is stored in the mode: rwxrwxrwx, where the first 3 letters rwx, shows the user has read, write and execute permissions for the file/directory/folder, next 3 rwx shows the group has read, write and execute permissions for the file/directory/folder, and the last 3 rwx shows that other(everyone else on the system) has read, write and execute permissions for the file/directory/folder. Note that in Linux this mode also tells you what type of instance you are dealing with – for regular file and a d for a directory, for example drwxrwxrwx – would show a directory, while -rwxrwxrwx would show a regular file.
What is a 3-tier architecture and how does it apply to Linux? Give some examples of popular software/services that are used in each tier.
A three-tier architecture simply means that there are three or more interacting tiers, where each tier has its own specific responsibility, a presentation tier, application tier and the data tier. The data tier stores information, the application tier handles logic, and the presentation tier is the graphical user interface (GUI). Example of this is: Web based application preparing and capturing data like Mozilla Firefox, python development tool for handling dynamic website, and a database server like MySQL, all working together to form an infrastructure.
What are some best practices for securing a Linux system? How would you implement them?
While securing Linux systems and servers, there are several basic , yet vital steps/processes to secure or harden a system: use strong and unique password, and enforce password policy by sudo nano/vim /etc/pam.d/common-password, and password feature like multi-factor authentication, and password managers/ generators, Use ssh key pairs to log into private servers, Update/patch system softwares regularly, enable automatic updates, Disable booting from external devices, close hidden open ports, netstat -s to see what ports are open, monitor and scan log files, utilize backups and test them often, and perform security audits. We can also manage which host we allow to access to services and processes, in the /etc/hosts_allow or /etc/hosts_deny. Add users to groups and manage the groups instead of each individual user.
Explain the differences between TCP and UDP protocols. In what situations would you use each one?
Transmission control protocol is a connection-oriented protocol, or communication standard used to transfer data files, between application programs and computing devices. It verifies that when a packet is sent, it is also received at the destination. User-Datagram protocol does the same thing as tcp, except it only send packets, it doesn’t verify delivery.
Name some examples of open-source and closed-source Linux distributions. What are some of the benefits and drawbacks of each?
Some examples of open-source Linux would be like ubuntu, CentOS, fedora, Linux mint cinnamon. Examples of closed-source Linux would be UNIX, and its derivatives, SunOS, Unixware, HP-UX, UNIX 9 etc.
What is swap space and why is it important for Linux systems? Describe the steps you would take to create a swap space on a Linux system.
A swap space in Linux is used to substitute disk space for RAM memory, when the amount of physical memory(RAM) is full, and the system needs more memory. Here resources inactive pages in memory are moved to the swap space. These are dedicated swap partitions, swap file It can help machines with small amounts of ram, it is not a replacement for more RAM, it is just a secondary type of memory in modern Linux.
The steps to create a swap space is to use the mkswap command with the specific location/ drive you want to make the partition, for example mkswap /dev/sdb2.
What is BASH and how would you create a BASH script? Provide an example of a simple script (the shell script can be in text).
The Linux command line is hosted by a program called shell. Most users prefer to stick with the default shell which is GNU Bourne-Again SHell (BASH). When you first launch a shell it uses a startup script located in. bashrc or .bash_profile file which allows you to customize the behavior of the shell. Shell Displays a $ (called a shell prompt) and displays a # for root (superuser shell). Bash can simplify certain operations that are hard to accomplish efficiently with a GUI. Bash script is a series of commands written in a file, that the program executes line by line, and has a extension of .sh.
So to create a bash script touch chins_world.sh, or vim chins_world.sh to edit the chins_world.sh file, use the #!/bin/bash add echo “hello” in a new line, save and exit, then chage the permission of the chins_world.sh to make it an executable using chmod u+x chins_world.sh. finally run the script using either ./chins_world.sh or bash chins_world.sh, to displays he contents of chins_world.sh, “hello world”.
What are some basic commands for user management in Linux? Describe how you would use them to create and manage users on a Linux system.
Linux is a multi-user operating system where several people may be logged in and actively working on one machine all at the same time. User and group management in Linux can be used to accomplish this objective. Some basic commands are adduser- add a user to the system, userdel- delete a user account and related files, addgroup- add group to the system, usermod- modify a user account, passwd “user/groupname”- add a password to a user or group, chage- change user password expiration information. Since all these commands modify/ create / delete system files, you need the sudo command to execute these commands successfully.