![]() When finished, use Ctrl D to send the message out for delivery. You can add additional recipients or just press Enter to skip. To send a basic email, you can use the following: $ mail -s "Subject Line" you press Enter, you'll be prompted with the Cc field. Install the package: $ apt-get install mailutils You'll need to have an SMTP server running locally on your machine, so that is something to be aware of. Mail-The mail command is a super neat tool that allows a user to send emails directly from the command line, without having to open a browser or dedicated client. In the above example, I'm doing a POST and passing the header and the body. Invoke awk by running the command providing an action between '' \ Sysadmins commonly use awk to extract data from files or piped from the output of other commands in the command line or Shell scripts. This command is available in most if not all Linux distributions as well as any other UNIX operating systems. How well do you know Linux? Take a quiz and get a badgeĪwk-The awk command implements the AWK programming language to process text, and it’s particularly good at processing data organized in columns.Linux system administration skills assessment.A guide to installing applications on Linux.Download RHEL 9 at no charge through the Red Hat Developer program.Say you’d like to grep on error, or warning, you could do something like this: $ egrep 'error|warning' file.txtĮgrep will support other patterns, I'm sure, but that one right there is the one I’ve always used it for, and I’ve found it very useful. I suggest you get familiar with the man page if you’d like to know more.Įgrep-Now, what if you want to filter on more than one word? I’ve always used egrep for this. There are a lot more options for grep, including filtering based on a file of keywords, regular expressions, you can even colorize the output. # tail -f /var/log/messages | grep -i error This is really useful for things like filtering logs, even live with tail -f. Now, I said you could use grep to filter the output of any command right? You do that with output redirection using a pipe. This will match on error, ERROR, erRoR, or whatever, as long as the letters are the same. You can tell grep to filter in a case-insensitive way using the -i flag. So grepping for “error” wont find “Error” or “ERROR”. It’s worth noting that grep is case sensitive, like many things in Bash. Subsystem sftp /usr/libexec/openssh/sftp-server ![]() Say you wanted to see all of the config options in your sshd config that are not commented out, you could do this: # grep -v \# /etc/ssh/sshd_config You can also reverse that by using an exclude flag. That’s what you’d call an Inclusive grep. This line contains a case sensitive ERROR To show you all of the lines in a given file that include the word “error” for example, you would do something like this: $ cat file.txt We’ll even talk a little bit about a very similar tool that extends grep a bit. ![]() You can grep for words you want to find, or invert that to show you everything that DOES NOT match your keyword. grep is a tool that will let you filter the standard output of just about anything on the command line. If you don’t already know about grep (and lets be honest, thats at least possible, if you’re new to the Linux command line), get familiar with it. It was eye-opening to see just how important these commands really are to the community and to sysadmins as a whole. For instance, if you wanted to cat all of the files listed by ls, you could use something like this: $ lsĬheck out an in-depth look at xargs from HowtoGeekĪwk/sed/(e)grep-This trio was named more times than any other command(s) by our community. A super basic example of this can be seen when pairing with the ls command. xargs allows you to run additional commands against the output of a given command. Ls xargs-This pairing was new to me however, it was really interesting to learn and has some potentially game-changing applications. You can find more information about the command here. For example, if you wanted to find directories that matched a specific name, you could use something like this: find path/ -type d -iname '*dir_name*' So without any further delay, let's jump into these.įind-This command is a part of findutils and allows for custom search commands. After processing the results, 17 of the commands emerged as being essential or at least hugely beneficial to the Linux sysadmin job. A few months ago, I asked the Enable Sysadmin contributor community to help me make a list of their most essential commands.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |