DevOps

Grep Command on Linux

devops_techaid71
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]
Example:
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

Permission

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.

Permission

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

Permission

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 test.zip your_folder

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

About the author

shohal