Linux Questions
Linux Questions
Answer: The Linux kernel is the core part of the Linux operating system,
responsible for managing system resources, hardware communication, and
enforcing security.
Answer: The main components are the Linux kernel, system libraries, system
utilities, shell, and user applications.
Answer: File permissions in Linux determine who can read, write, or execute a
file. They are assigned to the owner, group, and others.
Answer: Use the chmod command, followed by permission settings and the file
name, e.g., chmod 755 filename.
Answer: Use commands like cat, more, less, head, or tail to view file contents.
Answer: grep is used to search text or files for specific patterns. For example,
grep "word" filename searches for "word" in the specified file.
Answer: Runlevels are different modes of operation in Linux that define the
state of the machine, such as multi-user, single-user, and graphical modes.
Modern systems use systemd targets instead.
Answer: Use the free command to display memory usage, including total, used,
and available memory.
Answer: You can create a new file using commands like touch filename or
using redirection, e.g., echo "text" > newfile.txt.
Answer: Use the find command to search for files. For example, find /home -
name "file.txt" searches for file.txt in the /home directory.
27. What is the difference between hard links and soft links?
Answer: Hard links are direct pointers to file data, and deleting one link does
not affect others. Soft links (symbolic links) are references to another file’s
path.
Answer: System logs are typically stored in /var/log. You can view logs using
commands like cat, less, or tail. For example, tail -f /var/log/syslog.
Answer: > overwrites a file with new content, while >> appends new content to
the end of an existing file.
Answer: The /etc/passwd file stores user account information, including the
username, UID, GID, home directory, and shell.
Answer: Use the useradd command to create a new user. For example, sudo
useradd username creates a user, and passwd username sets the user’s password.
Answer: The /etc/shadow file stores encrypted user password information and
related password policies, such as expiration dates.
Answer: The chown command changes the ownership of files and directories.
For example, chown user:group filename changes the owner and group of the
file.
Answer: Swap space is a portion of the hard drive used as virtual memory when
the physical RAM is full. It helps in preventing system crashes when memory
runs out.
Answer: The df -h command displays the disk usage of file systems in a human-
readable format (e.g., MB, GB).
44. What does the du command do?
Answer: The du (disk usage) command shows the disk space used by files and
directories. For example, du -sh /home/user shows the total size of the
/home/user directory.
Answer: The tar command is used to archive multiple files into a single file
(with the .tar extension) and optionally compress it (using gzip or bzip2). For
example, tar -czvf archive.tar.gz /directory creates a compressed archive.
Answer: Use the tar command with the -x option. For example, tar -xzvf
archive.tar.gz extracts the contents of the .tar.gz file.
Answer: SSH (Secure Shell) is a protocol used to securely log into remote
systems. Use ssh user@hostname to connect to a remote system.
49. What is the difference between hard and soft mounting in Linux?
Answer: In hard mounting, if the server is down, the client will keep trying until
the server is up. In soft mounting, the client will return an error if the server
doesn’t respond after a timeout.