Blog

Blog

Top 100+ Linux Interview Question and Answers

Linux Interview Questions – 1.What is Linux?

Linux is an operating system, which is based on Linux Kernel.  It is an Open-Source Operating System, where it can run on different Hardware platforms. It provides a free and low-cost operating system for users. It is a user-friendly environment where they can easily modify and create variations in the source code.

2. Who invented Linux? Explain the history of Linux.

Linus Torvalds created Linux. Linus Torvalds was a student at the University of Helsinki, Finland in 1991. He started writing code on his own to get the academic version of Unix for free. Later on, it became popular as Linux Kernel.

3. What is Linux Kernel?

Linux kernel is the heart of the operating system. It acts as a bridge between Software and Hardware. If the Software requests the Hardware, then the kernel delivers the data between the Software and Hardware.

For example, if you want to play a song you should launch your default player, it requests the kernel to play a song, now the kernel will contact the hardware to seek the permissions or to seek the hardware components like if you plugged in any headset to the device. Most Android phones use Linux kernels. 

Yes, the kernel can edit, because it is released under General Public License.

4. What is Shell?

Shell is a computer program, that acts as an interface between the user and the kernel. Users can communicate with the kernel by writing programs, commands, and scripts on the shell. It accepts human-readable commands and converts them into kernel-understandable language.

5. How many types of Shells are there in Linux? 

They are five Shells in Linux:

  • C Shell (csh): It is like C syntax and provides spelling checking and job control.
  • Korn Shell (KSH): This is a high-level programming language shell.
  • Z Shell (Zsh): It provides some unique nature like it observes login/logout watching, file name generating, startup files, and closing comments. 
  • Bourne Again Shell (Bash): It is the default to Linux distributions.
  • Friendly Interactive Shell (Fish): It provides web-based configuration,  auto-suggestions, etc. 

6. What are the basic components of Linux?

Basic components of Linux

  1. Kernel: It is the core component of Linux, it acts as an interface between Software and Hardware.  
  2. Shell: It acts as an interface between the user and the Kernel.
  3. GUI:  It stands for Graphic User Interface, which is another way for the user to interact with the system. But it is unlike images, buttons, and text boxes for interaction.
  4. System Utilities: These are the software functions that allow users to manage the computer.
  5. Application Programs: A set of functions designed to perform a set of tasks.
Linux

7. What is BASH?

Bash is a Unix shell and command processor written by Brian Fox for the GNU project. It is free software and acts as a replacement for Bourne Shell. It is an interpreted and not compiled process which can also be run in the terminal window.

This allows users to write commands and cause actions. Bash is capable of reading commands from shell scripts.

8. What is the difference between Linux and Unix?

Here is the difference between Linux and Unix – mentioned below

LinuxUnix
Both paid and free distributions are available.Different paid structures for different levels of Unix.
Linux primarily uses GUI with an optional command-line interfaceUnix uses the command-line interface
Linux OS is portable and can be executed on different hard drivesUnix OS is not portable.
Linux is developed by a worldwide Linux community.Unix is developed by AT&T developers.
Linux is free. And it is downloaded through the internet under GNU licenses.Most Unix Like Operating Systems is not free.
Linux is used on home-based PCs, phones, etc.Unix is used in server systems.

And some other differences.

Linux is a Unix Clone. But if you consider Portable Operating System Interface (POSIX) standards then Linux can be considered as UNIX.

  • Linux Is Just Kernal

All Linux distributions include GUI system, GNU utilities, installation & management tools, GNU c/c++ Compilers, Editors (vi), and various applications like OpenOffice, and Firefox.

UNIX operating systems are considered as a complete OS as everything comes from a single vendor.

  • Security And Firewall

Linux comes with an Open-Source Netfilter and IPTables-based firewall tool to protect your server and desktop from crackers and hackers. UNIX Operating Systems come with their own firewall products. 

  • Backup and Recovery

UNIX and Linux come with their own set of tools for backing up data to tape and other backup media. However, both Linux and UNIX share some common tools such as tar, dump/restore, cpio, etc.

9. What is LILO?

