0% found this document useful (0 votes)
56 views

DEVOPS_NOTES

Uploaded by

bikotreslo.99
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

DEVOPS_NOTES

Uploaded by

bikotreslo.99
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

SWDOT501: DevOps APPLICATION

COMPETENCE: Apply DevOps techniques

At the end of the module the learner will be able to:

1. Perform server configuration

2. Deploy the system

3. Implement monitoring strategies


Learning outcome 1: Perform server configuration

IC1:Preparation of environment

✓ Definitions of key Terms

Development Operations(DevOps)

DevOps is a set of practices that integrates software development (Dev) and IT operations
(Ops) to improve the efficiency, speed, and quality of delivering software. It emphasizes
collaboration between developers and operations teams throughout the software development
lifecycle, from design to development and production support.

Server

In DevOps, a server refers to a computing system that provides various services essential for
software development, deployment, and operations. Servers are critical components of the
infrastructure that supports DevOps processes, from code development to application delivery.

Linux

Linux is a widely used open-source operating system that plays a crucial role in managing and
automating infrastructure, running applications, and facilitating development and deployment
processes. Its flexibility, reliability, and compatibility with DevOps tools make it a go-to platform for
many DevOps environments.

DevSecOps

DevSecOps is an extension of DevOps that integrates security practices into the DevOps workflow. It
stands for Development, Security, and Operations and emphasizes the importance of including security
at every stage of the software development lifecycle (SDLC), rather than treating it as an afterthought or
a separate process.

Container

In DevOps, a container is a lightweight, standalone, and executable software package that includes
everything needed to run an application such as the code, runtime, libraries, and system tools ensuring
that the application runs consistently across different computing environments. Containers enable
developers to package and isolate applications from the underlying infrastructure, making them highly
portable and efficient for deployment.

Node
In DevOps, a node typically refers to an individual machine or server that is part of a larger
infrastructure or network used for deploying, managing, and running applications and services. A
node can be a physical machine, a virtual machine (VM), or a container instance, depending on the
infrastructure setup. Nodes play a key role in various areas of DevOps, such as container
orchestration, distributed computing, and cluster management.

Infrastructure as Code IaC

Infrastructure as Code (IaC) is a key practice in DevOps where infrastructure (servers, networks,
databases, etc.) is managed and provisioned using code and automation, rather than through manual
processes. This approach allows developers and operations teams to define, deploy, and manage
infrastructure in a repeatable, scalable, and automated manner.

IaaS

Infrastructure as a Service (IaaS) in DevOps refers to a cloud computing model that provides
virtualized computing resources over the internet. With IaaS, organizations can rent
infrastructure components such as servers, storage, and networking on demand, rather than
purchasing and maintaining physical hardware. This allows for scalability, flexibility, and cost
savings, which are essential for DevOps practices like Continuous Integration (CI), Continuous
Delivery (CD), and automated deployment pipelines.

CI/CD

CI/CD in DevOps stands for Continuous Integration and Continuous Delivery/Deployment,


two critical practices that streamline the process of software development, testing, and delivery.
These practices automate workflows, reduce errors, and accelerate software releases, allowing
teams to deliver features and fixes to customers more frequently and reliably.

Continuous Integration (CI)

Continuous Integration (CI) is the practice of frequently integrating code changes from
multiple developers into a shared repository, where each change is automatically tested. The goal
is to identify bugs or issues early, ensuring that the application is always in a deployable state.

Continuous Delivery (CD)

Continuous Delivery (CD) is the next step after Continuous Integration. It ensures that the
integrated and tested code is always in a deployable state and can be released to production at
any time. The key difference between Continuous Delivery and Continuous Deployment
(discussed below) is that with Continuous Delivery, the deployment to production is triggered
manually.

 Identification of Linux distributions

What is a Linux Distribution?

A Linux distribution is an operating system based on the Linux kernel, which includes a
collection of software, utilities, and package management systems. Each distribution has a
unique focus, such as server performance, user-friendliness, security, or cloud integration,
making them suitable for different tasks in a DevOps workflow.

Common Linux Distributions in DevOps are:

1 .Ubuntu:

 Popular, user-friendly, based on Debian.


 Suited for desktops and servers.
 Uses APT package manager.

2. Fedora:

 Cutting-edge, supported by Red Hat.


 Regular updates with the latest open-source tools.
 Uses DNF package manager.

