Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
14 views5 pages

Linux Practice1

The document outlines a comprehensive guide for practicing various Linux skills, including file and directory permissions, user and group management, disk usage, process management, system services, file search, network configuration, cron jobs, RAID configuration, SSH, and backup techniques. Each section includes specific exercises aimed at enhancing understanding and practical application of these concepts. The exercises cover commands and procedures necessary for effective Linux system administration.

Uploaded by

bilal sheikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views5 pages

Linux Practice1

The document outlines a comprehensive guide for practicing various Linux skills, including file and directory permissions, user and group management, disk usage, process management, system services, file search, network configuration, cron jobs, RAID configuration, SSH, and backup techniques. Each section includes specific exercises aimed at enhancing understanding and practical application of these concepts. The exercises cover commands and procedures necessary for effective Linux system administration.

Uploaded by

bilal sheikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Linux Practice.

1
1. File and Directory Permissions

Goal: Understand and practice controlling access to files and directories.

Exercise Breakdown:

 Exercise 1: Modify File Permissions


o Use chmod to change file permissions:
1. Create a file: touch file.txt
2. Check the current permissions: ls -l file.txt
3. Modify permissions using symbolic mode:
 Give the owner read and write, the group read, and others no
permissions:
chmod u+rw,g+r,o-r file.txt
 Verify changes: ls -l file.txt
4. Use numeric mode (e.g., chmod 755 file.txt).
 Exercise 2: Change File Ownership
o Change the ownership of a file: chown user:group file.txt
o Verify: ls -l file.txt
o Example: Change the ownership to a different user and group:
chown john:admins file.txt
 Exercise 3: Working with umask
o View your current umask value: umask
o Set a custom umask value (e.g., umask 022).
o Create a file and check its default permissions after setting the umask.

2. User and Group Management

Goal: Learn to add, modify, and delete users and groups, and manage their access.

Exercise Breakdown:

 Exercise 1: Create Users


o Add a new user: sudo useradd newuser
o Set a password: sudo passwd newuser
o Check the user list: cat /etc/passwd
 Exercise 2: Modify Users
o Change the user's default shell: sudo usermod -s /bin/bash newuser
o Add the user to an additional group: sudo usermod -aG sudo newuser
o Verify group membership: groups newuser
 Exercise 3: Delete Users and Groups
o Delete a user: sudo userdel newuser
o Delete a group: sudo groupdel newgroup

3. Disk Usage and File Systems

Goal: Understand how to monitor disk usage and manage file systems.

Exercise Breakdown:

 Exercise 1: Check Disk Usage


o Check overall disk space usage: df -h
o Check disk space for a specific directory: du -sh /home/user
 Exercise 2: Partition a Disk
o List available disks: sudo fdisk -l
o Create a new partition on a disk using fdisk or parted.
o Format the partition with a filesystem:
sudo mkfs.ext4 /dev/sdb1
o Mount the partition to a directory: sudo mount /dev/sdb1 /mnt
 Exercise 3: Check Filesystem Health
o Run a filesystem check: sudo fsck /dev/sdb1
o Fix any errors that appear.

4. Process Management

Goal: Learn how to monitor and manage running processes.

Exercise Breakdown:

 Exercise 1: View Running Processes


o Use ps to list processes: ps aux
o Use top or htop to view real-time process usage.
o Look for processes consuming the most CPU and memory.
 Exercise 2: Kill Processes
o Find a process ID (PID) using ps or top: ps aux | grep <process_name>
o Kill a process by its PID: sudo kill <PID>
o Use killall to terminate all processes by name: sudo killall
<process_name>
 Exercise 3: Set Process Priority
o Start a process with lower priority using nice:
nice -n 10 command
o Change the priority of a running process using renice:
sudo renice -n 10 -p <PID>
5. System Services (Systemd)

Goal: Understand how to manage services and view logs.

Exercise Breakdown:

 Exercise 1: View Service Status


o Check the status of a service (e.g., SSH): sudo systemctl status ssh
o Start/Stop/Restart a service:
sudo systemctl start ssh, sudo systemctl stop ssh, sudo systemctl
restart ssh
 Exercise 2: Enable/Disable Services
o Enable a service to start at boot: sudo systemctl enable ssh
o Disable a service from starting at boot: sudo systemctl disable ssh
 Exercise 3: View Logs
o View logs for a service using journalctl: journalctl -u ssh
o View the system log: journalctl

6. File Search and Text Processing

Goal: Learn how to search for files and process text files.

Exercise Breakdown:

 Exercise 1: Find Files


o Search for files by name: find /path/to/search -name "file.txt"
o Find files modified within the last 7 days:
find /path/to/search -mtime -7
 Exercise 2: Search Within Files
o Search for a string in a file: grep "string" file.txt
o Search recursively within a directory:
grep -r "string" /path/to/dir
 Exercise 3: Use awk and sed
o Use awk to extract a specific column: awk '{print $1}' file.txt
o Use sed to replace text in a file: sed -i 's/old/new/g' file.txt

7. Network Configuration and Troubleshooting

Goal: Learn basic network management and troubleshooting techniques.


Exercise Breakdown:

 Exercise 1: View Network Interfaces


o List network interfaces: ip a or ifconfig
o Check IP address: ip addr show eth0
 Exercise 2: Test Network Connectivity
o Ping a remote host: ping google.com
o Trace the route to a remote server: traceroute google.com
 Exercise 3: Check Open Ports
o Check open ports using ss: ss -tuln
o Use netstat to see established connections: netstat -tuln

8. Cron Jobs and Automation

Goal: Learn to automate repetitive tasks.

Exercise Breakdown:

 Exercise 1: Create a Cron Job


o Open the crontab editor: crontab -e
o Set a cron job to run a script every day at midnight:

bash
Copy code
0 0 * * * /path/to/your/script.sh

 Exercise 2: List and Remove Cron Jobs


o List current cron jobs: crontab -l
o Remove a cron job by editing the crontab: crontab -e
 Exercise 3: Use at for One-Time Jobs
o Schedule a one-time task using at: echo "bash /path/to/script.sh" | at
02:00

9. RAID Configuration

Goal: Understand how to configure RAID arrays for redundancy and performance.

Exercise Breakdown:

 Exercise 1: Create a RAID 1 Array


o Create a RAID 1 array using mdadm:
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2
/dev/sdb /dev/sdc
o Check the RAID status: cat /proc/mdstat
 Exercise 2: Monitor and Manage RAID Arrays
o Add a new disk to the RAID array:
sudo mdadm --add /dev/md0 /dev/sdd
o Remove a failed disk:
sudo mdadm --remove /dev/md0 /dev/sdb

10. SSH and Remote Access

Goal: Secure and manage remote access to your system.

Exercise Breakdown:

 Exercise 1: Set Up SSH Key Authentication


o Generate an SSH key pair: ssh-keygen
o Copy the public key to the remote server: ssh-copy-id user@remotehost
 Exercise 2: Disable Password Authentication
o Edit /etc/ssh/sshd_config and set PasswordAuthentication no.
o Restart the SSH service: sudo systemctl restart ssh
 Exercise 3: Transfer Files with scp
o Copy a file to a remote server:
scp localfile.txt user@remotehost:/path/to/destination

11. Backup and Restore

Goal: Learn how to back up and restore data.

Exercise Breakdown:

 Exercise 1: Backup with rsync


o Create a backup of your home directory:
rsync -avz /home/user/ /backup/

You might also like