0% found this document useful (0 votes)
15 views3 pages

Linux and Grep Commands

This document provides a comprehensive list of essential Linux and grep commands for various tasks including file management, viewing and editing files, managing permissions, system processes, networking, and package management. It includes specific command syntax and options for each command, such as searching for text in files with grep and managing system resources. Additionally, it covers commands for creating archives and transferring files securely.

Uploaded by

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

Linux and Grep Commands

This document provides a comprehensive list of essential Linux and grep commands for various tasks including file management, viewing and editing files, managing permissions, system processes, networking, and package management. It includes specific command syntax and options for each command, such as searching for text in files with grep and managing system resources. Additionally, it covers commands for creating archives and transferring files securely.

Uploaded by

xedilo1642
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Essential Linux and Grep Commands

Grep Commands
grep "hello" [Link] — Search a word in a file

grep -i "hello" [Link] — Case-insensitive search

grep -r "hello" /path/to/dir — Recursive search in a directory

grep -n "hello" [Link] — Show line numbers with matches

grep -w "hello" [Link] — Search exact word match

grep -v "hello" [Link] — Invert match (lines not containing the pattern)

grep -c "hello" [Link] — Count number of matches

grep -o "hello" [Link] — Show only the matched part

grep "^hello" [Link] — Lines starting with "hello" (regex)

grep "hello$" [Link] — Lines ending with "hello" (regex)

grep -E "cat|dog" [Link] — Search multiple patterns using extended regex

Linux Commands

File and Directory Management


ls — List files and directories

cd — Change directory

pwd — Print working directory

mkdir — Create new directory

rm — Remove files or directories

cp — Copy files or directories

mv — Move or rename files or directories

touch — Create empty file

find — Search files and directories

File Viewing and Editing


cat — View file contents
less / more — View file page by page

head — Show first lines of a file

tail — Show last lines of a file

nano / vim / vi — Text editors

Permissions and Ownership


chmod — Change file permissions

chown — Change file owner

ls -l — View detailed file permissions

Process and System Management


ps — Show running processes

top / htop — Real-time system monitor

kill PID — Terminate process by ID

df -h — Show disk usage

du -sh — Show folder size

free -h — Show memory usage

uptime — Show how long the system has been running

uname -a — System information

whoami — Show current user

id — Show user and group info

Networking
ping — Check network connection

ifconfig / ip a — Show network interfaces

netstat -tuln — Show open ports

curl — Fetch web content

wget — Download files from the web

ssh user@host — Connect to remote server via SSH

Package Management
sudo apt update && sudo apt upgrade — Update/upgrade (Debian/Ubuntu)
sudo apt install packagename — Install package (Debian/Ubuntu)

sudo yum install packagename — Install package (RHEL/CentOS)

sudo dnf install packagename — Install package (Fedora/RHEL 8+)

Others
history — Show command history

alias — Create command shortcuts

man command — Show manual for a command

tar -czvf [Link] folder/ — Archive/compress files

scp file user@host:/path — Copy files between systems securely

You might also like