January 22, 2019

Srikaanth

Linux Latest Most Frequently Asked Interview Questions Answers

What Does Nslookup Do? Explain Its Two Modes.

Nslookup is used to find details related to a Domain name server. Details like IP addresses of a machine, MX records, servers etc. It sends a domain name query packet to the corresponding DNS.

Nslookup has two modes. Interactive and non interactive. Interactive mode allows the user to interact by querying information about different hosts and domains.

Non interactive mode is used to fetch information about the specified host or domain.

Interactive mode
Nslookup [options] [server]

What Is Bash Shell?

Bash is a free shell for UNIX. It is the default shell for most UNIX systems. It has a combination of the C and Korn shell features. Bash shell is not portable. any Bash-specific feature will not function on a system using the Bourne shell or one of its replacements, unless bash is installed as a secondary shell and the script begins with #!/bin/bash. It supports regular and expressions. When bash script starts, it executes commands of different scripts.

What Are Two Functions The Move Mv Command Can Carry Out?

The mv command moves files and can also be used to rename a file or directory.

What Does The Top Command Display?

Top provides an ongoing look at processor activity in real time.It displays a listing of the most CPU-intensive tasks on the system, and can provide an interactive inter¬ face for manipulating processes. (q is to quit)

How To Find Difference In Two Configuration Files On The Same Server?

Use diff command that is compare files line by line
diff -u /usr/home/my_project1/etc/ABC.conf /usr/home/my_project2/etc/ABC.conf

What Is The Best Way To See The End Of A Logfile.log File?

Use tail command - output the last part of files
tail -n file_name ( the last N lines, instead of the last 10 as default)

Please Write A Loop For Removing All Files In The Current Directory That Contains A Word 'log'?

for i in *log*; do rm $i; done

How To Switch To A Previously Used Directory?

cd -

What Are The Process States In Linux?

Process states in Linux
Running: Process is either running or ready to run.

Interruptible: a Blocked state of a process and waiting for an event or signal from another process.

Uninterruptible:- a blocked state. Process waits for a hardware condition and cannot handle any signal.

Stopped: Process is stopped or halted and can be restarted by some other process.

Zombie: process terminated, but information is still there in the process table.
Linux Latest Most Frequently Asked Interview Questions Answers
Linux Latest Most Frequently Asked Interview Questions Answers

What Is A Zombie?


Zombie is a process state when the child dies before the parent process. In this case the structural information of the process is still in the process table. Since this process is not alive, it cannot react to signals. Zombie state can finish when the parent dies. All resources of the zombie state process are cleared by the kernel.

Explain Each System Calls Used For Process Management In Linux.

System calls used for Process management
Fork () :- Used to create a new process
Exec() :- Execute a new program
Wait():- wait until the process finishes execution
Exit():- Exit from the process
Getpid():- get the unique process id of the process
Getppid():- get the parent process unique id
Nice():- to bias the existing property of process

How Do You List Files In A Directory?

ls - list directory contents
ls -l (-l use a long listing format)

How Do You List All Files In A Directory, Including The Hidden Files?

ls -a (-a, do not hide entries starting with .)

How Do You Find Out All Processes That Are Currently Running?

ps -f (-f does full-format listing.)

How Do You Find Out The Processes That Are Currently Running Or A Particular User?

ps -au Myname (-u by effective user ID (supports names)) (a - all users)

How Do You Kill A Process?

kill -9 8 (process_id 8) or kill -9 %7 (job number 7)
kill -9 -1 (Kill all processes you can kill.)
killall - kill processes by name most (useful - killall java)

What Would You Use To Edit Contents Of The File?

vi screen editor or jedit, nedit or ex line editor

What Would You Use To View Contents Of A Large Error Log File?

tail -10 file_name ( last 10 rows)

How Do You Log In To A Remote Unix Box?

Using telnet server_name or ssh -l ( ssh - OpenSSH SSH client (remote login program))

How Do You Get Help On A Unix Terminal?

man command_name
info command_name (more information)

How Do You List Contents Of A Directory Including All Of Its Subdirectories, Providing Full Details And Sorted By Modification Time?

ls -lac
-a all entries
-c by time

What Is A Filesystem?

Sum of all directories called file system.
A file system is the primary means of file storage in UNIX. File systems are made of inodes and superblocks.

How Do You Get Its Usage (a Filesystem)?

By storing and manipulate files.

How Do You Check For Processes Started By User 'pat'?

ps -fu pat (-f -full_format u -user_name )

How Do You Start A Job On Background?

bg %4 (job 4)

What Utility Would You Use To Replace A String '2001' For '2002' In A Text File?

Grep, Kde( works on Linux and Unix)

What Utility Would You Use To Cut Off The First Column In A Text File?

awk, kde

How To Copy File Into Directory?

cp /tmp/file_name . (dot mean in the current directory)

How To Remove Directory With Files?

rm -rf directory_name

What Is Linux Shell?

Linux shell is a user interface used for executing the commands. Shell is a program the user uses for executing the commands. In UNIX, any program can be the users shell. Shell categories in Linux are
Bourne shell compatible, C shell compatible, nontraditional, and historical.

