DEV Community

Cover image for LINUX FOR DEVOPS.....
Kasim Hussain
Kasim Hussain

Posted on

LINUX FOR DEVOPS.....

Linux Founder
Linus Benedict Torvalds is a Finnish software engineer best known for having initiated the development of the Linux kernel and git revision control system.

History of Linux
Linus Torvalds a student at the University of Helsinki, Finland, USA developed the first code of Linux i.e. Linux 0.01, which became so popular that people encourages him to develop the new code of Linux. On 5 September 1991 Linus Torvalds developed the first official version of Linux i.e. Linux 0.02.

Linux File System Hierarchy

Linux is an open-source operating system. Linux follows the File System Hierarchy in which everything is represented as a file i.e. stored in a directory. Linux has a single-rooted, inverted tree-like structure. The root directory in Linux is represented as "/" (forward slash) also called the top-level directory.

Top-level directory -> "/"

The base of the Linux directory is the root. This is the starting point of FSH. Every directory arises from the root directory. It is represented by a forward slash (/).

If someone says to look into the slash directory, they refer to the root directory.

/root

It is the home directory for the root user (superuser).
/bin -> User Binaries

Contains binary executable.

Common Linux commands you need to use in single-user modes are located under this directory.

Commands used by all the users of the system are located here.

/sbin -> System Binaries

Just like /bin, /sbin also contains binary executables.

But, the Linux commands located under this directory are used typically by the system administrators, for system maintenance purposes.

For example, iptables, reboot, fdisk, ifconfig, and swapon.

/dev -> Device Files

contains hardware device files.

Contains device files.

These include terminal devices, USB, or any device attached to the system.

For example: /dev/tty1, /dev/usbmon0.

/var -> Variable Files

The variable data files such as log files are located in the /var directory.

File contents that tend to grow are located in this directory. This includes:-

/var/log: System log files generated by OS and other applications.

/var/lib: Contains database and packages files.

/var/mail: Contains Emails.

/var/tmp: Contains temporary files needed for reboot.

/mnt -> Mount Directory

This directory is used to mount a file system temporarily.
/media -> Removable Media Devices

The /media directory contains subdirectories where removable media devices inserted into the computer are mounted.
/usr -> User Binaries

The /usr directory contains applications and files used by users, as opposed to applications and files used by the system.
/etc -> Configuration files

It contains all configuration files of the server.

The core configuration files are stored in the /etc directory. It controls the behavior of an operating system or application. This directory also contains startup and shutdown program scripts that are used to start or stop individual programs.

/boot -> Boot Loader Files

The /boot directory contains the files needed to boot the system.

For example, the GRUB bootloader's files and your Linux kernels are stored here.

/opt -> Optional Applications

The opt directory is used for installing the application software from third-party vendors that are not available in the Linux distribution. Usually, the software code is stored in the opt directory and the binary code is linked to the bin directory so that all users can run that software.
/home -> Home Directory

It contains the secondary user's home directory.
/tmp -> Temporary Files

A directory that contains temporary files created by the system and users.

Files under this directory are deleted when the system is rebooted.

Linux Architecture
In the Linux architecture, the two most important components are the shell and Kernel. The kernel is the one that gives commands to the hardware to perform necessary actions. On the other hand, the shell is used to access the kernel.

In simple words, the shell is used to communicate with the kernel using Linux commands, and based on these commands the kernel further orders the hardware to do so. Shell is used to get the kernel and the kernel is used to get the hardware.

Hardware includes several peripheral devices such as a CPU, HDD, and RAM.

Basic Commands
pwd -> It shows the present working directory.

Is -> It shows the available files and directory list in the current working directory.

uname -> It shows the name of the kernel (OS).

uname -r -> It shows the version of the kernel.

cd -> It is used to change the directory.

clear -> It is used for clearing the screen.

whoami -> It shows the current login user name.

history -> It shows a list of previously used commands.

date -> It shows the time and date.

Create a directory
To create a single directory.

Copy

mkdir dir_name
Enter fullscreen mode Exit fullscreen mode

To create multiple directories.

Copy

mkdir dir_name1 dir_name2 dir_name3
Enter fullscreen mode Exit fullscreen mode

To create a directory path (directory inside the directory).

Copy

mkdir -p dir1/dir2/dir3/dir4
Enter fullscreen mode Exit fullscreen mode

To create directories with serial-wise numbers.

Copy

mkdir dir{1..10}
Enter fullscreen mode Exit fullscreen mode

Create a file
To create a file.

Copy

touch file
Enter fullscreen mode Exit fullscreen mode

To create multiple files.

Copy

touch file1 file2 file3
Enter fullscreen mode Exit fullscreen mode

To create files with serial-wise numbers.

Copy

touch file{1..10}
Enter fullscreen mode Exit fullscreen mode

For copy & paste
To copy and paste files or directories.

Copy

cp <option> <source> <destination>
Enter fullscreen mode Exit fullscreen mode

Options :

-r or recursive

-v for verbose

-f for forcefully

For removing files and directory
For deleting files or directories.

Copy

rm -rvf file_name
rm -rvf dir_name
Enter fullscreen mode Exit fullscreen mode

For moving or renaming files & directory
To rename a file or directory.

Copy

mv old_name new_name
Enter fullscreen mode Exit fullscreen mode

To move a file, directory to another directory.

Copy

mv source_file destination
Enter fullscreen mode Exit fullscreen mode

User Management
For creating a user account.

Copy

useradd user_name
Enter fullscreen mode Exit fullscreen mode

For checking user account properties.

Copy

cat /etc/passwd
Enter fullscreen mode Exit fullscreen mode

For creating a user account password.

Copy

passwd user_name
Enter fullscreen mode Exit fullscreen mode

For checking user password properties.

Copy

grep user_name/etc/shadow
Enter fullscreen mode Exit fullscreen mode

For switching user accounts.

Copy

su user_name
Enter fullscreen mode Exit fullscreen mode

To log out from a user account.

Copy

exit
Enter fullscreen mode Exit fullscreen mode

Or press Ctrl + D key.

For Deleting a user account.

Copy

userdel user_name
Enter fullscreen mode Exit fullscreen mode

To change the user Login name.

Copy

usermod -l login_name old_name
Enter fullscreen mode Exit fullscreen mode

Group Management
In Linux, groups are collections of users. Creating and managing groups is one of the simplest ways to deal with multiple users simultaneously, especially when dealing with permissions. The /etc/group file stores group information and is the default configuration file.

To add a group account.

Copy

groupadd group_name
Enter fullscreen mode Exit fullscreen mode

To check group account property.

Copy

cat /etc/group
Enter fullscreen mode Exit fullscreen mode

For checking group admin property.

Copy

cat /etc/gshadow
Enter fullscreen mode Exit fullscreen mode

To delete a group.

Copy

groupdel group_name
Enter fullscreen mode Exit fullscreen mode

To add a single member to a group.

Copy

gpasswd -a user_name group_name
Enter fullscreen mode Exit fullscreen mode

To add multiple members to a group.

Copy

gpasswd -M user_name1,user_name2,user_name3 group_name
Enter fullscreen mode Exit fullscreen mode

To remove a group member.

Copy

gpasswd -d user_name group_name
Enter fullscreen mode Exit fullscreen mode

To make a group admin.

Copy

gpasswd -A user_name group_name
Enter fullscreen mode Exit fullscreen mode

Linux File System Permission
Type of File Permission

Basic Permission.

Special Permission.

Access Control List (ACL) Permission.

For checking file permission

Copy

ls -l file_name

For checking directory permissions

Copy

ls -ld dir_name

Permission in detail

There are 3 types of permission classes:-

User

Group

Other

Permission classes tell us about the permissions that users, group members, and other users have over that file/directory.

File type tells the type of file for eg. "d" stands for directory and "-" stands for file.

"r" stands for Read.

"w" stands for Write.

"x" stands for Execute.

Permission Set

Permission with numeric & symbol

For changing permissions

To add read permissions to the owner.

Copy

chmod u+r file_name
Enter fullscreen mode Exit fullscreen mode

To add read-write permissions to the group.

Copy

chmod g+rw file_name
Enter fullscreen mode Exit fullscreen mode

To remove read permission for others.

Copy

chmod o-r file_name
Enter fullscreen mode Exit fullscreen mode

For changing ownership

Copy

chown user_name file_name
chown user_name directory_name

For changing group ownership

Copy

chgrp group_name file_name
chgrp group_name directory_name

Set permissions with numeric values

r (read) = 4
w (write) = 2
x (execute) = 1

Copy

chmod 751 file_name

Access Control List (ACL)
Access control list (ACL) provides an additional, more flexible permission mechanism for file systems.

Access Control List is a service that provides special permission to specific users and groups for particular directories and files.

Use of ACL

