1. Which command lists all files including hidden ones in Linux?
- ls -a
- ls -l
- ls -R
- ls -h
Correct Answer: ls -a
ls -a
Get the Preplance app for a seamless learning experience. Practice offline, get daily streaks, and stay ahead with real-time interview updates.
Get it on
Google Play
4.9/5 Rating on Store
Linux & Shell Scripting · Complete Question Bank
Practice the complete collection of Linux & Shell Scripting interview questions including theory, coding, MCQs and real interview problems.
Questions
257
Full database
Topics
61
Categorised
Difficulty
Mixed Levels
Easy Hard
Scroll through every important Linux & Shell Scripting question asked in real interviews. Includes MCQs, subjective questions, and coding prompts.
Correct Answer: ls -a
ls -a
Browse more Linux & Shell Scripting questions, explore related subjects, or practice full interview sets to strengthen your preparation.
Correct Answer: pwd
pwd
Correct Answer: cd ..
cd ..
Correct Answer: mkdir and rmdir
mkdir newfolder rmdir newfolder
Correct Answer: mv
mv file.txt /home/user/docs/
Correct Answer: less
less /var/log/syslog
Correct Answer: -r
rm -r myfolder
Correct Answer: find
find . -name 'config.json'
Correct Answer: Searches text within files
grep 'error' app.log
alias ll='ls -alF' unalias ll
Correct Answer: chmod
chmod 755 script.sh
Correct Answer: chown
sudo chown ubuntu:devops app.log
Correct Answer: Group permissions
Correct Answer: useradd
sudo useradd -m -s /bin/bash devuser
Correct Answer: passwd
passwd vipul
Correct Answer: ps
ps -ef | grep nginx
Correct Answer: SIGTERM
kill 1234
Correct Answer: System summary and live process information
top
Correct Answer: renice
sudo renice -n -5 -p 3456
sleep 60 & jobs fg %1
sudo usermod -aG sudo vipul
Correct Answer: It tells the system which interpreter to use
#!/bin/bash
Correct Answer: var=10
name=Vipul echo $name
Correct Answer: read
read -p 'Enter your name: ' username
Correct Answer: if [ condition ]; then
if [ $age -gt 18 ]; then echo 'Adult' fi
Correct Answer: for i in 1 2 3 4 5; do ... done
for i in 1 2 3 4 5; do echo $i done
Correct Answer: while loop
while [ $count -le 5 ]; do echo $count ((count++)) done
Correct Answer: esac
case $option in 1) echo 'Start';; 2) echo 'Stop';; *) echo 'Invalid';; esac
Correct Answer: $?
cp file.txt /backup/ echo $?
Correct Answer: function
function greet() {
echo 'Hello User'
}
greeta=5; b=10; sum=$((a + b)); echo $sum
if [ -z "$input" ]; then echo 'Empty' fi
chmod +x deploy.sh ./deploy.sh
for host in server1 server2; do ping -c 1 $host done
if systemctl is-active --quiet nginx; then echo 'Nginx is running' else systemctl start nginx fi
Correct Answer: cron
crontab -e 0 2 * * * /home/user/backup.sh
Correct Answer: crontab -l
crontab -l
Correct Answer: at
echo 'ls /tmp' | at 11:30
Correct Answer: && runs next only if previous succeeds, while ; runs all commands
mkdir logs && cd logs
Correct Answer: &
sh long_script.sh &
Correct Answer: Appends output to an existing file
echo 'Backup complete' >> backup.log
Correct Answer: grep -c error logfile
grep -c error /var/log/syslog
Correct Answer: logrotate
echo 'First argument:' $1 echo 'Total args:' $#
set -e cp data.txt /backup/ || echo 'Backup failed'
0 3 * * 1 /scripts/cleanup.sh
./deploy.sh > deploy.log 2>&1
0 2 * * * /home/admin/backup.sh
grep 'FAILED' app.log | mail -s 'Daily Errors' admin@domain.com
Correct Answer: uptime
uptime
Correct Answer: df
df -h
Correct Answer: Disk space usage of files and directories
du -sh * | sort -rh | head -10
Correct Answer: free
free -h
Correct Answer: netstat -tuln
netstat -tuln
Correct Answer: Network latency and connectivity
ping google.com
Correct Answer: traceroute
traceroute 8.8.8.8
Correct Answer: -f
tail -f /var/log/syslog
Correct Answer: journalctl
journalctl -u nginx -f
ps aux --sort=-%cpu | head
ping 8.8.8.8 traceroute google.com
du -h --max-depth=1 /var | sort -hr | head
grep 'ERROR' /var/log/app.log | tail -n 20
sudo lsof -i :8080
Correct Answer: apt install
sudo apt install nginx -y
Correct Answer: yum install
sudo yum install httpd -y
Correct Answer: Manages low-level .deb package installations
sudo dpkg -i package.deb
Correct Answer: systemctl start nginx
sudo systemctl start nginx
Correct Answer: systemctl enable
sudo systemctl enable docker
Correct Answer: systemctl status nginx
sudo systemctl status nginx
Correct Answer: systemctl restart nginx
sudo systemctl restart nginx
Correct Answer: restart stops and starts service, reload applies new configs without stopping
sudo systemctl reload nginx
Correct Answer: journalctl -u servicename
journalctl -u ssh -f
sudo apt update && sudo apt upgrade -y
systemctl status nginx journalctl -u nginx
sudo apt remove nginx -y && sudo apt autoremove -y
systemctl list-unit-files --type=service | grep enabled
/etc/systemd/system/myapp.service
Correct Answer: ip a
ip a
Correct Answer: ping
ping 8.8.8.8
Correct Answer: hostnamectl
sudo hostnamectl set-hostname dev-server
Correct Answer: ufw enable
sudo ufw enable
Correct Answer: ufw allow ssh
sudo ufw allow ssh
Correct Answer: iptables -L
sudo iptables -L -v -n
Correct Answer: ssh
ssh user@192.168.1.10
Correct Answer: ssh-keygen
ssh-keygen -t rsa -b 4096
Correct Answer: scp
scp file.txt user@server:/tmp/
Host myserver HostName 192.168.1.20 User ubuntu IdentityFile ~/.ssh/id_rsa
sudo vi /etc/ssh/sshd_config PermitRootLogin no PasswordAuthentication no
sudo ufw status numbered sudo ufw delete 2
nc -zv 192.168.1.50 22
systemctl status ssh cat /var/log/auth.log
Correct Answer: lsblk
lsblk
Correct Answer: mount
sudo mount /dev/sdb1 /mnt/data
Correct Answer: umount
sudo umount /mnt/data
Correct Answer: Disk space usage by mounted filesystems
df -h
Correct Answer: du
du -sh * | sort -rh | head
Correct Answer: tar
tar -czf backup.tar.gz /home/user/
Correct Answer: gzip
gzip largefile.log
Correct Answer: rsync
rsync -av /data /backup/
Correct Answer: Lists filesystems to mount automatically on boot
/dev/sdb1 /mnt/data ext4 defaults 0 2
UUID=abcd-1234 /mnt/data ext4 defaults 0 2
rsync -av /var/www /backup/webdata/
tar -xzf backup.tar.gz -C /restore/
sudo smartctl -a /dev/sda
find / -type f -size +500M -exec ls -lh {} \;Correct Answer: ps
ps aux
Correct Answer: top
top
Correct Answer: htop
htop
Correct Answer: kill
kill -9 1234
Correct Answer: nice
nice -n 10 ./backup.sh
Correct Answer: renice
sudo renice +5 -p 4567
Correct Answer: bg/fg
bg %1 fg %1
Correct Answer: crontab -e
crontab -e 0 2 * * * /scripts/backup.sh
Correct Answer: at
echo 'rm /tmp/tempfile' | at 3:00 AM
jobs fg %1
0 3 * * 1 /scripts/cleanup.sh
watch -n 2 'ps -C nginx -o pid,cmd,%mem,%cpu'
0 2 * * * /scripts/backup.sh > /var/log/backup.log 2>&1
0 0 * * * /scripts/mysql_backup.sh
Correct Answer: An open-source Unix-like operating system kernel
Correct Answer: System configuration files
Correct Answer: Sets read, write, execute for owner; read and execute for group and others
Correct Answer: pwd
Correct Answer: Hard links point to inode, symbolic links point to filename; hard links break if original deleted
Correct Answer: The file type (- for regular file, d for directory, l for link)
Correct Answer: cp -r
Correct Answer: Searches for patterns in files and displays matching lines
Correct Answer: Stream editor for filtering and transforming text
Correct Answer: Pattern scanning and text processing language for extracting and manipulating data
Correct Answer: cat displays entire file at once, less allows paginated viewing with navigation
Correct Answer: Displays the last lines of a file and continues to show new lines as they are added
Correct Answer: Sorts lines and removes duplicates
Correct Answer: Extracts the first field (username) from each line using colon as delimiter
Correct Answer: Line count, word count, and byte count
Correct Answer: Process ID - a unique identifier assigned to each running process
Correct Answer: All processes for all users with detailed information
Correct Answer: kill uses PID, killall uses process name, pkill uses pattern matching
Correct Answer: Displays real-time system resource usage and running processes dynamically
Correct Answer: Runs the command in the background, returning control to the terminal
Correct Answer: Runs a command immune to hangups, continuing after terminal closes
Correct Answer: Memory usage in human-readable format (MB, GB)
Correct Answer: Average number of processes in run queue over 1, 5, and 15 minutes
Correct Answer: useradd
Correct Answer: Allows authorized users to run commands as root or another user
Correct Answer: User account information including username, UID, GID, home directory, and shell
Correct Answer: /etc/group
Correct Answer: su - starts a login shell with target user's environment, su keeps current environment
Correct Answer: Owner: read+write, Group: read, Others: read
Correct Answer: Allows only file owners to delete their files in the directory
Correct Answer: Extended permissions allowing fine-grained access control beyond standard owner/group/other
Correct Answer: ifconfig or ip addr
Correct Answer: Tests network connectivity by sending ICMP echo requests
Correct Answer: Secure remote login and command execution over encrypted connection
Correct Answer: TCP and UDP listening ports with numeric addresses
Correct Answer: apt update or apt-get update
Correct Answer: yum or dnf
Correct Answer: Configures service to start automatically at boot
Correct Answer: Transferring data from or to servers using various protocols including HTTP
Correct Answer: Specifies which interpreter should execute the script
Correct Answer: Assign with VAR=value, access with $VAR
Correct Answer: All positional parameters as separate words
Correct Answer: Redirects stderr (2) to wherever stdout (1) is going
Correct Answer: Success - command completed without errors
Correct Answer: Connects stdout of one command to stdin of the next command
Correct Answer: $(command) is newer, more readable, and nestable; both execute command and return output
Correct Answer: Single quotes: literal (no expansion), double quotes: expand variables, no quotes: word splitting and globbing
Correct Answer: if [ condition ]; then commands; fi
Correct Answer: Multi-way branching based on pattern matching
Correct Answer: for VAR in list; do commands; done
Correct Answer: Executes commands repeatedly while condition is true
Correct Answer: function name() { commands; } or name() { commands; }
Correct Answer: Declare: ARRAY=(val1 val2 val3), Access: ${ARRAY[index]}
Correct Answer: Creates interactive menu for user selection
Correct Answer: Parsing command-line options and arguments
Correct Answer: /var/log/
Correct Answer: minute hour day month weekday command
Correct Answer: An init system and service manager that boots the system and manages services
Correct Answer: mkfs
Correct Answer: top or htop
Correct Answer: tar
Correct Answer: Logical Volume Manager with Physical Volumes, Volume Groups, and Logical Volumes
Correct Answer: Boot from live USB/CD, check logs, repair filesystem, restore bootloader