Advanced Linux Commands {grep/awk}|| Day 5

My name is Abhishek vishwakarma and I am very exciting with devops field. I have a great interest in cloud computing technology and devops field, CI-CD, containerization, and automation and I am constantly exploring new ways to improve the software development and deployment process. I believe to solve real life problem in a simple way that can save time and money of organization bey implementing automation tools. Join with me on my in this journey in DevOps world.
Commands to create user in linux :
This command is used to create a user and create a directory for the same user name.
sudo useradd Abhishek-devops -mThis command is used to check if Abhishek-devops user is created.
sudo cat /etc/passwd
Commands to add/create groups
This command is use to create a group in linux.
sudo groupadd devopsCommands to check group is added
This command is use to check if a group in linux.
sudo cat /etc/group
Commands to add a user to a
devopsgroupThis command is use to add a single user (Abhishek-devops) to devops group and with below response Abhishek-devops user will be added to devops group.
sudo gpasswd -a Abhishek-devops devops
Commands to check
Abhishek-devopsuser is added todevopsgroup.This command is used to check users added to a group. The output is showing that Abhishek-devops is added to devops group.
sudo cat /etc/groupCommands to add multiple users to a signle group.
This command is used to add multiple users or members in a single group
Example : commands result is showing jethalal,vijay_qa,vijay_dev users added to devops group.
sudo gpasswd -M jethalal,vijay_qa,vijay_dev devops

8 . Commands to check permissions of a file.
This command is used to check permissions of a file.
Example: commands result is showing permissions of file.
bash ls -l backup.sh



grep command in Linux
grep stands for global search for regular expression and print out.
Grep command is used to find or search a regular expression or a string in a text file.
If you wish to search for a string in your current directory and all other subdirectories, search using the
- rflag as showngrep -r Hello
"Hello" word searched recursively in directory and sub directory.
This command is used to search "TRACE' word in log.txt file.
grep TRACE log.txtExample: Creaate a file with vim log.txt paste some log data and then run this command.

11 . This command is used to write searched output "TRACE' word in trace.txt file.

12 . awk commands :
The awk command is used for text processing in Linux. Although, the sed command is also used for text processing, but it has some limitations, so the awk command becomes a handy option for text processing. It provides powerful control to the data.
Example :
bash awk /INFO/ log.txt

To Print first column from logfile use '{print $1}' in awk command
awk '/INFO/ {print $1}' log.txt
ACL :
Access control list (ACL) provides an additional, more flexible permission mechanism for file systems. It is designed to assist with UNIX file permissions. ACL allows you to give permissions for any user or group to any disc resource.
Example ;
This command is used to check the permission of the log.txt file.
getfacl log.txt
Thanks for reading this blog these were some advance linux command.




