Skip to main content

Posts

Power of grep command in Linux.

  The grep filter searches a file for a particular pattern of characters, and displays all lines that contain that pattern. The pattern that is searched in the file is referred to as the regular expression (grep stands for global search for regular expression and print out). Syntax: grep [options] pattern [files] Options: -c : This prints only a count of the lines that match a pattern -h : Display the matched lines, but do not display the filenames. -i : Ignores, case for matching -l : Displays list of a filenames only. -n : Display the matched lines and their line numbers. -v : This prints out all the lines that do not matches the pattern -e exp : Specifies expression with this option. Can use multiple times. -f file : Takes patterns from file, one per line. -E : Treats pattern as an extended regular expression (ERE) -w : Match whole word -o : Print only the matched parts of a matching line, with each such part on a separate output line. -A n : Prints searched line and

Linux user account management.

Topics to be Covered in todays blogpost: How to add a user (useradd)? How to delete a user (userdel)? How to modify the user (usermod)? How to add the group? (groupadd)? How to delete a group? (groupdel)?  Files we will take a look at : /etc/passwd /etc/group How to Create a user ? useradd <username> How to identify if the user is created ? id <username> when you add the user 'shan' , automatically group called 'shan' is created.as you can see in the below snip that user and group of 'shan' is 'shan'. Also 'shan' directory automatically gets created in home directory. Question: How to create a user called 'victor' who is the part of QA team ,whose group is 'QA' ,shell type is '/bin/bash'? Also we want directory called 'victor' to be created in the home directory. Answer: useradd -g QA -s /bin/bash -c "Part of QA Team" -m -d /home/victor victor As you can see in the above snip that directory of