FE Notes Tips
FE Notes Tips
FE Notes Tips
(Feb 22 Q1)
LINUX PROPERTIES (Advantages)
1. Free and Open Source:
-Cost-free, available for download from the Internet without registration fees.
-Open-source nature allows users to access and modify the source code freely.
3. Continuous Operation:
-Designed for continuous operation without frequent reboots.
-Automated tasks during off-peak hours contribute to higher availability.
- Suitable for environments with limited system monitoring.
2. Debian: Stable and versatile. Strong open-source principles. A foundation for other distributions.
3. OpenSUSE: Has community and enterprise versions. Features YaST tool for easy system
configuration.
4. Fedora: Cutting-edge distribution, sponsored by Red Hat. A testing ground for new distribution.
Emphasizes the use of latest software.
5. Linux Mint: Based on Ubuntu. Elegant and user-friendly desktop experience. Includes multimedia
program for enhanced usability.
4. User Permissions: Limits access with specific user and process permissions. Ensures protection
against unauthorized access.
5. Firewall Defense: Offer powerful firewall tools for admins to set network traffic rules. Adds extra
layer of defense.
1. Applications: Software programs or applications that users interact with, providing various
functionalities.
2. Shell: The shell interprets user commands and facilitates communication between the user and
the kernel.
3. Kernel: The core of the operating system that manages hardware resources and ensures proper
interaction between software and hardware components.
4. Hardware: Physical components like terminals, printers, and disks that the kernel manages for the
system's overall operation.
5. Utilities: Additional tools and programs that assist in various tasks, enhancing the functionality of
the system.
1. User Commands: Executable programs and scripts that users run to perform tasks on the Linux
system.
2. Shell: The shell interprets user commands, finding and starting their execution. Bash is a popular
shell among several available.
3. Kernel: Manages hardware resources for the entire system, ensuring efficient communication
between software and hardware components.
4. File Systems: Organize and store data on storage devices, providing a structured way to access and
manage files.
5. Device Drivers: Enable the operating system to communicate with hardware devices, ensuring
proper functionality and interaction.
6. Hardware: Physical components of the computer, including devices like CPU, memory, and
storage. The kernel manages these resources for the entire system.
You are tasked with creating a shell script that provides various system management functionalities
through a user-friendly menu. The script allows users to perform operations:
The script includes a menu where users can enter a choice (1-4) to execute the corresponding option.
After completing an operation, users are asked whether they want to continue or exit the script.
#!/bin/bash
while true; do
# Display menu
echo "System Management Menu"
echo "1. List contents of a directory"
echo "2. View running processes"
echo "3. Change permissions of a file"
echo "4. Move a file or directory"
echo "5. Exit"
case $choice in
1)
# Option 1: List contents of a directory
read -p "Enter the directory path: " directory
ls -l $directory
;;
2)
# Option 2: View running processes
ps aux
;;
3)
# Option 3: Change permissions of a file
read -p "Enter the file path: " file
read -p "Enter the new permissions (e.g., 755): " permissions
chmod $permissions $file
;;
4)
# Option 4: Move a file or directory
read -p "Enter the source file/directory path: " source_path
read -p "Enter the destination path: " destination_path
mv $source_path $destination_path
;;
5)
# Option 5: Exit the script
echo "Exiting the script."
exit 0
;;
*)
# Invalid choice
echo "Invalid choice. Please enter a number between 1 and 5."
;;
esac
done
Meaning.
(Feb 23 Q6)
FILE PERMISSION + OCTAL
ls – l command: Displays the contents of the current directory + assigned permissions for each file or
subdirectory
i. rwxr--r--
- Octal: 744
- Meaning: The owner has read (4) + write (2) + execute (1) permissions, and the group and others
have read (4) permissions.
ii. r-xr-xr-x
- Octal: 555
- Meaning: The owner, group, and others have read (4) + execute (1) permissions.
iii. rwxr-xr-x
- Octal: 755
- Meaning: The owner has read (4) + write (2) + execute (1) permissions, and the group and others
have read (4) + execute (1) permissions.
FILE OWNERSHIP
Q: Change the ownership of a file named "file.txt" to a user named "user1" in Linux. Provide the
command to do so.
The user root can use the chown command to change the user and group affiliation of a file by using
the following syntax:
Normal users can use the chown command to allocate a file that they own to a new group:
chown .new_group file
TEXT EDITORS
1. vi: Classic and powerful text editor with different modes for editing and commands.
2. emacs: Versatile text editor with many features, known for flexibility.
4. xedit: Simple text editor for basic tasks in the X Window System.
5. gedit: Default text editor for GNOME desktop, easy for everyday use.
6. kwrite: Default text editor for KDE desktop, simple and efficient.
Definition:
-In Linux, `umask` is a command that controls default file permissions for new files and directories. The
`umask` value subtracts from the maximum permissions to determine the default permissions.
How it works:
- The umask value is subtracted from the maximum permission setting (usually 666 for files and 777
for directories).
- The result is the default permission that newly created files or directories will have.
Example:
- If the umask is set to 022, it means the default permissions for files will be 666 - 022 = 644, and for
directories, it will be 777 - 022 = 755.
1) DAEMON – THEORY
Definition: A daemon process in a computer system is a background process that runs independently
of any direct user interaction.
Characteristics:
- No User Interaction: Usually run without direct user involvement.
- Background Operation: Operate in the background, performing tasks or services.
- Long-Running: Designed to be long-running processes.
Purpose:
- Continuous Operation: Ensure that certain functions or services are available continuously.
- Efficiency: Contribute to the efficient operation of the system by handling tasks independently.
In summary, daemons are background processes in a computer system that operate independently
to provide continuous services or perform various tasks.
2) FOREGROUND VS BACKGROUND
Foreground:
- User Interaction: Processes run in the active, visible part of the computer screen where users interact
directly.
- Blocking: Often block the user interface, and user may need to wait for their completion before doing
other tasks.
- Examples: Running a command in the terminal without using backgrounding techniques, or
interacting with a graphical application directly.
Background:
- No Direct User Interaction: Processes run independently of direct user interaction, often without
blocking the user interface.
- Non-blocking: Allow users to continue interacting with the system while the processes run.
- Examples: Running a process in the background in the terminal using '&' or using background services
like daemons or background jobs.
Key Difference:
- Visibility:
FG are visible and interact directly with the user.
BG operate independently, not directly interacting with the user interface.
- User Engagement:
FG require user engagement.
BG allow users to continue working on other tasks.
END A PROCESS
killall command kills all processes with an indicated command name
kill command kills only the indicated process
CRON JOB
30 15 * * * /path/to/your/script.sh
Translation:
Minute: 30
Hour: 15 (3:30 PM)
Day_of_Month: Any day (*)
Month: Any month (*)
Day_of_Week: Any day of the week (*)
Command_to_Run: /path/to/your/script.sh
0 0 * * 0 /path/to/backup-script.sh
Translation:
Minute: 0
Hour: 0 (midnight)
Day_of_Month: Any day (*)
Month: Any month (*)
Day_of_Week: 0 (Sunday)
Command_to_Run: /path/to/backup-script.sh
EX 3: Original Cron Job: Run a cleanup script every weekday at 2:30 PM.
30 14 * * 1-5 /path/to/cleanup-script.sh
Translation:
Minute: 30
Hour: 14 (2:30 PM)
Day_of_Month: Any day (asterisk *)
Month: Any month (asterisk *)
Day_of_Week: 1-5 (Monday to Friday)
Command_to_Run: /path/to/cleanup-script.sh
NETWORK CONFIGURATION
Open SSH (secure shell) THEORY
-Definition:
A cryptographic network protocol that provides a secure way to access and manage network devices
and systems over an unsecured network.
-Key Features:
Secure Communication:
- Encrypts data transmitted over the network, ensuring confidentiality.
- Uses strong authentication methods, including passwords and public-key cryptography.
Remote Access:
- Allows users to log into remote machines and execute commands as if they were directly interacting
with the local machine.
- Provides a secure alternative to traditional methods like Telnet.
File Transfer:
- Supports secure file transfer between systems using SCP (Secure Copy) or SFTP (Secure File Transfer
Protocol).
Port Forwarding:
- Allows the creation of secure tunnels for forwarding network connections.
Tunneling:
- Supports tunneling of other protocols, enhancing security for various applications.
Authentication:
- Uses key-based authentication, improving security over password-based methods.
- Supports two-factor authentication for an added layer of security.
Configuration:
- SSH configuration is managed through the `ssh_config` and `sshd_config` files.
- Various options allow users to customize the behavior of SSH connections.
-Use Cases:
Server Administration: Remote management of servers and network devices.
Secure File Transfer: Securely transfer files between local and remote systems.
Tunneling: Establish secure tunnels for accessing services on remote machines.
Automated Tasks: Used in scripts and automated processes for secure communication.
Git and Version Control: Often used for secure access to Git repositories.
Commands:
ssh: Command to establish an SSH connection to a remote server.
scp: Command for secure file copying between local and remote systems.
sshd: SSH server daemon responsible for accepting connections.
SSH is a crucial tool for secure remote access, file transfer, and tunneling. It plays a significant role in
secure system administration and communication across networks.