In this article, we are going to cover an Introduction to Linux, Linux file system with examples, Interview questions and answers on Introduction to Linux and Linux file system.
Table of Contents
What is Linux?
Linux is a free and open-source operating system kernel that serves as the foundation for numerous operating systems, known as distributions (distros), such as Ubuntu, CentOS, and Fedora.
Renowned for its stability, security, and flexibility, Linux is widely used across various platforms, including servers, desktops, mobile devices, and embedded systems.
It supports multitasking, multi-user environments, and diverse file systems, making it a versatile choice for developers and system administrators. With its open-source nature, Linux encourages innovation and collaboration, providing users the freedom to modify and share its code.
Its vast community support and extensive ecosystem of tools and applications make Linux a cornerstone of modern computing.
Linux Architecture

Below is a simple breakdown of the Linux architecture:
Hardware Layer:
This layer consists of physical components like CPU, memory, hard disk, etc.
It provides the necessary resources for the kernel to manage and execute processes.
Kernel Layer
The kernel is the core of the Linux operating system, managing hardware and system resources.
It has three key components:
Process Management: Handles process creation, scheduling, and termination.
Memory Management: Allocates and manages RAM and virtual memory.
Device Drivers: Interfaces between hardware and software applications.
File System Management: Provides a hierarchical structure to store and retrieve files.
System Call Interface
Acts as the bridge between user space and kernel space.
Provides an interface for applications to interact with the kernel (e.g., open, read, write).
User Space
Shell: A command-line interface for users to interact with the OS.
Utilities and Applications: Programs like text editors, compilers, and other user-level applications.
Why DevOps Engineer should learn in Linux?
Linux is the backbone of DevOps, providing a stable and flexible platform for tools like Docker, Kubernetes, Jenkins, and Ansible. It powers cloud infrastructure, supports automation through scripting, and enables containerization with its kernel features. Linux servers are widely used for CI/CD pipelines, streamlining development and deployment processes. With robust security frameworks and powerful monitoring tools, Linux ensures secure and efficient DevOps environments. Its open-source nature fosters collaboration and innovation, aligning perfectly with DevOps principles
Linux File System overview
The Linux file system is widely used for its organized, flexible, and secure structure, making it ideal for both individual and enterprise environments. Its hierarchical organization ensures that system files are separated from user data, improving security and system management. By treating devices as files within the /dev directory, Linux simplifies hardware interaction and device management. The system allows easy mounting of additional storage devices under /mnt or /media, providing flexibility to extend storage without disrupting the system’s architecture.

Linux File System
Directory | Purpose | Example |
/ | Root directory; starting point of file system | cd / |
/home | User home directories | /home/user1 |
/etc | System and application configuration files | /etc/hostname |
/bin | Essential user commands | /bin/ls |
/sbin | System administration commands | /sbin/reboot |
/dev | Device files for hardware | /dev/sda |
/tmp | Temporary files (cleared on reboot) | /tmp/session123 |
/var/log | System and application logs | /var/log/syslog |
/lib | Shared libraries for executables | /lib/libc.so |
/boot | Files for booting the system | /boot/vmlinuz |
/mnt & /media | Mount points for external storage | /mnt/usb |
Quick commands:
- Navigate: cd /etc
- List files: ls /var/log
- View logs: cat /var/log/syslog
- Check disk: df -h
Basic Linux Commands with Examples
- pwd – Print working directory; shows the current directory path.
example :

- ls – List directory contents.
example:

- cd – Change directory.
example:

- wc – count lines, words.
example:

- mv – Move or rename files and directories.
example:

- rm – Remove files or directories.
example:

- mkdir – Create a new directory.
example:

- echo – Displays text or strings.
example:

- touch – Create an empty file or update the timestamp of a file.
example:

- cat – Concatenate and display file contents.
example:

