Linux Systems Administration

Linux Fundamentals for Newbies: All You Need to Work with Linux

Damian Igbe, Phd
Sept. 10, 2024, 12:34 p.m.

Subscribe to Newsletter

Be first to know about new blogs, training offers, and company news.

Linux Fundamentals for Newbies: All You Need to Work with Linux

Introduction to Linux

Linux is a powerful and flexible operating system that is widely used in servers, desktops, and embedded systems. This guide will cover the essential Linux concepts and commands you need to get started, along with practical lab exercises to solidify your understanding.

 

Key Concepts

1. What is Linux?

Linux is an open-source operating system kernel created by Linus Torvalds. It’s used in various distributions (distros), each tailored for different needs. Popular distros include Ubuntu, Fedora, and CentOS.

2. Distributions (Distros)

A Linux distribution is a variant of the Linux operating system that includes the Linux kernel along with other software, utilities, and a package manager. Some common distributions are:

  • Ubuntu: User-friendly and great for beginners.
  • Fedora: Cutting-edge features and software.
  • CentOS: Enterprise-focused and stable.

3. File System Hierarchy

Linux uses a hierarchical file system. Key directories include:

  • /: Root directory, the top of the hierarchy.
  • /home: User home directories.
  • /etc: Configuration files.
  • /var: Variable files like logs.
  • /usr: User programs and data.

4. Shell and Terminal

The shell is a command-line interface that allows users to interact with the operating system. The terminal is the application that provides access to the shell. Common shells include:

  • Bash: The most widely used shell in Linux.
  • Zsh: Known for its advanced features.

 

Basic Commands

1. Navigating the File System

  • pwd: Print working directory.
  • ls: List files and directories.
  • cd <directory>: Change directory.

2. File and Directory Management

  • cp <source> <destination>: Copy files or directories.
  • mv <source> <destination>: Move or rename files or directories.
  • rm <file>: Remove files. Use rm -r <directory> to remove directories.

3. Viewing and Editing Files

  • cat <file>: Display file contents.
  • more <file> and less <file>: View file contents page by page.
  • nano <file> and vim <file>: Edit files using text editors.

4. Permissions

  • chmod <permissions> <file>: Change file permissions.
  • chown <user>:<group> <file>: Change file owner and group.

5. System Information

  • uname -a: Display system information.
  • top: Show running processes and system usage.
  • df -h: Display disk space usage.
  • free -h: Show memory usage.

Package Management

Different distributions use different package managers:

  • Ubuntu/Debian: apt (e.g., sudo apt-get install <package>)
  • Fedora: dnf (e.g., sudo dnf install <package>)
  • CentOS: yum (e.g., sudo yum install <package>)

Basic Networking Commands

  • ifconfig or ip addr: Display network interfaces.
  • ping <host>: Check connectivity to a network host.
  • ssh <user>@<host>: Securely connect to a remote machine.

Getting Help

  • man <command>: Display the manual page for a command.
  • <command> --help: Show help information for a command.

 

Lab Exercises

Exercise 1: Setting Up Your Environment

  1. Open the Terminal: Access the terminal application on your Linux system.
  2. Check System Information:
    • Run uname -a to get details about your system.

Exercise 2: Navigating and Managing Files

  1. Create a Directory and File:
    • Create a directory named test_dir with mkdir test_dir.
    • Navigate into test_dir with cd test_dir.
    • Create a file named example.txt with touch example.txt.
  2. Edit and View File:
    • Open example.txt with nano example.txt, add some text, and save it.
    • View the file contents with cat example.txt.
  3. Copy and Move File:
    • Copy example.txt to backup.txt with cp example.txt backup.txt.
    • Rename backup.txt to archive.txt with mv backup.txt archive.txt.
  4. Delete File:
    • Delete archive.txt with rm archive.txt.

Exercise 3: Managing Permissions

  1. Change Permissions:
    • Change the permissions of example.txt to read-only with chmod 444 example.txt.
    • Verify permissions with ls -l example.txt.
  2. Change Ownership:
    • Change the owner of example.txt to a different user with sudo chown <user> example.txt (replace <user> with an actual username).

Exercise 4: Working with Packages

  1. Update Package List:
    • Update your package list with sudo apt-get update (Ubuntu/Debian) or sudo dnf check-update (Fedora).
  2. Install a Package:
    • Install the curl package with sudo apt-get install curl (Ubuntu/Debian) or sudo dnf install curl (Fedora).
  3. Verify Installation:
    • Check if curl is installed with curl --version.

Exercise 5: Networking Basics

  1. Check Network Configuration:
    • Display network interfaces with ip addr or ifconfig.
  2. Test Connectivity:
    • Ping a well-known website with ping google.com to check your network connection.
  3. Connect to a Remote Machine:
    • Use SSH to connect to a remote machine (if available) with ssh <user>@<host> (replace <user> and <host> with appropriate values).

Conclusion

By mastering these Linux fundamentals and completing the lab exercises, you’ll gain a solid foundation in using and managing Linux systems. Practice these commands and concepts regularly to build your proficiency and confidence.

Zero-to-Hero Program: We Train and Mentor you to land your first Tech role