Top 20 Linux practical questions asked in interview-2023
- How do you find all files with a specific extension in a directory?
find /path/to/directory -name "*.extension"
- How do you find the size of a file or directory?
du -sh /path/to/file_or_directory
- How do you display the contents of a file in the terminal?
cat /path/to/file
- How do you search for a string in a file?
grep "string" /path/to/file
- How do you copy a file from one directory to another?
cp /path/to/source_file /path/to/destination_directory
- How do you rename a file or directory?
mv /path/to/old_name /path/to/new_name
- How do you create a new user account?
adduser username
- How do you change file or directory permissions?
chmod permissions /path/to/file_or_directory
- How do you compress or decompress a file or directory?
tar -czvf archive.tar.gz /path/to/directory # Compress
tar -xzvf archive.tar.gz # Decompress
- How do you kill a process?
kill process_id
- How do you list all installed packages?
dpkg --list
- How do you update all installed packages?
apt-get update && apt-get upgrade
- How do you install a package?
apt-get install package_name
- How do you uninstall a package?
apt-get remove package_name
- How do you check the system load?
uptime
- How do you check system resources (CPU, memory, etc.) usage?
top
- How do you display the contents of a compressed file without decompressing it?
zcat /path/to/file.gz | less
- How do you check the available disk space on a partition?
df -h
- How do you monitor log files in real-time?
tail -f /var/log/file.log
- How do you display the network configuration of the system?
ifconfig
These are just some examples of practical Linux interview questions and their corresponding code snippets. Depending on the position and company, the questions may vary in difficulty and scope.