Think of a scenario in which a particular user is not a member of the group created by you but still, wants to give some read or write access, how can you do it without making the user a member of the group, here comes in picture Access Control List, ACL helps us to do this trick.

For checking ACL permissions.

Copy

getfacl file_name
getfacl dir_name
Enter fullscreen mode Exit fullscreen mode

To set ACL permissions for the user.

Copy

setfacl -m user::rwx file_name
setfacl -m user::rwx dir_name
Enter fullscreen mode Exit fullscreen mode

To remove the ACL permissions for the user.

Copy

setfacl -x user:user_name file_name
setfacl -x user:user_name dir_name
Enter fullscreen mode Exit fullscreen mode

To set ACL permissions for the group.

Copy

setfacl -m group::rwx file_name
setfacl -m group::rwx dir_name
Enter fullscreen mode Exit fullscreen mode

To remove ACL permissions for the group.

Copy

setfacl -x group file_name
setfacl -x group dir_name
Enter fullscreen mode Exit fullscreen mode

To remove all the ACL permissions.

Copy

setfacl -b file_name
setfacl -b dir_name
Enter fullscreen mode Exit fullscreen mode

Regular Expressions
Regular expressions are special characters that help search data, matching complex patterns.

GREP (Global Regular Expression Print)

The grep filter searches a file for a particular pattern of characters and displays all the lines that contain that pattern.

Search a word (string in a file).

Copy

grep root /etc/passwd
Enter fullscreen mode Exit fullscreen mode

Search a string in multiple files.

Copy

grep root /etc/passwd /etc/group
Enter fullscreen mode Exit fullscreen mode

Search a string insensitively in a file.

Copy

grep -i RooT /etc/passwd
Enter fullscreen mode Exit fullscreen mode

Search a string in all files recursively.

Copy

grep -r root /
Enter fullscreen mode Exit fullscreen mode

Inverting the string match.

Copy

grep -v root /etc/passwd
Enter fullscreen mode Exit fullscreen mode

Display the total lines of the string matched.

Copy

grep -c root /etc/passwd
Enter fullscreen mode Exit fullscreen mode

Display the file names that match the string.

Copy

grep -l root /etc/passwd /etc/shadow
Enter fullscreen mode Exit fullscreen mode

Display the file names that do not contain the string.

Copy

grep -L root /etc/passwd /etc/shadow
Enter fullscreen mode Exit fullscreen mode

Displaying the string match line with a number.

Copy

grep -n root /etc/passwd
Enter fullscreen mode Exit fullscreen mode

Display the lines that start with a string.

Copy

grep ^root /etc/passwd
Enter fullscreen mode Exit fullscreen mode

Display the lines that end with a string.

Copy

grep /bin/bash$ /etc/passwd
Enter fullscreen mode Exit fullscreen mode

Search and redirect output in a new file.

Copy

grep root /etc/passwd > /home/ubuntu/grep.txt
Enter fullscreen mode Exit fullscreen mode

Find
The Linux Find Command is one of the most important and much-used commands in the Linux system. The find command is used to search and locate the list of files and directories based on conditions you specify for files that match the arguments. Find can be used in a variety of conditions you can find files by permissions, users, groups, file type, date, size, and other possible criteria.

Find files under /home directory.

Copy

find /home -name file_name
Enter fullscreen mode Exit fullscreen mode

Find files with suid permission.

Copy

find / -perm 4755
Enter fullscreen mode Exit fullscreen mode

Find files with guid permission.

Copy

find / -perm 2644
Enter fullscreen mode Exit fullscreen mode

Find files with sticky bit permission.

Copy

find / -perm 1755
Enter fullscreen mode Exit fullscreen mode

Find command based on user.

Copy

find / -user root
Enter fullscreen mode Exit fullscreen mode

Find commands based on the group.

Copy

find / -group group_name
Enter fullscreen mode Exit fullscreen mode

Search the file with less than IOMB in a folder.

Copy

find /tmp -size -10M
Enter fullscreen mode Exit fullscreen mode

Search the file with more than IOMB in a folder.

Copy

find /tmp -size +10M
Enter fullscreen mode Exit fullscreen mode

WC (Word Count)
The wc command is used for counting words and line numbers.

Count the number of lines.

Copy

wc -l /etc/passwd
Enter fullscreen mode Exit fullscreen mode

Count the number of words.

Copy

c -w /etc/passwd
Enter fullscreen mode Exit fullscreen mode

Head
Head command is used to display the top lines of a file.

Display the top 10 lines of a file.

