Title: Linux Command Line — LearnCoachAssist

Q: What is the Linux command line interface (CLI)?
A: The Linux CLI is a text-based interface for interacting with the operating system using commands entered via a terminal emulator, allowing users to perform tasks efficiently without a graphical user interface.

Q: What is a shell in Linux?
A: A shell is a program that interprets commands entered into the CLI, processes them, and communicates with the kernel; common shells include Bash (Bourne Again SHell), the default on most distributions.

Q: How do you open a terminal in Linux?
A: Use keyboard shortcuts like Ctrl+Alt+T on Ubuntu or search for 'Terminal' in the applications menu; it launches a shell session for command execution.

Q: What does the pwd command do?
A: The pwd (Print Working Directory) command displays the absolute path of the current working directory, helping users confirm their location in the filesystem.

Q: How do you list files and directories in the current directory?
A: ls lists files and directories; add flags like -l for detailed view, -a to show hidden files, or -h for human-readable sizes.

Q: What does cd do and how is it used?
A: The cd (Change Directory) command navigates to a different directory; use cd /path for absolute paths, cd .. to go up one level, or cd ~ for home.

Q: What is the home directory and how to access it?
A: The home directory is the user's personal folder, typically /home/username; access it with cd or cd ~.

Q: How do you create a new directory?
A: Use mkdir directory_name to create a single directory or mkdir -p /path/to/nested/dir for parents; it fails if the directory already exists.

Q: How do you create an empty file?
A: touch filename creates an empty file or updates the timestamp of an existing one, useful for initializing files.

Q: What does cp do?
A: cp source destination copies files or directories; use -r for recursive directory copies and -i for interactive prompts.

Q: How do you move or rename a file?
A: mv source destination moves files/directories or renames them if destination is in the same directory.

Q: What is the rm command?
A: rm file removes files; rm -r dir deletes directories recursively, and -f forces without prompts—use cautiously as deletions are permanent.

Q: How do you view file contents with cat?
A: cat filename concatenates and displays file contents; combine with | less for paging long outputs.

Q: What is less used for?
A: less filename views files page-by-page with navigation keys (Space forward, b backward, q quit), more efficient than cat for large files.

Q: How do you view the first 10 lines of a file?
A: head filename shows the first 10 lines by default; use -n 5 to specify the number.

Q: What does tail do?
A: tail filename displays the last 10 lines; -f follows the file for real-time updates, ideal for logs.

Q: How do you view command help?
A: Use command --help for usage summaries or man command for detailed manuals (q to quit).

Q: What are file permissions in Linux?
A: Permissions control read (r), write (w), execute (x) access for owner, group, others, displayed as rwxr-xr-x in ls -l.

Q: How do you change file permissions with chmod?
A: chmod 755 file sets owner rwx, others rx (octal); or symbolic like chmod u+x file adds execute for user.

Q: What does chown do?
A: chown user:group file changes file ownership; requires root for other users' files.

Q: How do you check disk usage?
A: df -h shows filesystem disk space in human-readable format; du -sh dir summarizes directory sizes.

Q: What is output redirection?
A: Redirect command output to a file with > file (overwrite) or >> file (append), e.g., ls > list.txt.

Q: How do you redirect input?
A: command < file reads input from a file, e.g., sort < names.txt sorts file contents.

Q: What are pipes in Linux?
A: Pipes (|) chain commands, passing output of one as input to the next, e.g., ls | grep txt lists only .txt files.

Q: What does grep do?
A: grep pattern file searches for lines matching a pattern; flags like -i ignore case, -r recursive.

Q: How do you find files by name?
A: find /path -name "*pattern*" searches recursively; -type f for files, -type d for directories.

Q: What is locate?
A: locate filename quickly finds files by name using a pre-built database (update with updatedb).

Q: How do you list running processes?
A: ps aux lists all processes with details; top or htop provides interactive monitoring.

Q: How do you kill a process?
A: Find PID with ps, then kill PID (SIGTERM) or kill -9 PID (forceful SIGKILL).

Q: What is & for background jobs?
A: Append & to run commands in background, e.g., sleep 10 &; manage with jobs, fg, bg.

Q: How do you view command history?
A: history lists past commands; execute previous with !n (n=number) or !! for last.

Q: What are aliases?
A: Aliases create shortcuts: alias ll='ls -l'; add to ~/.bashrc for persistence, reload with source ~/.bashrc.

Q: How do you edit files with nano?
A: Run nano file; Ctrl+O save, Ctrl+X exit; simple for beginners.

Q: Basic Vim modes?
A: Vim has Normal (default), Insert (i key), Visual (v); :w save, :q quit, :wq save&quit in Normal mode.

Q: What is tar for archiving?
A: tar -cvf archive.tar dir creates; tar -xvf archive.tar extracts; combine with gzip: -z.

Q: How do you compress files with gzip?
A: gzip file compresses to .gz; gunzip file.gz decompresses.

Q: What does which do?
A: which command shows the full path of an executable in PATH.

Q: How do you update package index on Debian-based systems?
A: apt update refreshes package lists; follow with apt upgrade for updates.

Q: Install a package with apt?
A: sudo apt install package; remove with apt remove or apt autoremove for dependencies.

Q: What is yum or dnf on RPM systems?
A: yum install package or dnf install package (Fedora successor); yum update for system updates.

Q: How do you ping a host?
A: ping host tests network connectivity with ICMP echoes; -c 4 limits to 4 packets.

Q: What is ssh for?
A: ssh user@host securely connects to remote systems; use -p port for non-standard ports.

Q: How do you download files with wget?
A: wget URL downloads files; -r recursive, -O file specifies output name.

Q: What does curl do?
A: curl URL transfers data; -O saves file, often used for APIs: curl -X POST data.

Q: How do you check network interfaces?
A: ifconfig or ip addr shows IP addresses and status.

Q: What is a symbolic link?
A: A symlink is a pointer to another file: ln -s target linkname; hard links use ln target linkname.

Q: How do you monitor system resources?
A: free -h for memory, uptime for load average; vmstat for comprehensive stats.

Q: What is crontab for scheduling?
A: crontab -e edits user crontab; format: * * * * * command runs minute/hour/day/month/weekday.

Q: How do you uncompress .zip files?
A: unzip file.zip; create with zip archive.zip files.

Q: What does env show?
A: env lists environment variables; export VAR=value sets them persistently in shell.

Q: Advanced: How do you write a simple Bash script?
A: Start with #!/bin/bash, make executable chmod +x script.sh, run ./script.sh; use variables, loops, conditionals.