LILO means Linux Loader is a boot loader that is used for the Linux operating system. Most of the Linux Operating systems use LILO, to boot the operating system into the main memory to start the operations.

10. What is CLI?

CLI means Command Line Interface. It interacts with the computer program, where the user issues commands in the form of text lines. It Interacts with the computer terminals also, the interface accepts the text lines and converts them as a command to the operating system. 

YouTube Display Ad 3 page 0001 12

11. What is the advantage of Open Source?

Linux was one of the first Open-Source Technologies, many programmers added Software that is completely open to the users, which means you can download the file and change the code as you like. It has a wide range of options for users and increased security.

12. What is the disadvantage of Open Source?

The disadvantages of Open Source Operating Systems are mentioned below

  1. The difficulty of use – Some open-source applications may be tricky to set up and use. Others may lack user-friendly interfaces or features that your staff may be familiar with. This can affect productivity and prevent your staff from adopting or using programs with ease.
  2. Compatibility Issues – Many types of proprietary hardware need specialized drivers to run open-source programs, which are often only available from the equipment manufacturer. This can potentially add to the cost of your project. Even if an open-source driver exists, it may not work with your software as well as the proprietary driver.
  3. Liabilities and warranties – With proprietary software, the developer usually provides indemnification and warranty as part of a standard license agreement. This is because they fully control and copyright the product and its underlying code. Open-source software licenses typically contain only limited warranty and no liability or infringement indemnity protection
  4. Hidden costs – Software that is free up-front but later costs money to run can be a major burden, especially if you haven’t considered hidden costs from the outset.

13. How do you open a command prompt when issuing a command?

Launch your terminal by pressing CTRL+ALT+T or by giving the terminal in the menu search bar.

14. What is a swap space?

Swap Space is used when the physical Ram memory is running out. It will move the Ram inactive pages to the swap space. It can consider in the form of a dedicated swap partition or swap files.

15. What is the GUI?

GUI means Graphical User Interface. It is a human-computer interface that uses windows, images, icons, and menus which can be manipulated by using a mouse. Most of the modern applications in electronic gadgets communicate with the user through GUI. GUI is a combination of graphical and textual interaction that uses buttons, menus, message boxes, etc.

16. Explain File Permissions types in Linux.

Linux file permissions – Each file or directory has 3 permissions

They are 

  1. Read: It refers to only they can read the file.
  2. Write: It refers that they can write the file or modify the file of a directory.
  3. Execute: It affects the user’s capability to execute the file or to view the file of a directory. 

17. What are the environmental variables?

They are dynamic values that affect the process of programs on a computer. They exist in every operating system and their types may vary. They can be created, edited, saved, and deleted and they also give information about the system’s behavior.

18. What are the symbolic links? 

It will be redirected to another file using its path. Target files do not contain any data. Symbolic links redirect to another entry somewhere in the file system. If the target file is deleted, the link to that file is removed, but not the file.

19. What are the Hard links?

A Hard link is another name for an existing file on Linux. We can create so many numbers of Hard links, for any file. They can create links for other hard links.

20. What is redirection?

Redirection can be defined as changing the standard input and output devices. To redirect metacharacters are used, you can redirect the file or program. 

YouTube Banner Ad 2 page 0001 10

21. What are Daemons?

A Daemon is a background process that accepts requests for service from other computers, most operating systems use daemons in other forms.  

22. Describe the root account.

The root is the user name, which default has access to all files and commands. The root user can do many things, but an ordinary user cannot do like installing software, changing file permissions, etc.

23. Explain the virtual desktop.

A virtual Desktop is a user interface when you are facing the problem of how to manage multiple windows on your desktop, virtual desktop serves as an alternative. Virtual desktop stores remote server and allow you to use one or more programs on a clean slate. 

24. What are the different modes when using the vi editor?

There are three kinds of modes in vi editors. They are 

  • Command Mode/ Regular Mode
  • Insertion Mode/Edit Mode.
  • Ex Mode/ Replacement Mode. 

25. Explain File Permission groups in Linux.

There are three user-based permission groups for each file and directory.