3. Debian:

 Stable and reliable, often used in servers.


 Community-driven, minimal updates.
 Uses APT package manager.

4. Linux Mint:

 Easy to use, based on Ubuntu/Debian.


 Great for beginners transitioning from Windows.
 Uses APT package manager.

5. RHEL (Red Hat Enterprise Linux):

 Commercial, enterprise-focused.
 Offers long-term support and stability.
 Uses YUM/DNF package manager.
6. CentOS:

 Free version of RHEL.


 Popular in server environments for its stability.
 Uses YUM/DNF package manager.

1. SUSE Linux Enterprise Server (SLES):

 Enterprise-oriented, stable, and secure.


 Suited for business-critical applications.
 Uses Zypper package manager.

2. Puppy Linux:

 Extremely lightweight, ideal for older computers.


 Runs efficiently in RAM.
9. Lubuntu:

 Lightweight version of Ubuntu with LXQt desktop.


 Suitable for low-spec machines.
 Uses APT package manager.

10. Arch Linux:

 Flexible, minimalistic, rolling-release.


 Tailored for advanced users who want customization.
 Uses Pacman package manager.

11. Manjaro:

 User-friendly version of Arch Linux.


 Offers a more stable experience than Arch.
 Uses Pacman package manager.

12. Kali Linux:

 Security-focused, pre-loaded with penetration testing tools.


 Popular among ethical hackers.
 Uses APT package manager.

13. Parrot OS:

 Another security-focused distro for penetration testing and forensics.


 Lighter alternative to Kali Linux.
 Uses APT package manager.
14. Tails:

 Privacy-focused, routes internet traffic through Tor.


 Runs live from USB for anonymity.

15. Raspberry Pi OS:

 Designed for Raspberry Pi hardware.


 Lightweight and educational-focused.
 Based on Debian.

 Installation of Linux operating system

1. Install Ubuntu from a Bootable USB Drive (Most Common Method)

Steps:

1. Download the Ubuntu ISO:


o Visit the official Ubuntu website and download the latest version of Ubuntu as an ISO
file.

2. Create a Bootable USB Drive:


o Use tools like Rufus (for Windows), Etcher, or UNetbootin to create a bootable USB
drive with the Ubuntu ISO.
o Insert the USB drive into your computer and use one of these tools to burn the ISO file
to the USB.

3. Boot from USB:


o Insert the bootable USB drive into the computer where you want to install Ubuntu.
o Restart your computer and press the key to access the boot menu (usually F2, F10, F12,
or Esc, depending on your computer manufacturer).
o Select the USB drive from the boot options to boot into the Ubuntu installer.

4. Start the Installation Process:


o After booting from the USB, you will be presented with options. Select Install Ubuntu.

5. Partition and Install:


o Choose your installation type:
 Erase Disk and Install Ubuntu: A fresh installation, which will erase all data on
the drive.
 Install Ubuntu Alongside Windows: A dual boot setup where both operating
systems will be installed, and you can select which OS to boot into.
 Something Else: For custom partitioning.
o Follow the prompts to select your time zone, keyboard layout, and set up your user
account.
6. Complete the Installation:
o Once installation is complete, restart your computer, remove the USB drive, and you
should boot into Ubuntu.

2.install Ubuntu using VMWARE

Here’s a step-by-step guide to installing Ubuntu on VMware (Windows as the host system):

Step 1: Download VMware and Ubuntu ISO

1. Download VMware Workstation Player:

 Visit the official VMware website: VMware Workstation Player Download.


 Download and install VMware Workstation Player (free for non-commercial use).
 Follow the installation wizard to complete the VMware installation.

2. Download Ubuntu ISO:

 Visit the official Ubuntu website to download the latest Ubuntu Desktop version.
 Download the 64-bit Ubuntu ISO file.

Step 2: Install and Set Up VMware Workstation Player

1. Launch VMware Workstation Player:

 Open VMware Workstation Player from the Start Menu after installation.

2. Create a New Virtual Machine:

 Click on Create a New Virtual Machine.


 In the "New Virtual Machine Wizard", select Installer disc image file (ISO).
 Browse to the Ubuntu ISO file you downloaded and select it.
 Click Next.

