---
tags:
- linux
- l1
- flashcard-deck
- linux-fundamentals
---
<!-- wiki:breadcrumb:start -->
[Portal](../../../../library/portal/index.md) | **Level:** [L1: Foundations](../../../../library/portal/levels.md) | **Topics:** [Linux Fundamentals](../../../../library/portal/topics.md) | **Domain:** Linux
<!-- wiki:breadcrumb:end -->

id	category	difficulty	tags	question	answer	source_path
linux-fundamentals/01abb1adc7e4	linux-fundamentals	medium	linux, user-management	How to generate a random string of 7 characters?	`mkpasswd -l 7`\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/170-how-to-generate-a-random-string-of-7-characters.txt
linux-fundamentals/027f886af6a6	linux-fundamentals	medium	linux	How to rename the name of a file or a directory?	Using the `mv` command.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/138-how-to-rename-the-name-of-a-file-or-a-directory.txt
linux-fundamentals/03cd84910657	linux-fundamentals	easy	linux, commands	What command shows the current directory path?	`pwd` (Print Working Directory) displays the absolute path of your current directory. Example output: `/home/user/projects`. Use `pwd -P` to resolve symlinks and show the physical path. \nGotcha: in a symlinked directory, plain `pwd` may show the symlink path while `pwd -P` shows the real location.	projects/knowledge/interview/linux/562-pwd-command.txt
linux-fundamentals/06ed99f6fcf5	linux-fundamentals	medium	linux, system	What are soft limits and hard limits?	**Hard limit** is the maximum allowed to a user, set by the superuser or root. This value is set in the file `/etc/security/limits.conf`. The user can increase the **soft limit** on their own in times of needing more resources, but cannot set the **soft limit** higher than the **hard limit**.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/064-what-are-soft-limits-and-hard-limits.txt
linux-fundamentals/07499874dd58	linux-fundamentals	easy	linux, system	Every command fails with `command not found`. How to trace the source of the error and resolve it?	It looks that at one point or another are overwriting the default `PATH` environment variable. The type of errors you have, indicates that `PATH` does not contain e.g. `/bin`, where the commands (including bash) reside.\n\nOne way to begin debugging your bash script or command would be to start a subshell with the `-x` option:\n\n```bash\nbash --login -x\n```\n\nThis will show you every command, and its arguments, which is executed when starting that shell.\n\nAlso very helpful is show `PATH` variable values:\n\n```bash\necho $PATH\n```\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/015-every-command-fails-with-codecommand-not-foundcode.txt
linux-fundamentals/0a2e3fc0c03e	linux-fundamentals	easy	linux, commands	What is the cat command short for?	Concatenate — `cat` is short for concatenate. Its primary purpose is joining multiple files end-to-end and writing the result to stdout, though it is most commonly used to display the contents of a single file.\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/569-cat-meaning.txt
linux-fundamentals/0bf0187f0ba0	linux-fundamentals	easy	linux, system	How do I grep recursively?	Use `grep -r` (or `grep -rn` to include line numbers). Examples: `grep -r 'pattern' /path/to/dir` searches all files recursively. `grep -rn 'TODO' .` shows matches with line numbers. `grep -rl 'pattern' .` lists only filenames.\n\nRemember: grep = Global Regular Expression Print. `-r` recursive, `-i` insensitive, `-n` line numbers.\n\nExample: `grep -rn 'ERROR' /var/log/` — recursive with line numbers.	projects/knowledge/interview/linux/022-how-do-i-codegrepcode-recursively-explain-on-sever.txt
linux-fundamentals/104acd29438b	linux-fundamentals	easy	linux, commands, grep	How do you find a text string in files on Linux?	Using the grep command (e.g., grep "search_term" filename).\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/558-find-text-string-in-files.txt
linux-fundamentals/1421f0d43961	linux-fundamentals	medium	linux, system	Create a file with 100 lines with random values.	For example:\n\n```bash\ncat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 100 > /path/to/file\n```\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/067-create-a-file-with-100-lines-with-random-values.txt
linux-fundamentals/1a282e4b9c68	linux-fundamentals	medium	linux, bash, shell, globbing	What happens when you execute ls -l *.log?	The shell expands *.log before ls runs:\n\n1. Shell glob expansion:\n   - Shell finds all files matching *.log\n   - Replaces *.log with list of filenames\n   - ls sees: ls -l file1.log file2.log file3.log\n\n2. If no matches:\n   - Default: literal "*.log" passed to ls\n   - With nullglob: empty string (no argument)\n   - ls may error or show nothing\n\n3. ls execution:\n   - Receives expanded filenames\n   - Calls stat() on each file\n   - Displays long format info\n\nKey point: Glob expansion happens in shell, not in ls.\n- ls never sees the asterisk\n- Shell does pattern matching before exec	projects/knowledge/interview/linux/407-what-happens-when-you-execute-ls-l-log.txt
linux-fundamentals/219858e0a2c6	linux-fundamentals	medium	linux, permissions	Explain each field in the output of `ls -l` command	It shows a detailed list of files in a long format. From the left:\n\n* file permissions, number of links, owner name, owner group, file size, timestamp of last modification and directory/file name\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/134-explain-each-field-in-the-output-of-ls-l-command.txt
linux-fundamentals/22507477ecd1	linux-fundamentals	medium	linux, scripting	What does the following block do?:	These system calls are reading the file `/my/file` and 5 is the file descriptor number.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/310-what-does-the-following-block-do-openmyfile-5-read.txt
linux-fundamentals/235fdbfdfffb	linux-fundamentals	medium	linux	You would like to copy a file to a remote Linux host. How would you do?	There are multiple ways to transfer files between hosts. Personal opinion: use `rsync`\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/168-you-would-like-to-copy-a-file-to-a-remote-linux-ho.txt
linux-fundamentals/2642c9052952	linux-fundamentals	easy	linux, commands	What command creates a new directory?	`mkdir`. Use `-p` to create parent directories as needed (e.g., `mkdir -p /opt/app/logs`). Without `-p`, it errors if the parent doesn't exist.\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/567-mkdir-command.txt
linux-fundamentals/27a74fa5d325	linux-fundamentals	easy	linux, user-management	What is /etc/skel in Linux and how is it used during user creation?	`/etc/skel` is a skeleton directory whose contents are copied into new users' home directories when they are created with `useradd`.\n\nRemember: sed = Stream EDitor. `s/old/new/g` — s=substitute, g=global. `-i` = in-place.\n\nExample: `sed -i 's/old/new/g' file.txt`. `-i.bak` creates backup first.	projects/knowledge/interview/linux/273-what-is-etcskel-etcskel-is-a-directory-that-contai.txt
linux-fundamentals/2813d3f370f4	linux-fundamentals	hard	linux, system	The program returns the error of the missing library. How to provide dynamically linkable libraries?	Environment variable `LD_LIBRARY_PATH` is a colon-separated set of directories where libraries should be searched for first, before the standard set of directories; this is useful when debugging a new library or using a nonstandard library for special purposes.\n\nThe best way to use `LD_LIBRARY_PATH` is to set it on the command line or script immediately before executing the program. This way the new `LD_LIBRARY_PATH` isolated from the rest of your system.\n\nExample of use:\n\n```bash\nexport LD_LIBRARY_PATH="/list/of/library/paths:/another/path" ./program\n```\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/083-the-program-returns-the-error-of-the-missing-libra.txt
linux-fundamentals/2b3bf46b5fbb	linux-fundamentals	easy	linux, commands	What command removes an empty directory?	`rmdir`. It only removes empty directories — fails if the directory has contents. Use `rm -r` to recursively remove a directory and its contents.\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/579-rmdir-command.txt
linux-fundamentals/2c8109a75a68	linux-fundamentals	easy	linux, system	You have to find all files larger than 20MB. How you do it?	```bash\nfind / -type f -size +20M\n```\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/027-you-have-to-find-all-files-larger-than-20mb-how-yo.txt
linux-fundamentals/2d75e484933e	linux-fundamentals	easy	linux, commands	What does `rm -rf` do and why is it dangerous?	Recursively and forcibly removes a directory and its contents.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/578-rm-rf-command.txt
linux-fundamentals/2f028dabb000	linux-fundamentals	easy	linux, bash, shell, escaping	What is escaping? What escape character is used for?	Escaping prevents the shell from interpreting special characters.\n\nThe backslash (\) is the escape character:\n- \$ - Literal dollar sign\n- \\ - Literal backslash\n- \n - Newline (in echo -e)\n- \" - Literal quote inside double quotes\n\nExamples:\n- echo \$HOME → $HOME (literal)\n- echo "He said \"hello\"" → He said "hello"\n- touch file\ name.txt → Creates "file name.txt"\n\nWithin single quotes, no escaping needed (all literal).\nWithin double quotes, escape \, $, `, ", !\n\nRemember: sed = Stream EDitor. `s/old/new/g` — s=substitute, g=global. `-i` = in-place.\n\nExample: `sed -i 's/old/new/g' file.txt`. `-i.bak` creates backup first.	projects/knowledge/interview/linux/343-what-is-escaping-what-escape-character-is-used-for.txt
linux-fundamentals/31987c7f19c4	linux-fundamentals	easy	linux	What is the difference between man and info?	`man` provides concise reference pages organized by sections (1=commands, 5=file formats, 8=admin). `info` provides longer, hyperlinked tutorials in a Texinfo format with navigation between nodes. In practice, most people use `man`. Some GNU tools (like `coreutils`) have more detailed `info` pages than their `man` pages.	projects/knowledge/interview/linux/324-what-is-the-difference-between-man-and-info.txt
linux-fundamentals/34d78d7547ff	linux-fundamentals	easy	linux, commands	How do you create an empty file or update its timestamp?	`touch`. Creates the file if it doesn't exist; updates atime/mtime if it does. Commonly used to create empty marker/lock files or trigger build systems.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/568-touch-command.txt
linux-fundamentals/3839f10989b4	linux-fundamentals	easy	linux, rpm, deb, repositories	Where are repositories stored (based on the distribution)?	Repository configuration locations:\n\nRHEL/Fedora/CentOS:\n- /etc/yum.repos.d/*.repo\n- Contains: baseurl, gpgcheck, enabled\n- dnf config-manager --add-repo URL\n\nDebian/Ubuntu:\n- /etc/apt/sources.list\n- /etc/apt/sources.list.d/*.list\n- Format: deb URL distribution components\n- add-apt-repository for PPAs\n\nSUSE:\n- /etc/zypp/repos.d/\n- zypper addrepo\n\nAfter changes:\n- yum/dnf: Automatic refresh\n- apt: apt update required\n\nRemember: sed = Stream EDitor. `s/old/new/g` — s=substitute, g=global. `-i` = in-place.\n\nExample: `sed -i 's/old/new/g' file.txt`. `-i.bak` creates backup first.	projects/knowledge/interview/linux/383-where-repositories-are-stored-based-on-the-distrib.txt
linux-fundamentals/3982693f3a6d	linux-fundamentals	medium	linux	What each of the following matches	* The ? matches any single character\n  * The * matches zero or more characters\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/202-what-each-of-the-following-matches.txt
linux-fundamentals/3bbcc0fcf6d0	linux-fundamentals	medium	linux, control-flow, variables	How to create your own environment variables?	`X=2` for example. But this will persist to new shells. To have it in new shells as well, use `export X=2`\n\nRemember: `export VAR=val` for child processes. Without export = current shell only.\n\nGotcha: .bashrc=interactive shells, .bash_profile=login shells. Source of confusion.	projects/knowledge/interview/linux/325-how-to-create-your-own-environment-variables.txt
linux-fundamentals/3bc09fa76581	linux-fundamentals	medium	linux, system	How could you modify a text file without invoking a text editor?	For example: \n\n```bash\n# cat >filename ... - overwrite file\n# cat >>filename ... - append to file\ncat > filename << __EOF__\ndata\n__EOF__\n```\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/050-how-could-you-modify-a-text-file-without-invoking-.txt
linux-fundamentals/3d899f8406f0	linux-fundamentals	medium	linux, bash, shell, alias	What exactly does the command alias x=y do?	alias x=y creates a shell shortcut where typing 'x' expands to 'y'.\n\nBehavior:\n- When you type 'x', shell replaces it with 'y'\n- Only works in interactive shells\n- Doesn't work in scripts (by default)\n\nExamples:\n- alias ll='ls -la'\n- alias grep='grep --color=auto'\n- alias k='kubectl'\n\nProperties:\n- Aliases don't take arguments in the middle\n- Checked before command lookup\n- Can be overridden with \x or command x\n\nPersistence:\n- Add to ~/.bashrc or ~/.bash_aliases\n- Source file or restart shell\n\nManagement:\n- alias - List all aliases\n- alias x - Show specific alias\n- unalias x - Remove alias	projects/knowledge/interview/linux/409-what-exactly-the-command-alias-xy-does.txt
linux-fundamentals/41a0d5013d84	linux-fundamentals	medium	linux	How `cd -` works? How does it knows the previous location?	The shell stores the previous directory in the `$OLDPWD` environment variable. `cd -` is shorthand for `cd $OLDPWD` and prints the path it switches to.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/321-how-cd-works-how-does-it-knows-the-previous-locati.txt
linux-fundamentals/4291193b237c	linux-fundamentals	medium	linux	How can you send an HTTP request from your shell?	Use `nc` (netcat) to send raw HTTP requests: `echo -e 'GET / HTTP/1.1\r\nHost: example.com\r\n\r\n' | nc example.com 80`. More commonly, use `curl` for HTTP requests: `curl -v https://example.com`. Also available: `wget` for downloads, `httpie` (http command) for a user-friendly CLI. Gotcha: `nc` requires manual HTTP formatting including carriage returns.	projects/knowledge/interview/linux/255-how-can-you-send-an-http-request-from-your-shell.txt
linux-fundamentals/450b75b73d59	linux-fundamentals	easy	linux, commands	What does the ls command do in Linux?	It lists directory contents (files and folders) in the current working directory.\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/556-what-does-ls-command-do.txt
linux-fundamentals/45429dad96d0	linux-fundamentals	hard	linux, system	The Junior dev accidentally destroyed production database. How can you prevent such situations?	Prevent production disasters with layered safeguards:\n\n1. **Access control**: Restrict prod DB access to senior engineers. Use separate credentials per environment\n2. **Backups & tested restores**: Regular automated backups with periodic restore tests. Snapshots before changes\n3. **Environment isolation**: Separate dev/test/prod with different auth credentials. Never develop against prod\n4. **Disaster recovery plan**: Documented DR procedures with a backup datacenter or failover region\n5. **Replication with delay**: Slightly delayed replicas give a window to catch destructive mistakes\n6. **Post-mortems**: Document incidents to prevent recurrence. Focus on systemic fixes, not blame	projects/knowledge/interview/linux/086-the-junior-dev-accidentally-destroyed-production-d.txt
linux-fundamentals/46ba3cfbc378	linux-fundamentals	hard	linux, system	How to add new user without using `useradd`/`adduser` commands?	1. Add an entry of user details in `/etc/passwd` with `vipw`:\n\n```bash\n# username:password:UID:GID:Comments:Home_Directory:Login Shell\nuser:x:501:501:test user:/home/user:/bin/bash\n```\n\n > Be careful with the syntax. Do not edit directly with an editor. `vipw` locks the file, so that other commands won't try to update it at the same time.\n\n2. You will have to create a group with same name in `/etc/group` with `vigr` (similar tool for `vipw`):\n\n```bash\nuser:x:501:\n```\n\n3. Assign a password to the user:\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/122-how-to-add-new-user-without-using-codeuseraddcodec.txt
linux-fundamentals/4b36f42c83fd	linux-fundamentals	medium	linux, redirection	Demonstrate Linux output redirection	`ls > ls_output.txt` redirects stdout to a file, overwriting its contents. Key operators: `>` overwrites, `>>` appends, `2>` redirects stderr, `&>` redirects both stdout and stderr. \nExample: `find / -name '*.conf' 2>/dev/null` suppresses permission errors. Mnemonic: one arrow overwrites, two arrows append.	projects/knowledge/interview/linux/147-demonstrate-linux-output-redirection.txt
linux-fundamentals/4bdd7602cce2	linux-fundamentals	medium	linux	How would you split a 50 lines file into 2 files of 25 lines each?	You can use the `split` command this way: `split -l 25 some_file`\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/244-how-would-you-split-a-50-lines-file-into-2-files-o.txt
linux-fundamentals/4cd529a4585c	linux-fundamentals	hard	linux, system	How to read a file line by line and assigning the value to a variable?	For example:\n\n```bash\nwhile IFS='' read -r line || [[ -n "$line" ]] ; do\n  echo "Text read from file: $line"\ndone < "/path/to/filename"\n```\n\nExplanation:\n\n- `IFS=''` (or `IFS=`) prevents leading/trailing whitespace from being trimmed.\n- `-r` prevents backslash escapes from being interpreted.\n- `|| [[ -n $line ]]` prevents the last line from being ignored if it doesn't end with a `\n` (since  read returns a non-zero exit code when it encounters EOF).\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/101-how-to-read-a-file-line-by-line-and-assigning-the-.txt
linux-fundamentals/4cd78164628c	linux-fundamentals	easy	linux	How to check what is the hostname of the system?	`cat /etc/hostname`\n\nYou can also run `hostnamectl` or `hostname` but that might print only a temporary hostname. The one in the file is the permanent one.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/259-how-to-check-what-is-the-hostname-of-the-system.txt
linux-fundamentals/5419c9ac60f4	linux-fundamentals	easy	linux, system	How to find files that have been modified on your system in the past 60 minutes?	```bash\nfind / -mmin -60 -type f\n```\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/029-how-to-find-files-that-have-been-modified-on-your-.txt
linux-fundamentals/55e0826a4c68	linux-fundamentals	easy	linux, commands	How do you move up one directory level?	`cd ..` — the double dot `..` is a special directory entry pointing to the parent. Every directory has it (even `/`, where `..` points to itself).\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/565-cd-parent-directory.txt
linux-fundamentals/5cc73c114fdf	linux-fundamentals	medium	linux, career	What defines a "senior" Linux engineer?	Not years of experience - demonstrated capabilities:\n\n**Failure prediction**:\n* Sees problems before they happen\n* Understands failure modes\n* Designs for resilience\n\n**Blast radius control**:\n* Knows what could break from any change\n* Tests changes incrementally\n* Has rollback plans ready\n\n**Knowing when NOT to act**:\n* Resists urge to "fix" working systems\n* Asks questions before changing\n* Documents understanding before touching\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/465-what-defines-a-senior-linux-engineer.txt
linux-fundamentals/5f2a6959b66f	linux-fundamentals	medium	linux, control-flow, logging, user-management	Explain what each of the following commands does:	`useradd` - Command for creating new users \n  `usermod` - Modify the users setting\n  `whoami`  - Outputs, the username that we are currently logged in\n  `id`      - Prints the\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/274-explain-what-each-of-the-following-commands-does-u.txt
linux-fundamentals/62ab7e3be834	linux-fundamentals	medium	linux	True or False? Directories always have by minimum 2 links	True. Every directory has at least 2 hard links: its entry in the parent directory, and the `.` entry inside itself. Each subdirectory adds another link via its `..` entry.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/213-true-or-false-directories-always-have-by-minimum-2.txt
linux-fundamentals/6403b610d7ca	linux-fundamentals	medium	linux, system	Is there a way to redirect output to a file and have it display on stdout?	The command you want is named tee:\n\n`foo | tee output.file`\n\nFor example, if you only care about stdout:\n\n`ls -a | tee output.file`\n\nIf you want to include stderr, do:\n\n`program [arguments...] 2>&1 | tee outfile`\n\n`2>&1` redirects channel 2 (stderr/standard error) into channel 1 (stdout/standard output), such that both is written as stdout. It is also directed to the given output file as of the tee command.\n\nFurthermore, if you want to append to the log file, use `tee -a` as:\n\n`program [arguments...] 2>&1 | tee -a outfile`	projects/knowledge/interview/linux/071-is-there-a-way-to-redirect-output-to-a-file-and-ha.txt
linux-fundamentals/6a1f35143355	linux-fundamentals	easy	linux, commands	What command finds files by name in a directory tree?	`find`. Examples: `find /var -name '*.log'` by name, `find / -size +100M` by size, `find . -mtime -1` modified in last day. Combine with `-exec` to act on results.\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/574-find-command.txt
linux-fundamentals/6c59b4ea58f1	linux-fundamentals	medium	linux	Name 5 commands which are two letters long	Common two-letter commands: ls (list), wc (word count), dd (disk dump), df (disk free), du (disk usage), ps (processes), ip (network config), cp (copy), cd (change directory), mv (move), rm (remove), ln (link). These short names follow Unix philosophy of brevity — frequently used commands get the shortest names.	projects/knowledge/interview/linux/319-name-5-commands-which-are-two-letters-long.txt
linux-fundamentals/6e906f6a2d32	linux-fundamentals	medium	linux, control-flow	How to count the number of lines in a file? What about words?	For these we can use `wc` command.\n\n1. To count the number of lines in file\n```wc -l```\n\n2. To count the number of words in file\n```wc -w```\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/323-how-to-count-the-number-of-lines-in-a-file-what-ab.txt
linux-fundamentals/6f82c98f2c5e	linux-fundamentals	easy	linux, boot	What is special about the /tmp directory when compared to other directories?	`/tmp` folder is cleaned automatically, usually upon reboot.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/153-what-is-special-about-the-tmp-directory-when-compa.txt
linux-fundamentals/70a834c33c73	linux-fundamentals	medium	linux, control-flow	What ways are there for creating a new empty file?	* touch new_file\n  * echo "" > new_file\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/320-what-ways-are-there-for-creating-a-new-empty-file.txt
linux-fundamentals/7289c43cc793	linux-fundamentals	easy	linux, system	What is the difference between `rm` and `rm -rf`?	`rm` only deletes the named files (and not directories). With `-rf` as you say:\n\n- `-r`, `-R`, `--recursive` recursively deletes content of a directory, including hidden files and sub directories\n- `-f`, `--force` ignore nonexistent files, never prompt\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/021-what-is-the-difference-between-codermcode-and-code.txt
linux-fundamentals/7320513f3bea	linux-fundamentals	medium	linux, control-flow, user-management	Some of the commands in the previous question can be run with the -r/-R flag. What does it do? Give an example to when you would use it	The -r (or -R in some commands) flag allows the user to run a certain command recursively. For example, listing all the files under the following tree is possible when done recursively (`ls -R`):\n\n/dir1/\n  dir2/\n    file1\n    file2\n  dir3/\n    file3\n\nTo list all the files, one can run `ls -R /dir1`\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/133-some-of-the-commands-in-the-previous-question-can-.txt
linux-fundamentals/76ac946e02f6	linux-fundamentals	easy	linux, system	How can I sync two local directories?	To sync the contents of **dir1** to **dir2** on the same system, type:\n\n```bash\nrsync -av --progress --delete dir1/ dir2\n```\n\n- `-a`, `--archive` - archive mode\n- `--delete` - delete extraneous files from dest dirs\n- `-v`, `--verbose` - verbose mode (increase verbosity)\n- `--progress` - show progress during transfer\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/025-how-can-i-sync-two-local-directories.txt
linux-fundamentals/76bc13e5bf8f	linux-fundamentals	easy	linux, commands	How do you view the first 10 lines of a file?	`head`. By default shows first 10 lines. Use `-n 20` for 20 lines, or `-c 100` for first 100 bytes. Pairs with `tail` for viewing file ends.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/570-head-command.txt
linux-fundamentals/779c3b39d190	linux-fundamentals	easy	linux	How would you check what is the size of a certain directory?	`du -sh <dir>` — `-s` summarizes (total only), `-h` makes it human-readable. Without `-s`, it lists every subdirectory. `du -sh *` shows sizes of all items in current dir.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/216-how-would-you-check-what-is-the-size-of-a-certain-.txt
linux-fundamentals/791a8762548c	linux-fundamentals	medium	linux	How to follow file's content as it being appended without opening the file every time?	tail -f <file_name>\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/177-how-to-follow-files-content-as-it-being-appended-w.txt
linux-fundamentals/7b2eb9e49cc2	linux-fundamentals	medium	linux, control-flow, package-management	How to look for a package that provides the command /usr/bin/git? (the package isn't necessarily installed)	`dnf provides /usr/bin/git` (RHEL/Fedora) or `apt-file search /usr/bin/git` (Debian/Ubuntu) finds which package provides a specific file, even if the package is not installed. On RHEL: install `yum-utils` for `repoquery --whatprovides`. This is essential when you encounter a 'command not found' error and need to install the right package.	projects/knowledge/interview/linux/266-how-to-look-for-a-package-that-provides-the-comman.txt
linux-fundamentals/7c10515cd370	linux-fundamentals	medium	linux, packaging, rpm, deb	Do you have experience with packaging (building packages)?	Building packages varies by distribution:\n\nRPM (RHEL, Fedora, CentOS):\n- rpmbuild with .spec file\n- Defines build steps, dependencies, files\n- Result: .rpm package\n\nDEB (Debian, Ubuntu):\n- dpkg-buildpackage\n- debian/ directory with control files\n- Result: .deb package\n\nSteps typically include:\n1. Prepare source\n2. Configure build\n3. Compile\n4. Install to staging directory\n5. Package with metadata\n\nTools:\n- Mock/Koji: RPM build environments\n- pbuilder/sbuild: DEB build environments\n- fpm: Cross-format packaging\n- checkinstall: Quick packaging from make install\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/379-do-you-have-experience-with-packaging-as-in-buildi.txt
linux-fundamentals/810770c358be	linux-fundamentals	easy	linux, system	Many basic maintenance tasks require you to edit config files. Explain ways to undo the changes you make.	- manually backup of a file before editing (with brace expansion like this: `cp filename{,.orig}`)\n- manual copy of the directory structure where file is stored (e.g. `cp`, `rsync` or `tar`)\n- make a backup of original file in your editor (e.g. set rules in your editor configuration file)\n- the best solution is to use `git` (or any other version control) to keep track of configuration files (e.g. `etckeeper` for `/etc` directory)\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/026-many-basic-maintenance-tasks-require-you-to-edit-c.txt
linux-fundamentals/841fe2fe077e	linux-fundamentals	medium	linux, system	How to check if running as root in a bash script? What should you watch out for?	In a bash script, you have several ways to check if the running user is root.\n\nAs a warning, do not check if a user is root by using the root username. Nothing guarantees that the user with ID 0 is called root. It's a very strong convention that is broadly followed but anybody could rename the superuser another name.\n\nI think the best way when using bash is to use `$EUID` because `$UID` could be changed and not reflect the real user running the script.\n\n```bash\nif (( $EUID != 0 )); then\n  echo "Please run as root"\n  exit\nfi\n```	projects/knowledge/interview/linux/069-how-to-check-if-running-as-root-in-a-bash-script-w.txt
linux-fundamentals/883068473e28	linux-fundamentals	medium	linux, system	Is there an easy way to search inside 1000s of files in a complex directory structure to find files which contain a specific string?	For example use `fgrep`:\n\n```bash\nfgrep * -R "string"\n```\n\nor:\n\n```bash\ngrep -insr "pattern" *\n```\n\n- `-i` ignore case distinctions in both the **PATTERN** and the input files\n- `-n`  prefix each line of output with the 1-based line number within its input file\n- `-s` suppress error messages about nonexistent or unreadable files.\n- `-r` read all files under each directory, recursively.\n\nRemember: which=PATH, whereis=binary+man+src, type=alias/builtin/file. type is best.	projects/knowledge/interview/linux/079-is-there-an-easy-way-to-search-inside-1000s-of-fil.txt
linux-fundamentals/890e93b7f9cd	linux-fundamentals	easy	linux, system	What is an incremental backup?	An incremental backup is a type of backup that only copies files that have changed since the previous backup.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/031-what-is-an-incremental-backup.txt
linux-fundamentals/8af26fd62bd4	linux-fundamentals	easy	linux, bash, shell	How do you create a shortcut for a complex command in Bash?	Add an alias to `~/.bashrc` (or `~/.zshrc` for zsh). \nExample: `alias k='kubectl'` or `alias ll='ls -la'`. Run `source ~/.bashrc` to activate immediately without restarting the shell. Use `alias` with no arguments to list all current aliases. \nGotcha: aliases defined in the shell are lost when the session ends unless saved to the rc file.	projects/knowledge/interview/linux/559-bash-alias-creation.txt
linux-fundamentals/8b444295b288	linux-fundamentals	hard	linux, system	How do you run command every time a file is modified?	For example:\n\n```bash\nwhile inotifywait -e close_write filename ; do\n\n  echo "changed" >> /var/log/changed\n\ndone\n```\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/091-how-do-you-run-command-every-time-a-file-is-modifi.txt
linux-fundamentals/8c328d2f4cb6	linux-fundamentals	easy	linux, bash, shell	What is shell globbing and how does pattern matching work?	Filename pattern matching by the shell before command execution.\n\nPatterns:\n- * - Any characters (except leading dot)\n- ? - Exactly one character\n- [abc] - Any of a, b, c\n- [a-z] - Range\n- [!abc] - NOT listed\n\nExamples:\n- ls *.txt - All .txt files\n- rm test[0-9].txt - test0.txt through test9.txt\n\nShell expands globs BEFORE passing to command.\n\nRemember: *=any, ?=one char, [abc]=one of, {a,b}=expansion. Globs ≠ regex.	projects/knowledge/interview/linux/338-what-is-globbing.txt
linux-fundamentals/8d6bc388b23e	linux-fundamentals	medium	linux, bash, shell, globbing	Explain what will ls [0-5] match	ls [0-5] matches files whose name is exactly ONE character in the range 0-5.\n\nIt will match files named:\n- "0", "1", "2", "3", "4", "5"\n\nIt will NOT match:\n- "6", "7", "8", "9" (outside range)\n- "01" (two characters)\n- "file1" (multiple characters)\n\nThe [0-5] is a character class range - matches one digit from 0 to 5.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/341-explain-what-will-ls-0-5-match.txt
linux-fundamentals/939fe7bbf686	linux-fundamentals	easy	linux, commands	What does cd ~ accomplish?	It returns the user to their home directory.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/566-cd-home-directory.txt
linux-fundamentals/964cd22c5dd3	linux-fundamentals	easy	linux, shell	What is the # sign in a shell prompt usually indicative of?	The `#` prompt indicates a superuser (root) session, while `$` indicates a regular user session. This convention is defined in the PS1 shell variable and is nearly universal across Linux distributions. \nGotcha: running as root is dangerous — prefer `sudo` for individual commands to maintain an audit trail and limit exposure.	projects/knowledge/interview/linux/561-hash-sign-prompt.txt
linux-fundamentals/991db102159d	linux-fundamentals	easy	linux, scripting, shebang	What is the purpose of the shebang (#!) at the start of a script?	It specifies the interpreter for the script (e.g., #!/bin/bash tells the OS to run the script with the Bash shell).\n\nRemember: c=create, x=extract, t=list, v=verbose, f=file, z=gzip. "eXtract Ze File" = xzf.\n\nExample: Create: `tar czf arch.tar.gz dir/` Extract: `tar xzf arch.tar.gz`	projects/knowledge/interview/linux/563-purpose-of-shebang.txt
linux-fundamentals/9e1eec289feb	linux-fundamentals	easy	linux, commands	How do you list all files, including hidden ones?	`ls -a`. The `-a` flag includes entries starting with `.` (dotfiles). `ls -la` combines long format with hidden files for the most complete listing.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/563-ls-hidden-files.txt
linux-fundamentals/a058ce1174c3	linux-fundamentals	easy	linux, logging, user-management	What is stored in each of the following paths?	* binaries\n  * configuration files\n  * home directories of the different users\n  * files that tend to change and be modified like logs\n  * temporary files\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/152-what-is-stored-in-each-of-the-following-paths-bin-.txt
linux-fundamentals/a1b88891b97a	linux-fundamentals	easy	linux, bash, shell, wildcards	What are wildcards? Can you give an example of how to use them?	Wildcards are special characters for pattern matching in filenames.\n\nCommon wildcards:\n- * - Matches zero or more characters\n- ? - Matches exactly one character\n- [...] - Matches any character in brackets\n- [!...] - Matches any character NOT in brackets\n\nExamples:\n- ls *.log - All files ending in .log\n- rm file?.txt - file1.txt, file2.txt, etc.\n- cp [A-Z]*.pdf backup/ - PDFs starting with uppercase\n- mv *[0-9].bak archive/ - Files ending with digit.bak\n\nWildcards are expanded by shell before command execution.\n\nRemember: *=any, ?=one char, [abc]=one of, {a,b}=expansion. Globs ≠ regex.	projects/knowledge/interview/linux/339-what-are-wildcards-can-you-give-an-example-of-how-.txt
linux-fundamentals/a249a5f00616	linux-fundamentals	easy	linux, control-flow	You run ls and you get "/lib/ld-linux-armhf.so.3 no such file or directory". What is the problem?	The ls executable is built for an incompatible architecture.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/243-you-run-ls-and-you-get-libld-linux-armhfso3-no-suc.txt
linux-fundamentals/a939ed5244b0	linux-fundamentals	hard	linux, system	What is the easiest, safest and most portable way to remove `-rf` directory entry?	They're effective but not optimally portable:\n\n- `rm -- -fr`\n- `perl -le 'unlink("-fr");'`\n\nPeople who go on about shell command line quoting and character escaping are almost as dangerous as those who simply don't even recognize why a file name like that poses any problem at all.\n\nThe most portable solution:\n\n```bash\nrm ./-fr\n```\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/125-what-is-the-easiest-safest-and-most-portable-way-t.txt
linux-fundamentals/ab2b2b4c7cfa	linux-fundamentals	hard	linux, system	How to remove all files except some from a directory?	Solution 1 - with `extglob`:\n\n```bash\nshopt -s extglob\nrm !(textfile.txt|backup.tar.gz|script.php|database.sql|info.txt)\n```\n\nSolution 2 - with `find`:\n\n```bash\nfind . -type f -not -name '*txt' -print0 | xargs -0 rm --\n```\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/104-how-to-remove-all-files-except-some-from-a-directo.txt
linux-fundamentals/ad5ef765cfe5	linux-fundamentals	easy	linux	What is the difference between these two commands? Will it result in the same output?	The echo command receives two separate arguments in the first execution and in the second execution it gets one argument which is the string "hello world". The output will be the same.\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/141-what-is-the-difference-between-these-two-commands-.txt
linux-fundamentals/ae6307a0f5f9	linux-fundamentals	easy	linux, rpm, deb, packaging	How do you list the content of a package without actually installing it?	Depends on package format:\n\nRPM:\n- rpm -qlp package.rpm - List files in .rpm\n- rpm -ql package-name - List files of installed package\n- repoquery -l package - Query from repo\n\nDEB:\n- dpkg -c package.deb - List files in .deb\n- dpkg -L package-name - List installed package files\n- apt-file list package - From repo\n\nOther info:\n- rpm -qip package.rpm - Package info\n- dpkg -I package.deb - Package info\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/381-how-do-you-list-the-content-of-a-package-without-a.txt
linux-fundamentals/afe035ffd29d	linux-fundamentals	easy	linux, rpm, deb, packaging	How to know to which package a file on the system belongs?	Query package databases:\n\nRPM (RHEL/Fedora):\n- rpm -qf /path/to/file\n- Example: rpm -qf /bin/ls → coreutils\n\nDEB (Debian/Ubuntu):\n- dpkg -S /path/to/file\n- Example: dpkg -S /bin/ls → coreutils\n\nIf file not from package:\n- Commands return "not owned by any package"\n- File was manually created or from source install\n\nSearch for files not yet installed:\n- yum provides /path (or dnf)\n- apt-file search /path\n\nRemember: which=PATH, whereis=binary+man+src, type=alias/builtin/file. type is best.	projects/knowledge/interview/linux/382-how-to-know-to-which-package-a-file-on-the-system-.txt
linux-fundamentals/b1327a6d7775	linux-fundamentals	easy	linux, bash, shell, quoting	What is the difference between single and double quotes?	In bash, quotes affect variable and special character handling:\n\nSingle quotes ('...'):\n- Everything is literal\n- No variable expansion\n- No special character interpretation\n- echo '$HOME' prints: $HOME\n\nDouble quotes ("..."):\n- Variables are expanded\n- Command substitution works\n- Special chars \, $, `, ! interpreted\n- echo "$HOME" prints: /home/user\n\nBackticks/$(...)\n- Command substitution\n- Output replaces the expression\n\nExample:\n- name="world"\n- echo 'Hello $name' → Hello $name\n- echo "Hello $name" → Hello world\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/342-what-is-the-difference-single-and-double-quotes.txt
linux-fundamentals/b562e7a7e653	linux-fundamentals	medium	linux, system	How to make high availability of web application? 	Key requirements for managing user access at scale:\n\n1. **Authentication**: Centralized identity (LDAP/AD/SSO). MFA for privileged access\n2. **Authorization**: Role-based access control (RBAC). Principle of least privilege\n3. **Auditing**: Log all access and changes. Regular access reviews\n4. **Provisioning**: Automated onboarding/offboarding tied to HR systems\n5. **Password policy**: Minimum complexity, rotation, no shared accounts\n6. **Privileged access**: Separate admin accounts, just-in-time access, session recording\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/048-how-to-make-high-availability-of-web-application-b.txt
linux-fundamentals/bbc96bdbce3e	linux-fundamentals	easy	linux, system	What do the fields in `ls -al` output mean?	In the order of output:\n\n```bash\n-rwxrw-r-- 1 root root 2048 Jan 13 07:11 db.dump\n```\n\n- file permissions,\n- number of links,\n- owner name,\n- owner group,\n- file size,\n- time of last modification,\n- file/directory name\n\nFile permissions is displayed as following:\n\n- first character is `-` or `l` or `d`, `d` indicates a directory, a `-` represents a file, `l` is a symlink (or soft link) - special type of file\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/007-what-do-the-fields-in-codels-alcode-output-mean.txt
linux-fundamentals/bc41408ea687	linux-fundamentals	easy	linux, system	How is a user’s default group determined? How would you change it?	```bash\nuseradd -m -g initial_group username\n```\n\n`-g/--gid`: defines the group name or number of the user's initial login group. If specified, the group name must exist; if a group number is provided, it must refer to an already existing group.\n\nIf not specified, the behaviour of useradd will depend on the `USERGROUPS_ENAB` variable contained in `/etc/login.defs`. The default behaviour (`USERGROUPS_ENAB yes`) is to create a group with the same name as the username, with **GID** equal to **UID**.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/033-how-is-a-users-default-group-determined-how-would-.txt
linux-fundamentals/bc984f94fbe3	linux-fundamentals	hard	linux, system	Why do we need `mktemp` command? Present an example of use.	`mktemp` randomizes the name. It is very important from the security point of view.\n\nJust imagine that you do something like:\n\n```bash\necho "random_string" > /tmp/temp-file\n```\n\nin your root-running script. And someone (who has read your script) does\n\n```bash\nln -s /etc/passwd /tmp/temp-file\n```\n\nThe `mktemp` command could help you in this situation:\n\n```bash\nTEMP=$(mktemp /tmp/temp-file.XXXXXXXX)\necho "random_string" > ${TEMP}\n```\n\nNow this `ln /etc/passwd` attack will not work.\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/123-why-do-we-need-codemktempcode-command-present-an-e.txt
linux-fundamentals/c05765968b99	linux-fundamentals	easy	linux, redirection	What is the result of running the following command? yippiekaiyay 1>&2 die_hard	An output similar to: `yippikaiyay: command not found...` \nThe file `die_hard` will not be created\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/150-what-is-the-result-of-running-the-following-comman.txt
linux-fundamentals/c0a2213d9dda	linux-fundamentals	medium	linux, system	A project manager needs a new SQL Server. What do you ask her/his?	I want the DBA to ask questions like:\n\n- How big will the database be? (whether we can add the database to an existing server)\n- How critical is the database? (about clustering, disaster recovery, high availability)\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/066-a-project-manager-needs-a-new-sql-server-what-do-y.txt
linux-fundamentals/c17257e01053	linux-fundamentals	medium	linux, bash, shell, globbing	Explain what will ls [XYZ] match	ls [XYZ] matches files whose name is exactly ONE character that is either X, Y, or Z.\n\nIt will match:\n- A file named "X"\n- A file named "Y"\n- A file named "Z"\n\nIt will NOT match:\n- "XYZ" (three characters)\n- "xy" (lowercase)\n- "X1" (two characters)\n\nThe brackets define a character class - one character from the set.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/340-explain-what-will-ls-xyz-match.txt
linux-fundamentals/c45312a549c1	linux-fundamentals	medium	linux, system	How to exit without saving shell history?	`kill -9 $$` kills the current shell process immediately (SIGKILL), preventing history from being saved. Alternatively: `unset HISTFILE && exit` clears the history file variable before exiting gracefully. Also: `history -c && history -w && exit` clears the in-memory history and writes an empty file. \nGotcha: `kill -9 $$` may leave child processes orphaned.	projects/knowledge/interview/linux/077-how-to-exit-without-saving-shell-history.txt
linux-fundamentals/cbac00a1f510	linux-fundamentals	medium	linux	How do you create a new resource in Kubernetes?	* touch new_file.txt\n  * cat > new_file [enter] submit text; ctrl + d to exit insert mode\n  * truncate -s <size> new_file.txt\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/215-how-to-create-a-new-empty-file-a-file-with-text-wi.txt
linux-fundamentals/cbe5a29234ce	linux-fundamentals	medium	linux, rpm, packaging	RPM: Explain the .spec format. What should and can it contain?	The .spec file defines how to build an RPM package.\n\nMain sections:\n- Name, Version, Release: Package identity\n- Summary, License, URL: Metadata\n- Source0: Source tarball location\n- BuildRequires: Build dependencies\n- Requires: Runtime dependencies\n\nBuild sections:\n- %prep: Unpack and patch source\n- %build: Configure and compile\n- %install: Install to buildroot\n- %files: List packaged files\n- %changelog: Version history\n\nExample:\nName: myapp\nVersion: 1.0\nRelease: 1%{?dist}\n%build\n./configure && make\n%install\nmake install DESTDIR=%{buildroot}\n%files\n/usr/bin/myapp\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/380-rpm-explain-the-spec-format-what-it-should-and-can.txt
linux-fundamentals/ce34e15bed75	linux-fundamentals	medium	linux, redirection	Demonstrate Linux stderr to stdout redirection	`yippiekaiyay &> file` redirects both stdout and stderr to the same file. Equivalent long form: `yippiekaiyay > file 2>&1`. Key operators: `>` stdout, `2>` stderr, `&>` both, `>>` append. \nGotcha: order matters with the long form — `2>&1 > file` does NOT capture stderr to the file because redirection is processed left to right.	projects/knowledge/interview/linux/149-demonstrate-linux-stderr-to-stdout-redirection.txt
linux-fundamentals/cf6da2a98c08	linux-fundamentals	easy	linux	How can you check what is the path of a certain command?	`which <command>` searches PATH for the executable. `whereis <command>` finds the binary, source, and man page locations. `type <command>` is the most informative — it shows whether a command is an alias, shell builtin, function, or file. \nExample: `type ls` might show it is aliased to `ls --color=auto`. Use `type` as your default lookup.	projects/knowledge/interview/linux/140-how-can-you-check-what-is-the-path-of-a-certain-co.txt
linux-fundamentals/d24be916f3ef	linux-fundamentals	easy	linux, bash, shell	What is the .bashrc file?	A script executed when a new interactive shell starts.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/557-bashrc-file.txt
linux-fundamentals/d698b6710608	linux-fundamentals	easy	linux, package-manager, apt, yum	What is a Linux "package manager"?	It's a tool to install, update, and manage software packages (examples: apt on Debian/Ubuntu, yum or dnf on Red Hat/Fedora).\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/567-what-is-package-manager.txt
linux-fundamentals/da6c25d1885e	linux-fundamentals	medium	linux	List three ways to print all the files in the current directory	* ls\n* find .\n* echo *\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/322-list-three-ways-to-print-all-the-files-in-the-curr.txt
linux-fundamentals/da706b87ad34	linux-fundamentals	medium	linux	What types of web servers are you familiar with?	Common web servers: Nginx (event-driven, excels at reverse proxy and static content) and Apache httpd (process/thread-based, highly extensible with modules). Others: Caddy (automatic HTTPS), Lighttpd (lightweight), and Traefik (cloud-native reverse proxy with auto-discovery). Nginx is the most popular for modern deployments due to lower memory footprint and built-in load balancing.	projects/knowledge/interview/linux/269-what-types-of-web-servers-are-you-familiar-with.txt
linux-fundamentals/db871da42eb0	linux-fundamentals	easy	linux, commands	How do you view the last 10 lines of a file?	`tail`. By default shows last 10 lines. `tail -f` follows the file in real-time (great for watching logs). `tail -n 50` shows last 50 lines.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/571-tail-command.txt
linux-fundamentals/dd0a7cf20a5e	linux-fundamentals	medium	linux	What each of the following commands does?	* cd / -> change to the root directory\n  * cd ~ -> change to your home directory\n  * cd -> change to your home directory\n  * cd .. -> change to the directory above your current i.e parent directory\n  * cd . -> change to the directory you currently in\n  * cd - -> change to the last visited path\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/132-what-each-of-the-following-commands-does-cd-cd-cd-.txt
linux-fundamentals/dd62d653317d	linux-fundamentals	easy	linux, commands	How do you search for a specific string within a file?	`grep`. Examples: `grep -r 'error' /var/log/` recursive search, `grep -i` case-insensitive, `grep -c` count matches, `grep -n` show line numbers. Supports regex with `-E`.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/573-grep-command.txt
linux-fundamentals/dfcdea6be572	linux-fundamentals	medium	linux	Demonstrate one way to encode and decode data in Linux	Encode: `echo -n "some password" | base64`\nDecode: `echo -n "allE19remO91" | base64`\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/248-demonstrate-one-way-to-encode-and-decode-data-in-l.txt
linux-fundamentals/e46013ec3748	linux-fundamentals	hard	linux, system	How to redirect stderr and stdout to different files in the same line?	Just add them in one line `command 2>> error 1>> output`.\n\nHowever, note that `>>` is for appending if the file already has data. Whereas, `>` will overwrite any existing data in the file.\n\nSo, `command 2> error 1> output` if you do not want to append.\n\nJust for completion's sake, you can write `1>` as just `>` since the default file descriptor is the output. so `1>` and `>` is the same thing.\n\nSo, `command 2> error 1> output` becomes, `command 2> error > output`.	projects/knowledge/interview/linux/107-how-to-redirect-stderr-and-stdout-to-different-fil.txt
linux-fundamentals/e88d4f8a306d	linux-fundamentals	easy	linux, system	Execute combine multiple shell commands in one line.	If you want to execute each command only if the previous one succeeded, then combine them using the `&&` operator:\n\n```bash\ncd /my_folder && rm *.jar && svn co path to repo && mvn compile package install\n```\n\nIf one of the commands fails, then all other commands following it won't be executed.\n\nIf you want to execute all commands regardless of whether the previous ones failed or not, separate them with semicolons:\n\n```bash\ncd /my_folder; rm *.jar; svn co path to repo; mvn compile package install\n```	projects/knowledge/interview/linux/023-execute-combine-multiple-shell-commands-in-one-lin.txt
linux-fundamentals/e9ede31336b2	linux-fundamentals	medium	linux, control-flow	What do > and < do in terms of input and output for programs?	They take in input (<) and output for a given file (>) using stdin and stdout.\n\n`myProgram < input.txt > executionOutput.txt`\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/136-what-do-and-do-in-terms-of-input-and-output-for-pr.txt
linux-fundamentals/ea6af6e33c5d	linux-fundamentals	hard	linux, system	How to check if a string contains a substring in Bash?	You can use `*` (wildcards) outside a case statement, too, if you use double brackets:\n\n```bash\nstring='some text'\nif [[ $string = *"My long"* ]] ; then\n  true\nfi\n```\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/105-how-to-check-if-a-string-contains-a-substring-in-b.txt
linux-fundamentals/ecc2335ca7fe	linux-fundamentals	medium	linux, system	How to find out the dynamic libraries executables loads when run?	`ldd /bin/ls` lists the shared libraries (dynamic dependencies) that an executable loads at runtime. Example output shows libpthread.so, libc.so, and the dynamic linker (ld-linux). \nGotcha: never run `ldd` on untrusted binaries — it may execute them. Use `objdump -p <binary> | grep NEEDED` as a safer alternative.	projects/knowledge/interview/linux/080-how-to-find-out-the-dynamic-libraries-executables-.txt
linux-fundamentals/ecd3b8015d7c	linux-fundamentals	medium	linux	How to create a file of a certain size?	There are a couple of ways to do that:\n\n  * dd if=/dev/urandom of=new_file.txt bs=2MB count=1\n  * truncate -s 2M new_file.txt\n  * fallocate -l 2097152 new_file.txt\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/309-how-to-create-a-file-of-a-certain-size.txt
linux-fundamentals/ee39f4b7fd87	linux-fundamentals	easy	linux, system	How do you get help on the command line?	- `man` [commandname] can be used to see a description of a command (ex.: `man less`, `man cat`)\n\n- `-h` or `--help` some programs will implement printing instructions when passed this parameter (ex.: `python -h` and `python --help`)\n\nRemember: Man sections: 1=commands, 5=file formats, 8=admin. `man 5 passwd` = file format.	projects/knowledge/interview/linux/005-how-do-you-get-help-on-the-command-line.txt
linux-fundamentals/eec41a4992bc	linux-fundamentals	medium	linux, system	What is the main purpose of the intermediate certification authorities?	An intermediate CA sits between the root CA and end-entity certificates in the trust chain.\n\nPurpose:\n- **Protects root CA**: Root stays offline/air-gapped. Intermediate handles day-to-day signing\n- **Limits blast radius**: If compromised, only the intermediate is revoked, not the entire PKI\n- **Organizational delegation**: Different intermediates for different departments or purposes\n\nTrust chain: Root CA -> Intermediate CA -> Server/Client certificate. Servers must send the intermediate cert along with their own cert so clients can verify the full chain.\n\nRemember: Unix philosophy: one thing well, compose with pipes. `man cmd` is your friend.\n\nGotcha: Test destructive commands with echo or --dry-run first.	projects/knowledge/interview/linux/074-what-is-the-main-purpose-of-the-intermediate-certi.txt
linux-fundamentals/f2db8ca84d9a	linux-fundamentals	easy	linux, commands, logs	What does tail -f do?	`tail -f <file>` follows a file in real-time, printing new lines as they are appended — essential for monitoring live logs. \nExample: `tail -f /var/log/syslog`. Use `tail -F` to also handle file rotation (log files that get renamed and recreated). Alternative: `less +F <file>` for follow mode with the ability to search backward.	projects/knowledge/interview/linux/572-tail-f-command.txt
linux-fundamentals/f8f689cd93cd	linux-fundamentals	medium	linux, redirection	Demonstrate Linux stderr output redirection	`yippiekaiyay 2> error.txt` redirects stderr (file descriptor \n2) to error.txt while stdout still goes to the terminal. Useful for capturing error messages separately from normal output. \nExample: `find / -name '*.conf' 2> /dev/null` suppresses 'Permission denied' errors. Append with `2>>` instead of `2>` to avoid overwriting existing error logs.	projects/knowledge/interview/linux/148-demonstrate-linux-stderr-output-redirection.txt
linux-fundamentals/ff18538b23cf	linux-fundamentals	medium	linux, system	What is the preferred bash shebang and why? What is the difference between executing a file using `./script` or `bash script`?	You should use `#!/usr/bin/env bash` for portability: different \*nixes put bash in different places, and using `/usr/bin/env` is a workaround to run the first bash found on the `PATH`.\n\nRunning `./script` does exactly that, and requires execute permission on the file, but is agnostic to what type of a program it is. It might be a **bash script**, an **sh script**, or a **Perl**, **Python**, **awk**, or **expect script**, or an actual **binary executable**. Running `bash script` would force it to be run under `sh`, instead of anything else.	projects/knowledge/interview/linux/072-what-is-the-preferred-bash-shebang-and-why-what-is.txt

<!-- wiki:related:start -->
---

## Wiki Navigation

### Related Content

- [/proc Filesystem](../../../../library/topics/proc-filesystem/index.md) (Topic Pack, L2) — Linux Fundamentals
- [Advanced Bash for Ops](../../../../library/topics/advanced-bash/index.md) (Topic Pack, L1) — Linux Fundamentals
- [Adversarial Interview Gauntlet (30 sequences)](../../../../library/interview-scenarios/gauntlet/README.md) (Scenario, L2) — Linux Fundamentals
- Bash Exercises (Quest Ladder) *(CLI)* (Exercise Set, L0) — Linux Fundamentals
- [Case Study: CI Pipeline Fails — Docker Layer Cache Corruption](../../../../library/case-studies/cross-domain/ci-pipeline-docker-cache-registry/README.md) (Case Study, L2) — Linux Fundamentals
- [Case Study: Container Vuln Scanner False Positive Blocks Deploy](../../../../library/case-studies/cross-domain/container-vuln-scanner-false-positive/README.md) (Case Study, L2) — Linux Fundamentals
- [Case Study: Disk Full Root Services Down](../../../../library/case-studies/datacenter_ops/disk-full-root-services-down/README.md) (Case Study, L1) — Linux Fundamentals
- [Case Study: Disk Full — Runaway Logs, Fix Is Loki Retention](../../../../library/case-studies/cross-domain/disk-full-runaway-logs-loki/README.md) (Case Study, L2) — Linux Fundamentals
- [Case Study: HPA Flapping — Metrics Server Clock Skew, Fix Is NTP](../../../../library/case-studies/cross-domain/hpa-flapping-clock-skew-ntp/README.md) (Case Study, L2) — Linux Fundamentals
- [Case Study: Inode Exhaustion](../../../../library/case-studies/linux_ops/inode-exhaustion/README.md) (Case Study, L1) — Linux Fundamentals

<!-- wiki:related:end -->
