AK Deep Knowledge

Best linux commands for devops interview questions 2024

Linux Commands For Devops Interview Questions

CommandsStand ForDescription
lsListLists directory contents.
cdChange DirectoryChanges the current directory.
pwdPrint Working DirectoryPrints the current working directory.
cpCopyCopies files or directories.
mvMoveMoves files or directories.
rmRemoveRemoves files or directories.
touchTouchCreates an empty file or updates file timestamps.
mkdirMake DirectoryCreates a new directory.
chmodChange ModeChanges file permissions.
chownChange OwnerChanges file ownership.
grepGlobal Regular Expression PrintSearches for patterns in files.
findFindSearches for files and directories.
tailTailOutputs the last part of files.
headHeadOutputs the first part of files.
catConcatenateConcatenates files and prints on the standard output.
lessLess is MoreViews file contents interactively.
moreMoreViews file contents page by page.
killKillTerminates processes by ID or name.
psProcess StatusDisplays information about running processes.
topTable of ProcessesDisplays dynamic real-time system information.
dfDisk FreeShows disk space usage.
duDisk UsageShows directory space usage.
zipZipCompresses files into a zip archive.
unzipUnzipExtracts files from a zip archive.
tarTape ArchiveCreates, views, or extracts files from an archive.
curlClient URLTransfers data from or to a server.
wgetWeb GetDownloads files from the internet.
sshSecure ShellConnects to a remote machine securely.
scpSecure CopyCopies files securely between hosts.
rsyncRemote SyncSynchronizes files and directories between two locations.

a) Navigation

1. Switch folders

How do I move between different folders in Linux?

Answer: To navigate between folders in Linux, you can use the cd command followed by the directory path you want to switch to. For example, to move to a directory named “Documents” within your current location, you would type cd Documents.

2. List contents

How can I see what files are inside a folder?

Answer: You can use the ls command to list the contents of a folder. Simply type ls followed by the directory path if you want to list the contents of a specific folder. For example, ls /path/to/directory.

3. Current location

Where am I right now in the file system?

Answer: To see your current location within the file system, you can use the pwd command. Type pwd in the terminal will display the full path of your current working directory.

b) File Management

1. Copy a file

How do I make a copy of a file and put it somewhere else?

Answer: You can use the cp command to copy a file. Simply type cp followed by the name of the file you want to copy and then the destination where you want to place the copy. For example, cp file.txt /path/to/destination.

2. Move a file

How can I move a file to a different folder?

Answer: You can use the mv command to move a file to a different folder. Type mv followed by the name of the file you want to move and then the destination where you want to move it. For example, mv file.txt /path/to/destination.

3. Delete a file

How do I permanently remove a file?

Answer: To delete a file, you can use the rm command followed by the name of the file you want to delete. For example, rm file.txt. Be careful, as this action is irreversible and the file will be permanently deleted.

4. Create an empty file

How can I make a new file with nothing in it?

Answer: You can create an empty file using the touch command followed by the name of the file you want to create. For example, touch newfile.txt.

5. Make a new folder

How do I create a new folder to organize files?

Answer: To create a new folder, you can use the mkdir command followed by the name of the folder you want to create. For example, mkdir new_folder.

6. Delete a folder

How can I remove a folder and everything inside it?

Answer: You can use the rm command with the -r option to remove a folder and its contents recursively. For example, rm -r folder_name.

c) Permissions and Ownership

1. Control access

How can I decide who can see and change files/folders?

Answer: You can use the chmod command to change the permissions of files and folders in Linux. By modifying the permissions, you can control who can read, write, or execute a file or folder.

2. Change ownership

How do I transfer ownership of a file/folder to someone else?

Answer: You can use the chown command to change the ownership of a file or folder in Linux. This allows you to transfer ownership to another user or group.

d) Viewing and Searching

1. See last lines

How can I quickly look at the end of a file?

Answer: You can use the tail command followed by the filename to view the last few lines of a file. For example, tail filename.txt will display the last 10 lines of the file by default.

2. Find a file

How do I search for a specific file on my computer?

Answer: You can use the find command to search for files on your computer. For example, find /path/to/search -name filename will search for a file named “filename” in the specified directory.

e) Processes and Networking

1. Stop a program

How do I close a program that’s running?

Answer: You can use the kill command followed by the process ID (PID) of the program to stop it. First, you need to find the PID using the ps command, then use kill PID to terminate the program.

2. Create a shortcut

How can I make a quick way to access a file or folder?

Answer: In Linux, you can create shortcuts called symbolic links using the ln command. For example, ln -s /path/to/original /path/to/link will create a symbolic link named “link” that points to the original file or folder.

3. Hard vs. symbolic links

What’s the difference between these two types of shortcuts?

Answer: A hard link is a direct reference to the file’s inode, while a symbolic link is a separate file that contains the path to the original file. Hard links cannot cross file systems, while symbolic links can.

4. Search within a file

How do I find specific words or patterns inside a file?

Answer: You can use the grep command followed by the pattern you want to search for and the filename. For example, grep "pattern" filename.txt will search for the specified pattern within the file.

5. Find files

What can the “find” command do to search for files?

Answer: The find command is used to search for files and directories based on various criteria such as name, size, or type. It allows you to perform complex searches and execute actions on the found files.

6. Compress/uncompress files

How do I zip and unzip files in Linux?

Answer: You can use the zip command to compress files into a zip archive and the unzip command to extract files from a zip archive. For example, zip archive.zip file1 file2 will create a zip archive containing file1 and file2.

f) Network Management

1. See network settings

How do I view my current network setup?

Answer: You can use the ifconfig command to view your current network configuration in Linux. It displays information about network interfaces, IP addresses, and other network settings.

2. Manually configure network

How can I set up my network connection myself?

Answer: You can manually configure your network connection by editing configuration files such as /etc/network/interfaces or using tools like ifconfig and ip commands to set IP addresses, routes, and other network parameters.

3. Check internet connection

How do I make sure I’m connected to the internet?

Answer: You can use commands like ping or curl to check your internet connection. For example

  • ping google.com will send packets to Google’s servers to check connectivity.
  • curl http://example.com will attempt to retrieve a webpage.

4. Data flow

How can I see where my computer sends and receives data?

Answer: You can use network monitoring tools like netstat or tcpdump to view network connections and data transfer on your computer. These tools provide detailed information about network activity.

5. Open ports

How do I check which programs are using the internet?

Answer: You can use the netstat command to display active network connections and listening ports. This helps you identify which programs are using the internet and which ports they are using.

g) System Monitoring and Management

1. Monitor performance

How can I keep track of how well my computer is running?

Answer: You can use tools like top, htop, or vmstat to monitor system performance in Linux. These tools display information about CPU, memory, disk, and network usage in real-time.

2. What is crontab

What can I do with the “crontab” command?

Answer: crontab is a command-line utility in Linux used to schedule recurring tasks (cron jobs). It allows users to automate tasks by specifying commands or scripts to run at specified intervals.

3. Edit a file

How can I change the contents of a file directly in the terminal?

Answer: You can use text editors like nano, vi, or vim to edit files directly in the terminal. Simply open the file with one of these editors, make your changes, and then save and exit.

4. curl vs wget

What are the differences between these two downloading tools?

Answer: curl and wget are both command-line tools used for downloading files from the internet, but they have different features and capabilities.

  • curl supports various protocols and is more versatile.
  • wget is better suited for recursive downloads and mirroring websites.

5. Manage code with git

How do I use the “git” command to work on code projects?

Answer: git is a version control system used for tracking changes in code projects. You can use commands like git clone, git add, git commit, and git push to manage and collaborate on code repositories.

6. What is awk

What can the “awk” command do for processing data?

Answer: awk is a powerful text-processing tool in Linux used for pattern scanning and processing. It allows you to extract and manipulate data from files, perform calculations, and generate reports.

7. Search with awk

How can I use “awk” to find specific information in a file?

Answer: You can use awk with pattern matching to search for specific information in a file. For example, awk '/pattern/' filename will print lines containing the specified pattern.

8. Awk scripts

What are the basic parts of an “awk” script?

Answer: An awk script consists of one or more patterns and actions enclosed in curly braces {}. The pattern specifies when the action should be performed, and the action defines what should be done when the pattern is matched.

9. Calculations with awk

How can I use “awk” to perform math with data in a file?

Answer: awk can perform arithmetic operations on data in a file using mathematical expressions within the script. For example, awk '{sum += $1} END {print sum}' filename will calculate the sum of numbers in the first column of the file.

10. Format with awk

How can I use “awk” to make the output of a file look better?

Answer: awk can be used to format the output of a file by specifying the field separators, field widths, and other formatting options within the script. This allows you to align columns and customize the appearance of the output.

FAQ’S (Linux Commands For Devops Interview Questions)

Q: What is the most common Linux command for DevOps?

A: The most common Linux command for DevOps is arguably ls, which is used to list directory contents. It’s essential for navigating and understanding the structure of files and directories in Linux systems, a fundamental task in DevOps operations.

Q: How Linux is used in DevOps?

A: Linux is widely used in DevOps for several reasons. It offers a stable and reliable environment for hosting applications and services. DevOps engineers leverage Linux for tasks like infrastructure provisioning, configuration management, automation, containerization, and deployment, making it a cornerstone of DevOps practices.

Q: How to crack a DevOps interview?

A: To excel in a DevOps interview, focus on understanding DevOps principles, methodologies, and relevant tools thoroughly. Showcase your expertise in areas like version control systems, continuous integration/continuous deployment (CI/CD) pipelines, infrastructure as code (IaC), containerization, orchestration tools, and cloud platforms. Additionally, emphasize your problem-solving skills, collaboration abilities, and real-world project experience.

Q: What is the most important command in Linux?

A: While opinions may vary, one of the most important commands in Linux is cd, which stands for “change directory.” It allows users to navigate between different directories in the file system, a fundamental operation in Linux and essential for various tasks in system administration, development, and DevOps.

Q: Which Linux is best for DevOps?

A: There isn’t a one-size-fits-all answer to this question as the choice of Linux distribution for DevOps depends on specific requirements and preferences. However, popular distributions like Ubuntu, CentOS, Debian, and Fedora are commonly used in DevOps environments due to their stability, community support, package availability, and compatibility with DevOps tools and workflows.

Q: Is Linux enough for DevOps?

A: Yes, Linux is more than sufficient for DevOps. In fact, Linux is the preferred operating system for DevOps practices due to its flexibility, scalability, robustness, and extensive support for automation and orchestration tools. DevOps engineers leverage Linux for a wide range of tasks including infrastructure management, application deployment, configuration management, monitoring, and more.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top