Welcome, Guest. Please Login
 
  HomeHelpSearchLogin FAQ Radified Ghost.Classic Ghost.New Bootable CD Blog  
 
Pages: 1 2 3 
Send Topic Print
Using the Unix/Linux Shell Command-line - Part 2 (Read 45970 times)
MrMagoo
Übermensch
*****
Offline


Resident Linux Guru

Posts: 1026
Phoenix, AZ (USA)


Back to top
Re: Using the Unix/Linux Shell Command-line - Part 2
Reply #30 - Aug 1st, 2009 at 11:48pm
 
Rad wrote on Aug 1st, 2009 at 7:48pm:
do you ever use telnet?

Yes, but just to check to see if a port is reachable.

Rad wrote on Aug 1st, 2009 at 7:48pm:
still useful?

Barely.  It is not secure in any way, shape, or form and should not be used to do much of anything.

Interesting thing is that many protocols still implement telnet at a low level.  SMTP, for example, is basically a scripted telnet session.  Makes your skin kinda crawl to realize how insecure email is...

Rad.in.UbuntuVM wrote on Aug 1st, 2009 at 8:21pm:
Hmmm. I tried to connect to the Rad VPS via telnet ("open radified.com" at telnet prompt).

Ya, stick to SSH.  Tons of advantages.  Almost no disadvantage.

Rad.in.UbuntuVM wrote on Aug 1st, 2009 at 10:57pm:
mail

command not found. 

Was this on CentOS or Ubuntu?  I'm guessing CentOS from your output.  Mail is pretty basic, and many distros don't include it anymore.  They expect you to forward your mail to somewhere you can get to it from a decent mail client (Thunderbird etc..)

You can try 'yum install mail' if you really want it.

 
WWW  
IP Logged
 

Rad.in.UbuntuVM
Radmeister
**
Offline


Rad in Ubuntu 9.04 Jaunty
Virtual Machine

Posts: 92


Back to top
Re: Using the Unix/Linux Shell Command-line - Part 2
Reply #31 - Aug 3rd, 2009 at 5:40pm
 
MrMagoo wrote on Aug 1st, 2009 at 11:48pm:
Was this on CentOS or Ubuntu?

CentOS.

I've come to see both mail and telnet as ancient history. My telnet port (23) on Rad VPS was closed. Wiredtree sppt asked if I wanted them to open it. I said 'no'.
 
WWW  
IP Logged
 
Rad.in.UbuntuVM
Radmeister
**
Offline


Rad in Ubuntu 9.04 Jaunty
Virtual Machine

Posts: 92


Back to top
Re: Using the Unix/Linux Shell Command-line - Part 2
Reply #32 - Aug 3rd, 2009 at 6:35pm
 
11-02 - Environmental Variables

Many programs use Shell EV's as config options (including the shell)
name=value
name can have no spaces
if value has spaces, it must be enclosed in double quotes
can set new EV's or modify existing EV's
to find value of a given EV: > "echo $variable"
if a blank is returned, ether no such variable or value set to blank
"set" shows ALL EV's
e.g. "set | more"
EV's can usually be found at end of each man page
If you want an EV to be used by a program other than shell, usually have to EXPORT it:
e.g. "export variable" (notice no dollar sign)

Common EV's (Weird that these must be entered as > ALL CAPs)
LINES, COLUMNS, HOME, LOGNAME, PATH, PS1, SHELL, TERM

What's up with the ALL-CAPS? Thot there was something wrong with my system .. til I tried ALL-CAPs.
 
WWW  
IP Logged
 
MrMagoo
Übermensch
*****
Offline


Resident Linux Guru

Posts: 1026
Phoenix, AZ (USA)


Back to top
Re: Using the Unix/Linux Shell Command-line - Part 2
Reply #33 - Aug 3rd, 2009 at 6:36pm
 
Rad.in.UbuntuVM wrote on Aug 3rd, 2009 at 5:40pm:
I've come to see both mail and telnet as ancient history. My telnet port (23) on Rad VPS was closed. Wiredtree sppt asked if I wanted them to open it. I said 'no'.

Unfortunately, telnet is not ancient history.  Many people still use it for many different things, even though doing so is dangerous.  Good call leaving it closed; you open yourself up to too many potential security issues by using telnet.

Regarding mail, I don't know if your course covered it or not, but your mail is (most often) stored in a text file in /var/spool/mail.  In that directory, there is one file for each user, and all your mail is stored in that text file, each message appended after the other.  It's not pretty, but it is human readable.

Forwarding the mail to somewhere you can read it with a client would be good practice for you in configuring several system options, and seeing what kind of mail the system generates might interest you, but you can also just skim through this text file if you just want to get a general idea what is in there.
 
WWW  
IP Logged
 
Rad.in.UbuntuVM
Radmeister
**
Offline


Rad in Ubuntu 9.04 Jaunty
Virtual Machine

Posts: 92


Back to top
Re: Using the Unix/Linux Shell Command-line - Part 2
Reply #34 - Aug 3rd, 2009 at 7:17pm
 
11-03 - Your path

Where the shell looks to find executable utility programs
Typically, the PATH EV contains 5 or 6 directories .. 10 at most.
To add a directory on the end of current $PATH:
e.g. "PATH=$PATH:/home/rad/bin"
$PATH = contents of currently existing PATH variable.
Can also add a directory to the beginning
PATH=.:$PATH (looks in current directory first)
"echo" is part of the shell. It's not a separate execute program stored somewhere.
So echo will always work, even if PATH variable is trashed..
The PATH variable is about convenience. So you don't have to navigate to the directory. Ot type in the the full path name to the program.
Some experienced Unix users create a directory in their home directory, and put their own custom scripts in there, and then add that directory to the PATH variable, so they can run those scripts from anywhere.
 
