0% found this document useful (0 votes)
49 views19 pages

Welcome To LINUX World

Uploaded by

abidmohd253
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views19 pages

Welcome To LINUX World

Uploaded by

abidmohd253
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Welcome to LINUX World

Operating System (OS) Overview


• An Operating System (OS) is software that acts as an interface between computer
hardware components and users.
• Every computer must have at least one operating system to run other programs.
• The operating system provides a platform/environment to run applications, such as a
browser, notepad, MS Paint, calculator, etc.
• The operating system helps us communicate with the computer without knowing how
to code in a computer language.
• Note: We can't use a computer without having an OS.

History of OS
• Operating systems were developed in the 1950s. General Motors' research lab
implemented the first OS in the early 1950s for their IBM 701.
• In the mid-1960s, operating systems started using disks. In the late 1960s, the UNIX
operating system was developed.
• The first OS developed by Microsoft was MS-DOS, released in 1981.
• In 1985, the first operating system with a GUI (Graphical User Interface) was
released.
• We commonly use the Windows operating system on our computers and laptops.
• Windows OS is recommended for personal use.
• Windows is a single-user-based operating system.
• In real-time environments, we often use the Linux OS to run our applications.

Advantages of LINUX
• Linux is free and open source.
• Linux is a multi-user-based operating system.
• Linux is a highly secure operating system.

Explanation of the Linux User Scenario


• Servers might be present in the USA, but a developer can access those servers' OS
from India at any time due to Linux's capabilities.
• Multiple users can connect to a Linux machine simultaneously, which is why it is
called a multi-user-based operating system.
• AWS engineers or cloud engineers will set up Linux machines in the cloud.
• DevOps engineers will deploy our applications on the servers running on Linux OS.
• Developers will connect to Linux machines to check server/application logs.
History of LINUX
• In 1991, a student named Linus Torvalds developed the Linux OS.
• Linus Torvalds identified some challenges in the UNIX OS and suggested some
changes, but the UNIX OS team rejected his suggestions.
• Linus Torvalds used Minix OS to develop Linux:
o Linus + Minix
o The first two letters from his name and the last three letters from Minix OS:
▪ LI + NUX = LINUX
• Linus Torvalds released Linux OS with its source code to the market, allowing
anyone to modify Linux OS. That's why it is called an open-source operating system.
• As Linux OS is open source, many people and companies have taken Linux OS,
modified it according to their requirements, and released it into the market with
different names called Linux distributions:
o RHEL (Red Hat Enterprise Linux)
o Ubuntu
o CentOS
o Fedora
o OpenSUSE
o Kali Linux
o Debian

Environment Setup of Linux by AWS EC2 Using MobaXterm


Setting up a Linux environment on AWS EC2 using MobaXterm involves several steps, from
creating an AWS account to launching and accessing your EC2 instance. Here is a detailed
guide:

Step 1: Create an AWS Account

1. Visit AWS: Go to the AWS website and click on "Create an AWS Account."
2. Sign Up: Provide your email address and choose a password. Follow the prompts to
complete the registration, including entering payment information. AWS offers a free
tier for new users for the first 12 months.
3. Verify Account: AWS will send a verification email. Verify your account to activate
it.

Step 2: Access the AWS Management Console

1. Login: Go to the AWS Management Console and sign in with your AWS credentials.
2. Navigate to EC2: In the search bar, type "EC2" and select it from the dropdown. This
will take you to the EC2 Dashboard.

Step 3: Launch an EC2 Instance


1. Launch Instance: Click on the "Launch Instance" button on the EC2 Dashboard.
2. Choose an Amazon Machine Image (AMI): Select an AMI that is Linux-based. The
most common choice is "Amazon Linux 2 AMI."
3. Choose an Instance Type: For basic setups, the "t2.micro" instance is suitable and
falls under the free tier.
4. Configure Instance Details:
o Set the number of instances to 1.
o Ensure the default network settings are selected.
o You can leave other settings as default for basic setups.
5. Add Storage: The default settings usually suffice. The free tier includes 30 GB of
EBS (Elastic Block Store) storage.
6. Add Tags: Optionally, add tags to your instance for better management. For example,
add a "Name" tag with the value "MyLinuxInstance."
7. Configure Security Group:
o Create a new security group or select an existing one.
o Add a rule to allow SSH (port 22) from your IP address. You can find your IP
address by searching "What is my IP" in a browser.
8. Review and Launch: Review all settings and click "Launch."
9. Key Pair: Create a new key pair or use an existing one. Download the private key file
(.pem) and keep it secure. This file is used to access your instance.

Step 4: Access Your EC2 Instance Using MobaXterm

1. Download MobaXterm: If you haven't already, download and install MobaXterm


from the official website.
2. Launch MobaXterm: Open MobaXterm on your local machine.
3. Create a New Session:
o Click on the "Session" button in the top left corner.
o Select "SSH" as the session type.
4. Configure SSH Session:
o In the "Remote host" field, enter the Public DNS (IPv4) of your EC2 instance.
You can find this in the EC2 Dashboard under "Instances."
o Ensure the "Specify username" option is checked and enter ec2-user (or the
appropriate username for your AMI).
o Click on the "Advanced SSH settings" tab.
o In the "Use private key" field, click the file browser button and select your
downloaded .pem file.
5. Start the Session: Click "OK" to start the session. MobaXterm will use the provided
information to connect to your EC2 instance.
6. Accept Key Fingerprint: The first time you connect, you'll be asked to accept the
server's key fingerprint. Type yes and press Enter.
7. Connected: You should now be connected to your EC2 instance via SSH using
MobaXterm. You can start running Linux commands and managing your instance.
Explanation of EC2 Service
Amazon EC2 (Elastic Compute Cloud) is a web service that provides secure, resizable
compute capacity in the cloud. It is designed to make web-scale cloud computing easier for
developers.

Key Features of EC2

• Scalability: Easily scale up or down based on your requirements.


• Flexibility: Choose from a wide variety of instance types optimized for different use
cases.
• Pay-As-You-Go: Pay only for the compute time you use, making it cost-effective.
• Security: Provides secure login information for instances using key pairs. Security
groups act as a firewall to control traffic to instances.
• Variety of Operating Systems: Supports multiple operating systems including
various Linux distributions and Windows Server.

Common Use Cases

• Web Hosting: Hosting websites and web applications.


• Big Data Processing: Running big data applications like Hadoop and Spark.
• Development and Testing: Setting up development and test environments quickly.
• High-Performance Computing (HPC): Running high-performance computing
applications.

With these steps and explanations, you should be able to set up and understand the basics of a
Linux environment on AWS EC2, leveraging the powerful features of EC2 to meet your
computing needs.

Summary
This guide has covered the essential aspects of setting up a Linux environment on AWS EC2,
including:

• Creating an AWS account.


• Launching an EC2 instance.
• Accessing your instance using MobaXterm.
• Understanding the features and use cases of Amazon EC2.
• By following these steps, you'll be well on your way to effectively using AWS EC2
for your Linux-based projects and applications.
Comprehensive List of Linux Commands for DevOps

Basic Linux Commands

1. $ pwd
o Description: Print Working Directory.
o Usage: pwd
o Example: Displays the current directory path.
2. $ ls
o Description: List directory contents.
o Usage: ls [options] [directory]
o Options:
▪ -a: Include hidden files.
▪ -l: Long listing format.
▪ -h: Human-readable sizes.
▪ -r: Reverse order.
▪ -t: Sort by modification time.
▪ -R: Recursively list subdirectories.
o Examples:
▪ ls -l: Long listing format.
▪ ls -r: List in reverse order.
▪ ls -t: Sort by modification time.
▪ ls -lt: Long listing, sorted by modification time.
▪ ls -rt: Reverse order, sorted by modification time.
▪ ls -a: Include hidden files.
▪ ls -li: List with inode number.
▪ ls -R: Recursively list subdirectories.
▪ ls -lR: Long listing format, recursively.
3. $ cd
o Description: Change Directory.
o Usage: cd [directory]
o Example: cd /var/log
4. $ cp
o Description: Copy files and directories.
o Usage: cp [options] source destination
o Options:
▪ -r: Recursive copy (for directories).
o Example: cp file1.txt /tmp
5. $ mv
o Description: Move/rename files and directories.
o Usage: mv [options] source destination
o Example: mv oldname.txt newname.txt
6. $ rm
o Description: Remove files or directories.
o Usage: rm [options] file
o Options:
▪ -r: Recursive (for directories).
▪ -f: Force deletion.
o Example: rm -rf /tmp/testdir
7. $ mkdir
o Description: Create directories.
o Usage: mkdir [options] directory
o Options:
▪ -p: Create parent directories as needed.
o Example: mkdir -p /tmp/testdir
8. $ rmdir
o Description: Remove empty directories.
o Usage: rmdir directory
o Example: rmdir /tmp/testdir
9. $ touch
o Description: Create empty files or update the timestamp of existing files.
o Usage: touch filename
o Example: touch newfile.txt
10. $ cat
o Description: Concatenate and display files.
o Usage: cat [options] file
o Example: cat /etc/passwd
11. $ tac
o Description: Concatenate and display files in reverse.
o Usage: tac file
o Example: tac /etc/passwd
12. $ rev
o Description: Reverse lines characterwise.
o Usage: rev file
o Example: rev /etc/passwd
13. $ more
o Description: View file contents one page at a time.
o Usage: more filename
o Example: more /etc/passwd
14. $ less
o Description: View file contents with backward/forward navigation.
o Usage: less filename
o Example: less /var/log/syslog
15. $ head
o Description: Display the first lines of a file.
o Usage: head [options] file
o Options:
▪ -n N: Show the first N lines.
o Example: head -n 10 /var/log/syslog
16. $ tail
o Description: Display the last lines of a file.
o Usage: tail [options] file
o Options:
▪ -n N: Show the last N lines.
▪ -f: Follow the file (useful for logs).
o Example: tail -f /var/log/syslog
17. $ chmod
o Description: Change file modes or Access Control Lists (ACLs).
o Usage: chmod [options] mode file
o Options:
▪ u: User.
▪ g: Group.
▪ o: Others.
o Example: chmod 755
18. $ chown
o Description: Change file owner and group.
o Usage: chown [options] owner[:group] file
o Example: chown root:root /var/www/html
19. $ df
o Description: Report file system disk space usage.
o Usage: df [options]
o Options:
▪ -h: Human-readable format.
o Example: df -h
20. $ du
o Description: Estimate file space usage.
o Usage: du [options] [directory]
o Options:
▪ -h: Human-readable format.
▪ -s: Summary of directory usage.
o Example: du -sh /var/log
21. $ find
o Description: Search for files in a directory hierarchy.
o Usage: find [path] [expression]
o Example: find /var -name "*.log"
22. $ grep
o Description: Print lines matching a pattern.
o Usage: grep [options] pattern [file]
o Options:
▪ -i:Ignore case.
▪ -R: Recursive search.
▪ -c: Count the number of matches.
▪ -n: Show line numbers with output lines.
▪ -l: List filenames containing the pattern.
▪ -h: Suppress filename in output.
o Examples:
▪ grep -i "error" /var/log/syslog: Ignore case.
▪ grep -R "error" /var/log: Recursive search.
▪ grep -c "error" /var/log/syslog: Count matches.
▪ grep -n "error" /var/log/syslog: Show line numbers.
▪ grep -l "error" /var/log/*: List filenames containing the pattern.
▪ grep -h "error" /var/log/syslog: Suppress filename in output.
23. $ diff
o Description: Compare files line by line.
o Usage: diff [options] file1 file2
o Example: diff file1.txt file2.txt
24. $ ps
o Description: Report a snapshot of current processes.
o Usage: ps [options]
o Options:
▪ -e: All processes.
▪ -f: Full format listing.
o Example: ps -ef
25. $ top
o Description: Display tasks and system resource usage.
o Usage: top
o Example: Shows real-time system processes and resource usage.
26. $ kill
o Description: Send a signal to a process.
o Usage: kill [options] pid
o Example: kill 1234
27. $ history
o Description: Show command history.
o Usage: history
o Example: Displays previously executed commands.
28. $ sudo
o Description: Execute a command as another user (usually root).
o Usage: sudo command
o Example: sudo apt-get update
29. $ apt-get
o Description: APT package handling utility (for Debian-based systems).
o Usage: apt-get [options] command
o Example: sudo apt-get install nginx
30. $ yum
o Description: Package manager (for Red Hat-based systems).
o Usage: yum [options] command
o Example: sudo yum install httpd

Advanced Linux Commands

1. $ awk
o Description: Pattern scanning and processing language.
o Usage: awk 'pattern {action}' file
o Example: awk '{print $1}' /etc/passwd
2. $ sed
o Description: Stream editor for filtering and transforming text.
o Usage: sed [options] 'script' file
o Example: sed 's/old/new/g' file.txt
3. $ tar
o Description: Archive files.
o Usage: tar [options] [archive] [file/directory]
o Options:
▪ -c: Create an archive.
▪ -x: Extract an archive.
▪ -v: Verbose mode.
▪ -f: File name.
▪ -z: Compress with gzip.
▪ -j: Compress with bzip2.
o Examples:
▪ tar -czvf archive.tar.gz /path/to/directory
▪ tar -xzvf archive.tar.gz
4. $ gzip
o Description: Compress files.
o Usage: gzip [options] file
o Example: gzip file.txt
5. $ gunzip
o Description: Decompress files.
o Usage: gunzip [options] file
o Example: gunzip file.txt.gz
6. $ iptables
o Description: Administration tool for IPv4 packet filtering and NAT.
o Usage: iptables [options]
o Example: sudo iptables -L
7. $ docker
o Description: Manage Docker containers.
o Usage: docker [command]
o Commands:
▪ docker run: Run a container.
▪ docker ps: List running containers.
▪ docker stop: Stop a running container.
o Example: docker run -d nginx
8. $ kubectl
o Description: Kubernetes command-line tool.
o Usage: kubectl [command]
o Commands:
▪ kubectl get: List resources.
▪ kubectl apply: Apply a configuration to a resource.
▪ kubectl delete: Delete resources.
o Example: kubectl get pods
9. $ ansible
o Description: Automation tool for managing servers.
o Usage: ansible [command]
o Commands:
▪ ansible-playbook: Run an Ansible playbook.
▪ ansible-inventory: Display or dump the configured inventory.
o Example: ansible-playbook site.yml
10. $ git
o Description: Version control system.
o Usage: git [command]
o Commands:
▪ git clone: Clone a repository.
▪ git commit: Commit changes.
▪ git push: Push changes to a remote repository.
o Example: git clone
11. $ vagrant
o Description: Tool for building and managing virtualized development
environments.
o Usage: vagrant [command]
o Commands:
▪ vagrant init: Initialize a Vagrant environment.
▪ vagrant up: Start the Vagrant environment.
▪ vagrant halt: Stop the Vagrant environment.
o Example: vagrant up
12. $ terraform
o Description: Infrastructure as code tool.
o Usage: terraform [command]
o Commands:
▪ terraform init: Initialize a configuration.
▪ terraform apply:
Apply changes.
▪ terraform destroy: Destroy the infrastructure.
o Example: terraform apply

Command Combinations and Utilities


1. Combining Commands with Pipes (|)
o Example: ps -ef | grep nginx
o Description: List all processes and filter for nginx.
2. Using Redirection (>, >>, <)
o Example: ls -l > filelist.txt
o Description: Save the output of ls -l to filelist.txt.
o Example: cat file1.txt >> file2.txt
o Description: Append the contents of file1.txt to file2.txt.
3. Chaining Commands with &&
o Example: mkdir newdir && cd newdir
o Description: Create a new directory and change into it.
4. Using Subshells with ()
o Example: (cd /tmp && ls)
o Description: Change to /tmp, list files, and return to the original directory.
5. Command Substitution with $()
o Example: echo "The date is $(date)"
o Description: Insert the output of date into the echo statement.

By understanding these commands and their possibilities, you'll be well-equipped to perform


a wide range of tasks in a Linux environment, from basic file operations to advanced system
administration and DevOps workflows.

Working with Text Editors in Linux

VI Editor

The VI editor is a powerful text editor available on most Unix-like systems. It operates in
different modes, each serving a specific purpose. Here's a detailed guide to using VI:

VI Modes

1. Normal Mode: This is the default mode when you open VI. In this mode, you can
navigate the file, delete text, and perform other editing tasks.
2. Insert Mode: In this mode, you can insert text into the file. You switch to this mode
from Normal mode.
3. Visual Mode: This mode allows you to select text.
4. Command-Line Mode: Used for executing commands like saving and quitting.

Switching Between Modes

• Normal Mode to Insert Mode:


o Press i to insert text before the cursor.
o Press I to insert text at the beginning of the line.
o Press a to append text after the cursor.
o Press A to append text at the end of the line.
• Insert Mode to Normal Mode:
o Press Esc to return to Normal mode.
• Normal Mode to Visual Mode:
o Press v to start visual selection.
o Press V for line-wise visual selection.
• Normal Mode to Command-Line Mode:
o Press : to enter Command-Line mode.

Example: Creating and Editing a File with VI


1. Create a File:
2. Insert Text:
o Press i to enter Insert mode.
o Type your text.
o Press Esc to return to Normal mode.
3. Save and Exit:
o Press : to enter Command-Line mode.
o Type wq (write and quit) and press Enter.
4. Navigating Text:
o k: Move up one line.
o j: Move down one line.
o h: Move left one character.
o l: Move right one character.
o $: Move to the end of the line.

Using sed Command

sed is a stream editor used for parsing and transforming text. It processes input line by line
and applies specified commands to each line.

Basic Syntax

sed [options] 'command' file


Common Commands and Options

1. Substitute (s)
o Description: Replaces the first occurrence of pattern with replacement in
each line.
o Example: Replace apple with orange.

sed 's/apple/orange/' file

o Global Replacement (g): Replaces all occurrences in each line.

sed 's/apple/orange/g' file

o Case-Insensitive Replacement (I): Makes the search case-insensitive.

sed 's/apple/orange/I' file

o Only the Nth Occurrence (N): Replaces only the Nth occurrence.

sed 's/apple/orange/2' file

2. Delete (d)
o Description: Deletes lines that match the pattern.
o Example: Delete lines containing error.

sed '/error/d' file

o Delete Specific Line: Deletes a specific line number.

sed '3d' file

3. Print (p)
o Description: Prints lines that match the pattern.
o Example: Print lines containing warning.

sed -n '/warning/p' file

4. Append (a)
o Description: Appends text after lines that match the pattern.
o Example: Append End of file after lines containing EOF.

sed '/EOF/a\End of file' file

5. Insert (i)
o Description: Inserts text before lines that match the pattern.
o Example: Insert Start of file before lines containing HEADER.

sed '/HEADER/i\Start of file' file

6. Change (c)
o Description: Replaces lines that match the pattern with text.
o Example: Replace lines containing old_text with new_text.

sed '/old_text/c\new_text' file

7. Transform (y)
o Description: Replaces characters in old_chars with corresponding characters
in new_chars.
o Example: Replace characters abc with 123.

sed 'y/abc/123/' file

8. Print Line Numbers (=)


o Description: Prints line numbers along with lines.
o Example: Print line numbers for all lines.

sed '=' file

9. Replace and Save (-i)


o Description: Edits files in place (saves changes to the file).
o Example: Replace foo with bar and save the changes.

sed -i 's/foo/bar/g' file

Advanced Usage

1. Multiple Commands
o Description: Applies multiple sed commands to each line.
o Example: Replace foo with bar, then delete lines containing baz.

sed -e 's/foo/bar/g' -e '/baz/d' file

2. Address Ranges
o Description: Applies commands only within the specified range of lines.
o Example: Replace apple with orange from lines 2 to 5.

sed '2,5s/apple/orange/g' file

3. Using Patterns
o Description: Applies commands only to lines matching pattern.
o Example: Replace foo with bar only on lines containing baz.

sed '/baz/s/foo/bar/g' file

4. In-place Editing with Backup


o Description: Edits files in place with a backup of the original file.
o Example: Replace foo with bar and keep a backup of the original file.

sed -i.bak 's/foo/bar/g' file

Summary
• sed is a powerful tool for text processing, offering various commands to search,
replace, delete, and manipulate text.
• Understanding sed commands can simplify text processing tasks and automate
transformations.

File Permissions in Linux


File permissions determine who can read, write, or execute a file. Permissions are represented
by the characters r, w, and x, and are applied to the file owner, group, and others. Each
permission allows different types of access and actions on the file.

Permission Symbols

1. r (Read)
o Description: Grants the ability to view the contents of the file.
o Access: When read permission is granted, users can open and view the file's
content but cannot modify it.
o Usage Example: To list the contents of a file or to view a configuration file,
the read permission is necessary.
2. w (Write)
o Description: Allows modification of the file's content.
o Access: Users with write permission can change or overwrite the file's
content. This includes adding or deleting data within the file.
o Usage Example: To edit a text file or update a configuration file, write
permission is required.
3. x (Execute)
o Description: Enables running the file as a program or script.
o Access: When execute permission is granted, users can run the file if it is a
script or binary executable. This does not grant permission to modify or view
the file's content.
o Usage Example: To run a shell script or a compiled program, execute
permission is needed.
Permission Combinations

Permissions are applied to three categories:

• Owner (user): The file's owner, who can be granted any combination of r, w, and x
permissions.
• Group: Users who are members of the file's group, with permissions that can differ
from the owner.
• Others: All other users, with permissions that can be set separately from the owner
and group.

Examples of Permission Combinations

• r-- (Read Only)


o Grants read access to the file but not write or execute permissions.
o Users can open and view the file’s content but cannot modify or run it.
• rw- (Read and Write)
o Grants read and write access to the file, but not execute permission.
o Users can view and modify the file’s content but cannot run it as a script or
program.
• r-x (Read and Execute)
o Grants read and execute access but not write permission.
o Users can view the file’s content and execute it (if it is a script or program) but
cannot modify it.
• rw-x (Read, Write, and Execute)
o Grants full access: read, write, and execute.
o Users can view, modify, and run the file.

Numeric Permissions and Their Symbolic Equivalents


In Linux, file permissions are also represented numerically using octal values (0-7), which
correspond to the combination of r, w, and x permissions:

• 0 - No Permissions (---): No access to the file.


• 1 - Execute Only (--x): Only execute permission granted.
• 2 - Write Only (-w-): Only write permission granted.
• 3 - Write and Execute (-wx): Both write and execute permissions granted.
• 4 - Read Only (r--): Only read permission granted.
• 5 - Read and Execute (r-x): Both read and execute permissions granted.
• 6 - Read and Write (rw-): Both read and write permissions granted.
• 7 - Read, Write, and Execute (rwx): All permissions granted.

Combining Permissions
Permissions are specified for three categories (owner, group, others) and are combined into a
single octal number. For example:

• chmod 755 filename translates to rwxr-xr-x:


o Owner: rwx (Read, Write, Execute)
o Group: r-x (Read, Execute)
o Others: r-x (Read, Execute)
• chmod 644 filename translates to rw-r--r--:
o Owner: rw- (Read, Write)
o Group: r-- (Read)
o Others: r-- (Read)

Understanding these permissions helps in correctly setting file access controls to ensure
appropriate access levels are granted to different users.

Working with User Accounts in Linux


Creating a User Account to create a new user account,
use: sudo useradd username
Options:

• -m: Create a home directory.


• -s: Specify the shell (e.g., /bin/bash).
• -G: Add the user to additional groups.

Example: sudo useradd -m -s /bin/bash -G sudo username

Deleting a User Account to delete a user account,


use: sudo userdel username
Options:

• -r: Remove the home directory and mail spool.

Example: sudo userdel -r username


Renaming a User Account to rename a user account,
use: sudo usermod -l newusername oldusername
Options:

• -l: Specify the new login name.

Changing a User’s Password To change a user’s password,


use: sudo passwd username

Listing User Account to list all user accounts,


view the /etc/passwd file:cat /etc/passwd Or
use: cut -d: -f1 /etc/passwd

Working with Groups in Linux


Creating a Group to create a new group,
use: sudo groupadd groupname

Deleting a Group to delete a group,


use: sudo groupdel groupname

Renaming a Group to rename a group,


use: sudo groupmod -n newgroupname oldgroupname
Options:

• -n: Specify the new group name.

Adding a User to a Group to add a user to a group,


use: sudo usermod -aG groupname username
Options:

• -aG: Append the user to the specified group.

Removing a User from a Group to remove a user from a group,


use: sudo gpasswd -d username groupname

Listing Group Members to list the members of a group,


use: getent group groupname
Working with Find and Locate Commands
Find Command Searches for files and directories within a directory hierarchy.
Basic Syntax: find [path] [options] [expression]Examples:

• Find files by name: find /path/to/search -name filename


• Find files by type (e.g., directories): find /path/to/search -type d
• Find files by size: find /path/to/search -size +1G
• Find files modified in the last 7 days: find /path/to/search -mtime -7

Locate Command Finds files by name using a pre-built index database.


Basic Syntax: locate [filename]
Examples:

• Locate a file: locate filename


• Update the database: sudo update db

Common Network and System Commands


Ping Command Checks the reachability of a host on a network.
Basic Syntax: ping [hostname or IP address]
Example: ping
Man Command Displays the manual pages for commands.
Basic Syntax: man [command]
Example: man ls
Curl Command Transfers data from or to a server using various protocols.
Basic Syntax: curl [options] [URL]
Examples:

• Fetch a webpage: curl


• Download a file: curl -O

Wget Command Retrieves files from the web.


Basic Syntax: wget [options] [URL]
Examples:

• Download a file: wget


• Download a file and save it under a different name: wget -O newfile.txt

You might also like