InterviewStack.io LogoInterviewStack.io

Command Line and Shell Scripting Questions

Practical skills using command line interfaces and writing simple shell scripts for automation and system administration across operating systems. For Linux this includes navigation and file operations, file permissions, process and service inspection, log viewing, package and systemctl management, common text processing and search utilities such as grep, find, sed, and awk, piping and redirection, environment variables, command substitution, and interactive use of editors and remote access tools. Shell scripting fundamentals include variables, conditionals, loops, functions, argument handling, basic debugging, and using bash to automate repetitive tasks. The scope also covers essential Windows command line and shell basics where relevant, including interactive commands, simple PowerShell cmdlets for process and service management, file and permission commands, and differences in syntax and environment when performing equivalent administrative tasks on Windows. Candidates may be evaluated on writing short scripts, composing command pipelines to accomplish tasks, and explaining tradeoffs between interactive commands and scripted automation.

EasyTechnical
86 practiced
Explain the Linux file permission and ownership model: user/group/other, rwx bits and numeric modes. Given a dataset directory that should allow group access to 'data' group but deny world access, provide the commands to set permissions, change ownership to user 'etl' and group 'data', set a setgid bit so new files inherit the group, and explain edge cases (umask, ACLs).
EasyTechnical
90 practiced
Write a small POSIX-compatible bash script named `checkfile.sh` that accepts a single filename argument and prints whether the file exists, is readable, writable, executable, and its size in bytes. Include usage instructions and exit codes for the following conditions: missing arg, not found, success.
MediumTechnical
91 practiced
Explain what `set -euo pipefail` does in bash scripts. Provide an example where omitting these flags causes a subtle bug (such as ignoring a failing command in a pipeline) and show how enabling them changes script behavior. Also explain how to allow a specific command to fail without exiting.
MediumTechnical
94 practiced
Implement a bash script using `getopts` that accepts `-i input_file -o output_file -v (verbose) -h (help)`. The script should validate that the input exists and output directory is writable and should print usage and exit codes on invalid arguments. Provide the implementation sketch.
MediumTechnical
126 practiced
Write a PowerShell script that queries the Windows 'Application' event log for Error and Warning entries from the last 48 hours, filters by ProviderName 'MyETL', and exports results to a CSV with columns TimeCreated, LevelDisplayName, Message, and Computer. Also show how to produce a count of errors per machine.

Unlock Full Question Bank

Get access to hundreds of Command Line and Shell Scripting interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.