They are:

  1. Owner: Owners only will have to access the file or directory, they will not impact the actions of other users.
  2. Group: These permissions apply only to the group, that has been assigned to the file or directory. They will not impact the actions of other users.
  3. All Users: These permissions are applied to all users on the system.

26. What is a File system in Linux?

Linux file system stores and handles the data. Without a file system, it cannot know where the file starts and where the file ends.

27. Explain different file system types in Linux.

In Linux, there are many file systems:

Ext, Ext2, Ext3, Ext4, JFS, XFS, btrfs, ufs, autofs, devpts, ntfs and swap.

28. What are inode and process IDs?

The inode is a unique name given to each file and the process id is a unique name given to each process. 

29. What are the Process states in Linux?

Five process states in Linux. They are

  1. New/ Ready: A new process is created and ready to run.
  2. Running: The process is being executed.
  3. Blocked / Wait: The process is waiting for input from the user. 
  4. Terminated / Completed: The process completed the execution or terminated by the Operating System. 
  5. Zombie: The process is deleted, but still the information regarding the process exists in the process table.

30. Explain Process Management System Calls in Linux.

The process management system calls in Linux:

  • fork(): Used to create a new process.
  • exec(): Execute new process.
  • wait(): wait until process execution.
  • exit(): exit from the process.

System calls to get the Process id :

  • getpid(): to find the unique process id. 
  • getppid(): to find the unique parent process id. 

Linux Admin Interview Questions

YouTube Display Ad 3 page 0001 13

31. Why LVM is required?

LVM stands for Large Volume Management, it is a storage management device. Users can create, resize, and delete LVM partitions. It increases abstraction, flexibility, and control. LVM is used to gather existing storage devices into the group and allocate logical units. 

32. What is umask?

unmask stands for user file creation mode. When the user creates any file, it has default file permissions. So unmask will specify a few restrictions to the newly created file (it controls the file permissions).

umask [-S] [mask]

Options

-SAccept a symbolic representation of a mask, or return one.
maskIf a valid mask is specified, the umask is set to this value. If no mask is specified, the current umask value is returned.

32. What are the different modes of Network bonding in Linux?

Different modes of Linux network bonding

  • Mode-0(balance-rr): It is a default mode and is based on the Round-Robin policy. It offers fault tolerance and load-balancing features. It used a round-robin fashion to transmit the packets.
  • Mode-1(active-backup): It is based on the Active Backup policy and only one slave will act in the band and another one will act when the others fail in the band. It also provides fault tolerance.
  • Mode-2(balance-xor): It sets a xor mode between the source Mac address and destination Mac address to provide fault tolerance.
  • Mode-3(broadcast): It is based on broadcast policy and transmitted everything in the slave interface. It also provides fault tolerance and can be used only for a particular purpose.
  • Mode-4(802.3ad): It is a dynamic aggregation mode, it created aggregation groups which is having the same speed. It uses the transmit hashing method to select the slaves for outgoing traffic.
  • Mode-5(balance-tlb): The outgoing traffic is according to the current load on the slave, and the incoming traffic is received by the slave. It is called an adaptive transmit load balancing mode. 
  • Mode-6(balance-alb): It is an adaptive load balancing mode. It does not require any switch support. 

33. How to check the default route and routing table?

To display the default route and routing table, we use the following commands.

$ route-n


$ nestat-rn


$ IP

34. How to set the mask permanently for a user? 

If the unmask command is invoked without any arguments, it means it will display the current mask. 

To set the unmask permanently, we have two types.

They are:

  • Ocotal representation.
  • Symbolic representation.

35. What is network bonding in Linux?

Network Bonding is a process of combining more than two network interfaces to form a single network interface. It offers performance improvement and redundancy by increasing network throughput and bandwidth.

No need to worry if one interface is down or unplugged because the other will work. The behavior of the bonded interface depends on the bonding method. 

36. How to check which ports are listening in my Linux Server?

We have two commands to check which ports are in listening in Linux Server. Following are the two commands 

# netstat --listen
# netstat -l

37. How to share a directory using NFS?

