Unix Flashcards

1
Q

Specify the difference between absolute path and related path.

A

Absolute path refers to the exact path as defined from the root directory.

Related path refers to the path related to the current locations.

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

What are the main features of UNIX?

A
Machine independent
Portability
Multi-user operations
Unix Shells
Hierarchical file system
Pipes and filters
Background processors
Utilities
Development tools.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is called Shell?

A

The interface between user and system called a shell. Shell accepts commands and set them to execute for user operations.

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

What are the responsibilities of a shell?

A
Program Execution
Input/output redirection
Filename and variable substitution
Pipeline hookup
Environment control
Integrated programming language
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the UNIX command to list files/folders in alphabetical order?

A

The ‘ls –l’ command is used to list down files and folders in alphabetical order. When you use ‘ls –lt’ is list down files /folders sorted with modified time.

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

Describe links and symbolic links in UNIX?

A

Links are defined as a second name which is used to assign more than one name to a file. Although links are referred to as a pointer to another file it cannot be used to link filenames on different computers.

A Symbolic link is also known as the soft link is defined as a special type of file that contains links or references to another file or directory in the form of absolute or relative path. It does not contain the data actually in the target file but the pointer to another entry in the file system. Symbolic links can also be used to create a file system.

The following command is used to create a symbolic link:

Ln –s target link_name

Here, path is ‘target’
Name of the link is represented by link_name.

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

What is the FIFO?

A

FIFO (First In First Out) is also called named pipes and it is a special file for date transient. Data is read only in the written order. This is use to inter-process communications, where data write to one end and reads from another end of the pipe.

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

Describe fork() system call?

A

The command use to create a new process from an existing process is called fork().The main process is called parent process and new process id called child process. The parent gets the child process id returned and the child gets 0. The returned values are used to check which process which code executed.

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

‘It is not advisable to use root as the default login.’ Explain.

A

The root account is very important and it can leads to system damage easily with abusive usage. So that the securities that normally apply to user accounts are not applicable to the root account.

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

What is mean by Super User?

A

The user with access to all files and commands within the system is called super user. Generally, super user login is to root and the login is secured with the root password.

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

What is process group?

A

A collection of one or more processes is called process group. There is a unique process id for each process group. The function “getpgrp” returns the process group ID for the calling process. The group of processes associated with a call

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

What is the behavioral difference between “cmp” and “diff” commands?

A

Ans) Both commands for file comparison.

Cmp – Compare given two files with byte by byte and display the first mismatch.

Diff – Display changes that need to done to make both file identical.

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

What are the duties of following commands?chmod, chown, chgrp

A

chmod – Change the permission set of the file.
chown – Change ownership of the file.
chgrp – Change group of the file.

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

How to display the last line of a file?

A

This can perform using either “tail” or “sed” commands. The easiest way is to use “tail” command.

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

What are the various IDs in UNIX processes?

A

Process ID is a unique integer that UNIX uses to identify each process. The process executes to initiate other processes is called parent process and its ID is defined as PPID (Parent Process ID).

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

Who can kill a process?

A

Owner or process or root.

Every process is associated with a specific owner of the process. The owner has all the privileges over the process and is the user who executed the process.
Identification for a user is User ID. The process also associated with Effective User ID which determines the access privileges to accessing resources like files.

getpid() – Retrieve process id
getuid() – Retrieve user id
geteuid() – Retrieve effective user id

17
Q

What is the command to find maximum memory taking process on the server?

A

top or htop

18
Q

What is the command to find hidden files in the current directory?

A

‘ls –lrta’ is to display hidden files in current directory.

19
Q

What is the command to find the currently running process in Unix Server?

A

“ps –ef” command is used to find current running process. Also “grep” with a pipe can use to find specific process.

20
Q

What is the command to find remaining disk space in UNIX server?

A

The command “df -kl” use to get a detail description on disk space usage.

21
Q

What is the method to see command line history?

A

The “history” command display all the command used previously within the session.

22
Q

Discuss the difference between swapping and paging?

A

Ans) Swapping – Complete process is moved to main memory for execution. To provide the memory requirement, process size must be less than the available main memory capacity. The implementation is easy but is an overhead to the system. Memory handling is not more flexible with swapping systems.

Paging – Only the required memory pages are moved to the main memory for execution. The size of the process does not a matter of execution and it no needs to be less than available memory size. Allow a number of processes to load to main memory simultaneously.

