learning linux 3

 

User and Group Management in Linux

Managing Local Users:

  • Commands:
    • adduser / useradd: Create new users.
    • usermod: Modify existing user accounts.
    • userdel: Delete users.

Managing Local Groups:

  • Primary and Supplementary Groups: Each user has a primary group and can belong to multiple supplementary groups.
  • Commands:
    • groupadd: Create new groups.
    • groupmod: Modify existing groups.
    • groupdel: Delete groups.

Querying User Accounts:

  • Commands:
    • whoami: Displays the current logged-in user's name.
    • who: Lists users currently logged in and their login details.
    • w: Shows what users are currently doing.
    • pinky: A lightweight version of finger, provides user information.
    • last: Shows a history of user logins.
    • id username: Displays user identity information.

Managing Group Password Files:

  • Password File: Located in /etc/shadow, requires root access to edit.
  • Commands:
    • sudo vipw / sudo vipw -s: Safely edit the password file.
    • vigr: Edit group file.

User & Group Quotas:

  • Quota Management:
    • Enable quotas during mounting by scanning the drive with sudo quotacheck.
    • Activate quotas using sudo quotaon.
    • Edit quotas for users with sudo edquota username.
  • Types of Quotas:
    • Inodes: Limits the number of files a user can create.
    • Blocks: Limits the amount of disk space a user can consume.

Text Editing and Viewing

Text Editors:

  • Nano: Simple and user-friendly.
  • VI: Classic editor with two modes:
    • Insert Mode: Enter using i or a.
    • Command Mode: Exit using ESC, then save and quit with :wq, quit with :q!, and save only with :w.

Viewing Text:

  • Commands:
    • head: Displays the first lines of a file.
    • tail: Displays the last lines of a file.
    • more / less: View files interactively; less allows searching with /search and exiting with q.

Searching Text with grep:

  • Usage:
    • Regex: grep supports regular expressions.
    • Piping: Combine commands with | for complex searches.

Input/Output Redirection and Text Manipulation

Redirection:

  • Stdin: < and |
  • Stdout: >
  • Stderr: 2>

Special Files:

  • /dev/null: The "blackhole" where unwanted output is discarded.
  • tee: Sends output to both a file and stdout.
  • xargs: Passes stdin as arguments to another command.

Text Manipulation:

  • sort: Sorts lines in a file.
  • wc: Counts lines, words, and characters in a file.
  • cut / paste: Cuts and pastes columns of text.

Advanced Text Processing:

  • AWK: A powerful text processing language.
  • SED: Stream editor for filtering and transforming text.

File Management and Links

Hard and Soft Links:

  • Soft Link (Symbolic Link): Points to the file's location in the allocation table.
  • Hard Link: Points directly to the data on the disk, multiple links can reference the same data block.

Finding Files:

  • find: Powerful, slower, supports regex.
  • locate: Fast, uses a cached database; run sudo updatedb to refresh the database.

Copying Files Over a Network

Protocols and Tools:

  • SSH: Secure Shell protocol.
  • SCP: Secure copy, works over SSH.
  • Rsync: Copies files recursively and efficiently.

Service Management

Systemctl for Services:

  • Commands:
    • enable / disable: Set services to start on boot or not.
    • start / stop: Immediately start or stop a service.

Sys-V Runlevels:

  • Runlevels:
    • Debian/Ubuntu: 0, 1, 2, 6.
    • CentOS/Red Hat: 0, 1, 2, 3, 5, 6.
  • Changing Runlevels: Edit /etc/inittab or use telinit.
  • Managing Services:
    • Scripts: Located in /etc/init.d/.
    • Commands: chkconfig and service.

SystemD Init:

  • Isolate Services: Use systemctl isolate.
  • Manage Services: Use systemctl.

Network Server Roles and Virtualization

Network Server Roles:

  • Key Services:
    • NTP: Network Time Protocol.
    • SSH: Secure Shell.
    • DNS: Domain Name System.
    • DHCP: Dynamic Host Configuration Protocol.
    • Docker: Container management.
  • Configuration: Can be centralized or individual.

Virtualization and Server Closets:

  • Impact: Virtualization reduced the need for physical servers.
  • Sprawl Potential: Server sprawl was a problem, but Docker helps by containing and isolating services.

Understanding Web Servers, SSL, and More

Web Servers and SSL:

  • Basics: Understanding how web servers work and the importance of SSL for secure connections.

Local Network Roles vs. Cloud:

  • Shift to Cloud: Many local network roles are now handled by cloud services.

Authentication and Database Servers:

  • Roles: Ensuring secure access and data management.

Centralized Logging and Monitoring:

  • Syslog: Centralized logging.
  • SNMP: Simple Network Management Protocol for monitoring.

VPNs (Virtual Private Networks):

  • Options:
    • Site-to-Site.
    • End User to Site.
    • Protocols: IPSec, L2TP, OpenVPN, SSH.

Containers vs. Virtual Machines:

  • Differences: Containers share the host OS, while VMs have separate OS instances.
  • Container Systems: Tools like Docker for container management.

Clustering and Load Balancing:

  • Clustering: Combining multiple servers to work as a single unit.
  • Load Balancing: Distributing traffic, often using round-robin DNS.

System Maintenance and Device Management

Cron Jobs:

  • System-Wide: Configure cron jobs using /etc/cron.d.
  • Personal Crontab: Each user can have their own crontab.

AT Daemon:

  • Use Case: Schedule one-time tasks with at.

Foreground & Background Processes:

  • Management: Use &, fg, and bg commands to control process states.

Finding Local Devices:

  • Commands:
    • dmesg: Kernel ring buffer.
    • lsusb: List USB devices.
    • lspci: List PCI devices.
    • lsblk: List block devices.
    • lscpu: Display CPU architecture.

Virtual File System:

  • Directories:
    • /proc: Process information.
    • /sys: Kernel information.
    • /dev: Device files.

CUPS Printing:

  • Commands:
    • lpr: Print a file.
    • lpq: Display print queue.
    • lprm: Remove jobs from the print queue.
  • Web Interface: Manage CUPS via its web interface.

Understanding UDEV:

  • UDEV: Manages device nodes in /dev.
  • Sysfs: Exposes kernel device information.
  • Rules: Custom UDEV rules for device management.

Comments

Popular posts from this blog

Learning About Linux Server

Exploring Event Handling in JavaScript: From Basics to Async Projects