Linux File Types and Permission:-
In Linux, file types and permissions are essential for managing access and security within the system.
File types in Linux include regular files, directories, symbolic links, and device files, each represented by different characters when using the ls -l command.
Permissions define who can read, write, or execute a file and are crucial for controlling access to resources. These permissions are categorized into three levels: user (owner), group, and others.
Each category has three types of permissions:
- read (r),
- write (w),
- execute (x),
- represented as a 3-character string (e.g., rwxr-xr–).
chmod (change mode) command is used to modify file permissions. It allows users to set or remove specific permissions for the user, group, or others. Permissions can be modified using symbolic notation (e.g., chmod u+x file to add execute permission for the user) or numeric notation (e.g., chmod 755 file to set rwxr-xr-x permissions).
chown (change owner) command is used to change the ownership of a file or directory. It allows a user to set a new owner and/or group for a file. For example, chown user:group file changes the file’s owner to user and its group to group.
chgrp (change group) command is specifically for changing the group ownership of a file. For example, chgrp group file assigns the file to the specified group. These commands provide fine-grained control over file access, helping system administrators and users maintain security and proper access rights on Linux systems.
File Types in Linux
- – : Regular file
- d : Directory
- l : Symbolic link
- b : Block device
- c : Character device
- p : Named pipe (FIFO)
- s : Socket
File Permissions in Linux
- r : Read (view content of the file)
- w : Write (modify the file)
- x : Execute (run the file as a program)
- – : No permission (absence of r, w, or x)
Levels of permissions in Linux
- u : User (Owner)
- g : Group
- o : Others
- a : All (User, Group, and Others)
Linux commands for File and Directory
- View file permissions
ls -l filename
Change file permissions (chmod)
- Symbolic mode:
- Add permission: chmod u+x file (Add execute permission for the user)
- Remove permission: chmod g-w file (Remove write permission for the group)
- Set permission explicitly: chmod u=rwx,g=rx,o=r file (Set permissions to rwx for user, rx for group, r for others)
Numeric mode:
- chmod 755 file (User: rwx, Group: rx, Others: rx)
- chmod 644 file (User: rw, Group: r, Others: r)
- Change file owner (chown)
chown user:group filename
Change file group (chgrp)
chgrp group filename
Permissions Breakdown
- rwxr-xr–
- User (Owner): rwx (Read, Write, Execute)
- Group: r-x (Read, Execute)
- Others: r– (Read only)
Troubleshooting on Linux File System and Permission
To troubleshoot Linux file type and permissions issues:
- Identify File Type: Use ls -l to display file types (- for regular files, d for directories, etc.) and check if the file matches the intended type.
- Check Permissions: Inspect file permissions using ls -l. The output shows permissions for the owner, group, and others (e.g., rwx for read, write, execute).
- Modify Permissions: Use chmod to change file permissions, e.g., chmod 755 file for owner read/write/execute and others read/execute.
- Adjust Ownership: Use chown to change the owner or group of a file, e.g., chown user:group file.
- Test Accessibility: Verify access using the intended account and ensure permissions align with the required functionality.
Linux File System commands Interview Questions and Answers
1. What is the purpose of the ls command?
Answer: The ls command lists files and directories in the current directory.
2. How do you display the contents of a file?
Answer: Use the cat, less, or more commands. For example:
cat filename:
Displays the entire file.
less filename:
Allows scrolling through the file.
more filename:
Displays one screen at a time.
3. What does the cd command do?
Answer: The cd command is used to change the current working directory.
For example:
cd /path/to/directory.
4. How can you find the current directory you are in?
Answer: Use the pwd command to display the present working directory.
5. What does the touch command do?
Answer: The touch command creates an empty file or updates the timestamp of an existing file.
6. How do you view the first or last lines of a file?
Answer:
head -
n 5 filename: Displays the first 5 lines.
tail -
n 5 filename: Displays the last 5 lines.
7. What is the use of the cp command?
Answer: The cp command copies files or directories.
Example:
cp source_file destination_file.
8. How do you remove a file or directory?
Answer:
rm filename:
Deletes a file.
rm -r directory:
Deletes a directory and its contents.
9. What is the chmod command used for?
Answer: The chmod command changes file or directory permissions. Example:
chmod 755 file gives read, write, execute permissions to the owner and read/execute permissions to others.
10. How can you search for a specific word in a file?
Answer: Use the grep command. Example:
grep "word" filename.
11. What does the df command show?
Answer: The df command displays disk space usage of file systems.
12. How do you check running processes?
Answer: Use the ps or top command.
ps: Displays a snapshot of processes.
top: Provides a dynamic view of running processes.
13. What is the difference between > and >> in Linux?
Answer:
>: Overwrites the content of a file.
>>: Appends to the file without overwriting.
14. How do you display all running processes?
Answer: Use ps -ef or ps aux.
15. What does the sudo command do?
Answer: The sudo command allows a user to execute commands with elevated privileges.
16. How do you find the size of a file or directory?
Answer: Use du -h to get a human-readable size of files or directories.
17. How do you check the file type?
Answer: Use the file filename command to determine the type of a file.
18. What is the use of the wc command?
Answer: The wc command counts lines, words, and characters in a file.
Example:
wc filename.
19. How do you check active network connections?
Answer: Use the netstat or ss command.
20. How do you search for files in Linux?
Answer: Use the find command. Example:
find /path -name “filename” searches for a file by name.
Linux file type and permission interview questions with answers
1. What are the different types of files in Linux?
- Answer: In Linux, files can be of the following types:
- Regular file: Represented by – (e.g., text files, binary files).
- Directory: Represented by d.
- Symbolic link: Represented by l.
- Character special file: Represented by c.
- Block special file: Represented by b.
- Socket: Represented by s.
- Named pipe (FIFO): Represented by p.
2. What is the meaning of file permissions in Linux?
- Answer: File permissions in Linux define who can read, write, or execute a file. The permissions are divided into three categories:
- Owner: The user who owns the file.
- Group: The group associated with the file.
- Others: All other users.
Permissions are represented by three types:
- r: Read
- w: Write
- x: Execute
3. How do you view the permissions of a file?
- Answer: Use the ls -l command to display detailed file information, including permissions. Example:
ls -l filename
Output might look like:
-rwxr-xr--
This shows the file type, owner, group, and permission settings.
4. What does the chmod command do?
- Answer: The chmod command is used to change the permissions of a file or directory. It can use symbolic notation (r, w, x) or numeric notation (e.g., 755) to set permissions.
Example:
- chmod 755 file: Sets read, write, execute permissions for the owner, and read/execute for the group and others.
- chmod u+x file: Adds execute permission for the owner.
5. What is the meaning of the permission rwxr-xr–?
- Answer: The permission string rwxr-xr– represents:
- rwx: The owner has read, write, and execute permissions.
- r-x: The group has read and execute permissions.
- r–: Others have read-only permissions.
6. What is the chown command used for?
- Answer: The chown command is used to change the owner and/or group of a file or directory. Example:
- chown user:group filename: Changes the file’s owner to user and its group to group.
7. How do you change the permissions of a file using numeric values?
- Answer: Permissions are represented numerically as follows:
- r = 4
- w = 2
- x = 1
To set permissions, add the values for each user category (owner, group, others). Example:
- chmod 755 file:
- Owner: 7 (rwx → 4+2+1)
- Group: 5 (r-x → 4+1)
- Others: 5 (r-x → 4+1)
8. What is the difference between symbolic and numeric mode in chmod?
- Answer:
- Symbolic mode uses characters like r, w, x, and +, -, = to set permissions. Example: chmod u+x file.
- Numeric mode uses numbers to represent permissions. Example: chmod 755 file.
9. How do you set read, write, and execute permissions for the owner only?
- Answer: Use the chmod command:
- chmod 700 file: Gives read, write, and execute permissions to the owner and no permissions to the group or others.
10. What does the umask command do?
- Answer: The umask command sets default permissions for newly created files and directories. It defines which permissions should be masked (removed) when creating new files. For example, umask 022 sets default permissions of 755 for directories and 644 for files.
11. How do you change the permissions of a directory in Linux?
- Answer: Use the chmod command to modify the permissions of a directory, just like for a file. To grant execute permission to a directory (necessary for accessing it), you can run:
- chmod 755 directory_name
12. What are sticky bit, setuid, and setgid?
- Answer:
- Sticky bit: When set on a directory, it allows only the owner of a file to delete or rename it within that directory.
- setuid: When set on an executable file, it allows the file to run with the privileges of the file owner (usually root).
- setgid: When set on a directory, it ensures that files created within the directory inherit the group of the directory, rather than the user’s group.
Conclusion:
Introduction to Linux, Linux file system with examples, Interview questions and answers on Introduction to Linux and Linux file system
Related Articles:
Linux Networking and Services with Examples
Reference: