0% found this document useful (0 votes)
61 views4 pages

Linux Basics: File Management & Permissions

This document outlines a basic Linux training program consisting of three labs focused on directory and file management, permissions and ownership, and package management. Each lab includes specific exercises with commands and objectives, providing hands-on experience with essential Linux operations. Additionally, it includes assessment tasks to reinforce learning outcomes.

Uploaded by

Shikur Mohammed
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)
61 views4 pages

Linux Basics: File Management & Permissions

This document outlines a basic Linux training program consisting of three labs focused on directory and file management, permissions and ownership, and package management. Each lab includes specific exercises with commands and objectives, providing hands-on experience with essential Linux operations. Additionally, it includes assessment tasks to reinforce learning outcomes.

Uploaded by

Shikur Mohammed
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

Basic Linux Training – Lab Exercises

Lab 1: Directory and File Management


Objective: Learn how to create, navigate, manage, and manipulate directories and files using
basic Linux commands.

Duration: 1.5 hours

Exercise 1.1: Exploring the Filesystem

Commands: pwd, ls, cd, tree


1. Open the terminal.
2. Display your current working directory: pwd
3. List the contents of your home directory: ls
4. List all files including hidden ones: ls -a
5. Change directory to /etc and list its contents: cd /etc; ls
6. Return to your home directory: cd ~

Exercise 1.2: Creating and Managing Directories

Commands: mkdir, rmdir, mv, cp, rm


1. Create a new directory structure: mkdir -p ~/lab1/documents/reports
2. Verify directory creation: tree ~/lab1
3. Rename the folder: mv ~/lab1/documents ~/lab1/docs
4. Remove the reports directory: rmdir ~/lab1/docs/reports

Exercise 1.3: File Operations

Commands: touch, cat, nano, cp, mv, rm, head, tail


1. Create files: touch [Link] [Link] [Link]
2. Edit [Link] and add text.
3. Display file content: cat [Link]
4. Copy file: cp [Link] file1_backup.txt
5. Move file: mv [Link] ~/lab1/
6. Delete file: rm [Link]
Exercise 1.4: Searching and Finding Files

Commands: find, locate, grep


1. Find all .txt files: find ~ -name "*.txt"
2. Search for a word: grep "Linux" [Link]

Lab 2: Permissions and Ownership


Objective: Understand how Linux manages access to files and directories through
permissions and ownership.

Duration: 1 hour

Exercise 2.1: Viewing Permissions

Commands: ls -l, stat


1. Navigate to ~/lab1/docs
2. Display file permissions: ls -l
3. View detailed file information: stat [Link]

Exercise 2.2: Changing Permissions

Commands: chmod
1. Remove read permission for others: chmod o-r [Link]
2. Add execute permission for owner: chmod u+x [Link]
3. Set permission 644: chmod 644 [Link]
4. Verify: ls -l

Exercise 2.3: Changing Ownership

Commands: chown, chgrp


1. Create user: sudo adduser trainee2
2. Change owner: sudo chown trainee2 [Link]
3. Change group: sudo chgrp users [Link]
4. Verify: ls -l
Lab 3: Package Management
Objective: Learn how to install, update, and remove software packages using package
management tools.

Duration: 1.5 hours

Exercise 3.1: Updating and Upgrading Packages

Commands: sudo apt update, sudo apt upgrade


1. Update package lists: sudo apt update
2. Upgrade packages: sudo apt upgrade -y

Exercise 3.2: Installing and Removing Packages

Commands: apt install, apt remove


1. Install mysql-server: sudo apt install mysql-server
2. Remove package: sudo apt remove mysql-server

Exercise 3.3: Searching and Getting Package Information

Commands: apt search, apt show


1. Search for curl: apt search curl
2. Display info: apt show curl

Exercise 3.4: Installing from a .deb File

Commands: wget, dpkg, apt install -f


1. Download package: wget [Link]
[Link]
2. Install: sudo dpkg -i slack-desktop-*.deb
3. Fix dependencies: sudo apt install -f
Assessment Tasks

1. Create directory ~/practice with subdirectories scripts and notes.


2. Create text files inside notes/ and copy one into scripts/.
3. Change ownership of one file to another user.
4. Modify file permissions so only the owner can read/write it.
5. Install a package, display version, and uninstall it.

Common questions

Powered by AI