Copy

head /etc/passwd
Enter fullscreen mode Exit fullscreen mode

Display top specific no line of the file.

Copy

head -n 15 /etc/passwd
Enter fullscreen mode Exit fullscreen mode

Tail
The tail command is used to display the bottom lines of a file.

Display the bottom 10 lines of the file.

Copy

tail /etc/passwd
Enter fullscreen mode Exit fullscreen mode

Display the bottom specific lines of a file.

Copy

tail -n 5 /etc/passwd
Enter fullscreen mode Exit fullscreen mode

Archive File in Linux
Archiving is a process of combining multiple files and directories (same or different sizes) into one file. The archive process is very useful for the backup and compression size of data in Linux.

What is Tar?

The Linux tar stands for tape archive, which is used by a large number of Linux/Unix system administrators to compress size or drive backup. To create an archive tar there're needed some compression algorithms such as gzip, bz2 and xz.

Tar command syntax.

Copy

tar

c - To create

x - To extract

v - To verbose

f - To forcefully

t - To test

z - To gzip

j - To bz2

J - To xz

C - To specific destination

To create a tar archive file.

Copy

tar -cvf /mnt/backup.tar /var
Enter fullscreen mode Exit fullscreen mode

To show file size in a human-readable format.

Copy

du -sh /var
du -sh /mnt/backup.tar
Enter fullscreen mode Exit fullscreen mode

To extract a tar archive file on the default location.

Copy

tar -xvf /mnt/backup.tar
Enter fullscreen mode Exit fullscreen mode

To extract a tar archive file on a specific location.

Copy

tar -xvf /mnt/backup.tar -C /root/Desktop/
Enter fullscreen mode Exit fullscreen mode

To create a tar archive file with compress in size (gzip).

Copy

tar -cvzf /mnt/backup.tar.gz /var
Enter fullscreen mode Exit fullscreen mode

To extract a tar archive file with compress in size (gzip).

Copy

tar -xvzf /mnt/backup.tar.gz
Enter fullscreen mode Exit fullscreen mode

To extract a tar archive file with compress in size (bzip2/bz2).

Copy

tar -xvjf /mnt/backup.tar.bz2
Enter fullscreen mode Exit fullscreen mode

To create a tar archive file with compress in size (xz).

Copy

tar -cvJf /mnt/backup.tar.xz /var
Enter fullscreen mode Exit fullscreen mode

To extract a tar archive file with compress in size (xz).

Copy

tar -xvJf /mnt/backup.tar.xz
Enter fullscreen mode Exit fullscreen mode

Job Automation
Job automation allows us to perform tasks automatically in OS by using tools.

This feature is very useful for the administrator to assign the task to OS whenever he is not present or performs daily basis work.

Two types of job automation

at - at command is used to execute a job only one time.

crontab - Crontab command is used to execute jobs multiple times.

To set a job with at command.

Copy

date
8:10 AM
at > useradd shub
at > 
#Ctrl+d (write & quit)
Enter fullscreen mode Exit fullscreen mode

To show pending at job.

Copy

atq
Enter fullscreen mode Exit fullscreen mode

To remove at job.

Copy

atrm 2
Enter fullscreen mode Exit fullscreen mode

To restrict a user from accessing at.

Copy

vim /etc/at.deny
Shub (add here user name)
:wq #(write&quit)
Enter fullscreen mode Exit fullscreen mode

Cronjob:-

To start a crond service.

Copy

systemctl start crond
Enter fullscreen mode Exit fullscreen mode

To enable a crond service (Permanent on).

Copy

systemctl enable crond
Enter fullscreen mode Exit fullscreen mode

To set cron jobs.

Copy

crontab -e
Enter fullscreen mode Exit fullscreen mode

To show the cronjobs of the current user.

Copy

crontab -l
Enter fullscreen mode Exit fullscreen mode

To remove the cron jobs.

Copy

crontab -r
#Or go to the crontab file and remove job line
crontab -e
Enter fullscreen mode Exit fullscreen mode

To set a cronjob to other users.

Copy

crontab -u shub -e
Enter fullscreen mode Exit fullscreen mode

To show the cronjob, other users

Copy

crontab -u shub -l
Enter fullscreen mode Exit fullscreen mode

To restrict users from crond service.

Copy

vim /etc/cron.deny
Enter fullscreen mode Exit fullscreen mode

To check the crontab log file.

Copy

tail -f /var/log/cron
Enter fullscreen mode Exit fullscreen mode

