Grep Command on Linux

Written by shohal

Basic Grep Command

Basic Grep Command
The grep filter searches a file for a particular pattern of characters, and displays all lines that
contain that pattern
Example: history | grep sudo
grep [options] pattern [files]
grep -i “Class” cloudageskill.txt
Cat sample.txt | grep class
ls /home/shawon/ | grep cloud

Basic Find Command

1. find /home/shawon -iname sample.txt
2. find /home/shawon -iname bd*.pdf
3. find . -type f -exec sed -i ‘s/Old_Text/New_Text/g’ {} \;

System and Process Management

1. free -m
2. lscpu
3. top
4. htop
5. du -sh
6. df -h
7. ps aux
8. kill pid


User permissions. These permissions apply to a single user who has special
access to the file. This user is called the owner.

Group permissions. These apply to a single group of users who have access to
the file. This group is the owning group.

Other permissions. These apply to every other user on the system. These users
are known as others, or the world.


1. Read =4
2. Write = 2
3. Execute =1
Chmod 400 key-pair.pem
Chmod -R 755 sample_folder


You create a file, myfile.txt, using sudo or while logged in as root, so the file is owned by root.
However, you intend the file to be used by your regular user account, myuser.
sudo chown test myfile.txt
You own myfile.txt, but you want to give it to another user on the system named notme. You also
want to change the owning group to that user’s group, notmygroup.
sudo chown test:test myfile.txt

Linux Archives

1. zip -r your_folder

2. tar -czvf test.tar.gz /data/test/

About the author