3. Select Guest Operating System:

 Choose Linux as the Guest Operating System.


 For Version, select Ubuntu 64-bit (or your Ubuntu version).
 Click Next.
4. Name the Virtual Machine:

 Give your virtual machine a name (e.g., "Ubuntu VM").


 Choose a location on your computer to store the VM files (or leave it as default).
 Click Next.

5. Set Disk Size:

 Specify the disk size for your virtual machine (e.g., 20GB).
 Choose either Store virtual disk as a single file or Split virtual disk into multiple files (the latter
is better if you plan to move the VM to different locations).
 Click Next.

6. Customize Hardware (Optional):

 Before clicking Finish, you can customize your VM’s hardware (such as RAM and CPU cores).
 Click Customize Hardware and adjust:
o Memory: Set at least 2GB RAM (4GB is recommended for better performance).
o Processors: You can assign 2 CPU cores for better performance.
o Network Adapter: Leave as NAT unless you need specific network settings.
 Click Close, then Finish.

Step 3: Install Ubuntu in VMware

1. Start the Virtual Machine:

 In the main VMware window, select your new Ubuntu VM and click Play virtual machine to
start it.
 The Ubuntu installer will boot from the ISO file.

2. Select Installation Language:

 Choose your preferred language (e.g., English) and click Install Ubuntu.

3. Choose Keyboard Layout:

 Select the correct keyboard layout and click Continue.

4. Choose Installation Type:

 You will be asked to choose the installation type:


o Normal Installation: Includes apps like a web browser, utilities, and media players.
o Minimal Installation: Installs only basic utilities and a web browser.
 Choose Normal Installation and click Continue.
5. Updates and Other Software:

 Select the option for installing updates during installation and optionally check Install third-
party software for graphics, Wi-Fi, and additional media formats.
 Click Continue.

6. Partitioning:

 For virtual machines, choose Erase disk and install Ubuntu (this does not affect your actual hard
drive but only allocates virtual disk space).
 Click Install Now and then Continue.

7. Set Time Zone:

 Select your time zone from the map or drop-down list and click Continue.

8. Create a User Account:

 Set your name, computer name, username, and password for the Ubuntu system.
 Click Continue.

9. Install Ubuntu:

 The installer will now install Ubuntu. This process may take some time depending on your
system’s performance.

Step 4: Post-Installation Steps

1. Restart the Virtual Machine:

 Once installation is complete, you’ll be prompted to restart.


 Click Restart Now.
 VMware may prompt you to remove the installation medium (the ISO file). This is done
automatically, so press Enter.

2. Login to Ubuntu:

 After rebooting, you’ll see the Ubuntu login screen. Enter the username and password you
created earlier.
 You are now logged in to your Ubuntu system running on VMware!

Step 5: Install VMware Tools (Optional but Recommended)


VMware Tools improves the integration between Ubuntu and your host system, enabling
features like drag-and-drop, shared clipboard, and better performance.

Steps to Install VMware Tools:

1. Power on the Ubuntu VM and log in.


2. In VMware Player, go to the Player Menu > Manage > Install VMware Tools.
3. Mount the VMware Tools CD:
o Inside Ubuntu, the VMware Tools CD image will be mounted automatically.
o Open the VMware Tools disc icon on the Ubuntu desktop.

4. Extract the VMware Tools:


o Inside the CD, right-click the compressed .tar.gz file and select Extract Here.

5. Install VMware Tools:


o Open the terminal and navigate to the extracted folder:

cd /path/to/extracted/folder
sudo ./vmware-install.pl

o Follow the on-screen instructions to complete the installation.

6. Reboot your Ubuntu VM for the changes to take effect.

IC2: Applying Linux basics commands

1.system information commands

General System Information

1. uname – Print system information.


o Example: uname -a (Shows kernel version, hostname, and architecture)
2. hostname – Show or set the system’s hostname.
o Example: hostname
3. uptime – Show how long the system has been running along with load average.
o Example: uptime
4. whoami – Show the current user.
o Example: whoami
5. lsb_release – Display Linux distribution information.
o Example: lsb_release -a
6. dmesg – Print system boot and kernel messages.
o Example: dmesg | less
7. top – Display real-time system processes and resource usage.
o Example: top
8. htop – Interactive process viewer (requires installation).
o Example: htop
CPU Information

9. lscpu – Display information about the CPU architecture.