To share a directory using NFS, first edit the configuration file and ‘/etc/exports’ and add an entry like directory name ‘/<directory-name>’. Now restart the NFS service.

38. What are the default ports used for SMTP, DNS, FTP, DHCP, SSH, and squid?

Details mentioned below

ServicePort
SMTP25
DNS53
FTP20(Data Transfer) 21(Connections Established)
DHCP68(DHCP client), 67(DHCP server)
SSH22
Squid3128

39. How to lock a user account in Linux?

Locking user accounts is done for security purposes so that unauthorized users cannot log in. So, we have a few ways to lock the user account. Some of them are below. 

  1. Lock or disable the password using the passwd command.
  2. Expire the user account using the usermod command or chage command.
  3. Changing the shell using nologin command ( /sbin/nologin ).

Linux Commands Interview Questions

Youtube Banner Ads 3 1 page 0001 12

40. What is the ‘ls’ command and what it does do?

It is one of the basic commands in Linux. It is used to list all the files and directories in the file system.

Syntax: 

ls [OPTIONS] [FILES]

We can use it without passing the arguments, then it will list all the files in the current working directory. Files will be displayed in alphabetical order. 

Is

To list the specific directory files use the directory name in the syntax, follow as shown in the below syntax.

ls /etc

We can also pass multiple directories names in the syntax, but separated by space. 

ls /etc /var /etc/passwd

41. Where the kernel modules are located?

lib/modules/kernel-version/, this directory stores all the information about the compiled drives under the Linux system. Using the lsmod command also we can see the installed kernel modules. 

42. How to change the default run level in Linux?

To change the default run level in Linux use the init command.

43. What is the tail command in Linux?

The Tail command print the last N number of lines of the given data, it prints 10 lines by default. 

Syntax: 

tail [OPTION]... [FILE]

Example: 

$ cat names.txt
Tableau


sql server


linux administration


Now, check the syntax without giving any option or input.
$ tail state.t

44. What is the env command in Linux?

env is a shell command used to print a list of current environmental variables and it can run another process in another environment without any modification of the current environment. 

env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]
Options
TagDescription
i, –ignore environmentStart with an empty environment.
-0, –nulloutput line End with a 0 (null) byte rather than a new line.
-u, –unset=NAMEremoves variable NAME from the environment
–helpDisplay a help message and exit.

45. What is the top Command in Linux?

The top command is used to show the system process and it displays and updates the sorted process information. 

46. What is the netstat command in Linux?

netstat command gives various information about the network and routing tables, interface statics, and more about the system.

47. What is lsof command in Linux?

lsof means a List of files, we can know which file is opened by which process.

#lsof
-

48. Explain about chmod command.

This command is used to change the permission of files and directories. It’s an important command so, I’ll explain it briefly. Therefore, on the whole, there are three types of permission, read, write and execute which are represented by numbers as shown below.

  1. 4 – read permission
  2. 2 – write permission
  3. 1- execute permission

syntax:

$ chmod options permissions file name 


$ chmod [OPTION]... MODE[,MODE]... FILE...


$ chmod [OPTION]... OCTAL-MODE FILE...


$ chmod [OPTION]... --reference=RFILE FIL

49. What is the grep command in Linux?

grep command is a filter that is used for the global search for regular expressions.

Syntax:

grep [options] pattern [files]

50. What is ps command in Linux? 

The ps command displays the current process status of the system. And it displays the process IDs with some other related data also. 

Syntax: 

Ps [options]

Output:

[root@rhe17~]# ps




PID TTY    TIME CMD




12330 pts/0  00:00:00 bash




21621 pts/0  00:00
YouTube Banner Ad 2 page 0001 11

51. Explain about chown command.

Chown command: The command “chown” stands for change file owner and Group. This command is used to change the ownership of one or more files or folders for a specified user or group. 

syntax:

$ chown [OPTION]… [OWNER][:[GROUP]] FILE…
                                Or


  $ chown [OPTION]… –reference=RFILE FILE…

52. How to remove a file or directory from the system in Linux?

rm command: The rm command is used to remove the directory or file specified on the command line. You need to be careful while removing any file or directory.

Syntax:

rm filename— 

CommandDescription
rm filenameRemoves single file.
rm filename1, filename2, filename 3Removes multiple files.
 rm * .pdfRemoves all pdf files in the current directory. 
 rm -i filename(s)-i mean to confirm before deleting the file
 rm -f filename(s)Removes files without prompting
rm -fv *.txtRemove all .txt files in the current directory without prompting

53. What is the cp command in Linux?

cp command: cp command is used to copy files and directories. It is also used to back up files or directories.

Syntax:

$ cp filename

54. What is mkdir in Linux?

mkdir, the command allows users to create directories in Linux. Users can create multiple directories at once and can set the permissions to the directories.

Syntax: 

mkdir [options...] [directories ...]
OptionDescription
DirectoryName of the Directory to be created
-m=mode, –mode=modeTo set a file mode (Permissions, etc.) for the created Directories
-p, –parentsCreate Parent Directories
–v, –verboseVerbose Output. Print a message for the created Directory.
–Z= context, –context=contextIf you are using SELinux, this option sets the security context of each created Directory to context.
–helpShows help message and exit
–versionIt shows version information and exit

55. How to exit from vi editors?

We can use two commands to exit from the vi editor. They are

  • Wqwq command saves the current work and exits from the vi editor.
  • q!: q! The command does not save the current work, but it exits from the vi editor.

56. Explain rmdir command in Linux.

The rmdir is used to remove each directory specified on the command line. 

Syntax:

rmdir [-p] [-v | –verbose] [–ignore-fail-on-non-empty] directories

57. Enlist some Linux to file content commands.

File content commands

  1. head: Display the top lines of the file.
  2. tail: Display the last lines of the file.
  3. cat: Concatenate more than 2 files.
  4. more: Displays the content in pager form to view in the terminal. 

58. How to delete information from a file in vi?

The following commands are used to delete information from a file in vi editors.

  1. Command x deletes the current character.
  2. Command dd deletes the current line

Linux Technical Interview Questions and Answers for Experienced

Youtube Banner Ads 3 1 page 0001 13

59. Why do we use LINUX? 

We are many reasons, but a few important reasons are listed. Following are

  • High Stability: It is very stable and does not lead to crashes, it runs fastly as it is when it was installed first. 
  • Security: It is a dependable server, that offers high security to the user. Using Linux on your system it is easy to avoid viruses and malware. The attacker cannot change any changes in the system until the user logged in as the root user.
  • Easy to Operate: Linux is easy to operate and we can install it easily onto the system because all the variants of Linux have their own software repositories. You can update the system periodically with just a few clicks or you can set automatic updation.
  • Hardware Compatibility: Linux can use on any hardware, it doesn’t have any hardware restrictions. It uses efficiently all system resources.
  • Open Source: The source code is available as it is under Free and Open Source Software(FOSS).

60. What are the features of the Linux operating system?

Following are the features of the Linux Operating System

  • Portable: Software can work on different types of hardware in the same way. It can carry easily in pen drives and memory cards.
  • Open Source: Source code is available for free, and it’s a community-based development project. 
  • Multi-User: Multiple users can use ram, and applications, and run programs at the same time. 
  • Multiprogramming: Multiple programs or applications can run at the same time. 
  • Shell: It has a special interpreter program where you can execute programs and commands of the system. 
  • Security: It provides authentication, authorization, and encryption to provide security to the data. 

61. Differentiate between BASH and DOS?

Difference between Bash and Dos

BashDos
Commands are case sensitivecommands are not case sensitive
The backward slash ( / ) represents the directories separator.Backward Slash ( / ) represents command arguments.
Forward slash ( \ ) represents the escape character.Forward slash ( \ ) represents the directories separator.
Does not follow conventions naming in files.  Follow the naming convention in files.

62. What is meant by internal commands and external commands?

  • Internal Commands: Commands directly run by the shell are known as internal commands and there is no separate process to run the commands. 
  • External Commands: Commands which are run by the kernel are known as external commands and every single command has its own unique process id.

63. Enlist some Linux distributors (Distros) along with their usage.

We have so many Linux Distributors, among them, we discuss a few important ones.

  • Linux Mint: It is stable and robust. Linux Mint uses mate desktop and cinnamon. 
  • Debian: It stands for robustness, stability, and a well-oiled release cycle. It is user-friendly. Debian version 8 will be replaced by version 9.
  • Ubuntu: It is available for both desktop and server editions and is based on Debian.  
  • openSUSE: It is a good choice for new users and existing users.
  • Manjaro: It gives a pleasant experience for new and experienced users.

Linux Networking Interview Questions

YouTube Display Ad 3 page 0001 14

64. What is meant by PIPE in Linux?

It is a form of redirection that is used in Linux, it is used to combine more than two commands and the output of one command can take as input to the next command. 

Syntax:

command_1 | command_2 | command_3 | .... | command_N

65. Explain the features of a Stateless Linux Server.

Features of Stateless Linux Server

  1. Stores the prototype of every system.
  2. Stores the snapshot was taken. 
  3. Stores the home directories.
  4. Uses LDAP, which contains the information about which snapshot should run on which system. 

66. What is Zombie Process?

It is a process whose execution is completed but even the information exists in the process table. It occurs for the child process because the parent process needs to read the child process status. Once it is completed using the wait system call, then the zombie process is removed from the process table. This is known as Zombie Process.

67. Explain the work of the Ctrl+Alt+Del key combination on the Linux operating system.

In Linux, the Ctrl+Alt+Del key is used to restart the computer, and it does not display any confirmation message before rebooting the system. 

68. Describe how a parent and child process communicates with each other.

The parent process communicates with the child process by using pipes, sockets, messages queues, and more. 

69. What is a Stateless Linux Server?

It is a centralized server that does not have any existing states on the working station. It may have scenarios when a state of a particular system takes a snapshot then, the user wants all other machines to be in that particular state.

70. Why is Linux considered more secure than other operating systems?

Linux is an Open-Source Operating System, nowadays it is rapidly growing in the Technology market. We have a few reasons why Linux is more secure than other OS.

  • The perk of accounts: Linux allows only a few users to access the system. Thus, the virus cannot attack the whole system, it may cause only a few files in the system. 
  • Strong Community: Linux users first accomplished the files before they open. So they can save their systems from vulnerabilities. 
  • Iptables: Iptables are used by Linux because it checks the security circle of the system. 
  • Different Working Environment: Linux system has different working environments like Linux Mint, Debian, Arch, and many more, these working environments protect from viruses.
  • Recording in Linux: It maintains log history because later it can view the details of the system files easily. 
  • Few Users: Linux users are fewer compared to others, and due to this security will be more.

71. What is the cat command in Linux?

In Linux cat command concatenates and prints files. Users might issue cat to check the contents of your dependencies file or to confirm the version of the application that you have already built locally.

cat Example:

$ cat requirements.txt
flask    flask_pymongo

72. What is the tail command in Linux?

The tail command displays the last part of a file. Generally, users don’t need every logline to troubleshoot. Instead, you want to check what your logs say about the most recent request to your application.

tail Example:

$ tail -n 100 /var/log/httpd/access_log

73. What is the grep command in Linux?

grep searches file patterns. If you are looking for a specific pattern in the output of another command, grep highlights the relevant lines. Use this grep command for searching log files, specific processes, and more.

grep Example: 

$ cat tomcat.log | grep org.apache.catalina.startup.Catalina.start
12-Jan-2018 17:08:35.542 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 681 ms
YouTube Banner Ad 2 page 0001 12

74. What is the df -i command?

df -I command shows free inodes on mounted filesystems.

75. What is ps command in Linux?

the ps command displays the process status. Use this ps command to determine a running application or confirm an expected process.

ps Command Example:

$ ps -ef   $ ps -ef | grep tomcat

76. What is the top Command in Linux?

top command displays and updates sorted process information. Use this top command to determine which processes are running and how much memory and CPU they are consuming.

77. What is the df command in Linux?

Users can use the df command to troubleshoot disk space issues. Here df stands for display-free disk space.

df Command Example:

df -h

78. What is the difference between Linux and Windows?

LinuxWindows
Linux is available for FREEIt is paid software
It is an Open-Source operating systemIt is not an open-source OS
Linux customization is possibleNo customizations are available
It provides high-level securityCan’t defend against virus and malware attacks unless it is paid
Primary partitioning and logical partitioning available to bootBooting is available while primary partitioning only.
BackSlash separates directoriesThe forward slash separates directories
File names are case particularIrrespective of the case while naming files

79. What is the iptables command in Linux?

iptables command blocks or allows traffic on a Linux host, similar to a network firewall. This iptables command may prevent certain applications from receiving or transmitting requests.

80. What is the netstat command in Linux?

netstat command in Linux shows the network status. This netstat command shows network ports in use and their incoming connections.

81. What is a du command in Linux?

du command in Linux is used to retrieve more detailed information about which files use the disk space in a directory.

du Command Example:

$ du -sh /var/log/*
1.8M  /var/log/anaconda
384K  /var/log/audit
4.0K  /var/log/boot.log
0 /var/log/chrony
4.0K  /var/log/cron
4.0K  /var/log/maillog
64K /var/log/messages

82. What is the lsof command in Linux?

ls of command lists the open files associated with your application.

83. How do you kill the program using one port in Linux?

Use this command to kill the program using one port: sudo fuser -k 8000/tcp

84. How do you limit memory usage for commands?

·         ulimit -Sv 1000       # 1000 KBs = 1 MB
·         ulimit -Sv unlimited  # Remove limit

85. What does (cd dir && command) do?

cd dir && command goes to the dir, executes the command, and returns to the current directory.

Youtube Banner Ads 3 1 page 0001 14

86. What does the push command do?

push the command and put the current dir on the stack so you can pop back to it.

87. How do you get the full path of a file in Linux?

Use this command: readlink -f file.txt

88. What is the du -s * | sort -k1,1rn | head command used for?

This command shows top disk users in the current dir.

89. What does the cd command do?

Go to the $HOME directory

90. How do you list the contents of tar.gz and extract only one file?

Use these commands:

·         tar tf file.tgz
·         tar xf file.tgz filename

91. How do you find who is logged in?

Use this command to find who logged in: w

92. What is fdisk -l command used for?

fdisk -I command show disks partitions sizes and types (run as root).

93. How do you check the permissions of each directory to a file?

It is useful to detect permissions errors, for example when configuring a web server.

namei -l /path/to/file.txt

94. What does this du -hs /home/* | sort -k1,1h command do?

This command sorts paths by easy-to-interpret disk usage.

YouTube Display Ad 3 page 0001 15

95. How do you check resource usage?

Use this command to check resource usage: /usr/bin/time -v ls

96. How do you run the command every time a file is modified?

Use this command to do:

while inotifywait -e close_write document.tex
do
make
done

97. How to copy text to the clipboard?

Use this command: cat file.txt | xclip -selection clipboard.

98. What is the df -h command?

This command shows free space on mounted file systems.

99. What is the env command in Linux?

env command allows users to set or print the environment variables. During troubleshooting, users can find it useful for checking if the wrong environment variable prevents your application from starting.

env Command Example:

$ env
PYTHON_PIP_VERSION=9.0.1
HOME=/root
DB_NAME=test
PATH=/usr/local/bin:/usr/local/sbin
LANG=C.UTF-8
PYTHON_VERSION=3.4.6
PWD=/
DB_URI=mongodb://database:27017/test

100. How do you combine two lines from two sorted files in Linux?

Use this command: comm file1 file2.

YouTube Display Ad 3 page 0001 16

101. What does the cd – command do?

cd- command go to the previous directory.

102. What is the ls -lSr command?

ls – ISr command shows files by size, the biggest file will be displayed last.

103. How do you run a command for a limited time?

Use this command: timeout 10s ./script.sh

# Restart every 30 minutes
while true; do timeout 30m ./script.sh; done
Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare

Subscribe to Newsletter

Stay ahead of the rapidly evolving world of technology with our news letters. Subscribe now!