23
Q

What is the method to edit a large file without opening it in UNIX?

A

The “sed” command is available for this process ‘.sed’ stands for a team editor.

24
Q

What is called piping?

A

“piping” is used to combine two or more commands together. The output of the first command work as the input of the second command, and so on. Pipe character ( | ) is represent piping.

25
Q

What is the process to count the number of characters and line in a file?

A

“wc – c filename” command can use to retrieve the number of characters in a file and “wc –l filename” command can use to retrieve the number of lines in a file.

26
Q

What do understand by Kernel?

A

Unix operating system is basically divided into three parts, namely, the kernel, the shell and the commands and utilities. Kernel serves as the heart of the Unix operating system which does not deal directly with the user but rather act as a separate interactive program for users logged in.

It performs the following functions:

a) Interacts with the hardware
b) Perform tasks like memory management, file management and task scheduling.
c) Control computer resources
d) Help allotting resources to different tasks and users.

27
Q

Describe responsibilities of Shell in brief.

A

Apart from analyzing the input line as well as initiating the execution of the program entered by the user, Shell also serves various responsibilities.

Find below a brief description:

a) The shell is responsible for the execution of all the programs by analyzing the line and determining the steps to be performed and then initiate the execution of the selected program.
b) Shell allows you to assign values to the variables when specified on the command line. It also performs Filename substitution.
c) To take care of input and output redirection.
d) Performs pipeline hook-up by connecting the standard output from the command preceding the ‘|’ to the standard input of the one following ‘|’.
e) Provides certain commands to customize and control environment.
f) Has its own built-in integrated programming language which is typically easier to debug and modify.

28
Q

What is the role of the superuser?

A

There are basically three types of accounts in Unix operating system:

Root account
System accounts
User accounts

‘Root account’ is basically referred to as a ‘Super user’. This user has completely open access or says control on all files and commands on a system. This user can also be assumed as a system administrator and thus has the ability to run any command without any restriction. It is protected by the root password.

29
Q

Explain alias mechanism.

A

To avoid typing long commands or to improve efficiency, the alias command is used to assign another name to a command. Basically, it acts as a shortcut to the larger commands which can be typed and run instead.

For creating an alias in Unix, following command format is used:

alias name=’command you want to run’

Here, replace the ‘name’ with your shortcut command and replace ‘command you want to run’ with the larger command of which you want to create an alias of.

For example:

alias dir ‘Is –sFC’

here, in the above example ‘dir’ is the another name for the command ‘Is-sFC’. Thus user now simply is required to remember and use the specified alias name and the command will perform the same task as to be performed by the long command.

30
Q

What do you understand by terms ‘system calls’ and ‘library functions’ with respect to UNIX command?

A

System calls: As the name implies, system calls are defined as an interface which basically is used in the kernel itself. Although, they may not be fully portable but these calls request the operating system to perform tasks on behalf of user programs.

The system calls appear as a normal C function. Whenever a system call is invoked within the operating system, the application program performs context switch from user space to kernel space.

Library functions: The set of common functions that are not part of the kernel but is used by the application programs are known as ‘Library functions’. As compared to system calls, library functions are portable and can perform certain tasks only in ‘kernel mode’. Also, it takes lesser time for execution as compared to the execution of system calls.

31
Q

What do know about tee command and its usage?

A

‘tee’ command is basically used in connection with pipes and filters.

This command basically performs two tasks:

a) Get data from standard input and send it to the standard output.
b) Redirects a copy of the input data to the specified file.

32
Q

Stack vs. Heap

A

The stack and the heap are two different regions of memory your program can access. The main difference is how they’re managed.

The Stack is memory that’s managed (to some degree) for you. When you declare a variable from within a function the memory for that variable is allocated from the stack. This allows the memory to automatically be returned (deallocated) when the function returns.

The heap is memory that is NOT managed for you**. When you malloc something (allocate memory block) you are taking a chunk of memory from the heap. It will last forever until you explicitly free it.

Important differences: each thread has its own stack, while the heap is available globally. The stack is also used for temporary variables, while the heap basically doesn’t unallocate unless you specifically do so (failing to do so is what memory leaks are, basically). The stack gets created and exited with its thread, the heap is allocated at application startup, and is reclaimed by the OS when the program exits.