Sudo Command
What is sudo?

Sudo ("superuser do", or "switch user do") allows a user with proper permissions to execute a command as another user, such as the superuser.

Sudo allows a permitted user to execute a command as another user, according to specifications in the /etc/sudoers file.

Wheel group
A wheel is a system group that by default has sudo privileges, if we add any member to that group then that user got sudo privileges.

By default, all the members of the wheel group got sudo privileges.

Introduction In DevOps, Linux mastery is an essential skill. From infrastructure automation to continuous deployment, Linux drives most contemporary development environments. This guide discusses the key Linux skills for DevOps professionals.

Linux is an open-source operating system that is highly stable, secure, and flexible. Linux finds extensive applications in servers, desktops, and embedded systems. Linux has excellent performance, optimal resource utilization, and has a variety of distributions such as Ubuntu, Fedora, and CentOS. Its open-source model supports innovation and customization, and it is hence very popular among developers, IT specialists, and DevOps engineers

Why Linux for DevOps?

Open Source and Cost-Effective

Stability and Performance

Powerful Command Line Interface (CLI)

Automation and Scripting

Containerization and Orchestration Support

Strong Security Features

Cloud and Server Dominance

Flexibility in Environment Management

Wide Community Support

Popular DevOps Tools are Native to Linux

Advantages of Linux for DevOps:
Open Source & Affordable: Linux is open-source and free, highly customizable for DevOps environments without any licensing fees.

Strong Command Line Interface (CLI): The terminal in Linux provides strong utilities such as grep, awk, and sed, which simplify automation and scripting.

Stability & Dependability: Linux is famous for its solid performance, particularly in server environments, with little downtime.

Compatibility with DevOps Tools: Popular DevOps tools like Docker, Kubernetes, Jenkins, and Ansible are built to operate natively on Linux.

Security Features: Linux supports robust security features such as file permissions, roles for users, and inbuilt firewall functionality.

Automation Support: Linux offers shell scripting and support for automation tools, making automation of tasks easier.

Containerization & Virtualization: Native container support (e.g., Docker) and support for lightweight virtualization in Linux is vital to DevOps workflow.

Community Support: Linux has a large community of developers, providing comprehensive support for troubleshooting and enhancement.

Effective Package Management: Utilizing tools such as apt, yum, and dnf makes software installation, updates, and dependency management easy.

Remote Management: SSH (Secure Shell) support in Linux provides easy remote server management for DevOps teams.

Linux and Operating System Foundations:
Key Concepts Resource Management and Allocation How the OS allocates and manages CPU, memory, I/O devices, and processes.
File Management Hierarchical file systems, permissions, and file operations.

Device Management Managing hardware via device drivers.

Security Authentication, authorization, user roles, and access control.

Networking Network configuration, protocols, and services in Linux.

Multi-user and Multitasking in Linux How Linux supports multiple users and processes at once.

An Operating System's Components Kernel The central part of Linux that deals with hardware and system calls.
Application Layer Graphical User Interfaces (GUIs) and Command Line Interfaces (CLIs) that are utilized to communicate with the OS.

Interaction with the Kernel Through system calls, shell commands, and APIs.

Briefing on the Big 3 Operating Systems Windows, macOS, and Linux: A Comparison
User interface

File system

Customizability

System performance

Client OS vs. Server OS Use case differences, performance tuning differences, and feature differences.

Why Linux is Used in DevOps

Open-source and free

Stability and performance

Scripting and automation capabilities

Massive community and toolset (e.g., Docker, Kubernetes, Ansible).

Linux Commands That Every DevOps Engineer Should Know
As a DevOps engineer, mastering certain Linux commands is essential for efficient system administration, automation, and troubleshooting. Here are some crucial Linux commands that every DevOps engineer should know:

File and Directory Management
ls: List files and directories.

cd: Change the current directory.

pwd: Print the current working directory.

mkdir: Create a new directory.

rm: Remove files and directories.

cp: Copy files and directories.

mv: Move or rename files and directories.

find: Search for files and directories.

chmod: Change file permissions.

chown: Change file ownership.

chgrp: Change file group ownership.

  1. Text Manipulation and Viewing

cat: Concatenate and display file contents.

grep: Search for patterns in files.

head: Display the beginning of a file.

tail: Display the end of a file.

less: View file contents interactively.

sed: Stream editor for text manipulation.

awk: Text processing and data extraction tool.

  1. Process and System Management

ps: View running processes.