What Is Shell Script?

A shell script, as the name suggests, is a script written for the shell. Script here means a programming language used to control the application. The shell script allows different commands entered in the shell to be executed. Shell script is easy to debug, quicker as compared to writing big programs. However the execution speed is slow because it launches a new process for every shell command executed. Examples of commands are cp, cn, cd.

What Is Kernel? Explain The Task It Performs.

Kernel is used in UNIX like systems and is considered to be the heart of the operating system. It is responsible for communication between hardware and software components. It is primarily used for managing the systems resources as well.

Kernel Activities

The Kernel task manager allows tasks to run concurrently.

Managing the computer resources: Kernel allows the other programs to run and use the resources.

Resources include i/o devices, CPU, memory.

Kernel is responsible for Process management. It allows multiple processes to run simultaneously allowing user to multitask.

Kernel has an access to the systems memory and allows the processes to access the memory when required.

Processes may also need to access the devices attached to the system. Kernel assists the processes in doing so.

For the processes to access and make use of these services, system calls are used.

What Are Pipes?

A pipe is a chain of processes so that output of one process (stdout) is fed an input (stdin) to another. UNIX shell has a special syntax for creation of pipelines. The commands are written in sequence separated by |. Different filters are used for Pipes like AWK, GREP.
e.g. sort file | lpr ( sort the file and send it to printer)

Explain Trap Command; Shift Command, Getopts Command Of Linux

Trap command: controls the action to be taken by the shell when a signal is received.
Trap [OPTIONS] [ [arg] signspec..]
Arg is the action to be taken or executed on receiving a signal specified in signspec.
e.g. trap “rm $FILE; exit” // exit (signal) and remove file (action).

Shift Command: Using shift command, command line arguments can be accessed. The command causes the positional parameters shift to the left. Shift [n] where n defaults to 1. It is useful when several parameters need to be tested.

Getopts command: this command is used to parse arguments passed. It examines the next command line argument and determines whether it is a valid option.

Getopts {optstring} {variable1}. Here, optsring contains letters to be recognized if a letter is followed by a colon, an argument should be specified. E.g (whether the argument begins with a minus sign and is followed by any single letter contained inside options ) If not, diagnostic messages are shown. It is usually executed inside a loop.

Where Is Standard Output Usually Directed?

By default, your shell directs standard output to your screen or display.

What Is The Difference Between Ctrl-c And Ctrl-z?

When you have a process in progress which handle your prompt, there are some signals (orders) that we can send to theses process to indicate what we need

Control+C sends SIGINT which will interrupt the application. Usually causing it to abort, but a process is able to intercept this signal and do whatever it likes: for instance, from your Bash prompt, try hitting Ctrl-C. In Bash, it just cancels whatever you've typed and gives you a blank prompt (as opposed to quitting Bash)

Control+Z sends SIGTSTP to a foreground application, effectively putting it in the background on suspended mode. This is very useful when you want the application to continue its process while you are doing another job in the current shell. When you finish the job, you can go back into the application by running fg (or %x where x is the job number as shown in jobs).

I Want To Troubleshoot My Network But I Don’t Know How Does The Traceroute Command Work Exactly?

Traceroute is a program that shows you the route taken by packets through a network. It traces the route of packets from source to destination. It is commonly used when your network doesn’t work as well and you want to examine where can be the problem. Traceroute sends a UDP packet to the destination taking advantage of ICMP’s messages. ICMP has two types of messages: error-reporting messages and query messages. Query messages are generally used to diagnose network problems (the ping tool uses ICMP’s query messages). The error-reporting messages as the name suggest report errors if any in the IP packet; it uses Destination unreachable and Time exceeded errors message. It works by theses steps

Traceroute creates a UDP packet from the source to destination with a TTL(Time-to-live) = 1
The UDP packet reaches the first router where the router decrements the value of TTL by 1, thus making our UDP packet’s TTL = 0 and hence the packet gets dropped.
Noticing that the packet got dropped, it sends an ICMP message (Time exceeded) back to the source.
Traceroute makes a note of the router’s address and the time taken for the round-trip.
It sends two more packets in the same way to get an average value of the round-trip time. Usually, the first round-trip takes longer than the other two due to the delay in ARP finding the physical address, the address stays in the ARP cache during the second and the third time and hence the process speeds up.

The steps that have occurred up til now, occur again and again until the destination has been reached. The only change that happens is that the TTL is incremented by 1 when the UDP packet is to be sent to next router/host.
Once the destination is reached, Time exceeded ICMP message is NOT sent back this time because the destination has already been reached.
But, the UDP packet used by Traceroute specifies the destination port number to be one that is not usually used for UDP. Hence, when the destination computer verifies the headers of the UDP packet, the packet gets dropped due to the improper port being used and an ICMP message (this time – Destination Unreachable) is sent back to the source.
When Traceroute encounters this message, it understands that the destination has been reached. Even the destination is reached 3 times to get the average of the round-trip time.

What Stateless Linux Server? What Feature It Offers?