WWW  
IP Logged
 
Rad.in.UbuntuVM
Radmeister
**
Offline


Rad in Ubuntu 9.04 Jaunty
Virtual Machine

Posts: 92


Back to top
Re: Using the Unix/Linux Shell Command-line - Part 2
Reply #35 - Aug 3rd, 2009 at 7:37pm
 
11-04 - Your prompt

PS1 = Environment variable that represents shell prompt
set/change prompt via
e.g. "PS1=Rad" (notice P+S are capital letters)
bash offers dynamic prompt that changes with time.
 
WWW  
IP Logged
 

MrMagoo
Übermensch
*****
Offline


Resident Linux Guru

Posts: 1026
Phoenix, AZ (USA)


Back to top
Re: Using the Unix/Linux Shell Command-line - Part 2
Reply #36 - Aug 3rd, 2009 at 8:38pm
 
Rad.in.UbuntuVM wrote on Aug 3rd, 2009 at 7:37pm:
bash offers dynamic prompt that changes with time.

Well, more than time, it is usually set to change based on the user you are logged in as, the working directory you're in, and other things to give you feedback about where you are and what the system expects from you.
 
WWW  
IP Logged
 
Rad.in.UbuntuVM
Radmeister
**
Offline


Rad in Ubuntu 9.04 Jaunty
Virtual Machine

Posts: 92


Back to top
Re: Using the Unix/Linux Shell Command-line - Part 2
Reply #37 - Aug 3rd, 2009 at 8:57pm
 
11-05 - .profile

Changes made to Environment shell variables (such as PATH & PS1 prompt) are lost upon logout. Changes not permanent.
To make changes permanent .. put changes in .profile (in home directory)
Works for any program at all.
If you can type it on the command line, you can put it in your .profile
.profile is NOT the system-wide profile.
System-wide profile = /etc/profile (runs automatically)
Have to logout and log back in before changes made to .profile will take effect.
Or .. you can run ". .profile" and changes will take effect (be applied) withOUT having to log out & log back in.
.profile for Unix is the same as autoexec.bat for booting into DOS (a set of commands you wish to execute every time something occurs).
.profile is an example of a shell script (a simple shell script) .. a series of commands that are executed by the shell
 
WWW  
IP Logged
 
Rad.in.UbuntuVM
Radmeister
**
Offline


Rad in Ubuntu 9.04 Jaunty
Virtual Machine

Posts: 92


Back to top
Re: Using the Unix/Linux Shell Command-line - Part 2
Reply #38 - Aug 3rd, 2009 at 9:14pm
 
11-06 - Command-line history & editing

Command-line HISTORY = a shell feature .. allows you to re-enter a previous command without having to retype it.
The up-arrow key activates command-line history.
History normally includes last 50 commands.
Left-arrow key allows you to fix a mis-typed character without having to back-space and retype everything.
Regular Bourne shell has no command line history or editing features (at all).
Korn shell trickier to edit command line .. uses commands from vi (Press ESC first to acces )
k (instead of up-arrow key) to go up a line to access previous commands
enter to re-enter the command
Must first set "EDITOR=vi" as environmental variable
 
WWW  
IP Logged
 
MrMagoo
Übermensch
*****
Offline


Resident Linux Guru

Posts: 1026
Phoenix, AZ (USA)


Back to top
Re: Using the Unix/Linux Shell Command-line - Part 2
Reply #39 - Aug 3rd, 2009 at 9:35pm
 
Rad.in.UbuntuVM wrote on Aug 3rd, 2009 at 9:14pm:
The up-arrow key activates command-line history. 

Also, run the command 'history' to dump the entire history to stdout.  I often pipe it to grep to narrow down the command I'm looking for.
 
WWW  
IP Logged
 
Rad.in.UbuntuVM
Radmeister
**
Offline


Rad in Ubuntu 9.04 Jaunty
Virtual Machine

Posts: 92


Back to top
Re: Using the Unix/Linux Shell Command-line - Part 2
Reply #40 - Aug 3rd, 2009 at 9:44pm
 
11-07 - Other Shell Customizations & Options (umask)

Final module for course

umask = specifies shell permissions for all files created by the shell
We use the greater-than sign to create files with the shell.
e.g. "who > wholist.txt"
often "644"
to change:
umask permissions
NOTE: permissions which should be turned OFF (not on)
Regarding umask, 666 is considered full permissions.
So you SUBTRACT from 666 to get new permissions
In other words:
"umask 022" would yield new files with 644 permissions
umask does not consider the 'execute' permission (777)
"umask 606" would yield new files with 060 permissions
If you are frequently changing file permissions chmod, consider changing your umask and putting it in your .profile
 
WWW  
IP Logged
 

Rad.in.UbuntuVM
Radmeister
**
Offline


Rad in Ubuntu 9.04 Jaunty
Virtual Machine

Posts: 92


Back to top
Re: Using the Unix/Linux Shell Command-line - Part 2
Reply #41 - Aug 3rd, 2009 at 9:45pm
 
Done. I did it. Finished.
 
WWW  
IP Logged
 
Rad.in.UbuntuVM
Radmeister
**
Offline


Rad in Ubuntu 9.04 Jaunty
Virtual Machine

Posts: 92


Back to top
Re: Using the Unix/Linux Shell Command-line - Part 2
Reply #42 - Aug 3rd, 2009 at 10:32pm
 
Looking back, things I found most helpful.

* cd
* up-arrow
* pwd
* understanding absolute vs relative paths
* cp, rm & mv
* .. (parent directory)
* ctrl-d (to quit)
 
WWW  
IP Logged
 
Pages: 1 2 3 
Send Topic Print