top: Monitor system resources and processes in real-time.

kill: Terminate processes.

systemctl: Manage system services.

service: Control system services (older Linux distributions).

df: Display disk space usage.

du: Estimate file and directory disk usage.

free: Display system memory usage.

uptime: Show system uptime and load averages.

  1. Networking

ping: Send ICMP echo requests to a host.

curl or wget: Download files from the web.

ssh: Securely connect to remote systems.

scp: Securely copy files between systems.

netstat: Network statistics and connections.

ifconfig or ip: Network interface configuration.

iptables or ufw: Firewall configuration.

  1. Package Management

apt (Debian/Ubuntu) or yum (CentOS/RHEL): Package management commands for installing, updating, and removing software packages.

dpkg (Debian/Ubuntu) or rpm (CentOS/RHEL): Package management commands for querying package information and managing individual packages.

  1. Compression and Archiving

tar: Create and extract tar archives.

gzip, gunzip, bzip2, unzip: Compress and decompress files.

zip: Create and extract ZIP archives.

πŸ“‚ 1. Listing Commands (ls)
ls β†’ πŸ“‹ List files and directories.

ls -l β†’ πŸ“œ Detailed list with permissions, size, owner, etc.

ls -a β†’ πŸ‘€ Show hidden files.

ls -lh β†’ πŸ“ Human-readable file sizes.

ls -d */ β†’ πŸ“ List only directories.

ls *.sh β†’ πŸ› οΈ Show only .sh files.

πŸ”Ή Example:

Copy

ls -lh
ls -a

πŸ“ 2. Directory Commands
pwd β†’ πŸ“Œ Show current directory path.

cd folder β†’ πŸ”„ Change directory.

cd .. β†’ ⬆️ Move one level up.

cd - β†’ πŸ”™ Switch to previous directory.

cd ~ β†’ 🏠 Go to the home directory.

πŸ“‚ Creating Directories (mkdir)
mkdir newFolder β†’ πŸ—οΈ Create a new folder.

mkdir .NewFolder β†’ πŸ‘€ Create a hidden folder.

mkdir A B C D β†’ πŸ“‚ Create multiple folders at once.

mkdir /home/user/Mydirectory β†’ πŸ“ Create a folder in a specific location.

mkdir -p A/B/C/D β†’ πŸ”€ Create nested directories.

πŸ”Ή Example:

Copy

mkdir newFolder
mkdir .NewFolder
mkdir A B C D
mkdir /home/user/Mydirectory
mkdir -p A/B/C/D

πŸ“‚ Deleting Directories (rmdir, rm -r)
rmdir folder β†’ ❌ Remove empty directory.

rm -r folder β†’ 🚨 Remove non-empty directory.

πŸ”Ή Example:

Copy

rmdir emptyFolder
rm -r oldFolder

πŸ“„ 3. File Management
touch file.txt β†’ πŸ“„ Create a new empty file.

cat file.txt β†’ πŸ“– View file content.

cp file1 file2 β†’ πŸ“‘ Copy file.

mv old new β†’ ✏️ Rename/move file.

rm file.txt β†’ ❌ Delete a file.

vim file.txt β†’ ✍️ Open file in the Vim text editor.

πŸ”Ή Example:

Copy

touch notes.txt
cp notes.txt backup.txt
rm unwanted.txt
vim myfile.txt

πŸ”Ž 4. Searching Files & Text
find /path -name filename β†’ πŸ” Find file by name.

grep "word" file.txt β†’ πŸ”Ž Search inside a file.

πŸ”Ή Example:

Copy

find /home -name "notes.txt"
grep "error" log.txt

βš™οΈ 5. System & Process Management
df -h β†’ πŸ’Ύ Check disk space.

free -m β†’ πŸ”‹ Check RAM usage.

top β†’ πŸ“Š View real-time system processes.

kill PID β†’ ❌ Stop a process of mentioned process ID (PID).

πŸ”Ή Example:

Copy

df -h
top
kill 1234

Top comments (2)

Collapse
 
maame-codes profile image
Maame Afua A. P. Fordjour

This is a life-saver for those of us moving from a GUI-world into the terminal. The Linux Architecture section (Shell vs. Kernel) really clears up the 'why' behind the commands. It’s one thing to run chmod 751, but it’s another to understand that we’re actually communicating with the Kernel to manage hardware access. Saving this for my next late-night debugging session

Collapse
 
kasim_hussain_5f389fb5097 profile image
Kasim Hussain

thnx :)