A stateless Linux server is a centralized server in which no state exists on the single workstations. There may be scenarios when a state of a partilcuar system is meaningful (A snap shot is taken then) and the user wants all the other machines to be in that state. This is where the stateless Linux server comes into picture.

Features
It stores the prototypes of every machine.
It stores snapshots taken for those systems.
It stores home directories for those system.

Uses LDAP containing information of all systems to assist in finding out which snapshot (of state) should be running on which system.

What Is The Difference Between Internal And External Commands?

Internal commands are stored in the; same level as the operating system while external commands are stored on the hard disk among the other utility programs.

List The Three Main Parts Of An Operating System Command

The three main parts are the command, options and arguments.

What Is The Difference Between An Argument And An Option (or Switch)?

An argument is what the command should act on: it could be a filename, directory or name. An option is specified when you want to request additional information over and above the basic information each command supplies.

What Is The Purpose Of Online Help?

Online help provides information on each operating system command, the syntax, the options, the arguments with descriptive information.

Name Two Forms Of Security.

Two forms of security are Passwords and File Security with permissions specified.

What Command Do You Type To Find Help About The Command Who?

$ man who

What Is The Difference Between Home Directory And Working Directory?

Home directory is the directory you begin at when you log into the system. Working directory can be anywhere on the system and it is where you are currently working.

Which Directory Is Closer To The Top Of The File System Tree, Parent Directory Or Current Directory?

The parent directory is above the current directory, so it is closer to the root or top of the file system.

What Are Two Subtle Differences In Using The More And The Pg Commands?

With the more command you display another screenful by pressing the spacebar, with pg you press the return key.

The more command returns you automatically to the UNIX shell when completed, while pg waits until you press return.

When Is It Better To Use The More Command Rather Than Cat Command?

It is sometimes better to use the more command when you are viewing a file that will display over one screen.

How Many Vi Editor Modes Do You Know?

Three modes -
Command mode: letters or sequence of letters interactively command vi.
Insert mode: Text is inserted.
Command line mode: enter this mode by typing ":" and entry command line at the foot of the screen.

How Can You Terminate Vi Session?

Use command: ZZ that is save changes and quit.
Use command line: ":wq" that is write changes and quit.
Use command line: ":q!" to ignore changes and quit.

How Can You Copy Lines Into The Buffer In Command Mode?

yy - copy a single line defined by current cursor position
3yy - copy 3 lines. Current line and two lines below it.

We Saw The Mention On The Linux Bios Website About One Million Devices Shipped With Linux Bios. Could You Tell Us More About These Devices?

Yes, these are internet terminals that were built in India, based on the [x86 system-on-chip] STPC chip, I am told; also, there evidently is a Turkish-built digital TV that runs Linux BIOS. I have also heard that there are routers and many other embedded devices running Linux BIOS. I think at this point that 1 million is a low number. I am in contact with other set-top box vendors that are talking about numbers in the lOs of millions for their products. These numbers actually make the OLPC numbers seem small, which is in it amazing.

What's Your Goal For Your Talk At Fosdem?

I’d like to communicate the basic ideas — that Linux is a good BIOS, and why; why Linux BIOS is built the way it is; where we are going; and how people can help. Most importantly, why it all matters — and it really matters a lot. We’re on the verge of losing control of the systems we buy, and we need to make a conscious effort, as a community, to ensure this loss of control does not happen. That effort will not be without some sacrifice, but if we are to maintain our ability to use and program our machines, and have fun with them, we have to act now. Because, if the computing business stops being fun, what’s the point$

What Are Mysql Transactions?

A set of instructions/queries that should be executed or rolled back as a single atomic unit.

Explain Multi-version Concurrency Control In Mysql?

Each row has two additional columns associated with it - creation time and deletion time, but instead of storing timestamps, MySQL stores version numbers.

Name Two Methods You Could Use To Rename A File?

Two methods that could be used
a. use the mv command
b. copy the file and give it a new name and then remove the original file if no longer needed.

List All The Files Beginning With A?

To list all the files beginning with A command: ls A*

Which Of The Quoting Or Escape Characters Allows The Dollar Sign ($) To Retain Its Special Meaning?

