Linux Server Administration PDF
Document Details
2024
RWANDA TVET BOARD
Tags
Summary
This document is a past paper from the RWANDA TVET Board for 2024, covering the topic of Linux Server Administration. It provides an overview of Linux server environment, distributions, components, features, and advantages. The document also details user management, networking, and file system navigation in a Linux environment.
Full Transcript
BDC Linux Server Administration NITLS501 Administer Linux Server Competence RQF Level: 5 Learning Hours Credits: 10 100 Sector:...
BDC Linux Server Administration NITLS501 Administer Linux Server Competence RQF Level: 5 Learning Hours Credits: 10 100 Sector: ICT and Multimedia Trade: NETWORKING AND INTERNET TECHNOLOGIES Module Type: Specific Curriculum: ICTNIT5001 TVET Certificate V in Networking and Internet Technologies Copyright: © RWANDA TVET Board 2024 Issue Date: September, 2024 Page 2 of 46 LEARNING OUTCOME 1: PREPARE LINUX SERVER ENVIRONMENT 1. Identification of Linux server requirements 1.1 Introduction to Linux server A Linux admin, or Linux system administrator is similar to iOS and window, Linux is an operating system that connects the internal hardware in electronics, including phones and computer. What does a Linux administrator do? ❖ Linux administrator are responsible for maximizing the performance of the OS. ❖ Installing Linux server and system administrator. ❖ Updating the system after crashes or reboots. ❖ Performing maintenance checks and system backups. ❖ Reading error logs. ❖ Conducting root analyses. ❖ Processing user complaints. ❖ Training other administrator to use the system LINUX DISTRIBUTION A Linux distribution is essentially a complete operating system built around the Linux kernel. Various Linux distributions: ✓ Debian ✓ OpenSUSE ✓ Ubuntu ✓ Red Hat enterprise Linux ✓ Kali Linux ✓ Slackware ✓ MX Linux ✓ Zypper ✓ Android Page 3 of 46 ✓ CentOS ✓ Fedora PARTS OF LINUX OPERATING SYSTEM In general, the Linux operating system is made up of three parts; the kernel, the shell, and the programs. 1. Kernel: If we think of the Linux operating system in terms of layers, the kernel is the lowe\xst layer. It interfaces directly with the computer hardware and is responsible for allocating and managing the resouces available to programs. 2. Shell: The shell acts as an interface between the user and the kernel, is a command line interpreter translate commands which are listed in the order of execution preceded by sign. Common shells: Bash, Zsh, Fish, KornShell (ksh). 3. Programs: One of the main features of Linux is that it includes a variety of small programs to meet various needs. Typically, each of these programs does one thing and does it well. Linux’s features ❖ Simplified update for all installed software. ❖ Free software licensing ❖ Access to source code ❖ Multiple distribution ❖ Better malware protection Linux vs Window ❖ Window Is a licensed OS in which is designed for the individual with the perspective of having no computer programming knowledge and for business and other commercial users. Page 4 of 46 Users in windows (4 users): 1. Administrator 2. Standard 3. Child 4. Guest. Users in Linux (3 users): 1. Regular 2. Administrative 3. Service. ❖ In Linux files are ordered in tree structure storing with the root directory. ❖ In Microsoft window files are stored in folder on different data drivers like C: D: E: etc. ❖ Linux is very stable and more secure than window. ❖ Window user has forced security issues, since windows is most widely used OS hacker, spammers target frequently. ❖ Linux is open source while window is commercial proprietary Components of Linux System Linux Operating System has primarily four components ✓ Kernel: The core of Linux, managing hardware, processes, and memory. ✓ System Library: Specialized functions that applications use to access kernel features without direct code access. ✓ Shell is a command-line interface (CLI) that allows users to interact with the operating system. It provides a way to execute commands, run scripts, and manage files. Page 5 of 46 ✓ System Utility: System Utility programs are responsible to do specialized, individual level task. Advantages of Linux Open Source: Software that is open-source allows anybody to contribute, edit, and improve the source code. Additionally, it is free to download and use by users. Secure: Compared to Windows operating systems, Linux is more secure and less prone to attack. License expenses: Linux, unlike Microsoft Windows and Apple macOS, does not need explicit license costs. While many Linux companies offer system support for a charge, the OS itself is free to copy and use. Revive outdated computer systems: - Linux, which makes use of antiquated technologies like firewalls, backup servers, low-end systems, etc., can resurrect old and out-of-date PCs. Reliability: Linux is regarded as a trustworthy operating system and is well-supported with security updates. Easy to update: Linux offers quicker and simpler software updates than Windows does. Lightweight: Linux is portable. Easy to manage: With customization, users may quickly add or remove features as desired, as well as add icon sets and wallpapers. Unlike Windows, no restart is required after installing and removing apps. Page 6 of 46 Easy to Install: The Linux installation procedure is quicker than that of Windows and other operating systems. Ideal for Programming: Linux is widely used by programmers, so there is a wealth of online assistance for faults or situations. Privacy: To protect user privacy, Linux does not gather a lot of information from users. Efficiency: Without sacrificing efficiency, many networks and workstations can operate concurrently. LIMITATION OF LINUX 1. System Compatibility: Linux might have limited support for certain hardware devices, causing compatibility issues. 2. Steep Learning Curve: Linux can be more difficult to learn compared to other OSes, especially for those new to the command line. 3. Software Interoperability: Not all software is readily available for Linux, but there are alternatives and workarounds. 4. Lack of Standardization: Different Linux distributions can have compatibility issues due to varying package formats. 5. Commercial Support: Linux may have limited commercial support compared to other OSes. 6. Gaming Support: Gaming support for Linux can be limited, as many games are not developed natively for it. APPLICATIONS OF LINUX SERVER OS 1. Servers Web Servers Mail Servers Database Servers File Servers Page 7 of 46 2. Desktop Computers Security Free and Open-Source 3. Embedded Systems Smart TVs Routers and Modems IoT Devices Automotive 1.2 Description of the Linux server selection criteria 1.2.1 Hardware requirements Minimum Hardware Requirements CPU Compatible x86 64-bit processor Memory At least 4GB RAM Disk Space 20GB Graphics Device with openGL support (e.g: Intel HD/UHD Graphics) Network Active internet connection 1.2.2 Software requirements BIOS/UEFI: your computer’s UEFI/BIOS firmware should support booting from a USB driver or optic disc Page 8 of 46 2. Selection of Tools and Equipment Software tools are critical for managing, maintaining, and developing on Linux systems. The tools must be aligned with the objectives of the system, whether for server management, software development, or desktop usage. 2.1 Hardware Tools 1. Server: The core of the infrastructure. Choose a server based on your workload (e.g., web server, database server, file server) and performance requirements. 2. Network Interface Cards (NICs): Ensure sufficient network connectivity for your server's role. Consider factors like bandwidth, speed, and number of ports. 3. Storage Devices: Select appropriate storage for your data. Options include: a. Hard Disk Drives (HDDs): Cost-effective for large storage needs. b. Solid-State Drives (SSDs): Faster performance for critical applications. c. Network Attached Storage (NAS): Centralized storage for multiple servers. 4. Rackmount Equipment: If using a physical rack, ensure you have the necessary rails, cages, and power distribution units (PDUs). 5. Keyboard and Mouse: For local interaction with the server. 6. Monitor: For displaying output. 7. Uninterruptible Power Supply (UPS): Protect your server from power outages. Page 9 of 46 8. Cable Management: Keep cables organized and prevent damage. 9. Racks and Cabinets: If using physical servers in a data center. 2.2 Software Tools Linux server administrators rely heavily on software tools to manage and maintain their systems. Here are some essential ones: 1. Operating System: Ubuntu, Debian, CentOS, or Fedora are popular choices. 2. SSH Client: Securely connect to your server from remote locations. 3. Terminal Emulator: Interact with the server's command-line interface. 4. Text Editor: Create and edit configuration files (e.g., nano, vim, gedit). 5. Package Manager: Install, update, and remove software packages (e.g., apt, yum, dnf). 6. System Monitoring Tools: Track server performance and resource usage (e.g., htop, top, iftop). 7. Configuration Management Tools: Automate system configuration and deployment (e.g., Ansible, Puppet, Chef). 8. Scripting Languages: Automate tasks and create custom tools (e.g., Bash, Python, Perl). 9. Database Management Systems: Manage databases if your server handles data storage (e.g., MySQL, PostgreSQL). 10. Web Servers: Serve web content (e.g., Apache, Nginx). 11. Virtualization Software: Create and manage virtual machines (e.g., KVM, VMware, VirtualBox). Page 10 of 46 12. Cloud Management Tools: If using cloud-based infrastructure (e.g., AWS, Azure, GCP). 1.3 Installation of Linux OS Note: Installation process is very critical, please be careful throughout this process and remember to backup your data before proceeding. Step 1: Choose Your Linux Distribution Before diving into the process of installation, you need to choose a Linux distribution that suits your needs. As mentioned in Part 1, popular choices include Ubuntu, Fedora, and Debian. Step 2: Create a Bootable USB or DVD For USB: 1. Download Rufus (Windows) or Etcher (macOS/Windows/Linux), these are some free tools for creating bootable USB drives. 2. Insert a USB flash drive (8GB or larger) into your computer. 3. Open Rufus or Etcher. 4. Select the downloaded ISO file as the source. 5. Choose the USB drive as the destination. 6. Click “Start” or “Flash” to create the bootable USB drive. Page 11 of 46 Example with Rufus For DVD: 1. Insert a blank DVD into your computer’s DVD drive. 2. Use a disc-burning software like Brasero (Linux), ImgBurn (Windows), or Burn (macOS) to burn the downloaded ISO image to the DVD. Page 12 of 46 Step 3: Boot from the USB/DVD 1. Restart your computer and enter the BIOS/UEFI settings (usually by pressing F2, F12, or Del during startup). 2. Change the boot order to prioritize the USB drive or DVD drive. You need to make sure you’re not having any other USBs or DVDs mounted. 3. Save the changes and exit the BIOS/UEFI settings. Step 4: Installing Linux (Ubuntu) 1. Boot from the USB/DVD you created. You’ll see the Linux distribution’s installer. 2. When you boot into Linux for the first time, you’ll typically be greeted with an initial setup wizard. Language and Region: Select your preferred language and region settings. Keyboard Layout: Configure your keyboard layout to match your physical keyboard. Wi-Fi Settings (if applicable): If you’re using a wireless connection, you’ll need to set up your Wi-Fi network at this stage. User Account: Create or sign in with a user account. It’s generally recommended to use a non-root user for day-to-day tasks, as this enhances security. Page 13 of 46 3. Choose “Install Ubuntu” from the boot menu. 4. Follow the on-screen instructions to configure your keyboard layout, Wi-Fi settings (if applicable), and user account. 5. Partitioning: If you want to replace your current OS with Linux, choose ‘Erase disk and install Ubuntu,’ but be cautious as this will delete all existing data. 8. Wait for the installation process to complete. Step 5: Post-Installation Setup 1. Remove the USB/DVD and restart your computer. Page 14 of 46 2. Select the Linux distro you installed from the boot menu (if dualbooting). 3. Complete the initial setup by following the on-screen prompts. 4. Update Your System Page 15 of 46 LEARNING OUTCOME 2: MANAGE LINUX FILES AND DIRECTORIES 2.1 APPLYING LINUX COMMANDS Linux commands are the foundation of interacting with the operating system. They provide a powerful and flexible way to manage files, directories, processes, and more. Common Directories PATH DESCRIPTION 1. / Top level directory is the root file system and contain all of the file required. 2. /bin Contains essential command binaries 3. /boot Consists of the static bootloader, kernel executable and files required to boot the Linux OS. 4. /dev Contains device files to facilitate access to every hardware device attached to the system. 5. /etc Local system configuration files, configuration files for installed applications may be saved here as well. 6. /home Each user on the system has a subdirectory here for storage. 7. /lib Shared library files that are required for system boot. Page 16 of 46 8. /media External removable media devices such as USB driver are mounted here. 9. /mnt Temporary mount point for regular file systems. 10. /opt Optional files such as third- party tools can be saved here. 11. /sbin The directory contains executables used for system and administration (binary system). 12. /tmp Store temporary files. 13. /usr Contains executables, libraries non files etc 14. /var This directory contais variable data files such as log files, email in boxes, web application related files, cron files and more. 2.1.1 FILE SYSTEM NAVIGATION File system navigation in Linux refers to the process of moving around and accessing different directories and files within the computer's file system. Commonly Used File System Navigation Commands Linux Functions Commands Pwd Shows the current location. Ls List files and folders. Page 17 of 46 Linux Functions Commands Cd Change working directory. Mkdir Used to create new folder. Rmdir Remove an empty folder. Cp Creating a copy of a file in a new location. Mv Relocate files from one folder to another. 1. pwd (print working directory) The pwd command shows the current location in the system. It tells you which folder you’re currently in. pwd Observation The current directory is /home/kali/Templates 2. ls (list files and directories) The ls command is used to list the files and directories in the current directory. It provides an overview of what is inside a folder. Page 18 of 46 ls 3. cd (change directory) The cd command is used to move between folders. Let’s look into both the methods. Moving around nearby folder If you want to move into a folder that’s within the one you’re already in, you can just use its name. For instance, if you’re in your home directory and want to reach downloads. cd [directory name] cd Downloads Observation A. checking the current directory B. using cd command to change the directory C. observe the updated directory Going to a Specific Folder Page 19 of 46 Imagine telling someone the full address to find your house. Similarly, you can do the same by giving the complete path to the folder. For example, you want to access the documents folder inside the username folder. cd [directory path] cd /home/username/documents Observation Directory Structure Considering the above directory structure, the active directory was changed from Downloads to Documents by traversing from the home directory. 4. mkdir (make directory) The mkdir command, an abbreviation for “make directory,” allows you to create new folders within your existing file system. This provides a structured way to categorize and store your files. mkdir [directory name] Page 20 of 46 mkdir GeeksForGeeks Observation A. User tried to create a new folder named GeeksForGeeks B. changed the directory to newly created directory C. The active directory is updated 5. rmdir (remove empty directory) The rmdir command, short for “remove directory,” enables you to delete empty directories. This is useful for cleaning up unused folders and maintaining a streamlined file system. The syntax for rmdir is: rmdir [directory_name] Note: rmdir can only delete empty directories. Page 21 of 46 Observation Observe that the empty directory was removed. 6. cp (copy) The cp command acts like a duplicator, creating a copy of a file in a new location. cp [source_file] [location] For instance, to copy “image.jpg” from Downloads to Pictures while keeping the original, you’d use cp ~/Downloads/image.jpg ~/Pictures Obervation A. Executing the copying command. B. Changing the current active directory for checking. C. Using the list command, we can observe that the image.jpg was copied. 7. mv (move) The mv command is like a handy mover, allowing you to relocate files from one folder to another. mv [source_file] [location] Page 22 of 46 For instance, to move a file named “image.jpg” from your Downloads folder to Documents, you’d use mv ~/Downloads/image.jpg ~/Pictures Observation A. Executing the mv (move) command. B. Changing the current active directory. C. After executing ls (list) command, we can observe that the file has been transferred. Additional Shortcut Tips Serial No Symbol Symbol Name Function 1 ~ tilde shortcut to your home base 2. dot the folder you’re in right now 3.. double dot the folder one level above Page 23 of 46 1. ~ (tilde) – shortcut in Linux This symbol is like a shortcut to your home base. No matter where you are, typing tilde will always bring you back to your home folder. cd ~ The active directory was updated to home. 2.. (dot) – shortcut in Linux This simply means the folder you’re in right now. If you’re already inside a folder and want to work with something there, you can use the dot symbol. 3... (double dot) – shortcut in Linux This means the folder one level above the one you’re in, like going up a floor in a building. If you’re deep inside folders and want to go back a step, this will take you to the bigger folder that contains the one you’re in. cd.. Observation Page 24 of 46 A. The current directory is visible, and we execute the command. B. The active directory is updated. 4. tree – seeing the bigger picture in Linux This command isn’t exactly for moving around, but it helps you see all the folders at once. It shows how all the folders are connected, like a family tree, so you can understand the bigger picture. tree Observation All the files and folders of the active directory is listed Page 25 of 46 User Management User management involves creating, modifying, and deleting user accounts. It also includes managing user groups and assigning user roles. 1. Understanding Users and Groups User: An individual account that can log into the system. Group: A collection of users that can be managed together. Groups simplify permissions management by allowing you to set permissions for all members of a group. 2. Common User Management Commands Add a New User: sudo adduser username This command creates a new user account and sets a password. Delete a User: sudo userdel username This command deletes the user account but can leave their home directory intact. List All Users: You can see a list of all users by viewing the /etc/passwd file: cat /etc/passwd Change User Password: xx sudo passwd username User Expiration Date A user expiration date specifies the date after which a user account will be disabled. After the expiration date, the user will no longer be able to log in to the system. This is particularly useful for temporary user accounts, such as for contractors or guests. Here’s how you can manage the user expiration date: 1. Setting a User Expiration Date with chage The chage command is used to change user password expiry information, including setting an account expiration date. Page 26 of 46 Syntax: sudo chage -E YYYY-MM-DD username -E sets the expiration date. YYYY-MM-DD is the expiration date in the format of Year-Month-Day. username is the name of the user whose expiration date you want to set. Example: To set the expiration date for user john to December 31, 2024, you would run: sudo chage -E 2024-12-31 john After this date, the user john will not be able to log in. 2. Viewing User Expiration Date To check the expiration date for a user, you can use the following command: sudo chage -l username Example: sudo chage -l john This will display various details about the account, including the expiration date (if set): Last password change : Oct 01, 2023 Password expires : Nov 01, 2023 Password inactive : never Account expires : Dec 31, 2024 In this case, the account will expire on December 31, 2024. 3. Removing User Expiration Date If you want to remove the expiration date and allow the user to log in indefinitely, you can use the following command: sudo chage -E -1 username Example: sudo chage -E -1 john This will remove the expiration date for the user john, meaning the account will no longer have an expiration date and the user can continue logging in. Page 27 of 46 4. Automatic Account Expiration Based on Days You can also set the account to expire after a specific number of days. For instance, to set the account to expire 30 days after creation, you can use the -M option in chage: sudo chage -M 30 username This option specifies the maximum number of days between password changes before the account is considered expired. 5. Setting a Warning Period Before Expiration You can also configure a warning period to notify the user before their account expires. This can be done with the -W option. For example, to warn the user 7 days before expiration: sudo chage -W 7 username This will notify the user 7 days before the expiration date so they have a chance to change their password or take other actions. 6. Account Expiration in /etc/shadow The expiration date is stored in the /etc/shadow file. You can manually edit this file, but it’s not recommended unless you are familiar with its structure. In /etc/shadow, the expiration date is the field after the password hash. It is represented as the number of days since January 1, 1970 (the Unix epoch). Example of /etc/shadow entry: john:$6$H9G8L8LO$k7KJdkF5skldF44j34l5:17547:0:99999:7:31:2024 Here, the last number (31) indicates the expiration date (the 31st day of the month, in Unix days format). 3. Managing User Groups Create a New Group: sudo addgroup groupname Add a User to a Group: sudo usermod -aG groupname username Remove a User from a Group: You can use the deluser command: Page 28 of 46 sudo deluser username groupname List All Groups: cat /etc/group ADD USER TO GROUP To add a user to a group in Linux, you can use the usermod command, the gpasswd command, or the adduser command, depending on your Linux distribution. Here are a few methods: 1. Using usermod Command The usermod command is commonly used to modify user attributes, including adding a user to a group. sudo usermod -aG groupname username -aG: The -a (append) option adds the user to the additional group without removing them from other groups, while -G specifies the group to which the user is being added. groupname: Replace this with the name of the group you want to add the user to. username: Replace this with the username of the user you want to add. Example: sudo usermod -aG developers john This command will add the user john to the developers group. 2. Using adduser Command (Debian/Ubuntu Specific) On Debian-based systems (like Ubuntu), you can also use the adduser command to add a user to a group. sudo adduser username groupname Example: bash Copy code sudo adduser john developers This will add john to the developers group. Verify User's Group Membership After adding the user to the group, you can verify their membership by running: Page 29 of 46 groups username Example: groups john This command will list all groups that john is a member of, including developers if the addition was successful. Permission Management Permission management controls what users can do on the system, including file access and execution of programs. 1. Understanding File Permissions Each file and directory in Linux has three types of permissions: 1. Read (r) File: Allows users to view the contents of a file. For example, with read permission on a text file, a user can open and read the file’s contents. Directory: Allows users to view the list of files and subdirectories within the directory. However, they cannot access or modify the files inside without additional permissions. 2. Write (w) File: Allows users to modify the contents of a file. They can add, delete, or change the data within the file. Directory: Allows users to create, delete, and rename files within the directory. Write permission on a directory is often combined with execute permission to allow users to fully manage files within that directory. 3. Execute (x) File: Allows users to execute the file as a program or script, if it’s an executable file. For instance, a script file will only run if it has execute permission. Directory: Allows users to access and enter the directory using the cd command. If a directory has execute permission but not read permission, a user can access files within the directory if they know the file names, but they cannot list the contents of the directory. 2. Permission Structure Permissions are divided into three categories: Owner: The user who owns the file. Page 30 of 46 Group: Users who are members of the file's group. Others: Everyone else who is not the owner or in the group. Setting Permissions in Linux In Linux, file and directory permissions can be set using two notations: 1. Symsbolic Notation 2. Octal Notation Both methods are used with the chmod (change mode) command to modify the permissions of files and directories. 1. Symbolic Notation Symbolic notation represents permissions using letters (r, w, x) and operators (+, -, =). It allows you to add, remove, or set permissions for the file's owner (user), group, and others. Syntax: chmod [who][operator][permissions] filename Where: who: Specifies which users the change applies to. You can use: o u: User (Owner) o g: Group o o: Others o a: All users (user, group, and others) operator: Specifies the action: o +: Adds permissions o -: Removes permissions o =: Sets exact permissions (overrides existing permissions) permissions: Specifies the permissions to add or remove: o r: Read o w: Write o x: Execute Examples: 1. Add Execute Permission for the Owner: chmod u+x file.txt Adds execute permission for the owner. 2. Remove Write Permission for the Group: Page 31 of 46 chmod g-w file.txt Removes write permission for the group. 3. Set Read and Write Permissions for the Owner, Group, and Others: chmod a=rw file.txt Sets read and write permissions for the owner, group, and others, removing any existing permissions. 4. Add Execute Permission for All Users: chmod a+x file.txt Adds execute permission for the owner, group, and others. 2. Octal Notation In octal notation, each permission is represented by a number, and the combination of three numbers (one for the owner, one for the group, and one for others) defines the permissions for the file or directory. Numeric Values for Permissions: Read (r) = 4 Write (w) = 2 Execute (x) = 1 No Permission (-) = 0 Permissions Combination: The values for each permission are added together to determine the permission number: Read + Write + Execute (rwx) = 4 + 2 + 1 = 7 Read + Write (rw-) = 4 + 2 = 6 Read + Execute (r-x) = 4 + 1 = 5 Read only (r--) = 4 Write only (-w-) = 2 Execute only (--x) = 1 No permissions (---) = 0 Examples of Common Permissions in Octal Notation: 777: Full permissions for owner, group, and others (read, write, execute). 755: Owner has full permissions, group and others can read and execute. 644: Owner can read and write, group and others can only read. Page 32 of 46 700: Only the owner has full permissions (read, write, execute), group and others have no permissions. 777: All users have read, write, and execute permissions. How to Use Octal Notation with chmod: To change permissions using octal notation, use the following syntax: chmod [permissions] filename Examples: 1. Set Permissions to 755 (Owner can read/write/execute, Group and Others can read/execute): chmod 755 file.txt 2. Set Permissions to 644 (Owner can read/write, Group and Others can read): chmod 644 file.txt 3. Set Permissions to 777 (Full permissions for everyone): chmod 777 file.txt Summary of Permissions in Both Notations: Permission Symbolic Notation Octal Notation Read r 4 Write w 2 Execute x 1 No Permission - 0 When working with symbolic notation, you're explicitly adding or removing individual permissions. In octal notation, you're setting permissions using a compact numeric representation 1. Process Management Process management involves monitoring and controlling the processes running on your system. Each application or service you run is a process. Steps to Manage Processes in Ubuntu Desktop: 1. Open the System Monitor: o Click on the Show Applications icon (grid of dots) in the bottom-left corner. o Search for and open System Monitor. 2. View Running Processes: o In the System Monitor window, switch to the Processes tab. Page 33 of 46 o Here, you can see all the processes running on your system, along with their CPU and memory usage. 3. End a Process: o Right-click on the process you want to terminate. o Select Kill Process to stop it. 4. View Resource Usage: o Switch to the Resources tab to see CPU and memory usage over time. Command You can used To view all active processes on your system, you can use the following commands: ps: Shows information about active processes. By default, ps lists processes running in the current shell. ps aux # List all running processes in detail. o a: Shows processes for all users. o u: Displays the user who owns each process. o x: Lists processes without a terminal. top: Provides a real-time, dynamic view of the running processes. It shows CPU, memory usage, and other details about each process. top # Press 'q' to exit the top command. 2. Package Management Package management is the process of installing, updating, and removing software applications on your system. Steps to Manage Packages in Ubuntu Desktop: 1. Open the Software Center: o Click on the Show Applications icon. o Search for and open Ubuntu Software. 2. Install a Package: o Browse or search for the application you want to install. o Click on the application, then click the Install button. 3. Update Installed Packages: o In the Ubuntu Software window, click on the Updates tab. o If there are updates available, you can click on Install Now to update all installed software. 4. Remove a Package: o In the Ubuntu Software Center, search for the application you want to remove. o Click on it and select the Remove button. Command Page 34 of 46 Update Package List: sudo apt update Upgrade Installed Packages: sudo apt upgrade Install a Package (replace package-name with the actual package): sudo apt install package-name Remove a Package: sudo apt remove package-name Remove a Package and Its Configuration Files: sudo apt purge package-name Installing LibreOffice on Ubuntu Method 1: Using the Ubuntu Software Center 1. Open the Software Center: Click on the “Ubuntu Software” icon in your dock or search for "Software" in your application menu. 2. Search for LibreOffice: In the search bar, type "LibreOffice" to find the package. 3. Install LibreOffice: Click on the LibreOffice listing, then click "Install." Enter your password when prompted. 4. Open LibreOffice: Once installed, you can launch LibreOffice from your application menu. Method 2: Using the Terminal This method can be quicker and is recommended if you’re comfortable with basic terminal commands. 1. Open Terminal: Press Ctrl + Alt + T to open the Terminal. 2. Update Repositories: Ensure your package list is up-to-date by running: sudo apt update 3. Install LibreOffice: Run the following command to install LibreOffice: sudo apt install libreoffice 4. Launch LibreOffice: After installation, you can start LibreOffice by typing libreoffice in the Terminal or finding it in the application menu. Page 35 of 46 5. Launch LibreOffice: After installation, you can start LibreOffice by typing libreoffice in the Terminal or finding it in the application men If you want to create a new document named "MyDocument.odt" in your Documents folder, you would use: libreoffice --writer ~/Documents/MyDocument.odt Example: If your document is named "MyDocument.odt" and is located in your Documents folder, the command would be: libreoffice ~/Documents/MyDocument.odt Using youtube-dl (Alternative) If you prefer using youtube-dl, follow these steps: Step 1: Install youtube-dl 1. Open Terminal: Press Ctrl + Alt + T to open the Terminal. 2. Install youtube-dl: Run the following command: sudo apt install youtube-dl Step 2: Download a YouTube Video Use the same command format as above: youtube-dl Example: To download a video from: https://www.youtube.com/watch?v=abcd1234 You would run: youtube-dl https://www.youtube.com/watch?v=abcd1234 Page 36 of 46 3. Networking Networking management involves configuring network settings, connecting to networks, and troubleshooting connectivity issues. Steps to Manage Networking in Ubuntu Desktop: 1. Open Network Settings: o Click on the system menu in the top-right corner (where the Wi-Fi and battery icons are). o Select Settings, then click on Network. 2. Connect to a Wi-Fi Network: o In the Network settings, select Wi-Fi. o Toggle the switch to turn it on, then select your Wi-Fi network and click Connect. Enter the password if prompted. 3. Set Up a Wired Connection: o In the Network settings, select Wired. o Ensure it is toggled on. Your system should automatically connect if a cable is plugged in. 4. Check Network Status: o You can see the status of your connections in the Network settings window. Commond Viewing Network Interfaces ifconfig (deprecated, but still available in some systems): Displays information about all network interfaces. It shows details like IP address, MAC address, and packet statistics. ifconfig ip addr: Replaces ifconfig in modern distributions. Displays IP addresses and other network interface information. ip addr Connecting to Wi-Fi Networks Using nmcli (Network Manager command-line interface): nmcli dev wifi connect "Network_Name" password "Your_Password" This command connects to a Wi-Fi network with the specified name and password. iwconfig: Configures wireless network interfaces. This command is mostly used for monitoring or simple connections and requires more manual setup. sudo iwconfig wlan0 essid "Network_Name" Page 37 of 46 Testing Network Connectivity ping: Tests connectivity to another host (e.g., a server or another device). ping google.com traceroute: Shows the path packets take to reach their destination. Useful for diagnosing where connections might be dropping. traceroute google.com 4. Troubleshooting Troubleshooting involves diagnosing and resolving issues with your system or applications. Steps for Troubleshooting in Ubuntu Desktop: 1. Check System Logs: o Open System Monitor and switch to the Resources tab to identify high resource usage. o For more detailed logs, you can use Logs application (search for it in the application menu). 2. Look for Error Messages: o If an application crashes, look for any error messages that appear. This can often provide clues about the problem. 3. Check Internet Connectivity: o Make sure you are connected to a network by checking the Network settings. o If you have issues, try turning Wi-Fi off and on or restarting your router. 4. Reboot the System: o Sometimes, simply restarting the computer can resolve issues. 5. System Configuration System configuration involves adjusting system settings to optimize performance and usability. Steps for System Configuration in Ubuntu Desktop: 1. Open System Settings: o Click on the Show Applications icon. o Search for and open Settings. 2. Adjust Display Settings: o In the Settings window, click on Displays. o Here you can change the resolution, orientation, and display arrangement. 3. Configure Power Settings: o In the Settings window, click on Power. o Adjust settings like suspend time, screen brightness, and battery power options. Page 38 of 46 4. Manage User Accounts: o In the Settings window, click on Users. o Here you can add or manage user accounts, change user passwords, and set user privileges. 5. Set Up Automatic Updates: o In the Settings window, click on About and then Software Updates. o Configure how and when updates are installed. 1. Creation of Linux Files and Directories In Linux, files and directories are fundamental components of the file system. Files Files are used to store data, such as documents, images, executables, and more. Each file has a name and an associated set of permissions that define who can read, write, or execute it. Directories Directories (or folders) are special files that can contain other files and subdirectories. They help organize files into a hierarchical structure. 2. File System Categories/Types Linux supports various file system types, each with specific features and uses: Common File System Types: ext4: The most widely used file system for Linux, known for its performance and reliability. It supports large files and file systems. XFS: A high-performance file system suitable for large files and high-capacity storage. Btrfs: A modern file system with advanced features like snapshots, subvolumes, and dynamic disk allocation. FAT32: A file system commonly used for USB drives and compatibility with various operating systems. NTFS: Primarily used by Windows, but supported by Linux for interoperability with Windows partitions. Page 39 of 46 How to Install Ubuntu Desktop OS Step 1: Prepare for Installation 1. Download the Ubuntu ISO: o Go to the official Ubuntu website and download the latest version of the Ubuntu Desktop ISO file. 2. Create a Bootable USB Drive: o Use a tool like Rufus (Windows), Etcher, or UNetbootin to create a bootable USB drive with the Ubuntu ISO file. Insert a USB drive (at least 4GB) and select the ISO file using the tool. 3. Back Up Your Data: o If you plan to install Ubuntu alongside or instead of an existing operating system, make sure to back up important data. 4. Check System Requirements: o Ensure your system meets the minimum requirements: ▪ 2 GHz dual-core processor or better ▪ 4 GB RAM (8 GB recommended) ▪ 25 GB of free hard drive space ▪ A USB port or DVD drive for installation Step 2: Boot from the USB Drive 1. Restart Your Computer: o Insert the bootable USB drive and restart your computer. 2. Enter the Boot Menu: o Access the BIOS/UEFI boot menu by pressing a key such as F2, F12, Del, or Esc during startup (varies by manufacturer). 3. Select the USB Drive: o Choose the bootable USB drive from the boot menu to start the Ubuntu installer. Step 3: Start the Installation Process 1. Choose "Try Ubuntu" or "Install Ubuntu": o When the Ubuntu installer loads, you will see an option to "Try Ubuntu" or "Install Ubuntu." Choose "Install Ubuntu" to proceed with the installation. 2. Select Your Language: o Choose the language you prefer for the installation and click "Continue." 3. Keyboard Layout: o Choose your keyboard layout and click "Continue." Step 4: Configure Installation Options 1. Updates and Other Software: o You can choose to install normal installation (with all basic software) or minimal installation (with only essential utilities). Page 40 of 46 o You may also select the options to download updates and install third-party software for graphics and Wi-Fi hardware (recommended). 2. Installation Type: o Choose the installation type: ▪ "Erase disk and install Ubuntu": This option will delete all existing data on the selected drive and install Ubuntu. ▪ "Install Ubuntu alongside [other OS]": If you want to dual-boot with another operating system (e.g., Windows). ▪ "Something else": For custom partitioning. 3. Create Partitions (if choosing "Something else"): o You can manually create partitions, such as root (/), swap, and home, if you prefer custom partitioning. Step 5: Install Ubuntu 1. Select Your Time Zone: o Choose your location to set the time zone and click "Continue." 2. Create a User Account: o Enter your name, computer's name, username, and password. You can also choose to require a password to log in or log in automatically. 3. Start the Installation: o Click "Continue" to start the installation process. The installer will copy files and configure the system. Step 6: Complete the Installation 1. Wait for the Installation to Finish: o The installation process may take several minutes. Once completed, you will be prompted to restart your computer. 2. Remove the USB Drive: o When prompted, remove the USB drive and press Enter to restart. 3. Log In to Your New Ubuntu Desktop: o After the restart, you should see the Ubuntu login screen. Enter your password (if required) and start using Ubuntu! Optional Post-Installation Steps 1. Install Software Updates: o Go to Software Updater to install any available updates. 2. Install Additional Drivers: o Check for Additional Drivers under Software & Updates if you need proprietary drivers for hardware like graphics cards. 3. Set Up Software Repositories and Install Common Apps: o Use the Ubuntu Software Center or Terminal to install common applications like VLC, Chrome, or LibreOffice. Page 41 of 46 How to Install Ubuntu server OS Prerequisites 1. Download the Ubuntu Server ISO file: o Go to Ubuntu's official website and download the latest Ubuntu Server ISO file. 2. Create a Bootable USB Drive (if installing on physical hardware): o Use a tool like Rufus (for Windows), UNetbootin, or Etcher to create a bootable USB drive from the ISO. o Insert a USB drive (at least 2 GB), open the tool, select the ISO file, and create the bootable drive. 3. Check System Requirements: o Make sure the hardware meets Ubuntu Server's minimum requirements (1 GHz CPU, 512 MB RAM, 2 GB storage). Installation Process 1. Boot from the Installation Media: o Insert the bootable USB drive into the machine and restart it. o Access the BIOS or UEFI setup (typically by pressing F2, F12, DEL, or ESC during boot). o Change the boot order to prioritize the USB drive, then save and exit. 2. Start Ubuntu Server Installation: o Once the machine boots from the USB drive, the Ubuntu Server Installer will load. o Select your language and keyboard layout using the arrow keys and press Enter. 3. Select Installation Type: o Choose Install Ubuntu Server or Install Ubuntu and press Enter. 4. Configure Network: o Choose your network interface and configure it. o If connected via Ethernet, it should automatically detect your connection. For Wi-Fi, select the network and enter the password. 5. Configure Proxy (if needed): o If you use a proxy server for internet access, enter its details here. Otherwise, leave it blank and continue. 6. Configure the Mirror: o The installer will select the default mirror based on your location. You can accept it or change to another if desired. 7. Set Up Storage: o Choose Use an entire disk (erases all data on the disk) or Custom Storage Layout if you need to set up partitions manually. o Select the disk to install on, confirm partitioning, and proceed. 8. Set Up Profile: o Enter your name, server name (hostname), username, and password. o Confirm the details and proceed. 9. Install OpenSSH (Optional): o If you need to manage the server remotely, select Install OpenSSH server. This is recommended for remote management. Page 42 of 46 o Press Enter to continue. 10. Choose Featured Server Snaps: o The installer may offer additional software (Snaps) like Docker or Kubernetes. You can install these now or skip them to install later. 11. Begin Installation: o Review your settings and select Install Now. o The installer will proceed with the installation process, which may take several minutes. 12. Finish and Reboot: o Once the installation completes, the installer will prompt you to reboot. o Remove the USB drive when prompted, then press Enter to reboot. Page 43 of 46 1. What is UID (User ID)? Definition: The User ID (UID) is a unique number assigned to each user on a Linux system. It is used by the system to identify users, rather than their usernames. Types of UIDs: o 0: Reserved for the root user (superuser with full permissions). o 1-999: Reserved for system users and services (e.g., daemon, syslog). o 1000 and above: Assigned to regular (non-system) users. Purpose: The UID determines the access permissions and ownership of files and processes for a user. Command to View UID: id -u username Example Output: 1001 2. What is GID (Group ID)? Definition: The Group ID (GID) is a unique number assigned to a group on a Linux system. Groups are used to manage permissions for multiple users at once. Types of GIDs: o 0: Reserved for the root group. o 1-999: Reserved for system groups (e.g., adm, sudo). o 1000 and above: Assigned to regular groups created by administrators. Purpose: The GID determines the permissions for a group of users, allowing shared access to files and directories. Command to View GID: id -g username Example Output: 1001 3. Relationship Between UID and GID Every user is assigned a UID and belongs to at least one group with a GID. A user's primary group is defined by their default GID. Users can belong to multiple supplementary groups, each with its own GID. Page 44 of 46 4. Key Configuration Files /etc/passwd: Contains user account information, including the username, UID, and primary GID. Example: john:x:1001:1001:John Doe:/home/john:/bin/bash o 1001 (third field): UID o 1001 (fourth field): Primary GID /etc/group: Contains group information, including group names and GIDs. Example: developers:x:2050:john,mary o 2050: GID o john,mary: Members of the group. 5. How to Set or Change UID and GID Change UID: sudo usermod -u Example: sudo usermod -u 2001 john Change GID: sudo usermod -g Example: sudo usermod -g 2050 john Create a New Group with a Specific GID: sudo groupadd --gid Example: sudo groupadd --gid 3000 developers 6. Viewing User and Group Details View UID, GID, and Group Membership: Page 45 of 46 id username Example Output: uid=1001(john) gid=2050(developers) groups=2050(developers),1002(sales) List All Users and Groups: o Users: cat /etc/passwd o Groups: cat /etc/group 7. Importance of UID and GID Security: UIDs and GIDs ensure proper file access control, preventing unauthorized access. Collaboration: Groups allow multiple users to share access to files and directories, improving collaboration. System Management: Administrators use UIDs and GIDs to manage users and groups effectively. Page 46 of 46