o Example: lscpu
10. cat /proc/cpuinfo – View detailed information about the CPU.
o Example: cat /proc/cpuinfo

Memory Information

11. free – Display memory usage.


o Example: free -h (Shows memory in human-readable format)
12. vmstat – Report virtual memory statistics.
o Example: vmstat
13. cat /proc/meminfo – View detailed memory information.
o Example: cat /proc/meminfo

Disk and Filesystem Information

14. df – Display disk space usage.


o Example: df -h (Shows in human-readable format)
15. du – Estimate file and directory space usage.
o Example: du -sh /path/to/directory
16. lsblk – List block devices (e.g., hard drives and partitions).
o Example: lsblk
17. fdisk – View or modify disk partitions.
o Example: fdisk -l
18. mount – Show mounted filesystems.
o Example: mount
19. blkid – Locate and print block device attributes.
o Example: blkid
20. swapon – Show swap space usage.
o Example: swapon --show

Hardware Information

21. lshw – List hardware configuration (requires root access).


o Example: sudo lshw
22. lspci – List PCI devices.
o Example: lspci
23. lsusb – List USB devices.
o Example: lsusb
24. dmidecode – Display hardware information from the system BIOS.
o Example: sudo dmidecode

Network Information
25. ifconfig – Display network interface information (use ip for newer versions).
o Example: ifconfig
26. ip a – Display IP addresses and network interfaces.
o Example: ip a
27. netstat – Display network connections, routing tables, and interface statistics.
o Example: netstat -tuln
28. ss – Display socket statistics (modern replacement for netstat).
o Example: ss -tuln
29. ping – Check network connectivity.
o Example: ping google.com
30. traceroute – Trace the route packets take to a network host.
o Example: traceroute google.com
31. hostname -I – Display the system’s IP address.
o Example: hostname -I

2.File and Directory Management


Text Processing Commands are a set of built-in commands that are used to
manipulate text. These commands allow users to quickly and efficiently
search, modify, and extract data from text files.

Command Description Examples

cat Concatenate and display files cat file1.txt file2.txt

echo Display a line of text or string. Echo hello class

Example: tac file.txt


tac
Concatenate and display files in reverse.

sort Sort lines of text files sort file.txt

uniq Remove duplicate lines from a sorted file sort file.txt | uniq

grep Search for patterns in files grep "pattern" file.txt

cut Extract columns of text from files cut -f1,3 file.txt


Command Description Examples

Translate or delete characters

Use tr to perform different text


tr transformations, including case tr 'a-z' 'A-Z' < file.txt
conversion, squeezing or deleting
characters, and basic text
replacement.

Count lines, words, and characters in a


wc wc file.txt
file

diff Compare two files and show differences diff file1.txt file2.txt

nl Number lines in a file nl file.txt

head Display the first few lines of a file head file.txt

tail Display the last few lines of a file tail file.txt

Redirect output to a file and to the


tee ls | tee output.txt
terminal

fmt Format text files for printing fmt file.txt

pr Convert text files for printing pr file.txt

rev Reverse lines of a file rev file.txt

join Join lines from two files based on a Cat join file1.txt
common field file2.txt
Command Description Examples

Folder management commands

Example: pwd
pwd
Print the current working directory.

ls Example: ls or ls -l
List directory contents.

Change the current directory. Example: cd


cd /path/to/directory

Create a new directory. Example: mkdir


mkdir new_directory

Remove an empty directory. Example: rmdir


rmdir old_directory

Remove files or directories (use with caution, Example: rm -r


rm especially with -r). directory_name

Example: cp -r
source_directory
cp
Copy files or directories. destination_directory
Command Description Examples

du Estimate file space usage of a directory.  Example: du -sh


du directory_name

df  Example: df -h
Report file system disk space usage.

tree Display directory structure in a tree format.  Example: tree

Create an empty file or update the timestamp Example: touch


touch of a file or directory. new_file_or_directory

Display the directory part of a file or directory Example: dirname


dirname path. /path/to/directory/

3.text processing commands:

Text processing commands in Linux, used to manipulate, filter, search, and format text:

1. cat – Concatenate and display the content of files.


