linux commands( operating system, Lecture notes of Computer science

the book is about how to use linux in a professional way

Typology: Lecture notes

2025/2026

Uploaded on 06/22/2026

rayan-khaled-2
rayan-khaled-2 ๐Ÿ‡ง๐Ÿ‡ฌ

1 document

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
LINUX INTERVIEW QUESTIONS
Crack Your Next Interview with Confidence!
Author: Umar Shahzad
1. Filesystem Basics
1. What is the command to create an empty file?
โ— touch filename
2. How do you create a new directory?
โ— mkdir directory_name
3. How do you list all files in a directory?
โ— ls
4. How do you list all files, including hidden ones?
โ— ls -a
5. How do you display the current working directory?
โ— pwd
6. How do you move or rename a file?
โ— mv source_file destination_file
7. How do you copy a file?
โ— cp source_file destination_file
8. What command is used to delete a file?
โ— rm filename
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download linux commands( operating system and more Lecture notes Computer science in PDF only on Docsity!

LINUX INTERVIEW QUESTIONS

Crack Your Next Interview with Confidence! Author: Umar Shahzad

1. Filesystem Basics

  1. What is the command to create an empty file? โ— touch filename
  2. How do you create a new directory? โ— mkdir directory_name
  3. How do you list all files in a directory? โ— ls
  4. How do you list all files, including hidden ones? โ— ls -a
  5. How do you display the current working directory? โ— pwd
  6. How do you move or rename a file? โ— mv source_file destination_file
  7. How do you copy a file? โ— cp source_file destination_file
  8. What command is used to delete a file? โ— rm filename
  1. How do you delete a directory and its contents? โ— rm -r directory_name
  2. How do you display the contents of a file? โ— cat filename
  3. How do you display the first 10 lines of a file? โ— head filename
  4. How do you display the last 10 lines of a file? โ— tail filename
  5. How do you check free disk space? โ— df -h
  6. How do you display disk usage of a directory? โ— du -sh directory_name
  7. How do you search for a file by name in a directory? โ— find /path/to/directory -name filename
  8. How do you compress a file using gzip? โ— gzip filename
  9. How do you decompress a gzip file? โ— gunzip filename.gz
  10. How do you archive multiple files using tar? โ— tar -czvf archive.tar.gz files
  11. How do you extract a tar.gz archive? โ— tar -xzvf archive.tar.gz
  12. How do you mount a filesystem? โ— mount device_name mount_point
  13. How do you unmount a filesystem? โ— umount mount_point
  14. How do you create a symbolic link? โ— ln -s target_file link_name
  15. How do you view file types in a directory? โ— file filename
  16. How do you remove an empty directory? โ— rmdir directory_name
  17. How do you check for file existence? โ— test -f filename

2. File Permissions and Ownership

  1. How do you change file permissions? โ— chmod permissions filename
  1. How do you view system logs for a process? โ— journalctl -u service_name
  2. How do you create a custom alias for a command? โ— alias alias_name='command'
  3. How do you remove an alias? โ— unalias alias_name
  4. How do you run a command as another user? โ— sudo -u username command
  5. How do you list all environment variables? โ— printenv or env
  6. How do you export a variable in Linux? โ— export VAR=value

4. Networking

  1. How do you find the IP address of your system? โ— ip addr or ifconfig
  2. How do you check active network connections? โ— ss -tuln or netstat -tuln
  3. How do you ping a host to check connectivity? โ— ping host
  4. How do you test port connectivity? โ— telnet hostname port
  5. How do you display routing information? โ— route
  6. How do you check open ports on your system? โ— lsof -i
  7. How do you download files from the internet? โ— wget URL
  8. How do you transfer files between systems using SCP? โ— scp source_file user@remote_host:/destination_path
  9. How do you use SSH to connect to a remote server? โ— ssh user@remote_host
  10. How do you set up a static IP address? โ— Edit the network configuration file (e.g., /etc/network/interfaces )
  1. User Management
    1. How do you create a new user in Linux? โ— adduser username
    2. How do you delete a user? โ— userdel username
    3. How do you lock a user account? โ— passwd -l username
    4. How do you unlock a user account? โ— passwd -u username
    5. How do you switch to another user? โ— su - username
    6. How do you view currently logged-in users? โ— who or w
    7. How do you check user account information? โ— id username
    8. How do you list all users on the system? โ— cat /etc/passwd
    9. How do you create a group in Linux? โ— groupadd group_name
    10. How do you add a user to a group? โ— usermod -aG group_name username
    11. How do you change a userโ€™s default shell? โ— chsh -s /bin/bash username
    12. How do you change a userโ€™s home directory? โ— usermod -d /new/home/dir username
    13. How do you create a system user without a home directory? โ— adduser --system --no-create-home username
    14. How do you set or reset a userโ€™s password? โ— passwd username
    15. How do you check group memberships of a user? โ— groups username
  2. Package Management
    1. How do you install a package on Debian-based systems? โ— apt install package_name
    2. How do you update all packages on a Debian-based system? โ— apt update && apt upgrade
  1. How do you check currently mounted filesystems? โ— mount or df -h
  2. How do you list active cron jobs? โ— crontab -l
  3. How do you check log files? โ— tail -f /var/log/syslog or journalctl
  4. How do you analyze disk usage by directories? โ— du -h --max-depth=

10. Advanced Networking

  1. How do you configure a network interface? โ— ip addr add IP_ADDRESS dev interface
  2. How do you bring an interface up or down? โ— ip link set interface up or ip link set interface down
  3. How do you test DNS resolution? โ— nslookup domain_name
  4. How do you display ARP table entries? โ— arp -a
  5. How do you configure a firewall using iptables? โ— iptables -A INPUT -p tcp --dport port -j ACCEPT
  6. How do you save iptables rules? โ— iptables-save > /etc/iptables/rules.v
  7. How do you check open ports on a system? โ— ss -tuln
  8. How do you trace the route to a host? โ— traceroute hostname
  9. How do you monitor packet flow? โ— tcpdump
  10. How do you edit the hosts file? โ— nano /etc/hosts

11. Scripting and Automation

  1. How do you create a simple shell script? โ— #!/bin/bash
  2. How do you make a script executable? โ— chmod +x script_name
  3. How do you run a script? โ— ./script_name
  1. How do you use variables in a shell script? โ— variable=value and use with $variable
  2. How do you accept input in a script? โ— read variable_name
  3. How do you pass arguments to a script? โ— Use $1 , $2 , etc., for positional arguments
  4. How do you write an if-else condition in a script? โ— bash if [ condition ]; then commands else commands fi
  5. How do you write a for loop in a script? โ— bash for i in {1..5}; do echo $i done
  6. How do you schedule a script using cron? โ— crontab -e and add the schedule entry
  7. How do you debug a script? โ— bash -x script_name

12. Advanced Topics

  1. What is SELinux? โ— Security-Enhanced Linux for access control
  2. How do you check SELinux status? โ— sestatus
  3. How do you change SELinux mode? โ— setenforce 0 (permissive) or setenforce 1 (enforcing)
  4. How do you view running containers in Docker? โ— docker ps
  5. How do you stop a running Docker container? โ— docker stop container_id
  6. How do you create an SSH key pair? โ— ssh-keygen
  7. How do you use rsync for file transfer? โ— rsync -avz source destination
  8. How do you check the default gateway? โ— ip route
  9. How do you monitor file changes in real-time? โ— inotifywait
  10. How do you create a virtual environment in Python? โ— python3 -m venv env_name
  1. How do you check process memory usage? โ— ps aux --sort=-%mem
  2. How do you check process CPU usage? โ— ps aux --sort=-%cpu
  3. How do you check process status? โ— ps -o stat= -p PID
  4. How do you find a process by name? โ— pgrep process_name
  5. How do you check the number of processes running? โ— ps aux | wc -l

15. System Monitoring

  1. How do you monitor CPU usage? โ— top or htop
  2. How do you check system load? โ— uptime
  3. How do you monitor disk space? โ— df -h
  4. How do you monitor memory usage? โ— free -h
  5. How do you monitor swap usage? โ— swapon --show or free -h
  6. How do you check network usage? โ— ifstat
  7. How do you monitor network interfaces? โ— ip -s link
  8. How do you monitor real-time log files? โ— tail -f /var/log/syslog
  9. How do you check system uptime? โ— uptime
  10. How do you check system resource utilization? โ— vmstat

16. Cloud and Automation Tools

  1. How do you install AWS CLI? โ— pip install awscli
  1. How do you configure AWS CLI? โ— aws configure
  2. How do you create an S3 bucket using CLI? โ— aws s3 mb s3://bucket_name
  3. How do you list running EC2 instances? โ— aws ec2 describe-instances
  4. How do you create an EC2 instance? โ— aws ec2 run-instances --image-id ami_id --count 1 --instance-type t2.micro
  5. How do you deploy an application using Ansible? โ— Write a playbook and run ansible-playbook playbook.yml
  6. How do you configure Ansible inventory? โ— Edit /etc/ansible/hosts
  7. How do you use Terraform to create infrastructure? โ— Write a .tf file and run terraform apply
  8. How do you start a Kubernetes cluster? โ— Use kubeadm init
  9. How do you install Docker on a system? โ— Use apt-get install docker.io or yum install docker

17. Advanced File Handling

  1. How do you copy a directory recursively? โ— cp -r source_directory destination_directory
  2. How do you move or rename a file? โ— mv old_name new_name
  3. How do you remove a file? โ— rm filename
  4. How do you remove a directory recursively? โ— rm -r directory_name
  5. How do you find files by name? โ— find / -name "filename"
  6. How do you search for text within files? โ— grep "text" file_name
  7. How do you replace text in files? โ— sed -i 's/old_text/new_text/g' file_name
  8. How do you concatenate two files? โ— cat file1 file2 > new_file
  9. How do you compress a file? โ— tar -czf file_name.tar.gz directory_name
  1. How do you add a user to a group? โ— usermod -aG group_name username
  2. How do you list groups in Linux? โ— cat /etc/group
  3. How do you secure SSH access? โ— Disable root login by setting PermitRootLogin no in /etc/ssh/sshd_config
  4. How do you configure SSH key-based authentication? โ— Copy the public key to ~/.ssh/authorized_keys on the remote machine
  5. How do you view system logs in Linux? โ— journalctl or cat /var/log/syslog

Tips for Cracking the Interview

โ— Be practical: Demonstrate how to solve real-world issues. โ— Explain clearly: Donโ€™t just list commands; explain the reasoning behind them. โ— Share scenarios: Mention situations where you applied these skills, like troubleshooting, securing systems, or optimizing performance.

Follow my LinkedIn for more insightful notes! Share your learning experiences and let me

know which topic you'd like me to cover next. Your feedback matters!