Creating directories and files in Linux is accomplished using commands like 'mkdir' and 'touch'. For example, to create an organized directory structure, you can use 'mkdir -p ~/practice/scripts ~/practice/notes', which creates the 'practice' directory and its subdirectories 'scripts' and 'notes' in a single command. Files can be created using 'touch', such as 'touch ~/practice/notes/file1.txt', for placing files into the created directories . To verify the directory structure, you can use the 'tree' command, which graphically displays the files and folders within a directory, ensuring the correct setup .

You can adjust a file's permissions in Linux so that only the file owner can read and write it by using the 'chmod' command to set the permission mode to 600, as shown by the command 'chmod 600 filename' . This setting ensures that no other users, not even group members, can access the file, which is crucial for maintaining privacy and restricting access to sensitive information. However, this could also mean that collaborative work is hindered unless specific access is provisioned, requiring careful consideration when applying such settings for files in shared environments .

Key Linux commands for managing directories and files include 'mkdir' for creating directories, 'rmdir' for removing directories, 'cp' for copying files, 'mv' for moving/renaming files and directories, and 'rm' for deleting files. These commands enable users to effectively organize and manipulate the UNIX file system, ensuring proper structure and data management. For instance, the 'mkdir -p ~/lab1/documents/reports' command creates a directory and any necessary parent directories, while 'mv ~/lab1/documents ~/lab1/docs' renames the directory, maintaining the organizational hierarchy. Combining these commands allows efficient workflow and system maintenance .

Package management commands such as 'sudo apt update' and 'sudo apt upgrade' are essential for maintaining a Linux system's reliability and security. 'sudo apt update' refreshes the package index to ensure access to the latest software versions, and 'sudo apt upgrade' installs updates to current software packages, addressing vulnerabilities and improving functionality . Regular updates and upgrades ensure that systems remain secure against known vulnerabilities and can efficiently run the latest applications, thus enhancing both operational efficiency and security posture .

Installing a .deb package file involves downloading the file using a command like 'wget', such as 'wget https://downloads.slack-edge.com/linux_releases/slack-desktop-4.36.140-amd64.deb', followed by using 'dpkg' to install it, 'sudo dpkg -i slack-desktop-*.deb'. If there are missing dependencies, the 'sudo apt install -f' command is used to fix these dependencies . Dependency fixing might be necessary because packages often require specific versions of libraries or other software components to function properly, which ensures stable and working installations by resolving any existing software conflicts .

To ensure successful installation and immediate functional use of a package from a Linux repository, the following steps should be taken: First, run 'sudo apt update' to refresh the package list, ensuring availability of the latest versions. Next, execute 'sudo apt install package-name', for instance, 'sudo apt install mysql-server', to download and install the package . Upon completion, verify functionality by running the application's primary command or check its version using a command like 'mysql --version', and if issues occur, use 'sudo apt install -f' to fix dependencies .

The 'grep' command is used to search for specified patterns within files, such as finding a specific word or string in a document with 'grep "Linux" file1.txt' . In contrast, 'find' is used to search for files within the directory hierarchy based on criteria like name, type, and modification date, such as locating all .txt files with 'find ~ -name "*.txt"' . The ideal use case for 'grep' is when you need to perform content-based searching within files, whereas 'find' is best for locating files based on certain attributes, making them powerful tools for navigating and managing Linux systems .

Removing read permissions for 'others' on a file in a shared Linux environment, using a command such as 'chmod o-r file1.txt', means that users outside the owner and designated groups cannot access the file contents . This action effectively secures the file against unauthorized access and unwarranted exposure, which is critical in protecting sensitive or proprietary information. It also maintains data integrity by preventing unwanted file alterations or views, though it could potentially limit collaboration unless appropriate permissions for necessary users are set up explicitly .

User and group ownership settings are integral to the Linux file permission mechanism, influencing accessibility and security. The owner of a file can change the file's permissions using 'chmod', thus determining who can read, write, or execute the file. Group ownership allows multiple users to have similar access rights if they belong to the same group . Changing ownership with 'chown' or 'chgrp' can restrict or extend access; for instance, making a group the owner of a file allows all its members to access the file based on group permissions, which facilitates collaborative operations without compromising security .

Linux manages file access through a permissions scheme consisting of three types: read, write, and execute, coupled with file ownership by user and group. The 'chmod' command modifies file permissions, allowing for specific user access; for example, 'chmod 644 file1.txt' sets permissions so the owner can read/write, while others can only read . The 'chown' command changes the file's user owner, and 'chgrp' changes the group owner, both essential for control over who can modify or access the files. By using these commands, administrators ensure that sensitive data is adequately protected while still accessible to authorized users, reflecting critical security and teamwork dynamics .

You might also like