3 Assignment - Linux
3 Assignment - Linux
systemctl get-default
systemctl get-default
4.Additionally, we can reboot the system to ensure it boots into the newly configured
default target:
sudo reboot
Create a custom systemd service unit file for a specific application or task.
//Unit
Description=My Custom Service
After=network.target # Specify any dependencies here
//Service
Type=simple # Type of service (simple, forking, etc.)
ExecStart=/path/to/your/application # Command to start your application
WorkingDirectory=/path/to/your/application/directory # Working directory for your application
Restart=always # Restart the service if it exits
User=myuser # User to run the service as
Group=mygroup # Group to run the service as
Environment="ENV_VAR=value" # Optionally set environment variables
//Install
WantedBy=multi-user.target # Specify the target to install the service
//SeatDefaults
autologin-user=your_username
autologin-user-timeout=0
4. Restart LightDM:
Configure the system to run a script or command at boot time using systemd.
//Unit
Description=My Startup Script
//Service
Type=oneshot # Run script once at boot
ExecStart=/path/to/my/startup.sh # Replace with your script path
User=your_username # Optional, specify user to run the script under
//Install
WantedBy=multi-user.target # Adjust based on your target needs
2.Adding a line similar to the following, replacing <server_ip> with the IP address of your remote
syslog server and <facility>.<level> with the desired facility and log level to send
*.* @remote_server_ip:514
authpriv.warn /var/log/auth.warn
local7.*
Or
Using rules in your syslog/rsyslog configuration file to specify which logs should be
redirected.
Set up log rotation to manage log file sizes and ensure proper log file maintenance.
1.Edit the logrotate configuration file:
/path/to/your_log_file.log {
size 100M
rotate 10
compress
missingok
notifempty
}
kern:pipeline.* /var/log/kernel_pipeline.log
!authpriv.* /var/log/messages
System Tuning:
Optimize network settings for better performance, such as adjusting TCP/IP stack parameters.
Adjust file system parameters for improved disk I/O performance, such as adjusting the disk
scheduler or file system mount options.
Configure kernel parameters to optimize memory usage, process scheduling, or other system
behaviors.
# Set swappiness to 10
vm.swappiness = 10
Monitor system performance using tools like top, vmstat, or sar, and make appropriate tuning
adjustments based on the observed metrics.
• Utilizing tools like top, vmstat, sar, iotop, nethogs, etc., to monitoring system performance metrics
such as CPU, memory, disk I/O, and network utilization.
• Analyzing the output of these tools to identify performance bottlenecks and areas for improvement.
Implement security-related tuning, such as hardening the system against various types of
attacks or vulnerabilities.
PermitRootLogin no
PasswordAuthentication no
To unload a module:
2.Add the name of the module you want to load at boot time on a new line.
3.Save the file and exit the text editor.
blacklist module_name
# Create a cgroup
sudo cgcreate -g memory:mygroup
Tune I/O scheduler settings to optimize disk I/O performance for different workload
types.
Network Tuning:
Adjust network buffer sizes to optimize network performance.
Configure TCP/IP stack parameters, such as TCP window size or congestion control
algorithms, to improve network throughput and latency.
Implement Quality of Service (QoS) policies to prioritize network traffic for critical
applications or services.
sudo tc class add dev <interface> parent 1: classid 1:1 htb rate <rate>
sudo tc class add dev <interface> parent 1:1 classid 1:12 htb rate <rate>
sudo tc class add dev <interface> parent 1:1 classid 1:11 htb rate <rate>
sudo tc filter add dev <interface> parent 1: protocol ip prio 1 u32 match ip dport <port>
0xffff flowid 1:11
Determine the disk you want to partition by using the lsblk or fdisk -l command.
lsblk-l
fdisk -l
Format Partitions:
After partitioning, you need to format the partitions with a file system
Mount Partitions:
Finally, mount the formatted partitions to directories in the file system.
mkfs.ext4 /dev/sda3