New to SSH and looking for short talk

Hello, I am starting to learn command in ssh. I was recommended to learn this for a few reasons and have been given some short phrases to decode so that I may better learn. While I am finding great information online about operators/operands/operations and also the command line structure Linux uses, I still find arranging the information can be a little difficult.

Seeing as my friends who do know some of this are all busy most of the time I decided to come here and see if anyone has just a little bit of time to "coach" me a little. I'm coming into this field with no knowledge what so ever and have crammed quite a bit of knowledge in a short amount of time. I just feel like I'd retain more if I had someone to just chat with about it. I also intend to use this knowledge to help solve issues for other people in the future so whatever help you can give me will be payed forward 100 fold.

Thanks for any interest,

grep for days

Any command in particular you are having trouble learning?

Reading your post, I have the feeling that perhaps an IRC forum might be more helpful, if I understand your message. Peruse this link in how to go about that.

1 Like

Yes I have about three commands. I don't really want anyone to answer them for me, just review what I have surmised about them in real time (via maybe a chat client or email) and provide feedback that will set me in the right direction, if I am not already there. I will look into an IRC as you say, it may be a good place to chat with someone though feel free to message me or reply your interest to this thread if you have a few moments.

I would also greatly appreciate knowing what a good website for a beginner like myself should go to so that I can piece together the basics. Thanks for your reply Aia.

This site doesn't have an on-line chat feature. But, if you search the site for threads with the tag ssh you'll get a list of ~200 threads discussing how to use ssh.

