Linux is referred as the most used OS in the market for its efficiency and the fast performance. According to research Linux average salary ranges from $107,805 to $179,000. So, you have the wonderful opportunities as Linux Developer.
Here we have compiled Linux Interview Questions and Answers and presented in this blog based on opinion of Linux Experts. These Interview Questions will definitely help you in your interview. We divided the Interview Questions into four categories such as Basic, Admin, Technical and Command based Questions. If you have attended any interviews earlier, and haven't found the same questions you have faced, then comment those questions in the comment section, and we will add them in this blog. Crack the interview and set a wonderful path to your career as a Linux Developer.
- Linux Basic Interview Questions
- Linux Admin Interview Questions
- Linux Commands Interview Questions
- Linux Technical Interview Questions
Linux Basic Interview Questions
1. What is Linux?
Ans. 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. What is the difference between Linux and Unix?
Ans. Diffrences between Linux and Unix
|Both paid and free distributions are available.||Different paid structures for different levels of Unix.|
|Linux primarily uses GUI with an optional command line interface||Unix uses command line interface|
|Linux OS is portable and can be executed in different hard drives||Unix 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 download through intenet under GNU licenses.||Most Unix Like Operating Systems are not free.|
|Linux is used at home based pc’s, phones, etc.||Unix is used in server systems.|
And some other difference's.
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, Firefox.
UNIX operating systems are considered as a complete OS as everything come from a single vendor.
Security And Firewall
Linux comes with open source Netfilter and IPTables based firewall tool to protect your server and desktop from the crackers and hackers. UNIX operating systems comes with its 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, and cpio etc.
3. What is the core of the Linux operating system?
Ans: Kernel is the core for Linux operating system.
4. Who invented Linux?
Ans: Linus Torvalds created Linux.
5. What is the Linux Kernel? Is it legal to edit Linux Kernel?
Ans: Kernel is the heart of the operating system. It acts as a bridge between software and hardware. If Software requests the hardware, then kernel delivers the data between 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 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 of the Android phones use Linux kernels.
Yes, the kernel can edit, because it is released under General Public License.
6. Explain the history of Linux?
Ans: 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.
7. What is Shell?
Ans: Shell is a computer program which acts as an interface between the user and the kernel. User can communicate with the kernel by writing programs, commands and scripts on the shell. It accepts human readable commands and converts them into the kernel understandable language.
8. How many types of Shells are there in Linux?
Ans: They are five Shells in Linux:
C Shell (csh): It is like C syntax and provides spelling checking and job control.
Korn Shell (ksh): 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, 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.
9. What are the basic components of Linux?
Ans: Basic components of Linux
- Kernel: It is the core component of the Linux, it acts as an interface between Software and hardware.
- Shell: It acts as an interface between the user and the Kernel.
- 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, text boxes for interaction.
- System Utilities: These are the software functions that allow users to manage the computer.
- Application Programs: Set of functions designed to perform a set of tasks.
10. How do you open a command prompt when issuing a command?
Ans: Launch your terminal by pressing CTRL+ALT+T or by giving terminal in the menu search bar.
11. What is BASH?
Ans: 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.
12. What is LILO?
Ans: LILO means Linux Loader is a boot loader which is used for the Linux operating system. Most of the Linux Operating systems use LILO, to boot the operating system into main memory to start the operations.
13. What is a swap space?
Ans: Swap Space is used when then 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 a swap files.
14. What is CLI?
Ans: CLI means Command language Interpreter. It interacts with the computer program, where the user issues command in the form of text lines. It Interacts with the computer terminals also, the interface accepts the text lines and convert them as a command to the operating system.
15. What is the GUI?
Ans: 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?
Ans: Each file or directory has 3 permissions
- Read--It refers that only they can read the file.
- Write--It refers that they can write the file or modify the file of a directory.
- 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?
Ans: They are dynamic values which 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 the information about the system behaviour.
18. What is the advantage of Open Source?
Ans: Linux was one of the first open source technologies, many programmers added software that 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 to the users and increased security.
19. What is the disadvantage of Open Source?
Ans: Disadvantages of Open Source Operating System mentioned below
- Difficulty of use
- Compatibility Issues
- Liabilities and warranties
- Hidden costs
20. What are the symbolic links?
Ans: 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, link to that file is removed, but not the file.
21. What are hard links?
Ans: A hard link is an another name for an existing file on Linux. We can create so many number of hard links, for any file. They can create links for other hard links.
22. What is redirection?
Ans: Redirection can be defined as changing the standard input and output devices. To redirect metacharacters are used, you can redirect the file or program.
23. What are Daemons?
Ans: A Daemons is a background process which accepts the requests for service from other computers, most of the operating systems use daemons in other forms.
24. Describe the root account?
Ans: Root is the user name, that default have access to all files and commands. The root user can do many things, but an ordinary user cannot do like installing software, change file permissions, etc.
25. Explain virtual desktop?
Ans: 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.
26. What are the different modes when using the v editor?
Ans: There are three kinds of modes in vi editor. They are
- Command Mode/ Regular Mode
- Insertion Mode/Edit Mode.
- Ex Mode/ Replacement Mode.
27. What are inode and process id?
Ans: inode is a unique name given to each file and process id is a unique name given to each process.
28. What are the Process states in Linux?
Ans: Five process states in Linux. They are
- New/ Ready: A new process is created and ready to run.
- Running: The process is being executed.
- Blocked/ Wait: The process is waiting for input from the user.
- Terminated/ Completed: The process completed the execution or terminated by the operating system.
- Zombie: The process is deleted, but still the information regarding the process exists in the process table.
29. Explain Process Management System Calls in Linux?
Ans: 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.
30. Explain File Permission groups in Linux?
Ans: There are three user based permission groups for each file and directory.
- Owner: Owners only will have to access the file or directory, they will not impact the actions of other users.
- 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.
- All Users: These permissions are applied to all users on the system.
31. What Is a File system in Linux?
Ans: Linux file system stores and handles the data. Without a file system, it cannot know where the file starts from and where the file ends.
32. Explain different file system types in Linux?
Ans: In Linux, there are many file systems:
Ext, Ext2, Ext3, Ext4, JFS, XFS, btrfs, ufs, autofs, devpts, ntfs and swap.
Linux Admin Interview Questions
1. Why LVM is required?
Ans: LVM stands for Large Volume Management, it is a storage management device. User can create, resize and delete LVM partitions. It increases the abstraction, flexibility and control. LVM is used to gather existing storage devices into the group and allocate logical units.
2. What is umask?
Ans: unmask stands for user file creation mode. When the user creates any file, it has default file permissions. So unmask will specify few restrictions to the newly created file (it controls the file permissions).
umask [-S] [mask]
3. How to set the umask permanently for a user?
Ans: If the unmask command invoked without any arguments, it means it will display the current mask.
To set the unmask permanently, we have two types. They are
4. What is network bonding in Linux?
Ans: 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 behaviour of the bonded interface depends on the bonding method.
8. What are the different modes of Network bonding in Linux?
Mode-0(balance-rr): It is a default mode and based on Round-Robin policy. It offers fault tolerance and load balancing features. It used round-robin fashion to transmit the packets.
Mode-1(active-backup): It is based on 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.
Subscribe to our youtube channel to get new updates..!
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 it 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 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.
9. How to check the default route and routing table?
Ans: To display the default route and routing table, we use the following commands.
<strong>$ route-n</strong><br><br><strong>$ nestat-rn</strong><br><br><strong>$ ip </strong>
10. How to check which ports are listening in my Linux Server ?
Ans: We have two commands to check which ports are in listening in Linux Server. Following are the two commands
# netstat --listen # netstat -l
11. Where the kernel modules are located ?
Ans: lib/modules/kernel-version/, this directory stores all the information about the compiled drives under the Linux system. Using lsmod command also we can see the installed kernel modules.
12. How to change the default run level in Linux ?
Ans: To change the default run level in Linux use init command.
13. How to share a directory using nfs?
Ans: To share a directory using nfs, first edit the configuration file and ‘/etc/exportfs’ and add an entry like directory name ‘/
14. What are the default ports used for SMTP, DNS, FTP, DHCP, SSH and squid?
Ans. Details mentioned below
|FTP||20(Data Transfer) 21(Connections Established)|
|DHCP||68(dhcp client), 67(dhcp server)|
17.How to lock user account in Linux?
Ans: Locking user account is done for the security purpose, so that unauthorized users cannot login. So, we have a few ways to lock the user account. Some of them are below.
- Lock or disable the password using passwd command.
- Expire the user account using usermod command or chage command.
- Changing the shell using nologin command ( /sbin/nologin ).
Linux Commands Interview Questions
1. What is ls command and what it does?
Ans: It is one of the basic command in Linux. It is used to list all the files and directories in the file system.zom
<span style="color: #ecf0f1; background-color: #000000;">ls [OPTIONS] [FILES]</span>
We can use without passing the arguments, then it will list all the files in the current working directory. Files will displayed in alphabetical order.
<span style="background-color: #000000; color: #ecf0f1;">Is</span>
To list the specific directory files use directory name in the syntax, follow as shown in the below syntax.
We can also pass multiple directories names in the syntax, but separated by space.
ls /etc /var /etc/passwd
2. What is tail command in Linux?
Ans: The Tail command print last N number of lines of the given data, it prints 10 lines by default.
tail [OPTION]... [FILE]
$ cat names.txt
Tableau<br><br>sql server<br><br>linux administration<br><br>
Now, check the syntax without giving any option or input.
$ tail state.txt
<span style="font-family: 'courier new', courier, monospace;"><span style="color: #222222; font-family: Verdana;"><span style="white-space: pre-wrap;"><strong><em>Output:</em></strong><br></span></span></span>Tableau<br>sql server<br>linux administration<span style="font-family: 'courier new', courier, monospace;"><span style="color: #222222; font-family: Verdana;"><span style="white-space: pre-wrap;"><br></span></span></span>
4. What is grep command in Linux?
Ans: grep command is a filters which is used to global search for regular expressions.
grep [options] pattern [files]
5. What is ps command in Linux?
Ans: ps command display the current process status of the system. And it displays the process id’s with some other related data also.
PID TTY TIME CMD
12330 pts/0 00:00:00 bash
21621 pts/0 00:00:00 ps
6. What is env command in Linux?
Ans: env is a shell command is used to print list of current environmental variables and it can run another process in other environment without any modification of the current environment.
env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]
|-i, --ignore-environment||Start with an empty environment.|
|-0, --null||output line End with a 0 (null) byte rather than a newline.|
|-u, --unset=NAME||removes variable NAME from the environment|
|--help||Display a help message and exit.|
7. What is top Command in Linux?
Ans: top command used to show the system process and it displays and update the sorted process information.
8.What is netstat command in Linux?
Ans: netstat command gives various information about the network and routing tables, interface statics and more about the system.
9. What is lsof command in Linux?
Ans: lsof means List of file, we can know which file is opened by which process.
10.Explain about chmod command?
Ans: 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 ty0pe of permission, read, write and execute and are represented by numbers as shown below.
- 4 - read permission
- 2 - write permission
- 1- execute permission
$ chmod options permissions file name $ chmod [OPTION]... MODE[,MODE]... FILE... $ chmod [OPTION]... OCTAL-MODE FILE... $ chmod [OPTION]... --reference=RFILE FILE…
11. Explain about chown command?
Ans: 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.
$ chown [OPTION]… [OWNER][:[GROUP]] FILE… Or $ chown [OPTION]… –reference=RFILE FILE…
12. What is cp command in Linux?
Ans: cp command: cp command is used to copy files and directories. It is also used to backup files or directories.
$ cp file name
13. How to remove file or directory from the system in Linux?
Ans: rm command: The rm command is used to remove directory or file specified on the command line. You need to be careful while removing any file or directory.
|rm file name||Removes single file.|
|rm filename1, filename2, filename 3||Removes multiple files.|
|rm * .pdf||Removes all pdf files in the current directory.|
|rm -i filename(s)||-i means to confirm before deleting the file|
|rm -i filename(s)||Removes files without prompting|
|rm -fv *.txt||Remove all .txt files in the current directory without prompting|
14. What is mkdir in Linux?
Ans: mkdir, command allow users to create directories in the Linux. User can create multiple directories at once and can set the permissions to the directories.
mkdir [options...] [directories ...]
|Directory||name of the directory to be created|
|-m=mode, --mode=mode||to set a file mode (permissions, etc.) for the created directories|
|-p, --parents||create parent directories|
|--v, --verbose||Verbose output. Print a message for created directory.|
|--Z= context, --context=context||If you are using SELinux, this option sets the security context of each created directory to context.|
|--help||shows help message and exit|
|--version||It shows version information and exit|
15. Explain rmdir command in Linux?
Ans: The rmdir is used to remove each directory specified on the command line.
rmdir [-p] [-v | –verbose] [–ignore-fail-on-non-empty] directories
16. How to exit from vi editor?
Ans: We can use two commands to exit from the vi editor. They are
Wq: wq command saves the current work and exits from the vi editor.
q!: q! Command does not save the current work, but it exits from the vi editor.
17. How to delete information from a file in vi?
Ans: Following commands are used to delete information from a file in vi editor.
- Command x deletes the current character.
- Command dd deletes the current line.
18. Enlist some Linux file content commands?
Ans: File content commands
- head: Display top lines of the file.
- tail: Display last lines of the file.
- cat: Concatenate more than 2 files.
- more: Displays the content in pager form to view in the terminal.
Linux Technical Interview Questions and Answers
1. Enlist some Linux distributors (Distros) along with its usage?
Ans: We have so many Linux Distributors, among them we discuss few important ones.
Linux Mint: It is stable and robust. Linux Mint uses mate desktop and cinnamon.
Debian:It stands for robustness, stability, and 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 being 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.
2. Why we use LINUX?
Ans: We are some many reasons, in that few important reasons are listed out. Following are
High Stability: It is very stable and does not lead to crashes, it runs fastly as it is when it installed in first.
Security: It is dependable server, that offer high security to the user. Using Linux on your system it is easy to avoid virus and malware. The attacker cannot change any changes in the system until the user logged in at as root user.
Easy to Operate: Linux is easy to operate and we can install easily on to the system, because all the variants of the linux have there own software repositories. You can update the system periodically with just 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).
3.What are the features of Linux operating system?
Ans: Following are the features of Linux Operating System
Portable: Software can work on different types hardware in the same way. It can carry easily in pen drives and memory cards.
Open Source: Source code available for free, and it community based development project.
Multi-User: Multiple users can use ram, applications and run programs at a same time.
Multiprogramming: Multiple program or applications can run at a 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.
4. Differentiate between BASH and DOS?
|Commands are case sensitive||commands are not case sensitive|
|Backward slash(/) represents directories separator||‘/’ represents command arguments|
|Forward slash ‘’ represents escape character||‘’ represents directories separator|
|Does not follow conventions naming in files||Follow naming convention in files|
5. What is meant by internal commands and external commands?
Upcoming Batches - Linux Training!
6:30 AM IST
7:00 AM IST
6:30 AM IST
6:30 AM IST
Internal Commands: Commands directly run by the shell is known as internal commands and there is no separate process to run the commands.
External Commands: Commands which are run by kernel is known as external commands and for each single command has its own unique process id.
6. What is meant by PIPE in Linux?
Ans: It is 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.
command_1 | command_2 | command_3 | .... | command_N
7. Describe how a parent and child process communicates each other?
Ans: Parent process communicates with the child process by using pipes, sockets, messages queues and more.
8. What is Stateless Linux Server?
Ans: It is a centralized server which does not have any exists states on the working station. It may have scenarios when a state of particular system takes snapshot then, user wants all other machines to be in that particular state.
9. Explain features of Stateless Linux Server?
- Stores the prototype of every system.
- Stores the snapshot taken.
- Stores the home directories.
- Uses LDAP, which contains the information about which snapshot should run on which system.
10. What is Zombie Process?
Ans: It is a process whose execution is completed but even the information is exists in the process table. It occurs for child process because parent process need 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 know as Zombie Process.
11. Explain the work of Ctrl+Alt+Del key combination on Linux operating system?
Ans: In Linux, Ctrl+Alt+Del key is used to restart the computer, and it does not display any confirmation message before rebooted the system.
12. Why is Linux considered as more secure than other operating systems?
Ans: Linux is an open source operating system, nowadays it is rapidly growing in the technology market. We have few reasons why linux is more secure than other OS.
Perk of accounts: Linux allows only few users to access the system. Thus, virus cannot attack on whole system, it may cause only 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 used by the Linux because it check 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 the virus.
Recording in Linux: It maintains log history, because later it can view the details of the system files easily.
Few User: Linux users are less compared to others, due to this security will be more.
Q9. What is tail command in Linux?
Ans. tail command displays the last part of a file. Generally, users don't need every log line to troubleshoot. Instead, you want to check what your logs say about the most recent request to your application.
$ tail -n 100 /var/log/httpd/access_log
Q10. What is cat command in Linux?
Ans. 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 requirements.txt flask flask_pymongo
Q11. What is grep command in Linux?
A. 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.
$ 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
Q12. What is ps command in Linux?
Ans. ps command displays 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
Q13. What is env command in Linux?
Ans. 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
Q14. What is top Command in Linux?
Ans. 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.
Q15. What is netstat command in Linux?
A. netstat command in Linux shows the network status. This netstat command shows network ports in use and their incoming connections.
Q16. What is lsof command in Linux?
A. lsof command lists the open files associated with your application.
Q17. What is df command in Linux?
A. Users can use df command to troubleshoot disk space issues. Here df stands for display free disk space.
df Command Example:
Q18. What is du command in Linux?
A. 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
Q19. What is iptables command in Linux?
A. 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.
Linux Vs Windows
|Linux is available for free||Windows has to be bought|
|It is an open source OS||It is not open source OS|
|One can customize Linux||No customizations available|
|Provides high level security||Cannot defend virus and malware attacks|
|Primary partitionig and logical partitioning available to boot||Booting available while primary partitioning only|
|Back Slash separates directories||Forward slash separates directories|
|File names are case particular||Irrespective of case while naming files
Q20. What does cd - command do?
A. cd- command go to the previous directory.
Q21. What does cd command do?
A. Go to $HOME directory
Q22. What does (cd dir && command) do?
A. cd dir && command goes to the dir, execute the command and return to the current directory.
Q23. What does pushd command do?
A. pushhd command put current dir on stack so you can pop back to it.
Linux Admin Interview Questions
Q24. What is ls -lSr command?
A. ls - ISr command shows files by size, biggest file will be displayed last.
Q25. What is du -s * | sort -k1,1rn | head command used for?
A. This command shows top disk users in current dir.
Q26. What does this du -hs /home/* | sort -k1,1h command do?
A. This command sort path by easy to interpret disk usage.
Q27. What is df -h command?
A. This command show free space on mounted file systems.
Q28. What is df -i command?
A. df -i command shows free inodes on mounted filesystems.
Q29. What is fdisk -l command used for?
A. fdisk -I command show disks partitions sizes and types (run as root).
Q30. How do you kill program using one port in Linux?
A. Use this command to kills the program using one port: sudo fuser -k 8000/tcp
Q31. How do you limit memory usage for commands?
A. ulimit -Sv 1000 # 1000 KBs = 1 MB
ulimit -Sv unlimited # Remove limit
Q32. How do you get full path of a file in Linux?
A. Use this command: readlink -f file.txt
Q33. How do you list contents of tar.gz and extract only one file?
A. Use these commands:
- tar tf file.tgz
- tar xf file.tgz filename
Q34. How do you find who is logged in?
A. Use this command to find who logged in: w
Q35. How do you check permissions of each directory to a file?
A. It is useful to detect permissions errors, for example when configuring a web server.
namei -l /path/to/file.txt
Q36. How do you run command every time a file is modified?
A. Use this command to do:
while inotifywait -e close_write document.tex
Q37. How to copy text to clipboard?
A. Use this command: cat file.txt | xclip -selection clipboard
Q38. How do you check resources usage?
A. Use this command to check resource usage: /usr/bin/time -v ls
Q39. How do you run a command for a limited time?
A. Use this command: timeout 10s ./script.sh
# Restart every 30 minutes
while true; do timeout 30m ./script.sh; done
Q40. How do you combine two lines from two sorted files in Linux?
A. Use this command: comm file1 file2.