The double quote (") allows the dollar sign ($) to retain its special meaning. Both the backslash (\) and single quote (') would remove the special meaning of the dollar sign.

What Is A Faster Way To Do The Same Command? Mv Fileo.txt Newdir Mv Filel.txt Newdir Mv File2.txt Newdir Mv File3.txt Newdir?

A shortcut method would be: mv file?.txt newdir

List Two Ways To Create A New File

a.Copy a file to make a new file.
b. Use the output operator e.g. ls -l > newfile.txt

What Is The Difference Between > And >> Operators?

The operator > either overwrites the existing file (WITHOUT WARNING) or creates a new file.
The operator >> either adds the new contents to the end of an existing file or creates a new file.

How Can You See All Mounted Drives?

mount -l

How Can You Find A Path To The File In The System?

locate file_name (locate - list files in databases that match a pattern)

What Linux Hotkeys Do You Know?

Ctrl-Alt-F1 Exit to command prompt
Ctrl-Alt-F7 or F8 Takes you back to KDE desktop from command prompt
Crtl-Alt-Backspace Restart XWindows
Ctrl-Alt-D Show desktop

What Can You Tell About The Tar Command?

The tar program is an immensely useful archiving utility. It can combine an entire directory tree into one large file suitable for transferring or compression.

What Types Of Files You Know?

Files come in eight flavors
Normal files
Directories
Hard links
Symbolic links
Sockets
Named pipes
Character devices
Block devices

How You Will Uncompress The File?

Use tar command (The GNU version of the tar archiving utility)
tar -zxvf file_name.tar.gz

What Does Grep() Stand For?

General Regular Expression Parser.

Explain Mysql Locks.

Table-level locks allow the user to lock the entire table, page-level locks allow locking of certain portions of the tables (those portions are referred to as tables), row-level locks are the most granular and allow locking of specific rows.

Explain Mysql Architecture.

The front layer takes care of network connections and security authentications, the middle layer does the SQL query parsing, and then the query is handled off to the storage engine. A storage engine could be either a default one supplied with MySQL (MyISAM) or a commercial one supplied by a third-party vendor (ScaleDB, InnoDB, etc.)

List The Main Applications Of 8 Bit Microprocessors?

8 bit microprocessors are used in a variety of applications such as appliances automobiles ,industrial process and control applications.

What Is Nv-ram?

Nonvolatile Read Write Memory, also called Flash memory. It is also know as shadow RAM.

Can Rom Be Used As Stack?

ROM cannot be used as stack because it is not possible to write to ROM.

What Is Stack?

Stack is a portion of RAM used for saving the content of Program Counter and general purpose registers.

What Is Flag?

Flag is a flip-flop used to store the information about the status of a processor and the status of the instruction executed most recently .

Which Processor Structure Is Pipelined?

All x86 processors have pipelined structure.

What Is A Compiler?

Compiler is used to translate the high-level language program into machine code at a time. It doesn’t require special instruction to store in a memory, it stores automatically. The Execution time is less compared to Interpreter.

Differentiate Between Ram And Rom?

RAM: Read / Write memory, High Speed, Volatile Memory. ROM: Read only memory, Low Speed, Non Voliate Memory.

What Is A Microprocessor?

Microprocessor is a program-controlled device, which fetches the instructions from memory, decodes and executes the instructions. Most Micro Processor is single- chip devices.

What Command Would You Use To Create An Empty File Without Opening It To Edit It?

You use the touch command to create an empty file without needing to open it. s a and e point to invalid commands, though either of these might actually be aliased to point to a real command. s b and c utilize editors, and so do not satisfy the requirements of the . actually touch is used to change the timestamps of a file if its exits, otherwise a new file with current timestamps will be created.

What Do You Type To Stop A Hung Process That Resists The Standard Attempts To Shut It Down?

The kill command by itself tries to allow a process to exit cleanly. You type kill -9 PID, on the other hand, to abruptly stop a process that will not quit by any other means. Also, pressing CtrI+C works for many programs. 
s b and d are only valid in some contexts, and even in those contexts will not work on a hung process.

Which Two Commands Can You Use To Delete Directories?

You can use rmdir or rm -rf to delete a directory. a is incorrect, because the rm command without any specific flags will not delete a directory, it will only delete files. s d and e point to a non-existent command.

What Is Difference Between At And Cron?

Cron command is used to schedule the task daily at the same time repeatedly ,“at” command is used to schedule the task only once i.e. to run only one time.

Which Of The Following Tasks Cannot Be Accomplished With The Touch Command?

The touch command is usually used to modify either a file’s access or modification time. It can also be used to create a new file.

You Want To Copy The User's Home Directories To A New Location. Which Of The Following Commands Will Accomplish This?

The -r option tells the cp command to recurs the directories. The -P option retains the original permissions.

You Read An Article That Lists The Following Command: Dd If=/dev/fdo Bs=512 Of=/new What Does This Accomplish?

The dd command is a special copy command often used for floppy disks and tapes. The if= option specifies the source; the bs= is the block size; and the of= option is the output.

Which Transistor Is Used In Each Cell Of Eprom?

Floating .gate Avalanche Injection MOS (FAMOS) transistor is used in each cell of EPROM.

What Is Called .scratch Pad Of Computer.?

Cache Memory is scratch pad of computer.

Define Hcmos?

High-density n- type Complimentary Metal Oxide Silicon field effect transistor.

What Is 1st / 2nd / 3rd / 4th Generation Processor?

The processor made of PMOS I NMOS / HMOS I HCMOS technology is called 1st / 2nd / 3rd / 4th generation processor, and it is made up of 4 / 8 / 16 / 32 bits.

Why 8085 Processor Is Called An 8 Bit Processor?

Because 8085 processor has 8 bit ALU (Arithmetic Logic Review). Similarly 8086 processor has 16 bit ALU.

Give Examples For 8 I 16 / 32 Bit Microprocessor?

8-bit Processor - 8085 I Z80 / 6800; 16-bit Processor - 8086 / 68000 / Z8000; 32-bit Processor - 80386 I 80486.

You Attempt To Delete A File Called Sales.mem Using The Rm Command But The Command Fails. What Could Be The Problem?

In order to delete a file, you must have write rights to the directory containing the file.

You Want To Search For Sale And Sales. What Regular Expression Should You Use?

Use the asterick (*) to match to zero or more characters. The ‘$‘ matches to any one character so sale$ would not find sale.

You Want To Know How Many Lines In The Kickoff File Contains 'prize'. Which Of The Following Commands Will Produce The Desired Results?

Using the -c option with the grep command will show the total number of lines containing the specified pattern rather than displaying the lines containing the pattern.

You Want To Verify Which Lines In The File Kickoff Contain 'bob'. Which Of The Following Commands Will Accomplish This?

The -n option when used with sed prints only the lines containing the pattern. In this case, the pattern is ‘Bob’ and the file to be searched is kickoff.

You Have A File Called Docs.z But Do Not Know What It Is. What Is The Easiest Way To Look At The Contents Of The File?

The .Z extension indicates that this is a file that has been compressed using the compress utility. The zcat utility provides the ability to display the contents of a compressed file.

After Copying A File To A Floppy Disk, What Should You Do Before Removing The Disk?

If you do not unmount the floppy before removing it, the files on the floppy may become corrupted.

You Have Set Quotas For All Your Users But Half Of Your Users Are Using More Space Than They Have Been Allotted. Which Of The Following Could Be The Problem?

Quotas are set on a partition by partition basis. If your users have home directories on different partitions, you will need to configure quotas for each partition.

What Is The Real Mean Of Dhcp?

Dynamic addressing simplifies network administration because the s/w keeps track of IP addresses rather than requiring an administrator to manage the task. That means new computer can be added to the network without any risk of manually assigning unique IP address.

What Is Nfs? What Is Its Job?

NFS stands for Network File System. NFS enables filesystems physically residing on one computer system to be used by other computers in the network, appearing to users on the remote host as just another local disk.

In Linux Os, What Is The File Server?

The file server is a machine that shares its disk storage and files with other machines on the network.

What Are The Techniques That You Use To Handle The Collisions In Hash Tables?

We can use two major techniques to handle the collisions. They are open addressing and separate chaining. In open addressing, data items that hash to a full array cell are placed in another cell in the array. In separate chaining, each array element consists of a linked list. All data items hashing to a given array index are inserted in that list.

What Is The Major Advantage Of A Hash Table?

The major advantage of a hash table is its speed. Because the hash function is to take a range of key values and transform them into index values in such a way that the key values are distributed randomly across all the indices of a hash table.

What Is Write Command?

The write command enables you to write an actual message on the other terminal online. You have to issue the write command with the login ID of the user with whom you want to communicate. The write command informs the user at the other end that there is a message from another user. write pastes that message onto the other user’s terminal if their terminal’s write permissions are set. Even if they are in the middle of an edit session, write overwrites whatever is on the screen. The edit session contents are not corrupted; you can restore the original screen on most editors with Ctrl-L. write is mostly used for one-way communication, but you can have an actual conversation as well.

Why You Shouldn't Use The Root Login?

The root login does not restrict you in any way. When you log in as root, you become the system. The root login is also sometimes called the super user login. With one simple command, issued either on purpose or by accident, you can destroy your entire Linux installation. For this reason, use the root login only when necessary. Avoid experimenting with commands when you do log in as root.

How Big Should The Swap-space Partition Be?

Swap space is used as an extension of physical RAM, the more RAM you have, the less swap space is required. You can add the amount of swap space and the amount of RAM together to get the amount of RAM Linux will use. For example, if you have 8MB of RAM on your machine’s motherboard, and a 16MB swap-space partition, Linux will behave as though you had 24MB of total RAM.

What Command Should You Use To Check The Number Of Files And Disk Space Used And Each User's Defined Quotas?

The repquota command is used to get a report on the status of the quotas you have set including the amount of allocated space and amount of used space.

You Have A Large Spreadsheet Located In The /data Directory That Five Different People Need To Be Able To Change. How Can You Enable Each User To Edit The Spreadsheet From Their Individual Home Directories?

By creating a link to the file in each user’s home directory, each user is able to easily open and edit the spreadsheet. Also, any changes that are made are seen by all the users with access.

You Have A File Called Sales Data And Create Symbolic Links To It In Bob's Home Directory. Bob Calls You And Says That His Link No Longer Works. How Can You Fix The Link?

Because the link in bob’s directory is a symbolic link, if the file sales data in the /data directory is deleted, the symbolic link will no longer work.

What Is Meant By Sticky Bit?

When the sticky bit is set on a world writable directory, only the owner can delete any file contained in that directory.

Your Default Umask Is 002. What Does This Mean?

The digits of your umask represent owner, group and others in that order.
The 0 gives read and write for files and the 2 gives read only for files.

Which Of The Following Commands Will Replace All Occurrences Of The Word Rate With The Word Speed In The File Racing?

When using sed to do a search and replace, its default action is to only replace the first occurrence in each line. Adding the ‘g’ makes sed replace all occurrences of the search term even when it occurs multiple times on the same line.

You Have A Tab Delimited File Called Phonenos And Want To Change Each Tab To Four Spaces. What Command Can You Use To Accomplish This?

By default, expand converts tabs to eight spaces. Use the -t option to change this behavior.

You Issue The Command Head * What Would The Resulting Output Be?

If the number of lines to display is not specified, the first ten lines of the specified file are displayed. The asterick tells head to display the content of each file in the present working directory.

What Text Filter Can You Use To Display A Binary File In Octal Numbers?

The od text filter will dumpt the contents of a file and display it in 2-byte octal numbers.

What Would Be The Result Of The Command Paste -s Dog Cat?

The paste text filter usually joins two files separating the corresponding lines with a tab. The -s option, however, will cause paste to display the first file, dog, then a new line character, and then the file cat.

You Wish To Print The File Vacations With 60 Lines To A Page. Which Of The Following Commands Will Accomplish This?

The default page length when using pr is 66 lines. The -l option is used to specify a different length.

What Would Be The Result Of Issuing The Command Cat Phonenos?

The tac text filter is a reverse cat. It displays a file starting with the last line and ending with the first line.

You Need To See The Last Fifteen Lines Of The Files Dog, Cat And Horse. What Command Should You Use?

The tail utility displays the end of a file. The -15 tells tail to display the last fifteen lines of each specified file.

Which Field Is Used To Define The User's Default Shell?

command-The last field, called either command or login command, is used to specify what shell the user will use when he logs in.

When You Create A New Partition, You Need To Designate Its Size By Defining The Starting And Ending?

cylinders-When creating a new partition you must first specify its starting cylinder. You can then either specify its size or the ending cylinder.

What Can You Type At A Command Line To Determine Which Shell You Are Using?

echo $SHELL-The name and path to the shell you are using is saved to the SHELL environment variable. You can then use the echo command to print out the value of any variable by preceding the variable’s name with $. Therefore, typing echo $SHELL will display the name of your shell.

In Order To Display The Last Five Commands You Have Entered Using The Fc Command, You Would Type?

fc -5-The fc command can be used to edit or rerun commands you have previously entered. To specify the number of commands to list, use -n.

What Command Should You Use To Check Your File System?

fsck-The fsck command is used to check the integrity of the file system on your disk.

What File Defines The Levels Of Messages Written To System Log Files?

kernel.h-To determine the various levels of messages that are defined on your system, examine the kernel.h file.

What Account Is Created When You Install Linux?

root-Whenever you install Linux, only one user account is created. This is the super user account also known as root.

What Daemon Is Responsible For Tracking Events On Your System?

Syslogd-The syslogd daemon is responsible for tracking system information and saving it to specified log flies.

Where Standard Output Is Usually Directed?

To the screen or display-By default, your shell directs standard output to your screen or display.

What Utility Can You Use To Show A Dynamic Listing Of Running Processes?

Top-The top utility shows a listing of all running processes that is dynamically updated.

Who Owns The Data Dictionary?

The SYS user owns the data dictionary. The SYS and SYSTEM users are created when the database is created.

What Command Can You Use To Review Boot Messages?

dmesg
The dmesg command displays the system messages contained in the kernel ring buffer.
By using this command immediately after booting your computer, you will see the boot messages.

Nscd Sometimes Die Itself And Dns Resolving Doesn't Happen Properly. How Can We Avoid Nscd For Dns And There Is A Disadvantage To Bypass It?

nscd is a daemon that provides a cache for the most common name service requests. When resolving a user, group, host, service..., the process will first try to connect to the nscd socket (something like /var/run/nscd/socket).

If nscd has died, the connect will fail, and so nscd won't be used and that should not be a problem.

If it's in a hung state, then the connect may hang or succeed. If it succeeds the client will send its request (give IP address for www.google.com, passwd entries...). Now, you can configure nscd to disable caching for any type of database (for instance by having enable-cache hosts no in /etc/nscd.conf for the hosts database).

However, if nscd is in a hung state, it may not be able to even give that simple won't do , so that won't necessarily help. nscd is a caching daemon, it's meant to improve performance. Disabling it would potentially make those lookups slower. However, that's only true for some kind of databases. For instance, if user/service/group databases are only in small files (/etc/passwd, /etc/group, /etc/services), then using nscd for those will probably bring little benefit if any. nscd will be useful for the hosts database.

How Can I Redirect Both Stderr And Stdin At Once?

command > file.log 2>&1 : Redirect stderr to "where stdout is currently going". In this case, that is a file opened in append mode. In other words, the &1 reuses the file descriptor which stdout currently uses.

command 2>&1 | tee -a file.txt

What Is The Difference Between /dev/random And /dev/urandom To Generate Random Data?

The Random Number Generator gathers environmental noise from device drivers and other sources into entropy pool. It also keeps an estimate of Number of bits of noise in entropy pool. It is from this entropy pool, random numbers are generated.

/dev/random will only return Random bytes from entropy pool. If entropy pool is empty, reads to /dev/random will be blocked until additional environmental noise is gathered. This is suited to high-quality randomnesses, such as one-time pad or key generation.

/dev/urandom will return as many random bytes as requested. But if the entropy pool is empty, it will generate data using SHA, MD5 or any other algorithm. It never blocks the operation. Due to this, the values are vulnerable to theoretical cryptographic attack, though no known methods exist.

For cryptographic purposes, you should really use /dev/random because of nature of data it returns. Possible waiting should be considered as an acceptable tradeoff for the sake of security, IMO. When you need random data fast, you should use /dev/urandom of course.

Both /dev/urandom and /dev/random are using the exact same CSPRNG (a cryptographically secure pseudorandom number generator). They only differ in very few ways that have nothing to do with “true” randomness and /dev/urandom is the preferred source of cryptographic randomness on UNIX-like systems.

What Is The Difference Between Tar And Zip ?

Sometimes sysadmins Linux need to save data safety and to this, it is recommended to compress the data. We have some methods or commands for compression on Linux. So frequently asked s could be why should I use this command instead of another one example, why should I use tar instead of zip. To this, you should know the difference between the two.

tar is only an archiver whereas zip is an archiver and compressor. Tar uses gzip and bzip2 to achieve compression. With using tar command, we preserve metadata information of file and directories like seiuid, setgid and sticky bit information which are very important while zip doesn't preserve theses information. It is very important for criticals information. Other advantages of using tar is the fact that it assembles all the files into a single file to compress directly while zip compress file by file.

How To Check Open Ports On A Remote Server Without Netcat Or Nmap Linux Command?

In the work of sysadmin, we can sometimes want to check open ports on our remote server. But if we are on a machine where can not install nmap or we don't have the possibility to install a tool which can help us to check open ports, what could we do?

We can check it with bash using /dev/tcp or /dev/udp to open a TCP or UDP connection to the associated socket.

The command behavior is

$ echo > /dev/tcp/$host/$port

we can associate a message to display if the port is opened

$ echo > /etc/tcp/8.8.8.8/53 && echo "OPEN PORT"

OPEN PORT

$ echo > /dev/tcp/8.8.8.8/80 && echo "GOOD" || echo "NOT OPEN"

-bash: connect: Connection timed out

-bash: /dev/tcp/8.8.8.8/80: Connection timed out

NOT OPEN

Systemd Over Init System, What Do You Think?

Systemd is well designed. It was conceived from the top, not just to fix bugs, but to be a correct implementation of the base system services. A systemd, may refer to all the packages, utilities and libraries around daemon. It was designed to overcome the shortcomings of init. It itself is a background process which is designed to start processes in parallel, thus reducing the boot time and computational overhead. It has a lot other features as compared to init while Sysvinit was never designed to cope with the dynamic/event-based architecture of the current Linux kernel. The only reason why we still use it today is the cost of a migration.

Systemd ships a growing number of useful, unified command-line interfaces for system settings and control (timedatectl, bootctl, hostnamectl, loginctl, machinectl, kernel-install, localectl). In Debian, they use the existing configuration files without breaking compatibility.

Systemd makes the boot process much simpler, entirely removing the need to specify dependencies in many cases thanks to D-Bus activation, socket activation, file/inotify activation and udev integration.

Systemd supports SELinux integration while SysV doesn't

Systemd can handle the boot process from head to toe, without needing to use any of the existing shell scripts. Systemd extends the logging features of the system in many ways with journald, and can remain integrated with the existing rsyslog daemon. Logs are in a structured format, attributed to filename, line of code, PID and service. They include the early boot (starting from initramfs). They can be quickly filtered and programmatically accessed through an efficient interface.

Systemd unit files, unlike SysV scripts, can usually be shipped by upstream, or at least shared with other distributions (already more than 1000 existing unit files in Fedora) without any changes, the Debian specifics being handled by systemd itself.

Systemd is incredibly fast (1 second to boot). It was not designed with speed in mind, but doing things correctly avoids all the delays currently incurred by the boot process.

The transition plan is easy, since existing init scripts are treated as first-class services: scripts can depend (using LSB headers) on units, units can depend on scripts. More than 99% of init scripts can be used without a modification.

It is not just init. It unifies, in fewer lines of code, everything that is related to starting services and managing session groups: user login, cron jobs, network services (inetd), virtual TTY management… Having a single system to handle all of that allows us to remove a lot of cruft, and to use less memory on the system.

What Basics Measures Could You Take To Secure An Ssh Connection?

For Linux sysadmins, it is frequent to access servers by ssh. But are we sure the communication established is really good secured?

There some additionals very simple steps that can be taken to initially harden the SSH service, such as

Disabling root login, and even password-based logins will further reinforce the security of the server.
Disabling password-based logins and allow key based logins which are secured but can be taken further by restricting their use from only certain IP addresses.
Changing the standard port to something other significantly decreases random brute force attempts from the internet
Forcing the service to use only version 2 of the protocol will introduce both security and feature enhancement.
The whitelist approach can be taken, where only the users that belong to a certain list can log in via SSH to the server.

What Is Lvm And Does It Required On Linux Servers?

LVM is a logical volume manager. It requires to resize filesystem size. This size can be extended and reduced using lvextend and lvreduce commands respectively.  You can think of LVM as dynamic partitions, meaning that you can create/resize/delete LVM partitions from the command line while your Linux system is running: no need to reboot the system to make the kernel aware of the newly-created or resized partitions. LVM also provides

You can extend over more than one disk if you have more than one hard-disk. They are not limited by the size of one single disk, rather by the total aggregate size.

You can create a (read-only) snapshot of any LV (Logical Volume). You can revert the original LV to the snapshot at a later time, or delete the snapshot if you no longer need it. This is handy for server backups for instance (you cannot stop all your applications from writing, so you create a snapshot and backup the snapshot LV), but can also be used to provide a "safety net" before a critical system upgrade (clone the root partition, upgrade, revert if something went wrong).

you can also set up writeable snapshots too. It allows you to freeze an existing Logical Volume in time, at any moment, even while the system is running. You can continue to use the original volume normally, but the snapshot volume appears to be an image of the original, frozen in time at the moment you created it. You can use this to get a consistent filesystem image to back up, without shutting down the system. You can also use it to save the state of the system, so that you can later return to that state if you mess things up. You can even mount the snapshot volume and make changes to it, without affecting the original.

What Is The Minimum Number Of Partitions You Need To Install Linux?

2
Linux can be installed on two partitions, one as / which will contain all files and a swap partition.

What Is The Name And Path Of The Main System Log?

/var/log/messages

By default, the main system log is /var/log/messages.

What Utility Can You Use To Automate Rotation Of Logs?

logrotate

The logrotate command can be used to automate the rotation of various logs.

What Key Combination Can You Press To Suspend A Running Job And Place It In The Background?

ctrl-z

Using ctrl-z will suspend a job and put it in the background.

What Command Is Used To Remove The Password Assigned To A Group?

gpasswd -r

The gpasswd command is used to change the password assigned to a group. Use the -r option to remove the password from the group.

In Order To Improve Your System's Security You Decide To Implement Shadow Passwords. What Command Should You Use?

The pwconv command creates the file /etc/shadow and changes all passwords to 'x' in the /etc/passwd file.

What Command Should You Use To Check The Number Of Files And Disk Space Used And Each User's Defined Quotas?

The repquota command is used to get a report on the status of the quotas you have set including the amount of allocated space and amount of used space.

You Have A File Called Phonenos That Is Almost 4,000 Lines Long. What Text Filter Can You Use To Split It Into Four Pieces Each 1,000 Lines Long?

The split text filter will divide files into equally sized pieces. The default length of each piece is 1,000 lines.

You Want To Create A Compressed Backup Of The Users' Home Directories. What Utility Should You Use?

You can use the z modifier with tar to compress your archive at the same time as creating it.

You Wish To Restore The File Memo.ben Which Was Backed Up In The Tarfile Mybackup.tar. What Command Should You Type?

This command uses the x switch to extract a file. Here the file memo.ben will be restored from the tarfile MyBackup.tar.

What Is Cache Memory?

Cache memory is a small high-speed memory. It is used for temporary storage of data & information between the main memory and the CPU (center processing unit). The cache memory is only in RAM.

What Is Interrupt?

Interrupt is a signal send by external device to the processor so as to request the processor to perform a particular work.

Difference Between Static And Dynamic Ram?

Static RAM: No refreshing, 6 to 8 MOS transistors are required to form one memory cell, Information stored as voltage level in a flip flop.

Dynamic RAM: Refreshed periodically, 3 to 4 transistors are required to form one memory cell, Information is stored as a charge in the gate to substrate capacitance.

What Is The Difference Between Primary & Secondary Storage Device?

In primary storage device the storage capacity is limited. It has a volatile memory. In secondary storage device the storage capacity is larger. It is a nonvolatile memory. Primary devices are: RAM / ROM. Secondary devices are: Floppy disc I Hard disk.

Why Does Microprocessor Contain Rom Chips?

Microprocessor contain ROM chip because it contain instructions to execute data.

What Is Meant By Latch?

Latch is a D- type flip-flop used as a temporary storage device controlled by a timing signal, which can store 0 or 1. The primary function of a Latch is data storage. It is used in output devices such as LED, to hold the data for display.

What Is The Difference Between Microprocessor And Microcontroller?

In Microprocessor more op-codes, few bit handling instructions. But in Microcontroller: fewer op-codes, more bit handling Instructions, and also it is defined as a device that includes micro processor, memory, & input / output signal lines on a single chip.

What Is The Disadvantage Of Microprocessor?

It has limitations on the size of data. Most Microprocessor does not support floating-point operations.

Is The Data Bus Is Bi-directional?

The data bus is Bi-directional because the same bus is used for transfer of data between Micro Processor and memory or input / output devices in both the direction.

Is The Address Bus Unidirectional?

The address bus is unidirectional because the address information is always given by the Micro Processor to address a memory location of an input I output devices.

Subscribe to get more Posts :