Linux -Day-1
### Project: Basic Linux- Command Line Practice
#### Scenario:
You have just logged into a new Linux server as a regular user. Your task is to navigate the file system, manage directories and files, gather system information, and understand basic user management concepts. This project will guide you through a sequence of commands that are essential for everyday tasks in a Linux environment.
1. `clear` - Clear the Terminal Screen
- Objective: Start with a clean terminal.
- Command:
clear
2. `pwd` - Print Working Directory
- Objective: Confirm your current location in the file system.
- Command:
pwd
- Expected Output: Display the full path of the current directory (e.g., `/home/username`).
3. `cd ..` - Change to Parent Directory
- Objective: Move up one level in the directory structure.
- Command:
cd ..
4. `cd ~` - Change to Home Directory
- Objective: Return to your home directory.
- Command:
cd ~
5. `mkdir` - Make a New Directory
- Objective: Create a directory named `practice_dir` in your home directory.
- Command:
mkdir practice_dir
6. `ls` - List Directory Contents
- Objective: Verify that the `practice_dir` directory has been created.
- Command:
ls
7. `cd` - Change to a Specific Directory
- Objective: Navigate into the `practice_dir` directory.
- Command:
cd practice_dir
pwd
8. `echo` - Display a Line of Text
- Objective: Create a text file named `sample.txt` with the content "Hello, Linux!".
- Command:
echo "Hello, Linux!" > sample.txt
9. `cat` - Concatenate and Display File Content
- Objective: Display the contents of `sample.txt`.
- Command:
cat sample.txt
10. `cp` - Copy Files and Directories
- Objective: Copy `sample.txt` to a new file named `sample_copy.txt`.
- Command:
cp sample.txt sample_copy.txt
11. `mv` - Move or Rename Files and Directories
- Objective: Rename `sample_copy.txt` to `sample_renamed.txt`.
- Command:
mv sample_copy.txt sample_renamed.txt
12. `rm` - Remove Files or Directories
- Objective: Delete `sample_renamed.txt`.
- Command:
rm sample_renamed.txt
13. `rm -rf` - Remove Files or Directories Forcefully
- Objective: Delete the `practice_dir` directory and its contents.
- Command:
cd ~
rm -rf practice_dir
14. `uname -a` - Display System Information
- Objective: Get detailed information about the system.
- Command:
uname -a
15. `/etc/os-release` - Display Operating System Information
- Objective: Check the OS version and details.
- Command:
cat /etc/os-release
16. `lscpu` - Display CPU Information
- Objective: View details about the CPU.
- Command:
lscpu
17. `lsmemory` - Display Memory Information
- Objective: View details about the system memory.
- Command:
lsmemory
18. File System Basics
- Objective: Understand how files and directories are organized in Linux. Discuss the hierarchical structure of directories, starting from the root `/`.
- Explanation: The root directory `/` is the top of the file system hierarchy. All other directories and files branch out from here.
19. User Management Basics
- Objective: Understand the basics of user accounts and groups. Discuss the importance of `/etc/passwd` and `/etc/group` files.
- Explanation: Each user has an account with a unique username. Users can be part of one or more groups, which help manage permissions.
20. Absolute Path vs. Relative Path
- Objective: Understand the difference between absolute and relative paths.
- Explanation:
- Absolute Path: Specifies the full path from the root directory (e.g., `/home/username/practice_dir`).
- Relative Path: Specifies the path relative to the current directory (e.g., `./practice_dir`).
21. Difference Between Root User and Normal User
- Objective: Understand the distinction between the root user and normal users.
- Explanation: The root user has unrestricted access to all commands and files, while normal users have limited permissions. This distinction helps protect the system from accidental or malicious changes.
22. `sudo su -` - Switch to Root User
- Objective: Switch to the root user to perform administrative tasks.
- Command:
sudo su -
- Note: Use this command with caution, as the root user can make irreversible changes to the system.
### Outcome:
By the end of this project, you will have practiced essential Linux commands in a logical sequence, gaining a basic understanding of file system navigation, file manipulation, system information retrieval, and user management. You will also learn about the differences between root and normal users, and how to switch to the root user when necessary.
### Project: Managing Software Packages with YUM and Git
#### Scenario:
You are setting up a development environment on a CentOS-based Linux server. As part of this setup, you need to manage software packages using the YUM package manager. Specifically, you'll be installing and configuring Git, a popular version control system. This project will guide you through installing, updating, and managing software packages with YUM, using Git as the primary example.
#### 1. Update System Packages
- Objective: Ensure that your system packages and YUM repositories are up to date.
- Command:
sudo yum update -y
- Explanation: This command updates all installed packages to their latest versions and refreshes the package index.
#### 2. Install Git
- Objective: Install Git using YUM.
- Command:
sudo yum install git -y
- Explanation: This command installs Git, along with any dependencies, from the default YUM repositories.
#### 3. Verify Installation
- Objective: Confirm that Git has been installed successfully and check its version.
- Command:
git --version
- Expected Output: The command should display the installed version of Git (e.g., `git version 2.x.x`).
#### 4. Remove Git
- Objective: Uninstall Git using YUM to free up system resources.
- Command:
sudo yum remove git -y
- Explanation: This command removes Git from the system, along with any dependencies that are no longer needed.
#### 5. Reinstall Git
- Objective: Reinstall Git to ensure you can easily manage packages with YUM.
- Command:
sudo yum install git -y
- Explanation: Reinstalls Git, showing how easy it is to manage software packages with YUM.
#### 6. Enable and Configure a YUM Repository
- Objective: Add a third-party repository and install a package from it.
- Example: Adding the EPEL (Extra Packages for Enterprise Linux) repository.
- Command:
sudo yum install epel-release -y
- Explanation: The EPEL repository provides additional packages that are not available in the default CentOS repositories.
- Install a package from EPEL:
sudo yum install htop -y
- Explanation: Installs `htop`, a system-monitoring tool, from the EPEL repository.
### Additional Notes:
- List Installed Packages:
yum list installed
- Explanation: Displays all installed packages on the system.
- Search for Packages:
yum search git
- Explanation: Searches for packages related to Git in the YUM repositories.
- Get Package Information:
yum info git
- Explanation: Provides detailed information about the Git package, including version, size, and description.
### Outcome:
By the end of this project, you will have gained practical experience in using YUM to manage software packages on a CentOS-based system. You'll be able to update your system, install and remove software packages like Git, manage repositories, and verify installations. This knowledge is fundamental for maintaining a well-functioning Linux environment.