Linux Interview Questions Flashcards
How to check the kernel version of a Linux system?
uname -a
uname -v
unmae -r
How to see the current IP address on Linux?
ifconfig
OR
ip addr show
How to check for free disk space in Linux?
df -ah
a: all file system
h: human readable
How to see if a Linux service is running?
Older systems: service service_name status
Newer Systems: systemctl status service_name
How to check the size of a directory in Linux?
du -sh directory_name
How to check for open ports in Linux?
netstat -tupln
t: tcp
u: udp
p: program
l: listening
n: numerical value instead of host/user name
How to check Linux process information(CPU usage, memory, user information, etc.)?
ps -aux | grep process_name
top
htop
atop
How to deal with mounts in Linux
mount
ex: mount /dev/sda2 /mnt
fstab: Automatic boot time mounting
Location: /etc/fstab
How do you look stuff up?
Man pages
Stack overflow
Google
Official documentation
What is an init system?
The first special process that the kernel starts
init starts all the other services
init re-parents orphaned processes
What a linux user is made of ?
An entry in the following files:
- /etc/group
- / etc/shadow
- /etc/passwd
What do you know about proc?
What can you do with proc?
Kernel state presented as a file system tree
Find information about processes
Something wrong about processes
Troubleshooting
How to connect to a machine on the cloud?
Is there a VPN involved?
ssh to connect to remote hosts
ex: ssh root@ipaddress
Authentication with a password, key
How to copy a file to a remote host?
rsync username@ipaddress:/username/home/mytextfile.txt
What’s the difference between starting and enabling a service?
Starting is for that one time
Enabling is to start at boot time or whatever is defined
How to show the default route/default gateway?
ip route show
How do you deal with logging?
via journalctl
journalctl -fu
journalctl -xe : for adding explanation to errors
How to deal with a weird process?
How to find out more about it?
top/htop/atop
See the binaries: ps aux | grep
Poke /proc to see what that command was called with
lsof -p : file handles and network sockets
netstat or ss
What can prevent you from creating a file?
Incorrect ownership / permissions
inode exhaustion