本段 61 题 | 来源:fullstack + general + design | 知识点:操作系统与网络
691. What is an inode in a file system?
文件系统中的inode是什么?
- 知识点: 操作系统与网络 / 算法与数据结构 (主题: os, cs-fundamentals;标签: interviewbit, operating-system, topic-specific, os, cs-fundamentals)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c0658d557c902bb6a39 | 官方: 否 | 付费: 否
答案:
An inode is a data structure used by a file system to store metadata about a file, not the file’s actual content.
inode是文件系统用来存储文件元数据(而非文件实际内容)的数据结构。
An inode typically contains: - File size
inode通常包含:- 文件大小
- Ownership and permissions
- Timestamps (creation, modification, access)
Pointers to the data blocks on disk
File names are stored separately in directory entries, which map names to inode numbers. This separation allows multiple filenames to reference the same file data.文件名分别存储在目录条目中,这些条目将名称映射到inode编号。这种分离允许多个文件名引用相同文件数据。
692. What is NUMA architecture, and how is it different from SMP?
什么是NUMA架构,它与SMP有何不同?
- 知识点: 操作系统与网络 / 算法与数据结构 (主题: os, cs-fundamentals;标签: interviewbit, operating-system, topic-specific, os, cs-fundamentals)
- 类型: technical | 难度: hard | 子类型: system-design
- 分类: fullstack
- id: 69b37c0658d557c902bb6a3c | 官方: 否 | 付费: 否
答案:
NUMA (Non-Uniform Memory Access) is a memory architecture where each processor has its own local memory, and access time depends on whether the memory is local or remote.
NUMA(非均匀内存访问)是一种内存架构,其中每个处理器都有自己的本地内存,访问时间取决于内存是本地还是远程。
SMP (Symmetric Multiprocessing) is an architecture where all processors share a single, uniform memory space with equal access time.
SMP(对称多处理)是一种架构,其中所有处理器共享一个统一的内存空间,访问时间相等。
Key differences include: - NUMA: memory access time varies based on location
主要区别包括:- NUMA:内存访问时间因位置而异
- SMP: memory access time is uniform
NUMA scales better for large systems, while SMP is simpler and easier to manage
Modern multi-core servers commonly use NUMA to improve performance and scalability.现代多核服务器通常使用NUMA来提高性能和可扩展性。
693. How does the OS handle deadlock detection vs deadlock prevention?
操作系统如何处理死锁检测与死锁预防?
- 知识点: 操作系统与网络 / 算法与数据结构 (主题: os, cs-fundamentals;标签: interviewbit, operating-system, topic-specific, os, cs-fundamentals)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c0658d557c902bb6a3f | 官方: 否 | 付费: 否
答案:
Deadlock detection allows the system to enter a deadlock state and then checks periodically to see if a deadlock has occurred. Once detected, the OS recovers by terminating or rolling back one or more processes to break the deadlock.
死锁检测允许系统进入死锁状态,然后定期检查是否发生了死锁。一旦检测到,操作系统通过终止或回滚一个或多个进程来打破死锁,从而恢复系统。
Deadlock prevention avoids deadlocks altogether by ensuring that at least one of the necessary deadlock conditions (mutual exclusion, hold and wait, no preemption, circular wait) never occurs. This is done by restricting how resources are requested or allocated.
死锁预防通过确保至少一个必要的死锁条件(互斥、持有并等待、不可抢占、循环等待)永远不会发生,从而完全避免死锁。这是通过限制资源请求或分配的方式来实现的。
694. What is Belady’s anomaly, and why does it occur?
什么是Belady异常,为什么它会发生?
- 知识点: 操作系统与网络 / 算法与数据结构 (主题: os, cs-fundamentals;标签: interviewbit, operating-system, topic-specific, os, cs-fundamentals)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c0658d557c902bb6a42 | 官方: 否 | 付费: 否
答案:
Belady’s anomaly is a phenomenon where increasing the number of page frames results in more page faults instead of fewer.
Belady异常是一种现象,即增加页框数量反而导致更多页面错误,而不是更少。
It occurs in certain algorithms, like FIFO, because they do not consider page usage patterns. Adding more memory can change the page replacement order in a way that increases faults.
它发生在某些算法(如FIFO)中,因为这些算法不考虑页面使用模式。增加更多内存可能会以增加错误数量的方式改变页面替换顺序。
Algorithms like LRU and Optimal do not suffer from Belady’s anomaly because they are stack algorithms, meaning the set of pages in memory with n frames is always a subset of the pages with n+1 frames.
像LRU和Optimal这样的算法不会遭受Belady异常,因为它们是栈算法,意味着具有n个页框的内存中的页面集合始终是具有n+1个页框时的页面集合的子集。
695. Compare FIFO, LRU, and Optimal page replacement algorithms.
比较FIFO、LRU和Optimal页面替换算法。
- 知识点: 操作系统与网络 / 算法与数据结构 (主题: os, cs-fundamentals;标签: interviewbit, operating-system, topic-specific, os, cs-fundamentals)
- 类型: technical | 难度: hard | 子类型: coding
- 分类: fullstack
- id: 69b37c0658d557c902bb6a45 | 官方: 否 | 付费: 否
答案:
These page replacement algorithms decide which memory page to remove when new pages need to be loaded into memory. - FIFO (First-In, First-Out) replaces the page that has been in memory the longest. It is simple to implement, but it does not consider how frequently or recently a page is used.
这些页面替换算法决定当新页面需要加载到内存时移除哪个内存页面。- FIFO(先进先出)替换在内存中停留时间最长的页面。它实现简单,但不考虑页面使用的频率或最近性。
- LRU (Least Recently Used) replaces the page that has not been accessed for the longest time. It performs better than FIFO in most cases, but requires tracking page usage.
Optimal replaces the page that will not be used for the longest time in the future. It provides the best possible performance but is not practical to implement because future access patterns are unknown.
Optimal is mainly used as a benchmark to evaluate other algorithms.Optimal主要用作评估其他算法的基准。
696. How does a Translation Lookaside Buffer (TLB) improve performance?
翻译后备缓冲器(TLB)如何提高性能?
- 知识点: 操作系统与网络 / 算法与数据结构 (主题: os, cs-fundamentals;标签: interviewbit, operating-system, topic-specific, os, cs-fundamentals)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c0658d557c902bb6a48 | 官方: 否 | 付费: 否
答案:
A Translation Lookaside Buffer (TLB) is a small, fast cache that stores recent virtual-to-physical memory address translations.
翻译后备缓冲器(TLB)是一个小而快的缓存,存储最近的虚拟到物理内存地址转换。
Instead of accessing the page table in memory for every address translation, the CPU first checks the TLB. If the entry is found (a TLB hit), the translation is done quickly. If not (a TLB miss), the system falls back to the page table.
对于每次地址转换,CPU不直接访问内存中的页表,而是首先检查TLB。如果找到条目(TLB命中),转换会快速完成。如果未找到(TLB未命中),系统则回退到页表。
By reducing frequent page table lookups, the TLB significantly improves memory access speed and overall system performance.
通过减少频繁的页表查找,TLB显著提高了内存访问速度和整体系统性能。
697. What is Multi-Level Feedback Queue (MLFQ) scheduling?
什么是多级反馈队列(MLFQ)调度?
- 知识点: 操作系统与网络 / 算法与数据结构 (主题: os, cs-fundamentals;标签: interviewbit, operating-system, topic-specific, os, cs-fundamentals)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c0658d557c902bb6a4b | 官方: 否 | 付费: 否
答案:
Multi-Level Feedback Queue (MLFQ) is a CPU scheduling algorithm that uses multiple priority queues and dynamically adjusts a process’s priority based on its behavior.
多级反馈队列(MLFQ)是一种CPU调度算法,它使用多个优先级队列,并根据进程的行为动态调整其优先级。
Processes that use the CPU for short bursts are given higher priority, while CPU-intensive processes are gradually moved to lower-priority queues. This allows the scheduler to favor interactive and I/O-bound tasks without requiring prior knowledge of execution time.
使用CPU进行短突发处理的进程被赋予更高优先级,而CPU密集型进程逐渐被移到较低优先级队列。这使得调度器能够优先处理交互式和I/O密集型任务,而无需事先知道执行时间。
MLFQ improves responsiveness and fairness by adapting to how processes actually behave rather than relying on fixed priorities.
MLFQ通过适应进程的实际行为而非依赖固定优先级来提升响应性和公平性。
698. Define variables in PowerShell.
在 PowerShell 中定义变量。
- 知识点: 操作系统与网络 / 编程语言基础 (主题: powershell, windows;标签: interviewbit, powershell, topic-specific, windows)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c1d58d557c902bb77a6 | 官方: 否 | 付费: 否
答案:
A variable is a unit of memory where values are stored. In PowerShell, variables are depicted by text strings that begin with a dollar sign ($), such as $a, $process, or $my_var. PowerShell variables are way more effective as those can be mapped to underlying classes in the framework of .NET. PowerShell considers variables as .NET objects, which implies they can save data and control data in numerous ways. Variable names in PowerShell start with a dollar sign and include a mix of numbers, letters, symbols, and spaces.
变量是存储值的记忆单元。在 PowerShell 中,变量由以美元符号($)开头的文本字符串表示,如 $a、$process 或 $my_var。PowerShell 变量更为有效,因为它们可以映射到 .NET 框架中的底层类。PowerShell 将变量视为 .NET 对象,这意味着它们可以以多种方式保存和控制数据。PowerShell 中的变量名以美元符号开头,并包含数字、字母、符号和空格的混合。
For example, $var="HELLO" saves the string HELLO in the $var variable. Variables can also possess various scopes, including global, local, script, private, and numbered scopes.
例如,$var="HELLO" 将字符串 HELLO 保存在 $var 变量中。变量还可以拥有各种作用域,包括全局、本地、脚本、私有和编号作用域。
699. Explain PowerShell’s comparison operators?
解释 PowerShell 的比较运算符?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: powershell, windows;标签: interviewbit, powershell, topic-specific, windows)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c1d58d557c902bb77ac | 官方: 否 | 付费: 否
答案:
Comparison Operators compares the value in PowerShell. There are four kinds of comparison operators that are used, namely equality, match, containment and replace. In PowerShell, one of the essential comparison operators is –eq that is utilized inplace of “=” sign for declaring variables. Similarly, there are other operators like –ne for “not equal” , -gt ( greater than ) or –lt (less than).
比较运算符用于比较 PowerShell 中的值。有四种类型的比较运算符被使用,即相等、匹配、包含和替换。在 PowerShell 中,一个关键的比较运算符是 –eq,它用于替代声明变量时的“=”符号。类似地,还有其他运算符,如 –ne 表示“不等于”,-gt(大于)或 –lt(小于)。
Conclusion
结论
PowerShell is securely incorporated into nearly all of Microsoft’s products. There are specific actions in popular products like Microsoft 365 and Server 2016 that cannot be accomplished with a GUI and can solely be accomplished with PowerShell. It is 100% required for certain tasks, the capability to automate with PowerShell makes comprehending it a worthwhile skill for numerous IT professionals. Once you begin to understand, all that can be accomplished with PowerShell, it unlocks a whole new set of capabilities. From fundamental automation to advanced scripting, PowerShell can deliver a lot of opportunities for streamlining tasks and saving time. The above-mentioned question and answers will help ace the interview.
PowerShell 已安全地集成到 Microsoft 几乎所有产品中。在 Microsoft 365 和 Server 2016 等热门产品中,某些特定操作无法通过 GUI 完成,只能通过 PowerShell 实现。对于某些任务,它是 100% 必需的,使用 PowerShell 进行自动化的能力使其成为众多 IT 专业人士值得掌握的技能。一旦你开始理解 PowerShell 所能完成的所有事情,它就会开启一套全新的能力。从基础自动化到高级脚本编写,PowerShell 可以提供许多简化任务和节省时间的机会。上述问题和答案将有助于在面试中表现出色。
700. What is pipeline in PowerShell?
什么是 PowerShell 中的管道?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: powershell, windows;标签: interviewbit, powershell, topic-specific, windows)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c1d58d557c902bb77b0 | 官方: 否 | 付费: 否
答案:
The concept of linking together commands with pipeline operator ( | ) is termed as a pipeline in PowerShell. That indicates the outcome from the first command is further sent down the pipeline as input to the second command for processing and the outcome of the second command is sent down to the pipeline as input to the third command and it goes on.
使用管道运算符(|)将命令连接起来的概念被称为 PowerShell 中的管道。这意味着第一条命令的结果被进一步发送到管道中作为第二条命令的输入进行处理,第二条命令的结果被发送到管道中作为第三条命令的输入,以此类推。
701. Tell about PowerShell’s Get-ServiceStatus function?
介绍 PowerShell 的 Get-ServiceStatus 函数?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: powershell, windows;标签: interviewbit, powershell, topic-specific, windows)
- 类型: technical | 难度: hard | 子类型: coding
- 分类: fullstack
- id: 69b37c1d58d557c902bb77b4 | 官方: 否 | 付费: 否
答案:
The functions of Get-ServiceStatus allow filtering of window services. PowerShell documents the services that are both ‘Running’, and ‘Stopped’ during scripting. By default, when Get-Service is operated without parameters, all the local computer's services are returned. You can control this cmdlet to obtain only certain services by selecting the service name or the display name of the services, or you can pipe service objects to this cmdlet. - Example 1: Get all services on the computerThis example fetches all of the services on the computer. It acts as though you typed Get-Service *. The default display displays the status, service name, and display name of each service.Get-Service
Get-ServiceStatus 的函数允许过滤 Windows 服务。PowerShell 在脚本编写过程中记录了既处于“运行”状态又处于“已停止”状态的服务。默认情况下,当 Get-Service 不带参数操作时,会返回本地计算机的所有服务。你可以通过选择服务名称或服务的显示名称来控制此 cmdlet 仅获取特定服务,或者你可以将服务对象通过管道传递给此 cmdlet。- 示例 1:获取计算机上的所有服务此示例获取计算机上的所有服务。它就像你输入了 Get-Service * 一样。默认显示显示每个服务的状态、服务名称和显示名称。Get-Service
- Example 2: Get services that commence with a search stringThis example recovers services with service names that start with WMI (Windows Management Instrumentation).Get-Service "wmi*"
702. Describe what is the benefit of Array in PowerShell?
描述 PowerShell 中数组的好处是什么?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: powershell, windows;标签: interviewbit, powershell, topic-specific, windows)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c1d58d557c902bb77b9 | 官方: 否 | 付费: 否
答案:
The usage of Array in PowerShell is to execute a script against remote computers. To build an array, you have to construct a variable and assign the array. Arrays are defined by “@”symbol, they are portrayed as hashtable but are not followed by curly braces.
在 PowerShell 中使用数组是为了对远程计算机执行脚本。要构建数组,你必须构造一个变量并分配数组。数组由“@”符号定义,它们表现为哈希表,但不后跟花括号。
To utilize an array in a program, you must call a variable to reference the array, and you can define the kind of array the variable can reference.
要在程序中使用数组,你必须调用一个变量来引用数组,并且你可以定义该变量可以引用的数组类型。
Mentioned below is the syntax for declaring an array variable:
下面提到的是声明数组变量的语法:
$A = 1, 2, 3, 4
$A = 1, 2, 3, 4
Or
或者
$A = 1..4
$A = 1..4
Note − By default type of object of the array is System.Object. GetType() method returns the type of the array. Type can be passed.
注意 − 默认情况下,数组对象的类型为 System.Object。GetType() 方法返回数组的类型。可以传入类型。
Example:
示例:
The mentioned code snippets are examples of this syntax −
上述代码片段是该语法的一些示例 −
[int32[]]$intA = 1500,2230,3350,4000
[int32[]]$intA = 1500,2230,3350,4000
$A = 1, 2, 3, 4
$A = 1, 2, 3, 4
$A.getType()
$A.getType()
703. What is the benefit of the hashtable in PowerShell?
在 PowerShell 中使用哈希表有什么好处?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: powershell, windows;标签: interviewbit, powershell, topic-specific, windows)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c1d58d557c902bb77bd | 官方: 否 | 付费: 否
答案:
A hash table is also called the dictionary. It is a collection that lets you accumulate data in a “key-value” pair association. The “key” and “value” can be of any data and length. To display a hash table you will have to make use of @ followed by curly braces.
哈希表也称为字典。它是一种集合,允许您以“键-值”对关联的方式累积数据。“键”和“值”可以是任意数据类型和长度。要显示哈希表,您必须使用 @ 后跟花括号。
The syntax of a hash table is as follows:
哈希表的语法如下:
PowerShellCopy
PowerShellCopy
@{= ; [ = ] ...}
@{ <名称> = <值>; [<名称> = <值> ] ...}
704. What is your take on Variable Interpolation?
您对变量插值有何看法?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: powershell, windows;标签: interviewbit, powershell, topic-specific, windows)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c1d58d557c902bb77c1 | 官方: 否 | 付费: 否
答案:
When a variable is incorporated into double-quoted strings, then PowerShell transforms the name of that variable via its value. Generally, this feature in PowerShell is emanated as variable interpolation. It provides a more readable, easier-to-read, and convenient syntax to create a formatted string.
当变量被合并到双引号字符串中时,PowerShell 会通过其值转换该变量的名称。通常,PowerShell 中的这一特性被称为变量插值。它提供了一种更易读、更易理解且更方便的语法来创建格式化字符串。
705. Describe what is Powershell Get-command?
描述一下什么是 PowerShell 的 Get-command?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: powershell, windows;标签: interviewbit, powershell, topic-specific, windows)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c1d58d557c902bb77c6 | 官方: 否 | 付费: 否
答案:
The Get-Command cmdlet acquires all commands that are performed on the computer, such as functions, cmdlets, aliases, applications, filters, and scripts. Get-Command fetches the commands from PowerShell commands and modules that were imported from other sessions.
Get-Command cmdlet 获取在计算机上执行的所有命令,例如函数、cmdlet、别名、应用程序、筛选器和脚本。Get-Command 从 PowerShell 命令以及从其他会话导入的模块中获取命令。
Example: Get commands in the current session
示例:获取当前会话中的命令
This command utilizes the ListImported parameter to obtain only the commands in the current session.
此命令利用 ListImported 参数仅获取当前会话中的命令。
PowerShellCopy
PowerShellCopy
Get-Command -ListImported
Get-Command -ListImported
706. Do you make PowerShell scripts to deploy components in SharePoint?
你是否编写 PowerShell 脚本在 SharePoint 中部署组件?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: powershell, windows;标签: interviewbit, powershell, topic-specific, windows)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c1d58d557c902bb77ca | 官方: 否 | 付费: 否
答案:
If you construct a web part with the help of VS 2010 then, you can deploy it utilizing cntrl+f5. To activate the web part component you can document a PowerShell script (.ps1) and run it after deployment.
如果你借助 VS 2010 构建一个 Web 部件,那么你可以使用 Ctrl+F5 进行部署。要激活该 Web 部件组件,你可以编写一个 PowerShell 脚本(.ps1)并在部署后运行它。
707. Why is scripting debugging important?
为什么脚本调试很重要?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: powershell, windows;标签: interviewbit, powershell, topic-specific, windows)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c1d58d557c902bb77ce | 官方: 否 | 付费: 否
答案:
Scripting debugging is an essential attribute to comprehend how to use PowerShell. Concentrate on how scripting debugging can enhance your workflow and the entire project.
脚本调试是理解如何使用 PowerShell 的重要属性。重点关注脚本调试如何增强你的工作流程和整个项目。
Scripting debugging is necessary as it permits IT professionals to quickly scan the scripts, functions, expressions, and commands while executing. This allows us to determine possible errors, maintain model scripts and improve performance.
脚本调试是必要的,因为它允许 IT 专业人员在执行时快速扫描脚本、函数、表达式和命令。这使我们能够确定可能的错误、维护模型脚本并提高性能。
708. Describe what is Powershell Pipeline used for?
描述 PowerShell 管道用于什么?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: powershell, windows;标签: interviewbit, powershell, topic-specific, windows)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c1d58d557c902bb77d3 | 官方: 否 | 付费: 否
答案:
PowerShell pipeline is utilized for combining two statements like when the output of a statement becomes the input of the second statement.
PowerShell 管道用于组合两个语句,例如当一个语句的输出成为第二个语句的输入时。
For example,
例如,
Command-1 | Command-2 | Command-3
Command-1 | Command-2 | Command-3
In this example, the objects that Command-1 emits are sent to Command-2. Command-2 processes the objects and sends them to Command-3. Command-3 processes the objects and sends them down the pipeline. As there are no more commands in the pipeline, the results are displayed at the console.
在此示例中,Command-1 发出的对象被发送到 Command-2。Command-2 处理这些对象并将它们发送到 Command-3。Command-3 处理这些对象并将它们发送到管道下游。由于管道中不再有其他命令,结果显示在控制台上。
709. Describe the various types of execution policies in PowerShell?
描述 PowerShell 中有哪些不同类型的执行策略?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: powershell, windows;标签: interviewbit, powershell, topic-specific, windows)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c1d58d557c902bb77d7 | 官方: 否 | 付费: 否
答案:
PowerShell utilizes execution policies to regulate how it loads configuration files and runs scripts. Implementation of these policies only happens on Windows platforms. The PowerShell execution policies are mentioned below:
PowerShell 利用执行策略来规范其加载配置文件和运行脚本的方式。这些策略的实施仅发生在 Windows 平台上。PowerShell 执行策略如下所述:
AllSigned:
The scripts can run.脚本可以运行。
Needs that all scripts and configuration files be signed by a reliable publisher, which includes scripts that you compose on the local computer.
要求所有脚本和配置文件必须由受信任的发布者签名,这包括您在本地计算机上编写的脚本。
Encourages you before executing scripts from publishers that are still not categorized as untrusted or trusted.
鼓励您在从尚未归类为不受信任或受信任的发布者执行脚本之前进行确认。
Risks running signed, but vicious, scripts.
存在运行已签名但恶意脚本的风险。Bypass:
Nothing is stopped and there are no alerts or prompts generated.不会阻止任何操作,也不会生成任何警报或提示。
The Bypass execution policy is created for configurations in which a PowerShell script is constructed into a larger application or for configurations in which PowerShell is the basis for a program that possesses its security model.
Bypass 执行策略适用于将 PowerShell 脚本集成到更大应用程序中的配置,或适用于 PowerShell 作为具有自身安全模型的程序基础的配置。Default:
Restricted for Windows clients.适用于 Windows 客户端的 Restricted(受限)。
RemoteSigned for Windows servers.
适用于 Windows 服务器的 RemoteSigned(远程签名)。RemoteSigned:
The default execution policy for the Windows system.Windows 系统的默认执行策略。
Scripts can run.
脚本可以运行。
A digital signature from an authorized publisher is required on internet downloaded scripts and configuration files. It contains email and instant messaging programs.
从互联网下载的脚本和配置文件需要来自授权发布者的数字签名。它包含电子邮件和即时通讯程序。
It doesn't need digital signatures on scripts that are not downloaded from the internet and composed on the local computer.
对于并非从互联网下载且由本地计算机编写的脚本,无需数字签名。
It executes internet downloaded scripts that are not signed if the scripts are unblocked, like utilizing the Unblock-File cmdlet.
如果未签名的互联网下载脚本已被解除阻止,例如使用 Unblock-File cmdlet,则执行这些脚本。
Risks executing unsigned scripts from sources except for the internet and signed scripts that could be malicious in nature.
存在执行来自互联网以外来源的未签名脚本以及可能具有恶意的已签名脚本的风险。Restricted:
The default implementation policy for Windows client computers.适用于 Windows 客户端计算机的默认实施策略。
Allows individual commands, but does not permit scripts.
允许单个命令,但不允许脚本。
Stops operating all script files, including configuration files (.ps1xml), PowerShell profiles (.ps1), and module script files (.psm1) formatting
停止运行所有脚本文件,包括配置文件(.ps1xml)、PowerShell 配置文件(.ps1)和模块脚本文件(.psm1)的格式化。Undefined:
There is no implementation policy specified in the current scope.当前范围内未指定实现策略。
The execution policy is Restricted for Windows clients and RemoteSigned for Windows Server if the implementation policy in all scopes is Undefined.
如果所有范围内的实现策略均为未定义,则 Windows 客户端的执行策略为受限,Windows Server 的执行策略为远程签名。Unrestricted:
The default execution policy for non-Windows systems and cannot be modified.非 Windows 系统的默认执行策略,且无法修改。
Unsigned scripts can operate. There is a chance of running malicious scripts.
未签名的脚本可以运行,存在运行恶意脚本的风险。
Alerts the customer before running scripts and configuration files that do not belong from the Local intranet zone.
在运行不属于本地 Intranet 区域的脚本和配置文件之前,向客户发出警告。
710. Explain the importance of PowerShell brackets?
解释 PowerShell 括号的重要性?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: powershell, windows;标签: interviewbit, powershell, topic-specific, windows)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c1d58d557c902bb77db | 官方: 否 | 付费: 否
答案:
- Parenthesis Brackets(): These brackets are utilized for required arguments.
- Square Brackets[]: These sorts of brackets are used to specify the optional items.
- Braces Brackets{}: These kinds of brackets are utilized in blocked statements.
711. What are Automatic variables?
什么是自动变量?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: powershell, windows;标签: interviewbit, powershell, topic-specific, windows)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c1e58d557c902bb77e0 | 官方: 否 | 付费: 否
答案:
The automatic variables are defined as those variables that save store state information for PowerShell. These variables will include the details of a customer and the system, default and runtime variables, and PowerShell settings. These variables can be designed and handled by Windows PowerShell.
自动变量被定义为保存 PowerShell 状态信息的变量。这些变量将包括客户和系统的详细信息、默认和运行时变量,以及 PowerShell 设置。这些变量可以由 Windows PowerShell 设计和处理。
A few of the very popular Automatic Variables are mentioned below: - $: This variable includes the last token available in the last line that is received by the session.
下面是一些非常流行的自动变量:- $:此变量包含会话接收的最后一行中的最后一个标记。
- $?: This variable may include the completion status of the last operation. If the last operation succeeded, its value is TRUE and FALSE if it has failed.
- $^: It may include the first token of the last line obtained by the session.
- $Args: Includes a collection of the undeclared parameters or parameter values. These are handed over to a script, script block, or function. When you construct a function, you can display the parameters by making use of the param keyword or by incorporating a comma-separated list of parameters in parentheses just after the function name.
- $Error: This variable includes an array of error objects that represent the most recent errors. The current mistake is the first error object in the array ($Error[0]).
- $ForEach: This variable includes the enumerator (not the resulting values) of a ForEach loop. You can make use of the properties and processes of enumerators on the value of the $ForEach variable. This variable lives only while the ForEach loop is operating; it gets deleted post the completion of the loop.$Home – This variable includes the full path of the customer’s home directory. This variable is the counterpart of the %homedrive%%homepath% environment variables, commonly known as C:\Users.
- $OFS – $OFS is a remarkable variable that saves a string (Series of characters) that you wish to utilize as an output field separator. Employ this variable when you are transforming an array into a string. By default, the value of $OFS is ” “, but you can modify the value of $OFS in your session, by just typing $OFS=””. If you are anticipating the default value of ” ” in your module, script, or configuration output, be mindful that the $OFS default value has not been modified anywhere in your code.
712. Explain what is a "while loop" in PowerShell?
解释 PowerShell 中的“while 循环”是什么?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: powershell, windows;标签: interviewbit, powershell, topic-specific, windows)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c1e58d557c902bb77e4 | 官方: 否 | 付费: 否
答案:
IT professionals make use of loops when they require to complete a block of commands numerous times.
IT 专业人士在需要多次完成一组命令时使用循环。
Example: An entry-controlled loop, a "while loop" runs commands consecutively as long as the provided condition is true. A bunch of IT professionals prefers to employ "while loops" rather than "for statements" as the syntax is less complex."
示例:作为入口控制循环,“while 循环”在提供的条件为真时连续运行命令。许多 IT 专业人士更倾向于使用“while 循环”而不是“for 语句”,因为其语法更简单。
The following example prints the values from 1 to 5 using the while loop:
以下示例使用 while 循环打印从 1 到 5 的值:
PS C:\> while($count -le 5) 2. >> { 3. >> echo $count 4. >> $count +=1 5. >> }
- PS C:\> while($count -le 5) 2. >> { 3. >> echo $count 4. >> $count +=1 5. >> }
Output: 1 2 3 4 5
输出:1 2 3 4 5
In this instance, the condition ($count is less than equal to 5) is true while $count = 1, 2, 3, 4, 5. Every time through the loop, the value of a variable $count is incremented by 1 utilizing the (+=) arithmetic assignment operator. When $count equals 6, the condition statement assesses to false, and the loop exits.
在此示例中,条件($count 小于等于 5)在 $count = 1, 2, 3, 4, 5 时为真。每次循环时,变量 $count 的值通过使用 (+=) 算术赋值运算符增加 1。当 $count 等于 6 时,条件语句评估为假,循环退出。
713. What is the importance of sed command and awk command?
sed 命令和 awk 命令的重要性是什么?
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c4f58d557c902bc74ed | 官方: 否 | 付费: 否
答案:
- sed Command: sed command is an acronym for stream editor. It is used for editing a file without using an editor. The SED command performs a variety of operations on files, such as searching, finding and replacing, inserting and deleting. However, substitution or find and replace are the most commonly used features of SED.Syntax: sed options file Example: Execution over Shell Interpreter/Editor
/u/user1/Shell_Scripts_2020> echo "Hi Gourav" | sed 's/Hi/Hello/'
/u/user1/Shell_Scripts_2020> echo "Hi Gourav" | sed 's/Hi/Hello/'
In this case, “s” command in sed replaces the string Hi with “Hello”.
在这个例子中,sed 中的“s”命令将字符串 Hi 替换为“Hello”。
Output:
输出:
Hello Gourav
你好,Gourav
- awk Command: The command is a scripting language generally used to manipulate data and generate reports. There is no need to compile it and users are allowed to have access to a variable, string functions, numeric functions, and logical operations.Syntax: awk options File Name Example: Script/Code
/u/user1/Shell_Scripts_2017> cat > script10
/u/user1/Shell_Scripts_2017> cat > script10
Hello Aisha
Hello Aisha
Hello Rohan
你好,Rohan
Hello Gourav
你好,Gourav
An awk command/utility assigns variables in following way:
awk 命令/工具按以下方式分配变量:
$0 -> For whole line (e.g. Hello Aisha)
$0 -> 表示整行(例如 Hello Aisha)
$1 -> For the first field i.e. Hello
$1 -> 表示第一个字段,即 Hello
$2 -> For the second field
$2 -> 表示第二个字段
Execution over Shell Interpreter/Editor
通过 Shell 解释器/编辑器执行
awk ‘{print $0}’ script10
awk ‘{print $0}’ script10
The above script prints all the 3 lines completely.
上面的脚本会完整地打印这 3 行。
Output:
输出:
Hello Aisha
Hello Aisha
Hello Rohan
你好,Rohan
Hello Gourav
你好,Gourav
Execution over Shell Interpreter/Editor
通过 Shell 解释器/编辑器执行
awk ‘{print $1}’ script10
awk ‘{print $1}’ script10
The above script prints only the first word i.e., Hello from each line.
上述脚本只打印每行的第一个单词,即 Hello。
Output:
输出:
Hello
Hello
Hello
Hello
Hello
Hello
714. What do you mean by crontab?
crontab 是什么意思?
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc74f0 | 官方: 否 | 付费: 否
答案:
Crontab stands for "cron table," meaning that it makes use of the cron scheduler to perform tasks. In other words, it is the list of commands that you wish to run on a regular schedule and the command that will let you manage it. It is possible to view or edit the table of commands using the crontab command. In addition to the schedule, the term "Crontab" also refers to the name of the program used to edit the schedule.
Crontab 代表“cron 表”,意味着它利用 cron 调度器来执行任务。换句话说,它是您希望按固定时间表运行的命令列表,以及允许您管理该列表的命令。可以使用 crontab 命令查看或编辑命令表。除了调度之外,“Crontab”还指用于编辑该时间表的程序名称。
715. Name two files of crontab command.
说出 crontab 命令的两个文件。
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc74f3 | 官方: 否 | 付费: 否
答案:
cron.deny and cron.allow are two files in the /etc/cron.d directory that controls access to the crontab command. Crontab command tasks such as creating, editing, displaying, or removing crontab files are relegated to specific users through these files. Both files usually consist of a list of user names, one user name per line. Together, these access control files perform the following functions: - cron.allow decides which users are allowed to run the crontab command.
cron.deny 和 cron.allow 是 /etc/cron.d 目录中的两个文件,用于控制对 crontab 命令的访问。通过这些文件,crontab 命令的任务(如创建、编辑、显示或删除 crontab 文件)被分配给特定用户。两个文件通常都包含一个用户名列表,每行一个用户名。这些访问控制文件共同执行以下功能:- cron.allow 决定哪些用户被允许运行 crontab 命令。
- cron.deny decides which users are denied from using the crontab command.
- When cron.allow or cron.deny doesn't exist, superuser privileges are required to run it.
716. Name the command that is used to take the backup.
说出用于备份的命令。
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc74f6 | 官方: 否 | 付费: 否
答案:
The backup is taken using the tar command. Tar is an acronym for tape archive and is used to create backups using tar, gzip, and bzip. Files can be saved and restored from and to a tape using this command. In this, files and directories are generally compressed into tarballs, an archive file. For this purpose, it is among the most widely used commands. Furthermore, the tarball can be easily moved from one server to another.
备份是使用 tar 命令进行的。Tar 是“tape archive”的缩写,用于使用 tar、gzip 和 bzip 创建备份。使用此命令,文件可以保存到磁带并从磁带恢复。在此过程中,文件和目录通常被压缩成 tarball,这是一种归档文件。为此,它是最广泛使用的命令之一。此外,tarball 可以轻松地从一台服务器移动到另一台服务器。
717. Write the difference between $* and $@
写出 $* 和 $@ 之间的区别
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc74f9 | 官方: 否 | 付费: 否
答案:
Unlike $@, where each quoted argument is treated as a separate argument, $* treats each positional parameter as a single argument.
与 $@ 不同,$@ 中每个带引号的参数被视为单独的参数,而 $* 将每个位置参数视为单个参数。
718. Name the command that is used to compare the strings in a shell script.
指出用于在 Shell 脚本中比较字符串的命令名称。
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc74fc | 官方: 否 | 付费: 否
答案:
To compare text strings, use the test command. By comparing each character in each string, the test command usually compares text strings. In most cases, tests are generally included as a conditional execution of shell commands. It can be used for: - Comparison of file attributes
要比较文本字符串,请使用 test 命令。通过比较每个字符串中的每个字符,test 命令通常会比较文本字符串。在大多数情况下,测试通常作为 Shell 命令的条件执行而被包含。它可以用于:- 比较文件属性。
- Comparison of strings
Comparing basic arithmetic operations
Using square brackets ([ and ]) around the EXPRESSION is equivalent to testing it with the test.在 EXPRESSION 周围使用方括号([ 和 ])等同于使用 test 对其进行测试。
Syntax of test command: - test EXPRESSION
test 命令的语法:- test EXPRESSION
- test EXPRESSION && true-command
- test EXPRESSION || false-command
test EXPRESSION && true-command || false-command
Examples: - test 50 -gt 40 && echo "Yes" || echo "No"示例:- test 50 -gt 40 && echo "Yes" || echo "No"
Because 50 is greater than 40, this command prints the text "Yes". - ["Excellent" = "Excellent"]; echo $?
因为 50 大于 40,所以此命令会打印文本 "Yes"。- ["Excellent" = "Excellent"]; echo $?
As the two strings are identical, this command prints "0" because the expression is true.
由于这两个字符串相同,所以此命令打印 "0",因为表达式为真。
719. Write down the Syntax for all the loops in Shell Scripting.
写出 Shell 脚本中所有循环的语法。
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc74ff | 官方: 否 | 付费: 否
答案:
In shell scripting, you can use three looping statements as given below: - while statement
在 Shell 脚本中,您可以使用如下给出的三种循环语句:- while 语句。
- for statement
until statement
Syntax is as follows: - For Loop: Loops that operate on lists of items are known as loops. Each item in the list receives the same set of commands.语法如下:- For 循环:对项目列表进行操作的循环被称为循环。列表中的每个项目都会接收相同的命令集。
Syntax:
语法:
for var in word1 word2 ... wordN
for var in word1 word2 ... wordN
do
do
Statement to be executed
要执行的语句
done
完成
Example:
示例:
for a in 1 2 3 4 5 6 7 8 9 10
for a in 1 2 3 4 5 6 7 8 9 10
do
do
if [ $a == 3 ]
if [ $a == 3 ]
then
然后
break
中断
fi
fi
echo "Iteration no $a"
echo "迭代次数 $a"
done
完成
Output”
输出”
$bash -f main.sh
$bash -f main.sh
Iteration no 1
迭代次数 1
Iteration no 2
迭代次数 2
- While Loop: It involves evaluating a command first and then executing a loop based on the result. The loop will be terminated if the command raises to false.
Syntax:
语法:
while command
while 命令
do
do
Statement to be executed
要执行的语句
done
完成
Example:
示例:
a=0
a=0
while [ $a -lt 3 ]
while [ $a -lt 3 ]
do
do
echo $a
输出 $a
a=expr $a + 1
a=expr $a + 1
done
完成
Output:
输出:
$bash -f main.sh
$bash -f main.sh
0
1
2
3
- Until Loop: As often as the condition/command evaluates to false, the until loop is executed. Once the condition or command becomes true, the loop terminates.
Syntax:
语法:
until command
直到命令执行
do
do
Statement to be executed until command is true
要执行的语句,直到命令为真
done
完成
Example:
示例:
a=0
a=0
until [ $a -gt 3 ]
直到 [ $a -gt 3 ]
do
do
echo $a
输出 $a
a=expr $a + 1
a=expr $a + 1
done
完成
Output:
输出:
$bash -f main.sh
$bash -f main.sh
0
1
2
3
720. What are interactive and non-interactive shells?
什么是交互式和非交互式shell?
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc7502 | 官方: 否 | 付费: 否
答案:
Interactive shell: /bin/bash and /bin/sh is interactive shell. It is a non-login shell that gets started from a command line. It first copies the parent environment and then invokes.
交互式shell:/bin/bash和/bin/sh是交互式shell。它是一种从命令行启动的非登录shell。它首先复制父环境,然后调用。
Non-Interactive shell: /sbin/nologin shell is non-interactive shell. It is present when the shell script is running and just inherits the parent's environment.
非交互式shell:/sbin/nologin shell是非交互式shell。当shell脚本运行时它存在,并且仅继承父环境。
721. How will you pass and access arguments to a script in Linux?
在Linux中,你如何传递和访问脚本的参数?
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc7505 | 官方: 否 | 付费: 否
答案:
In scripts, arguments are passed as follows:
在脚本中,参数传递方式如下:
scriptName "Arg1" "Arg2"…."Argn"
scriptName "Arg1" "Arg2"…."Argn"
Arguments in a script can be accessed as follows:
脚本中的参数可以通过以下方式访问:
$1 , $2 .. $n
$1、$2到$n
722. What do you mean by the “s” permission bit in a file?
文件中的“s”权限位是什么意思?
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc7508 | 官方: 否 | 付费: 否
答案:
The SUID (Set User ID) bit is known as the "s" bit. SUIDS are special file permissions for executable files that enable other users to run the file as the file owner. There will be an s (to indicate SUID) special permission for the user instead of the normal x, which represents execute permissions. A file that has the "s" bit set will grant the process the rights of the file's owner while the program is running.
SUID(设置用户ID)位被称为“s”位。SUID是用于可执行文件的特殊文件权限,使其他用户能以文件所有者的身份运行该文件。对于用户,会有一个“s”(表示SUID)特殊权限,而不是通常表示执行权限的“x”。设置了“s”位的文件,在程序运行期间,会授予进程文件所有者的权限。
Example:
示例:
Executing the "passwd" command to change the password, for example, allows the user to write the new password to the shadow file even though its owner is "root".
例如,执行“passwd”命令更改密码时,即使用户不是root,也能让用户将新密码写入shadow文件。
723. How will you debug a shell script?
你会如何调试shell脚本?
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc750b | 官方: 否 | 付费: 否
答案:
With set, you can turn on or off debugging options in the shell: - Set -x: This displays commands and their arguments as they are being executed.
使用set命令,你可以在shell中开启或关闭调试选项:- Set -x:这会显示正在执行的命令及其参数。
- Set -v: It displays shell input lines in real-time as they are read.
724. What is the best way to debug the shell script/program problems?
调试shell脚本/程序问题的最佳方法是什么?
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: coding
- 分类: fullstack
- id: 69b37c5058d557c902bc750e | 官方: 否 | 付费: 否
答案:
Following are some common methods of debugging a script: - The shell script can be modified to include debug statements to display the information that can be useful in identifying the problem.
以下是调试脚本的一些常见方法:- 可以修改shell脚本,加入调试语句以显示有助于识别问题的信息。
- By setting -x in the script, we can enable debugging.
725. Name the command that is used to display the shell's environment variable.
说出用于显示shell环境变量的命令名称。
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc7516 | 官方: 否 | 付费: 否
答案:
Shell functions, along with other Linux programs, are controlled by environmental variables. Any child process of the shell has access to an environment variable. These variables are necessary for some programs to function properly. env or printenv commands can be used to display the shell's environment variables.
Shell函数以及Linux中的其他程序,都受环境变量控制。shell的任何子进程都可以访问环境变量。某些程序正常运行需要这些变量。可以使用env或printenv命令来显示shell的环境变量。
726. Name different commands that are available to check the disk usage.
说出可用于检查磁盘使用情况的不同命令。
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc7519 | 官方: 否 | 付费: 否
答案:
The following commands are available to check disk space usage: - df – It is used to find out how much space is left on a disk.
以下命令可用于检查磁盘空间使用情况:- df – 它用于查看磁盘上还剩多少空间。
- du – With this command, you can find out how much disk space the specified files and each subdirectory take up.
- dfspace – Using this command, you can check the amount of free disk space in MB.
727. What do you mean by metacharacters?
元字符是什么意思?
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc751c | 官方: 否 | 付费: 否
答案:
In a data field or program, metacharacters are special characters that provide information about other characters. In shells, they're called regular expressions. A character that is neither a letter nor a number is generally considered a metacharacter. Using shell metacharacters, you can group together commands, redirect and pipe input/output, put commands in the background, reduce the size of file names and path names, etc. You can use them as wildcards to specify a file name without typing in the file's full name. The most common metacharacters are as follows: - Asterisk (): Use the to match any character.
在数据字段或程序中,元字符是提供有关其他字符信息 的特殊字符。在shell中,它们被称为正则表达式。既不是字母也不是数字的字符通常被视为元字符。使用shell元字符,你可以分组命令、重定向和管道输入/输出、将命令置于后台、缩小文件名和路径名的长度等。你可以将它们用作通配符来指定文件名,而无需输入文件的完整名称。最常见的元字符如下:- 星号():使用来匹配任何字符。
- Question Mark (?): It matches a single character in the filename.
- Brackets ([…]): The metacharacters used here match some specified characters.
- Hyphen (-): When placed within [] (brackets), the - metacharacter matches a specified range.
728. How will you find total shells available in your system?
你如何找出系统中可用的所有shell?
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc7523 | 官方: 否 | 付费: 否
答案:
Within your system, there are several shells available. If you want to find all the shells on the system, you can use $ cat /etc/shells.
在你的系统中,存在多种shell。如果你想查找系统上的所有shell,可以使用$ cat /etc/shells命令。
Example:
示例:
$ cat /etc/shells
Execution over Shell Interpreter/Editor:
在 Shell 解释器/编辑器中的执行:
$ cat /etc/shells
Output:
输出:
/bin/sh
/bin/sh
/bin/bash
/bin/bash
/sbin/nologin
/sbin/nologin
/bin/ksh
/bin/ksh
/bin/csh
/bin/csh
729. Explain how you will open a read-only file in Unix/Shell.
解释你将如何在 Unix/Shell 中打开一个只读文件。
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc7526 | 官方: 否 | 付费: 否
答案:
You can open a read-only file by: vi –R
你可以通过以下方式打开只读文件:vi –R
730. Name the command that one should use to know how long the system has been running.
说出应该使用哪个命令来了解系统已经运行了多长时间。
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc7529 | 官方: 否 | 付费: 否
答案:
Using the Uptime command, you can see how long your system has been active. You can also determine the number of users with running sessions, and the average system load for 1, 5, and 15 minutes. The information displayed at once can also be filtered based on your specified options.
使用 uptime 命令,你可以查看系统已激活的时间。你还可以确定有运行会话的用户数量,以及 1、5 和 15 分钟的平均系统负载。显示的信息也可以根据你指定的选项进行过滤。
Example: $ uptime
示例:$ uptime
Entering the above command at the shell prompt, namely $ uptime, will produce the following output:
在 shell 提示符下输入上述命令,即 $ uptime,将产生以下输出:
9:21am up 86 day(s), 11:46, 3 users, load average: 2.24, 2.18, 2.16
9:21am up 86 day(s), 11:46, 3 users, load average: 2.24, 2.18, 2.16
731. Write difference between grep and find command.
写出 grep 和 find 命令之间的区别。
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc752f | 官方: 否 | 付费: 否
答案:
- Grep command: This command facilitates searching and displaying content based on regular expressions specified by the user. Using the Grep command, one can search in a file for patterns. Grep command have the following syntax:grep “literal string”
Example:
示例:
grep “apple” file1.txt //Displays all the lines with the word “apple” in the file1
grep “apple” file1.txt //显示 file1 中包含单词“apple”的所有行
grep “apple” file1.txt file2.txt //Scan multiple documents and search the word “apple” in both files.
grep “apple” file1.txt file2.txt //扫描多个文档并在两个文件中搜索单词“apple”
- Find command: The FIND command searches for files and folders based on their size, modification time, and access time. You can use this command to search files and directories. Find command have the following syntax:find
Example:
示例:
find –type f // Command will find all the files
find –type f // 命令将查找所有文件
find –type d //Command will find all the directories
find –type d // 命令将查找所有目录
find . –name file1.txt //Command will find file1.txt in the current directory.
find . –name file1.txt // 命令将在当前目录中查找 file1.txt
732. How can we create a function in shell script?
如何在 shell 脚本中创建函数?
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: coding
- 分类: fullstack
- id: 69b37c5058d557c902bc7532 | 官方: 否 | 付费: 否
答案:
In other programming languages, shell functions are much like subroutines, procedures, and functions. The syntax for declaring a function is as follows:
在其他编程语言中,shell 函数很像子程序、过程和函数。声明函数的语法如下:
function_name ()
function_name ()
{
list of commands
命令列表
}
Function_name is the name of your function, and that's what you'll use to call it from anywhere in your script. The function name must be followed by parentheses, then a list of commands enclosed in braces.
Function_name 是您的函数名称,您将使用它从脚本中的任何位置调用该函数。函数名后必须跟括号,然后是包含在大括号中的命令列表。
Example:
示例:
The following example shows how function can be used:
以下示例展示了函数的使用方法:
!/bin/sh
Define your function here
Hello ()
Hello ()
{
echo "Hello World"
echo "Hello World"
}
Invoke your function
Hello
Hello
The following output will be displayed after execution:
执行后将显示以下输出:
$./test.sh
$./test.sh
Hello World
Hello World
733. How to use pipe commands?
如何使用管道命令?
- 知识点: 操作系统与网络 (主题: shell, linux, scripting;标签: interviewbit, shell-scripting, topic-specific, shell, linux, scripting)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5058d557c902bc7535 | 官方: 否 | 付费: 否
答案:
Pipe command allows you to use several commands in the same way, in which the output of one is used as input for another. Like a pipeline, each process output is directly input to the next one. A pipe is represented by the symbol "|". The flow of data through a pipeline is unidirectional, i.e., from left to right.
管道命令允许你以相同的方式使用多个命令,其中一个命令的输出用作另一个命令的输入。如同管道一样,每个进程的输出直接输入到下一个进程。管道用符号“|”表示。通过管道的数据流是单向的,即从左到右。
Syntax :
语法:
command_1 | command_2 | command_3 | .... | command_N
命令_1 | 命令_2 | 命令_3 | .... | 命令_N
Conclusion
结论
You can automate a lot of repetitive manual tasks with shell scripting, which is an easy and powerful programming method. Modern programming languages offer many of the features that make them appealing to programmers. DevOps engineers and automation testers often find this concept vital in preparing for interviews. Shell scripting allows the development of simple to complex scripts. A number of daily tasks can be automated using shell scripting as well. We thought of making your job easier by putting together an ensemble of the most frequently asked interview questions and sample answers on shell scripting. These interview questions will definitely help you understand that shell is basically an interface between the user and the operating system, which interprets user commands to be executed by the kernel or operating system.
通过Shell脚本,你可以自动化许多重复的手动任务,这是一种简单而强大的编程方法。现代编程语言提供了许多使其对程序员有吸引力的特性。DevOps工程师和自动化测试人员常常发现这一概念在面试准备中至关重要。Shell脚本允许开发从简单到复杂的脚本。许多日常任务也可以通过Shell脚本实现自动化。我们希望通过汇集一些最常被问及的Shell脚本面试问题和样本答案,让你的工作更轻松。这些面试问题肯定会帮助你理解,Shell基本上是用户与操作系统之间的接口,它解释用户命令,由内核或操作系统执行。
Useful Resources:
有用资源:
Unix Interview
Unix面试
Automation Testing Interview
自动化测试面试
Devops Interview
DevOps面试
734. What is Concurrency?
什么是并发?
- 知识点: 操作系统与网络 (主题: software-engineering;标签: interviewbit, software-engineering, topic-specific)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c5558d557c902bc77c8 | 官方: 否 | 付费: 否
答案:
In software engineering, concurrency refers to a set of techniques and mechanisms that allow the software to do many tasks at the same time. Concurrency can be achieved by using languages like C++ or Java because these languages support the concept of thread. New hardware and software features are required to achieve concurrency.
在软件工程中,并发是指一组允许软件同时执行多项任务的技术和机制。并发可以通过使用C++或Java等语言来实现,因为这些语言支持线程的概念。实现并发需要新的硬件和软件特性。
735. What is the best automation software available for Windows?
Windows上最好的自动化软件是什么?
- 知识点: 操作系统与网络 (主题: system-engineer;标签: interviewbit, system-engineer, topic-specific)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c6758d557c902bc8352 | 官方: 否 | 付费: 否
答案:
Good automation software is a must-have for anyone looking to improve their productivity or to do away with tedious and boring routines. The following is a list of the best free automation software available for Windows 10/11. - RoboTask
对于任何希望提高生产力或摆脱繁琐枯燥的日常事务的人来说,好的自动化软件都是必备的。以下是为Windows 10/11提供的最佳免费自动化软件列表。 - RoboTask
- Pulover's Macro Creator
- AutoHotkey
- AutoIt
- TinyTask
- Easy Clicks Macros
- Macro Express
- WinAutomation
- JitBit Macro Recorder, etc.
736. I'm using Windows 10 and I'm getting a blank screen with the cursor visible. This occurs every time I log in and every time I update. So, what can I do now?
我使用的是Windows 10,登录时和更新时都会出现只有光标可见的空白屏幕。那么,现在我能做些什么呢?
- 知识点: 操作系统与网络 (主题: technical-support;标签: interviewbit, technical-support, topic-specific)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c7958d557c902bc8beb | 官方: 否 | 付费: 否
答案:
If the issue persists before logging in, try the instructions below: - To access the project menu, hold down the Windows key and press P. It's natural, however, that you won't be able to see anything.
如果在登录前问题仍然存在,请尝试以下说明: - 要访问投影菜单,请按住Windows键并按P。不过,您自然看不到任何内容。
- Press Enter after pressing the up and down arrows several times.
- You should be able to see your screen if it works; if not, retry this step a few more times.
If you're logging in with a password-protected account, press CTRL or space to input the password and push enter. You may need to go through a couple of trials before you finish.
If the above method does not work, follow the steps below to uninstall the graphic card driver. - Press alt+ctrl+del to open the Task Manager.如果上述方法不起作用,请按照以下步骤卸载显卡驱动程序。 - 按alt+ctrl+del打开任务管理器。
- Go to the file folder and then start a new task.
- Enter the command devmgmt.msc.
- Go to safe mode if you can't open the task manager.
- Hold down the Windows key and also the X key, then select Device Manager.
- Locate the graphic card, right-click it, and select Delete/Disable Driver Software from the menu.
- The dark screen should disappear after restarting your computer.
There are a few more steps you can take. In the device manager, you can turn off the onboard graphics. You can deactivate the dual monitor plus CPU Graphics Multi-Monitor in the BIOS. You could also try updating your BIOS or uninstalling the programs that are causing the issue. You could instead use HDMI rather than DVI to connect your display. Numerous different procedures can assist you in resolving the blank screen problem.
您还可以采取更多步骤。在设备管理器中,您可以关闭板载显卡。您可以在BIOS中停用双显示器加CPU图形多显示器。您还可以尝试更新BIOS或卸载导致问题的程序。您也可以使用HDMI而不是DVI连接显示器。多种不同的程序可以帮助您解决空白屏幕问题。
737. A customer complains about his missing DVD drive on Windows from the list of devices on My Computer. What solution would you suggest?
一位客户抱怨他的Windows系统中“我的电脑”设备列表里缺少DVD驱动器。您会建议什么解决方案?
- 知识点: 操作系统与网络 (主题: technical-support;标签: interviewbit, technical-support, topic-specific)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c7958d557c902bc8bf4 | 官方: 否 | 付费: 否
答案:
The following are the list of methods to fix this issue: - Drivers must be installed again: By heading to Start, Control Panel, System and Security, System, and then Device Manager, you can replace the drivers for the CD/DVD drive. Expand CD/DVD-ROM Drives, now right-click the device and select Uninstall from the drop-down menu. When you restart your computer, Windows should recognise the disc and reinstall the drivers automatically. If your hardware does not appear in Device Manager, you may have a hardware issue, such as a defective connection or a dead hard drive. If your computer is old, this is a good alternative to consider.
以下是解决此问题的方法列表: - 必须重新安装驱动程序:通过转到“开始”、“控制面板”、“系统和安全”、“系统”,然后进入“设备管理器”,您可以替换CD/DVD驱动器的驱动程序。展开“DVD/CD-ROM驱动器”,右键单击设备并从下拉菜单中选择“卸载”。当您重新启动计算机时,Windows应识别光盘并自动重新安装驱动程序。如果您的硬件未出现在设备管理器中,您可能遇到硬件问题,例如连接故障或硬盘损坏。如果您的计算机较旧,这是一个值得考虑的好选择。
- Examine the BIOS settings: If you were recently in the BIOS, double-check that the drive wasn't accidentally disabled. This is extremely uncommon, although it can happen in rare circumstances. This is particularly true if you entrusted your computer to others for repairs or other services. Make sure the CD/DVD ROM drive is at least listed as an option on the Boot options page.
- Upper/ Lower Filters Problem: If your Windows XP or Windows Vista system is unable to identify the CD/DVD drive, you may be experiencing a common issue that will not appear on any computer that has received the most recent Windows updates. To fix the problem with Windows XP and Vista, you must update two registry entries. You have the option of downloading the repair from Microsoft or doing it manually. You have to delete the upper filters and the lower filters and restart your device.
- Run the Troubleshooter for Hardware and Devices: If you're having trouble with Windows 7, try running the Hardware and Devices Troubleshooter. This will instantly diagnose the issue and attempt to fix it. This will most likely only work if the CD/DVD drive is visible in the BIOS and Device Manager, but not elsewhere in Windows. You have a hardware or connection issue if you don't see it in those two areas. By heading to Start, Control Panel, and then typing troubleshooter into the search box, you can start the troubleshooter. Select Troubleshooting from the drop-down menu. Finally, click Configure a device under Hardware and Sound. When you click Next, Windows will automatically detect and attempt to resolve any issues.
- Registry edit: If none of the above methods works, you might attempt editing a registry key that has been removed or corrupted.
- Drive letter: You should also double-check that the drive does have a drive letter assigned to this and that the letter hasn't already been occupied by another device. To see whether the drive letter is leading the drive to show up now, read my earlier post on how to alter drive letters in Windows.
- System Restore: If you're still having problems and your drive was showing up before but is now missing, you can try doing a system restore to a time since it was working properly. A new software package can sometimes corrupt your system, causing it to stop recognising your CD/DVD drive.
738. In Windows 10, network computers are not visible in Explorer. How would you go about resolving this?
在Windows 10中,网络计算机在资源管理器中不可见。您将如何解决此问题?
- 知识点: 操作系统与网络 (主题: technical-support;标签: interviewbit, technical-support, topic-specific)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c7958d557c902bc8c00 | 官方: 否 | 付费: 否
答案:
Because the problem of not seeing all network machines in Windows 10 can occur for several reasons, I'll go over all of the possible solutions in this context.
由于在Windows 10中看不到所有网络机器的问题可能由多种原因引起,我将在此处介绍所有可能的解决方案。
Method 1: Configure the most recent version of Windows 10.
方法1:配置最新版本的Windows 10。
In Windows 10 versions 1709, 1803 & 1809, the issue "Network does not show machines" occurs. The issue has been resolved in the most recent Windows 10 versions. So, before trying the procedures below, upgrade your system to the most recent version of Windows 10 (1909).
在Windows 10版本1709、1803和1809中,会出现“网络不显示机器”的问题。该问题已在最新的Windows 10版本中得到解决。因此,在尝试以下操作之前,请将您的系统升级到Windows 10的最新版本(1909)。
Method 2: Using the IP Address to directly access the shares.
方法2:使用IP地址直接访问共享。
The next step is to type "\" and the static IP address of the computer hosting the shared folder in the explorer's address bar to resolve the issue(s). After you've accessed the shares, right-click on the shared folder and select Map a Network Drive to make it easier to access the folders at any time.
下一步是在资源管理器的地址栏中输入“\”和承载共享文件夹的计算机的静态IP地址来解决此问题。访问共享后,右键单击共享文件夹并选择“映射网络驱动器”,以便随时更轻松地访问文件夹。
Method 3: Make the necessary changes to the Network Discovery settings.
方法3:对网络发现设置进行必要的更改。
Modifying the network discovery settings and the "Function Discovery" services as below is the next step in viewing the other machines in your network: - STEP 1: ENABLE NETWORK DISCOVERY.
修改网络发现设置和“功能发现”服务如下所示,这是查看网络中其他机器的下一步: - 步骤1:启用网络发现。
- STEP 2: AUTOMATICALLY RUN THE REQUIRED SERVICES.
- Set the 'Startup type' of the following four services in the Windows Services panel as follows:
Function Discovery Provider Host (fdPHost) -> Automatic Function Discovery Resource Publication (FDResPub) -> Automatic Delayed Start SSDP Discovery > Manual -> Manual UPnP Device Host > Manual -> Manual
功能发现提供程序主机(fdPHost)-> 自动功能发现资源发布(FDResPub)-> 自动延迟启动 SSDP发现 > 手动 -> 手动 UPnP设备主机 > 手动 -> 手动
Method 4: Restart the Service of Function Discovery Resource Publication (FDResPub). - Restarting the FDResPub service is another way to fix the "Windows 10 not seeing network computers" problem. To do so, right-click on the Function Discovery Resource Publication service and select Restart from the menu that appears.
方法4:重启功能发现资源发布(FDResPub)服务。 - 重新启动FDResPub服务是解决“Windows 10看不到网络计算机”问题的另一种方法。为此,请右键单击“功能发现资源发布”服务,并从出现的菜单中选择“重新启动”。
Method 5: Remove the Function Discovery Resource Publication service's trigger. - Type the following command in Command Prompt as Administrator: sc triggerinfo FDResPub delete
方法5:删除函数发现资源发布服务的触发器。- 在管理员命令提示符中键入以下命令:sc triggerinfo FDResPub delete
Check to see whether you can see the network computers after restarting your computer.
Note: Type the following command to restore the removed trigger: sc triggerinfo FDResPub start/strcustom/fbcfac3f-8460-419f-8e48-1f0b49cdb85e/PROFILE_CHANGED_TO_PRIVATE注意:键入以下命令以恢复已删除的触发器:sc triggerinfo FDResPub start/strcustom/fbcfac3f-8460-419f-8e48-1f0b49cdb85e/PROFILE_CHANGED_TO_PRIVATE
Method 6: Enable support for SMB 1.0/CIFS file sharing. - If you still can't find the other computers on your network after using the aforementioned techniques, go ahead and enable the 'SMB 1.0/CIFS File Sharing Support' function.
方法6:启用SMB 1.0/CIFS文件共享支持。- 如果在使用上述技术后仍无法在网络中找到其他计算机,请继续并启用“SMB 1.0/CIFS文件共享支持”功能。
Note: Because SMB v1 isn't secure, Microsoft suggests mapping network drives rather than enabling it.
注意:由于SMB v1不安全,微软建议映射网络驱动器而不是启用它。
Method 7: In Windows 10 Pro, enable Remote Desktop.
方法7:在Windows 10专业版中,启用远程桌面。
This method is only applicable to Windows 10 Professional Editions. - In Windows Explorer, right-click on the This PC icon and choose Properties.
此方法仅适用于Windows 10专业版。- 在Windows资源管理器中,右键单击“此电脑”图标并选择“属性”。
On the left, select Remote Settings.
Note: In the most recent Windows 10 versions, select Remote Desktop from the left pane and then turn on the Remote Desktop switch on the right. Finally, press the Confirm button. - Choose Allow remote connections to this computer on the Remote tab, then Apply & OK.注意:在最新的Windows 10版本中,从左侧窗格选择“远程桌面”,然后打开右侧的“远程桌面”开关。最后,按“确认”按钮。- 在“远程”选项卡上选择“允许远程连接到此计算机”,然后应用并确定。
- Restart your computer.
739. How would you resolve DNS issues?
您如何解决DNS问题?
- 知识点: 操作系统与网络 (主题: troubleshooting;标签: interviewbit, troubleshooting, topic-specific)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c7f58d557c902bc8f15 | 官方: 否 | 付费: 否
答案:
Following are some ways to resolve DNS issues: - Check your cords and connections: If you're using wired connections, double-check that everything is correctly plugged in. If you're using a wireless network, ensure sure it's turned on and connected. Check to see if your router is turned on and working.
以下是解决DNS问题的一些方法:- 检查您的电缆和连接:如果您使用有线连接,请仔细检查所有连接是否正确插入。如果您使用无线网络,请确保其已打开并已连接。检查路由器是否已打开并正常工作。
- Rule out ISP problems: Make sure you're not having problems with your Internet service provider by attempting to link with another device. If you can directly connect to your ISP without going through the router, do so.
- Reboot your router: Turn it back on after a minute and wait till the indicator lights cease blinking before attempting to connect.
- Scan for malware: In some situations, a virus could be preventing you from accessing the internet. In this instance, you may have more pressing concerns to address before addressing IP connectivity.
- Examine your TCP/IP settings: These options control how your computer interacts with others. You could have recently updated these settings and attempted to manually enter them. Find "Manage network connections" in your computer's networking or control panel. Locate and tap on both IPv6 and IPv4 "Properties" under "Local Area Connections," "Properties." Make sure "Obtain an IP address automatically" and "Obtain DNS servers address automatically" are both checked.
- Clean out your DNS cache: Your computer's DNS cache is where it saves networking information from previous visits and efforts to connect to online sites. The cache can get corrupted as a result of incorrect data. Type ipconfig /flushdns into the command prompt to flush, or clear, this cache. The DNS cache will now have to update the DNS information the next time you visit a website.
- Obtain a new domain name: Is your website address functional but taking you to an unfamiliar site? It's most possible that you neglected to renew the domain name.If necessary, update and reinstall the network adapter driver: When was the last time you updated your drivers? This may be causing problems, especially if you've upgraded your PC's hardware since purchasing it. You can fix DNS problems by manually searching for network device driver updates and updating them.
- Switch to Google's public DNS servers: Google's servers are usually more dependable and may be utilised without going via your ISP. You can change your DNS servers to Google's by altering the following properties in your Internet Protocol Version 4 (TCP/IPv4).
740. An ADSL (Asymmetric Digital Subscriber Line) router connects a PC to the internet. The DNS server IP address is specified on the ADSL router. Is it necessary to configure the DNS server IP address on the computer to access the internet?
一个ADSL(非对称数字用户线路)路由器将PC连接到互联网。DNS服务器IP地址在ADSL路由器上指定。是否需要在计算机上配置DNS服务器IP地址才能访问互联网?
- 知识点: 操作系统与网络 (主题: troubleshooting;标签: interviewbit, troubleshooting, topic-specific)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c7f58d557c902bc8f1c | 官方: 否 | 付费: 否
答案:
It is necessary to configure the DNS server IP address on the machine. Take the case of a person who wants to visit a website. When a user starts a browser and types the website's URL name, a DNS resolution is required, in which the URL name is submitted to a DNS server. The PC must start the DNS request, which necessitates the configuration of the DNS server IP address on the PC. The DNS request will fail if the PC does not recognise the DNS server IP address, and internet access will be lost.
需要在机器上配置DNS服务器IP地址。以一个人想访问网站的情况为例。当用户启动浏览器并输入网站的URL名称时,需要进行DNS解析,其中URL名称被提交给DNS服务器。PC必须发起DNS请求,这需要在PC上配置DNS服务器IP地址。如果PC无法识别DNS服务器IP地址,DNS请求将失败,互联网访问将丢失。
741. Name the various commands that are used for the user information in UNIX.
说出UNIX中用于用户信息的各种命令。
- 知识点: 操作系统与网络 / 系统设计/架构 (主题: unix, systems;标签: interviewbit, unix, topic-specific, systems)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c8758d557c902bc92d0 | 官方: 否 | 付费: 否
答案:
The various commands that are used for displaying the user information in Unix are: - id: This displays the active user id with login and group.
在Unix中用于显示用户信息的各种命令是:- id:显示带有登录名和组的活动用户ID。
- last: This displays the last login of the user in the system.
- who: This determines who is logged onto the system.
- groupadd admin: This is used to add group ‘admin’.
- usermod –a: This is used to add an existing user to the group.
742. Explain Virtual memory
解释虚拟内存
- 知识点: 操作系统与网络 / 系统设计/架构 (主题: unix, systems;标签: interviewbit, unix, topic-specific, systems)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c8758d557c902bc92d3 | 官方: 否 | 付费: 否
答案:
Virtual Memory is a process or a system to address more memory than physically exists. The model consists of a set of memory pages, usually 4 KB each. There is a translation layer between virtual memory addresses and physical memory addresses. This translation layer is part of the kernel and is usually written in machine language(Assembly) to achieve optimal performance when translating and mapping addresses. Each time a user process accesses memory, the kernel uses the address translation layer to map the virtual memory address into a physical memory address. Virtual Addressing makes it possible to address larger amounts of memory than physically exist.
虚拟内存是一种处理或系统方式,用于寻址比物理存在更多的内存。该模型由一组内存页组成,通常每页4 KB。虚拟内存地址和物理内存地址之间存在一个转换层。该转换层是内核的一部分,通常用机器语言(汇编)编写,以在转换和映射地址时实现最佳性能。每次用户进程访问内存时,内核都会使用地址转换层将虚拟内存地址映射到物理内存地址。虚拟寻址使得能够寻址比物理存在更多的内存量。
743. Explain the kill() system call and its return values?
解释kill()系统调用及其返回值?
- 知识点: 操作系统与网络 / 系统设计/架构 (主题: unix, systems;标签: interviewbit, unix, topic-specific, systems)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c8758d557c902bc92d6 | 官方: 否 | 付费: 否
答案:
kill() system call sends signals to any process which further takes suitable action according to the signal. It takes two arguments, first is PID, to which you want to send a signal and the signal you want to send is second. This method returns the following return values: - 0 - means that the process exists with the given PID and the system allows sending signals to it.
kill()系统调用向任何进程发送信号,进程会根据信号采取相应操作。它接受两个参数,第一个是PID,即你想发送信号的进程;第二个是你想发送的信号。该方法返回以下返回值:- 0 - 表示具有给定PID的进程存在,且系统允许向其发送信号。
- -1 and errno==ESRCH - means that the process/process group with specified PID does not exist
- -1 and errno==EPERM - means that the sender has no permission to send a signal to the target process.
- EINVAL - means an invalid signal was specified.
744. Explain mount and unmount commands.
解释mount和unmount命令。
- 知识点: 操作系统与网络 / 系统设计/架构 (主题: unix, systems;标签: interviewbit, unix, topic-specific, systems)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c8758d557c902bc92d9 | 官方: 否 | 付费: 否
答案:
Mount: The mount command mounts a storage device or file system onto an existing directory making it accessible to users.
Mount:mount命令将存储设备或文件系统挂载到现有目录上,使其对用户可访问。
Unmount: This unmount command detaches the mounted file system safely. It also informs the system of any pending read and write operations.
Unmount:unmount命令安全地分离已挂载的文件系统。它还会通知系统任何待处理的读写操作。
745. Can you explain a little bit about command substitution?
你能稍微解释一下命令替换吗?
- 知识点: 操作系统与网络 / 系统设计/架构 (主题: unix, systems;标签: interviewbit, unix, topic-specific, systems)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c8758d557c902bc92dc | 官方: 否 | 付费: 否
答案:
Command substitution is a method by which the command is substituted by its output. We can use this to assign the output to a variable.
命令替换是一种将命令替换为其输出的方法。我们可以使用它来将输出赋值给变量。
$ DATE=date
$ echo "Date is $DATE"
Date is Thu May 27 03:59:57 IST 2021
日期是2021年5月27日星期四03:59:57 IST
746. What is the difference between ps -ef and ps -auxwww?
ps -ef和ps -auxwww之间有什么区别?
- 知识点: 操作系统与网络 / 系统设计/架构 (主题: unix, systems;标签: interviewbit, unix, topic-specific, systems)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c8758d557c902bc92df | 官方: 否 | 付费: 否
答案:
ps -ef will not list the processes with a very long command line while ps -auxwww will list those processes as well. This sometimes helps in debugging as we do not always want to list all the processes but if we are not getting any idea we should switch to the ps -auxwww command.
ps -ef不会列出命令行很长的进程,而ps -auxwww也会列出这些进程。这在调试时有时很有帮助,因为我们并不总是想列出所有进程,但如果得不到任何线索,我们应该切换到ps -auxwww命令。
747. What is the Zombie process in UNIX? How do you find the Zombie process?
UNIX中的僵尸进程是什么?如何找到僵尸进程?
- 知识点: 操作系统与网络 / 系统设计/架构 (主题: unix, systems;标签: interviewbit, unix, topic-specific, systems)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c8758d557c902bc92e6 | 官方: 否 | 付费: 否
答案:
Zombie processes are those child processes that get finished before the parent process. So after finishing up, the process structure and address space are removed and freed back to the system but the entry in the process table still exists. To be able to get the status of the child process the parent calls wait(). In the interval between the child terminating and the parent calling wait(), the child is said to be a 'zombie'.
僵尸进程是在父进程之前完成的那些子进程。因此完成后,进程结构和地址空间被移除并释放回系统,但进程表中的条目仍然存在。为了能够获取子进程的状态,父进程调用wait()。在子进程终止和父进程调用wait()之间的间隔内,该子进程被称为“僵尸”。
748. You have an IP address in your network, how will you find the hostname and vice versa?
你的网络中有一个IP地址,你如何找到主机名,反之亦然?
- 知识点: 操作系统与网络 / 系统设计/架构 (主题: unix, systems;标签: interviewbit, unix, topic-specific, systems)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c8758d557c902bc92e9 | 官方: 否 | 付费: 否
答案:
nslookup command is used to query internet domain name servers which can be used to find hostname from an IP address and for reverse lookup also, Similarly host command can also be used.
nslookup命令用于查询互联网域名服务器,可用于从IP地址查找主机名,也可用于反向查找。同样,host命令也可以使用。
749. Explain system bootup in UNIX.
解释UNIX中的系统启动过程。
- 知识点: 操作系统与网络 / 系统设计/架构 (主题: unix, systems;标签: interviewbit, unix, topic-specific, systems)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c8758d557c902bc92ec | 官方: 否 | 付费: 否
答案:
It is the first thing when the system starts. It has majorly 5 phases - Hardware - BIOS fired up and checks for the hardware connection
这是系统启动时的第一件事。它主要有5个阶段 - 硬件 - BIOS启动并检查硬件连接。
- Operating System Loader - The OS loader is located in the initial 512-byte block of the boot device known as the MBR
- Kernel - It initializes various components of the computer, operating system and each portion of software responsible for task, usually consider a driver
- root user-space process (init and inittab) - This defines what should be run when the /sbin/init program is instructed to enter a particular run-level, giving the administrator an easy way to establish an environment for some usage
- Boot scripts - For each managed service (mail, nfs server, cron, etc.), there is a single startup script located in a specific directory.
750. What are different classes of jobs?
不同类别的作业有哪些?
- 知识点: 操作系统与网络 / 系统设计/架构 (主题: unix, systems;标签: interviewbit, unix, topic-specific, systems)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c8758d557c902bc92ef | 官方: 否 | 付费: 否
答案:
The UNIX operating system job scheduler provides three different types of job classes - Time-share Job Class - This is the default job class and has priority 0 through 59, with 59 being the highest priority. In this job class, each process is assigned a time slice where the time slice specifies the number of CPU clock ticks that a particular task can occupy. Once the process finishes its time slice, the process is placed on the sleep queue, and the priority decreases.
UNIX 操作系统作业调度器提供三种不同类型的作业类别 - 分时作业类别 - 这是默认的作业类别,优先级为 0 到 59,其中 59 是最高优先级。在此作业类别中,每个进程被分配一个时间片,时间片指定特定任务可以占用的 CPU 时钟滴答数。一旦进程完成其时间片,该进程会被置于睡眠队列,并且优先级降低。
- System Job Class - This class is reserved for system daemon processes. The priority range for the system job class is between 60 and 99. These are of higher priority than the time-share job class. This is to ensure that the system can provide services to the time-share job class processes when system services such as memory, and/or file I/O are requested.
- Real-Time Job Class - This is the highest priority job class and has no time slice. Real-time process priorities range between 100 and 159. This ensures that critical processes always acquire the CPU as soon as the process is scheduled to run. Because there is no time slice the number of context switches is reduced significantly.
751. What are the various IDs in UNIX processes?
UNIX 进程中有哪些不同的 ID?
- 知识点: 操作系统与网络 / 系统设计/架构 (主题: unix, systems;标签: interviewbit, unix, topic-specific, systems)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: fullstack
- id: 69b37c8758d557c902bc92f2 | 官方: 否 | 付费: 否
答案:
There are 3 ids associated with the Unix process: - PID - Process Id, which is unique in the range of 0 to 3000.
Unix 进程关联有 3 个 ID: - PID - 进程 ID,在 0 到 3000 范围内是唯一的。
- PPID - Parent process id
PGID - Process group id, which is used to group processes together.
getppid() retrieves the Parent Process ID, getpid() retrieves the Process ID and getpgrp() retrieves the process group ID. The process also has a real user ID (the UID), an effective user ID (the EUID), a real user group ID (the GID), and an effective user group ID (the EGID).getppid() 获取父进程 ID,getpid() 获取进程 ID,getpgrp() 获取进程组 ID。进程还具有真实用户 ID(UID)、有效用户 ID(EUID)、真实用户组 ID(GID)和有效用户组 ID(EGID)。
评论