To learn more about command line structure (commands, utilities, arguments, options, operands, pipelines, ...), start by reading the man page on your system for the shell you use (most likely man bash , man dash , or man ksh depending on what Linux distribution you're using). I strongly suggest that you get comfortable using the shell before you try to dig too deep into ssh . When using ssh , you're dealing with a shell on your local system issuing shell commands to a shell on a remote system. You have to understand quoting so that you'll understand what the local shell will do and what will be passed to the remote shell.

If you try to do something and you can explain to us what you are trying to do, show us the input(s) you have, show us the output(s) you want, show us what you have done, and show us what you are getting from what you have done; we will be happy to try to explain where you went wrong and how to fix it.

1 Like

Thanks Don, that's great information. Here is the first line of code that I deciphered. Mind you, I have no previous knowledge of ssh, linux or anything of the sort. If you feel like giving it a look over you are welcome to critique my understanding.

On a side note I will not be inputting any of this into my host server. I am just learning with paper and pen theory before I start to punch in the commands.

The line at the top is what I was given to figure out the meaning of. The following lines are explanations of my understanding of what the variables listed are. The paragraph at the end is my explanation of what the command does.

root@server [~]# grep -o '/home/[Aa-Zz]*' /etc/passwd/home/deerlet

; root@server - Root name servers are the servers at the root of the Domain Name System (DNS) hierarchy. This is declaring where the command will take place.

;~ - home directory

;# - expands the parameter of the subsequent line

;grep - command-line utility for searching plain-text data sets for lines matching a regular expression.

-o � specifies that the command should only return exact matches for an argument

;* - Expands to the positional parameters, starting from one. When the expansion occurs within a double-quoted string (see Double-Quotes), it shall expand to a single field with the value of each parameter separated by the first character of the IFS variable, or by a <space> if IFS is unset. If IFS is set to a null string, this is not equivalent to unsetting it; its first character does not exist, so the parameter values are concatenated.

This command starts by declaring the root of the server that you are in as the starting point for the command. By using [~]# it defines that it is starting the grep in the home directory. It is searching only for exact values that contain '/home/[Aa-Zz]*' in the directory searched. In specific, the �/home/[Aa-Zz]*� means the home directory with any subdirectory comprised of any combination of letter A capital or lower case through Z capital or lower. The * is what tells you that it will accept any combination of such letters and will expand the parameters to any number of letters, not just

root@server [~]# grep -o '/home/[Aa-Zz]*' /etc/passwd/home/deerlet
The blue pertains to the shell
The purple pertains to the command issued, in this case grep

root@server [~]# This part is the prompt message (visual clue). This part is setup by the shell you are using at the time of login. In the bash shell (for example) it is recorded in the environment variable $PS1 . However, it can be influenced or modified by the variable $PROMPT_COMMAND . It can have literally any message.
You can see the values of these variable by issuing the commands:

echo $PS1
echo $PROMPT_COMMAND

In this case, by convention the interpretation means:
root : the name of the user currently using the shell, it can be set in PS1 with the alias short-hand \u, in bash
@ : at
server : host name logged in; it can be set in PS1 with the shot-hand alias \h in bash
space [~] : cosmetic look; the ~ represents the home path of the currently logged user; it dynamically changes if set in PS1 with a \w or \W
# : A symbol to represent the superuser at the helm. It is convention. A regular user might have the symbol % or $. But there's nothing that said that it has to be anything.

The grep command:
-o : a flag to make grep just output the matched pattern, instead of the line where found.
' /home/[Aa-Zz]* ' : BRE (Basic Regular Expression) pattern, it is surrounded by single quotes to tell the shell not to try to interpreted the content and passed to grep as it.
[Aa-Zz] : Character class; The A and lower z are redundant since the range a-Z converts them. [a-Z] does the same.
* : Meta character; it means match zero or more of the previous character. Do not confuse with the shell glob (*) character that exist in the shell.

/etc/passwd/home/deerlet : path of the file that grep will read, in order to try to find lines that match the pattern previously mentioned.

Fantastic. I had it a bit mixed up so this is a much better explanation. How about this one?

sed -i.bak "13iwww       IN     CNAME    lantstic.com."  /var/named/lantstic.com.db

sed � live stream editor. Can replace multiple occurrences of text simultaneously.

-i � in-place argument. When combined with sed it replaces text and overwrites the original.

-i.bak � when using the extension .bak at the end of �i this allows you to keep a copy of the old file under that extension.

13iwww � specifies the 13th line on where to insert the sed replacement

IN � declares you are replacing

CNAME -

Lanstic.com. � in the quoted text it is the text being searched and replaced

This command uses the �sed� stream editor to replace a line of text with another. In this case it is looking for the 13th line in a file and replacing the CNAME of it wit lantstic.com. It should first create the backup (-i.bak) to /var/named/lanstic.com.db.tmp and if it is successful will mv (move) the old var/named/lanstic.com.db.tmp and replace it with the new var/named/lanstic.com.db

OK. We have a long way to go.

I agree with a lot of what Aia said, but will expand on a couple of things later...

First, never try to learn how to use a UNIX or Linux system from a book without having an active account on a system and a keyboard and display device where you can interactively type in commands and see the results immediately. And, until you are much more experienced AND are actually trying to perform system administration duties, use a normal user account (not root) to play around. (When you are running as root, you can do some serious damage to the system; when you are running as a normal user, you might screw up some of your files but you won't hurt the system nor any other users.) But when you're playing with things like grep , there is VERY little chance that you'll hurt anything.

I think Aia meant convention instead of conversion.

When used in a grep command in this position, /home/[Aa-Zz]* is a BRE, but:
[Aa-Zz] is a RE matching expression; not a character class. And the matching expression matches a single character that is A , a character in the inclusive range of characters starting with a and ending with Z , and the character z . But the range expression a-Z is only defined if a comes before Z in the collating sequence in the the current locale. In the C and POSIX locales (and in most locales available on UNIX and Linux systems, Z comes before a . On some systems the end points will be reversed and it will match the characters in the string Z[\]^_`a and in other systems, it will be rejected producing a diagnostic message from grep saying that the BRE /home/[Aa-Zz]* is invalid.

If you're trying to match a string of alphabetic characters in the current locale, An RE matching expression containing a character class expression that would do that is [[:alpha:]] . In the C and POSIX locales, the RE matching expression [A-Za-z] would match the same list of characters. But in locales with other alphabetic characters (such as accented vowels in Spanish locales, Cyrillic characters in Russian locales, etc.), these expressions might match very different sets of characters.

On UNIX and Linux systems, /etc/passwd is the name of a regular file containing what is frequently called the user database. Since it is a regular file, the pathname /etc/passwd/home/deerlet will yield an ENOTDIR error while trying to resolve that pathname and grep (if it didn't abort with a bad BRE error) will issue a diagnostic saying it can't open that file and quit.

As I suggested before, PLEASE stop trying to guess what these commands do and type them into your keyboard and see how they behave instead. Then, if you don't understand what happened, open up a new thread with the command that isn't working the way you think it should. Trying to keep track of multiple questions in a single thread confuses people who are trying to help you.

For the case above, the sed editing command is 13i (not 13iwww ) and it tells sed to insert text before line 13. With a GNU sed on a Linux system, the text to be inserted will be:

www       IN     CNAME    lantstic.com.

And, the file being edited is /var/named/lanstic.com.db . Do note that the pathnames with and without the leading slash character are very different unless you are sitting in your system's root directory when you invoke that sed command.

I apologize for the confusion Don but in my original statement I only requested anyone with free time to simply talk with me about what I saw when reading a line of code and then offer some advice. These are not issues, I don't have access to a server nor am I planning to punch these in.

I am just a newbie that is trying to piece things together with limited amounts of knowledge and looking for some advice. It's not a critical situation. If I posted in the wrong forum, my deepest apologies. I do not mean to stress anyone out, I'm just looking to chat. From what Aia said in her first post I have since gone and found a great IRC channel to chat in that preforms just what I was looking for.

To clarify, I have less than a weeks worth of knowledge about Linux and Bash (which is the shell I am working in). I should have also clarified that earlier. If you are too busy or do not wish to offer some tips to a knowledge seeking individual then I will not take offense to you not responding and will adversely greatly appreciate what little hints you give me. There are many things that I need to look into such as a more concrete guide for Bash/ssh commands and I am working towards finding a good one. I also have just recently found out about the "man" information that the ssh will provide for you which I intend to use to its fullest.

Again, thank you for the very detailed information. These command lines are just ones that friends sent to me and, while they might not be perfect, they assured me that by just simply understanding some of this I will have a good knowledge of the basics to being an Admin. Clearly they have some learning to do as well :smiley:

There is no need to apologize, and we are not averse to answering your questions. I am just pointing out that much of your confusion appears to be because in the text you are getting from your friends as samples to evaluate, you cannot see the difference between what the system will type as a prompt for you to enter commands and as output produced by your commands versus what you will type into the system in response to prompts from your shell. If you could login to a system and type in a few commands much of this would be immediately obvious.

A half hour sitting at a keyboard and trying some of these commands would easily save you days of time guessing at what a command is supposed to do.