o Example: cat file.txt
2. echo – Display a line of text or a string.
o Example: echo "Hello, World!"
3. grep – Search for patterns in text using regular expressions.
o Example: grep "pattern" file.txt
4. sed – Stream editor for text transformations like search, find, and replace.
o Example: sed 's/old/new/g' file.txt
5. awk – A powerful text pattern scanning and processing language.
o Example: awk '{print $1}' file.txt
6. cut – Remove sections from each line of files.
o Example: cut -d ',' -f 2 file.txt
7. sort – Sort lines of text files.
o Example: sort file.txt
8. uniq – Report or omit repeated lines.
o Example: uniq file.txt
9. tr – Translate, squeeze, or delete characters from input.
o Example: tr 'a-z' 'A-Z' < file.txt
10. wc – Print the number of lines, words, and bytes in files.
o Example: wc file.txt
11. head – Display the first few lines of a file.
o Example: head -n 5 file.txt
12. tail – Display the last few lines of a file.
o Example: tail -n 5 file.txt
13. nl – Number lines of files.
o Example: nl file.txt
14. fmt – Simple text formatter.
o Example: fmt file.txt
15. pr – Format text for printing.
o Example: pr -h "Title" file.txt
16. paste – Merge lines of files horizontally.
o Example: paste file1.txt file2.txt
17. join – Join lines of two files on a common field.
o Example: join file1.txt file2.txt
18. split – Split a file into pieces.
o Example: split -l 100 file.txt
19. tac – Concatenate and display files in reverse order.
o Example: tac file.txt
20. rev – Reverse characters in each line.
o Example: rev file.txt
21. od – Dump files in octal and other formats.
o Example: od -c file.txt
22. fold – Wrap lines of text at a specified width.
o Example: fold -w 50 file.txt
23. xargs – Build and execute command lines from standard input.
o Example: cat file.txt | xargs echo
24. iconv – Convert text file encoding.
o Example: iconv -f UTF-8 -t ISO-8859-1 file.txt
25. file – Determine the file type of a file.
o Example: file file.txt

4.process management commands

1. ps – Display a snapshot of current processes.


o Example: ps aux (Shows all running processes with detailed information)
2. top – Display real-time information about running processes and system resource usage.
o Example: top
3. htop – An interactive process viewer (requires installation, similar to top but more user-
friendly).
o Example: htop
4. pgrep – Search for processes by name or other attributes.
o Example: pgrep firefox (Lists process IDs for Firefox)
5. pidof – Find the process ID (PID) of a running program.
o Example: pidof firefox
6. jobs – List active jobs in the current session.
o Example: jobs

Managing Processes

7. kill – Send a signal to terminate a process by PID.


o Example: kill 1234 (Terminates process with PID 1234)
8. killall – Kill all processes by name.
o Example: killall firefox
9. pkill – Send a signal to processes based on name or other attributes.
o Example: pkill firefox
10. nice – Start a process with a specific priority.
o Example: nice -n 10 command (Starts command with a lower priority)
11. renice – Change the priority of a running process.
o Example: renice 15 1234 (Changes the priority of process with PID 1234)
12. bg – Resume a suspended job in the background.
o Example: bg %1 (Resumes job 1 in the background)
13. fg – Bring a background job to the foreground.
o Example: fg %1 (Brings job 1 to the foreground)
14. nohup – Run a command that ignores hangup signals (keeps running after logging out).
o Example: nohup command &
15. disown – Remove jobs from the shell’s job table to prevent them from being killed when
the shell exits.
o Example: disown %1

Process Monitoring and Information

16. ps -ef – Display all processes in full-format listing.


o Example: ps -ef | grep ssh (Finds all ssh processes)
17. pstree – Display processes in a tree format.
o Example: pstree
18. strace – Trace system calls and signals made by a process.
o Example: strace -p 1234 (Trace process with PID 1234)
19. lsof – List open files and the processes using them.
o Example: lsof -p 1234 (Lists files opened by process 1234)
20. watch – Run a command periodically and display the output.
o Example: watch -n 1 ps aux (Displays the ps aux output every second)
21. uptime – Display how long the system has been running, including the number of users
and the load average.
o Example: uptime
22. vmstat – Report virtual memory statistics, including processes.
o Example: vmstat 5 (Reports every 5 seconds)
Process Control and Signals

23. signal – List available signals you can send to processes.


o Example: kill -l (Shows available signals)
24. xkill – Graphically kill a window (useful in GUI environments).
o Example: xkill (Click on a window to kill it)
25. bg/fg/nice – Manage job control and process priority.
o Example: fg %1 (Brings job 1 to the foreground)

Advanced Process Management

26. atop – An advanced system and process monitor (requires installation).


o Example: atop
27. iotop – Monitor disk I/O usage by processes (requires installation).
o Example: iotop
28. schedtool – Manage and display real-time process scheduling (advanced, requires
installation).

Example: schedtool -R -p 1234 (Sets process with PID 1234 to real-time priority)

5. Package management commands

APT (Advanced Package Tool) – Debian/Ubuntu-Based Distributions

1. Update package list


o sudo apt update
o Updates the local package list from repositories.
2. Upgrade installed packages
o sudo apt upgrade
o Installs the latest versions of all installed packages.
3. Install a package
o sudo apt install package_name
oInstalls a specific package.
oExample: sudo apt install vim
4. Remove a package
o sudo apt remove package_name
o Removes the package, but keeps configuration files.
o Example: sudo apt remove vim
5. Purge a package
o sudo apt purge package_name
o Removes the package along with configuration files.
6. Search for a package
o apt search package_name
o Searches for a package by name or description.
7. Show package information
o apt show package_name
o Displays detailed information about a package.
8. List all installed packages
o apt list --installed
o Lists all installed packages on the system.
9. Autoremove unused packages
o sudo apt autoremove
o Removes unnecessary packages that were automatically installed and are no
longer needed.
10. Check for broken dependencies
o sudo apt check
o Checks for issues with installed packages.

6.user and group management commands

User Management Commands

1. Add a new user


o sudo adduser username
o Adds a new user to the system with default settings.
o Example: sudo adduser john
2. Create a user (alternative)
o sudo useradd username
o Adds a user without creating a home directory by default (use -m to create the
home directory).
o Example: sudo useradd -m john
3. Delete a user
o sudo deluser username
o Removes a user but keeps their home directory.
o Example: sudo deluser john
4. Delete a user and home directory
o sudo deluser --remove-home username
oRemoves both the user and their home directory.
oExample: sudo deluser --remove-home john
5. Change a user’s password
o sudo passwd username
o Sets or updates a password for the specified user.
o Example: sudo passwd john
6. Modify user details
o sudo usermod options username
o Modify a user’s account information (e.g., change home directory, shell, etc.).
o Example: sudo usermod -d /new/home john (Changes John's home directory)
7. Lock a user account
o sudo usermod -L username
o Locks the user’s account (prevents login).
o Example: sudo usermod -L john
8. Unlock a user account
o sudo usermod -U username
o Unlocks a locked user account.
o Example: sudo usermod -U john
9. Show user information
o id username
o Displays a user’s UID (User ID), GID (Group ID), and group memberships.
o Example: id john
10. Show user details (alternative)
o getent passwd username
o Displays full information about a user.
o Example: getent passwd john
11. List all users
o cut -d: -f1 /etc/passwd
o Lists all users from the /etc/passwd file.

Group Management Commands

1. Add a new group


o sudo addgroup groupname
o Creates a new group.
o Example: sudo addgroup developers
2. Delete a group
o sudo delgroup groupname
o Deletes an existing group.
o Example: sudo delgroup developers
3. Add a user to a group
o sudo usermod -aG groupname username
oAdds a user to a specific group.
oExample: sudo usermod -aG developers john (Adds user "john" to the
"developers" group)
4. Remove a user from a group
o sudo gpasswd -d username groupname
oRemoves a user from a group.
oExample: sudo gpasswd -d john developers
5. Change a user's primary group
o sudo usermod -g groupname username
o Changes the user’s primary group.
o Example: sudo usermod -g developers john
6. Show group details
o getent group groupname
o Displays information about a specific group.
o Example: getent group developers
7. List all groups
o cut -d: -f1 /etc/group
o Lists all groups from the /etc/group file.
8. Show all groups a user belongs to
o groups username
o Lists all groups that the specified user belongs to.
o Example: groups john

Managing User and Group Permissions


1. Change file ownership
o sudo chown owner:group filename
oChanges the owner and group of a file or directory.
oExample: sudo chown john:developers file.txt
2. Change file group ownership
o sudo chgrp groupname filename
o Changes only the group ownership of a file or directory.
o Example: sudo chgrp developers file.txt
3. Set permissions for files and directories
o chmod permissions filename
o Changes the read, write, and execute permissions for files and directories.
o Example: chmod 755 script.sh

User and Group Account Management Files

 /etc/passwd – Contains user account information.


 /etc/shadow – Contains encrypted passwords for user accounts.
 /etc/group – Contains group account information.
 /etc/sudoers – Configures user privileges for the sudo command.

7.Sytem control commands:

Systemd Commands (System and Service Management)

Most modern Linux distributions use systemd as the default system and service manager. These
commands allow you to control services, boot targets, and other system operations.

1. Check the status of a service


o systemctl status service_name
o Shows the status (active, inactive, failed) of a specific service.
o Example: systemctl status nginx
2. Start a service
o sudo systemctl start service_name
o Starts a service.
o Example: sudo systemctl start nginx
3. Stop a service
o sudo systemctl stop service_name
o Stops a running service.
o Example: sudo systemctl stop nginx
4. Restart a service
o sudo systemctl restart service_name
o Restarts a running service.
o Example: sudo systemctl restart nginx
5. Reload a service
o sudo systemctl reload service_name
o Reloads the configuration of a service without stopping it.
o Example: sudo systemctl reload nginx
6. Enable a service at boot
o sudo systemctl enable service_name
o Enables a service to start automatically at boot.
o Example: sudo systemctl enable nginx
7. Disable a service at boot
o sudo systemctl disable service_name
o Disables a service from starting automatically at boot.
o Example: sudo systemctl disable nginx
8. Check all active services
o systemctl list-units --type=service --state=active
o Lists all currently active services on the system.
9. Check failed services
o systemctl --failed
o Lists all failed services.
10. Check system boot logs
o journalctl -b
o Displays logs from the current boot.

Shutdown, Restart, and Reboot Commands

1. Shutdown the system immediately


o sudo shutdown now
o Shuts down the system immediately.
2. Shutdown the system at a specific time
o sudo shutdown hh:mm
o Shuts down the system at a specified time.
o Example: sudo shutdown 22:00 (Shutdown at 10 PM)
3. Cancel a scheduled shutdown
o sudo shutdown -c
o Cancels a scheduled shutdown or reboot.
4. Restart the system
o sudo reboot
o Reboots the system immediately.
5. Power off the system
o sudo poweroff
o Powers off the system immediately.
6. Halt the system
o sudo halt
o Stops the system but leaves it powered on.
7. Reboot the system immediately
o sudo systemctl reboot
o Reboots the system using the systemctl command.
8. Shut down the system using systemctl
o sudo systemctl poweroff
o Shuts down the system using the systemctl command.
Runlevel and Boot Target Management

Systemd uses targets to manage different system states (formerly known as runlevels in
SysVinit systems).

1. Check current runlevel (target)


o systemctl get-default
oShows the current default boot target (runlevel).
2. Change the runlevel (target)
o sudo systemctl isolate target_name
o Changes the system to a different target.
o Example: sudo systemctl isolate multi-user.target (Switches to non-
graphical multi-user mode)
3. Set default runlevel (target)
o sudo systemctl set-default target_name
o Changes the default boot target.
o Example: sudo systemctl set-default graphical.target (Sets graphical
mode as the default boot target)
4. List available targets
o systemctl list-unit-files --type=target
o Lists all available system targets (runlevels).

System Monitoring and Information Commands

1. Show system uptime


o uptime
o Displays how long the system has been running, along with the current time and
load average.
2. Show system load average
o uptime or cat /proc/loadavg
o Shows the load average for the last 1, 5, and 15 minutes.
3. Show current users
o w or who
o Lists users currently logged into the system.
4. Show recent system logs
o journalctl
o Displays the system logs managed by systemd.
5. Show kernel messages
o dmesg
o Displays kernel ring buffer messages (useful for debugging hardware or kernel
issues).
6. View hardware information
o lshw
o Lists detailed hardware information.
7. View disk usage
o df -h
o Shows disk space usage in a human-readable format.
8. Check free memory
o free -h
o Displays memory usage in a human-readable format.

System Configuration Commands

1. Manage swap space


o swapon -s
o Shows active swap partitions and files.
o sudo swapon /swapfile
o Activates a swap file or partition.
o sudo swapoff /swapfile

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy