0% found this document useful (0 votes)
28 views2 pages

Linux File Editing Viewing Searching Cheat Sheet 1

This cheat sheet provides essential commands for editing, viewing, and searching files in Linux. It includes instructions for using editors like nano and vim, viewing file contents with commands like cat and less, and searching for text within files using grep and find. Additionally, it offers power tips for text replacement and match counting.

Uploaded by

Cnu Sri
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)
28 views2 pages

Linux File Editing Viewing Searching Cheat Sheet 1

This cheat sheet provides essential commands for editing, viewing, and searching files in Linux. It includes instructions for using editors like nano and vim, viewing file contents with commands like cat and less, and searching for text within files using grep and find. Additionally, it offers power tips for text replacement and match counting.

Uploaded by

Cnu Sri
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

Linux File Editing, Viewing, and Searching Cheat Sheet

1. File Editing

nano filename -> Easy editor for beginners

vim filename -> Powerful modal editor

vi filename -> Classic version of vim

Nano Shortcuts:

CTRL + O -> Save

CTRL + X -> Exit

CTRL + K -> Cut line

CTRL + U -> Paste line

Vim Basics:

i -> Insert mode

Esc -> Command mode

:w -> Save

:q -> Quit

:wq -> Save and quit

dd -> Delete line

/word -> Search word

n -> Next match

2. File Viewing

cat filename -> Show file contents

more filename -> Paginate through large file

less filename -> Scrollable view, /search

head -n 10 filename -> First 10 lines

tail -n 10 filename -> Last 10 lines

tail -f filename -> Follow live updates (logs)

3. Searching

Search Inside Files:

grep "text" filename -> Search for text in file


grep -i "text" filename -> Case-insensitive search

grep -r "text" /path/dir -> Recursive search

grep -n "text" filename -> Show line numbers

grep -A3 -B2 "text" filename -> Show context lines

Search Files/Dirs:

find /path -name "file.txt" -> Find by name

find /path -iname "*.log" -> Case-insensitive search

find . -type f -mtime -1 -> Modified in last 1 day

locate filename -> Fast file search (needs updatedb)

which command -> Path of a command

4. Power Tips

sed 's/old/new/g' file -> Replace text

grep -c "word" file -> Count matches

grep --color "word" file -> Highlight matches

grep "text" *.log -> Search in multiple files

grep -rn "error" /var/log/ -> Search + show line number

You might also like