Welcome, Guest. Please Login
 
  HomeHelpSearchLogin FAQ Radified Ghost.Classic Ghost.New Bootable CD Blog  
 
Pages: 1 2 3 4 5 
Send Topic Print
Using the Unix/Linux shell command-line (Read 114591 times)
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
Reply #30 - Jul 25th, 2009 at 12:31am
 
 
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
Reply #31 - Jul 25th, 2009 at 3:01pm
 
Rad.in.UbuntuVM wrote on Jul 24th, 2009 at 7:24pm:
Is RegEx like a search prgm, or just the characters used in the strings that you search for?

Regular Expressions are arbitrary patterns.  So, you could look for 2 numbers, followed by any number of letters.  Or, you could look for the letters "betr" at the beginning of a word or the beginning of a line.  You use a regular expression to describe the pattern you are looking for.

Rad.in.UbuntuVM wrote on Jul 24th, 2009 at 7:24pm:
In other words, do you have to use RegEx in conjunction with another prgm?

Correct.  Regular Expressions are just patterns.  You need some program to search for the program you are describing with the regular expression.  grep is the best known such program.
 
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
Reply #32 - Jul 25th, 2009 at 3:13pm
 
Rad.in.UbuntuVM wrote on Jul 25th, 2009 at 12:31am:

I appreciate that Nigel keeps us on our toes even tho he chooses not to participate directly.

From the article:
Quote:
Many people now associate the bogus percentages with Dale's "Cone of Experience," developed in 1946 by Edgar Dale. It provided an intuitive model of the concreteness of various audio-visual media. Dale included no numbers in his model and there was no research used to generate it. In fact, Dale warned his readers not to take the model too literally.

When I first heard of the cone, I understood that it came out of research done at Arizona State.  Even then, I didn't take the numbers literally (or it would have seemed to be a complete waste of time to read anything at all!) It's neat to learn that the original author didn't intend it to be taken any more seriously than I did anyway.

To me, its more about the different types of learning and that we need to be aware of the style and type of learning we are using at any particular moment, along with the effect it's having (or more importantly - not having.)

Send my thanks to Nigel for making the distinction.
 
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
Reply #33 - Jul 25th, 2009 at 3:21pm
 
MrMagoo wrote on Jul 25th, 2009 at 3:13pm:
I appreciate that Nigel keeps us on our toes even tho he chooses not to participate directly.

Yeah, he'll drop me an email from time to time. Chock-full of techie-goodies, which I usually have to read 3 times, cuz there's so much there.

Quote:
You asked: "Is RegEx like a search prgm, or just the characters used in the strings that you search for?". The answer is neither; regular expressions are actually a concept in formal logic. In particular, the regular languages have the special property that matching a pattern can be done by a special kind of thing called a finite state machine, whereas more complicated types of patterns require more complex kinds of machines to match.

Regular expressions were widely popularised in the 1970's by the smart folks at Bell Labs who worked on the early UNIX utilities because they knew of all this theory, and exploited it by writing programs that took regular expressions and implemented them very efficiently by "compiling" the patterns into such state machines so the matching process would be very efficient (and thus making their pattern-matching capability more useful in practice).

The answer to the next question is: "do you have to use RegEx in conjunction with another prgm?" is that any program which has strings coming into it can use the regular expression concept profitably by giving users the ability to specify patterns of input using them. In the original UNIX systems it simply tended to be that working with regular expressions was usually done by using one of the specialized programs (grep, awk, and such like) for matching then, but that's largely due to the fact that early UNIX was designed for the PDP-11, when each program had to fit in 64k of code and 64k of data.

UNIX's approach of making it easy to glue programs together was as much a matter of making a virtue out of necessity (that 64k limit) than anything else. These days, since even devices like mobile phones have unimaginably large amounts of memory compared to then, any program that wants to employ regular expressions can just use one of the many programming libraries which provide them to expose the capability of working with regular expressions to end users, if it makes sense for them to do so given their intended users.

- Nigel

BTW - have you noticed "The Shadow" has 'disappeared'? (I kinda made a funny there.) He sent me a note saying 'Bye' a month or two ago. Why did he leave? Only 'TheShadow' knows. =)

http://www.mysterynet.com/shadow/
 
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
Reply #34 - Jul 25th, 2009 at 3:48pm
 
07-01 - Process Control

Process = running program (emphasis on 'running')
There is only one ls program, but if 5 users are currently using the ls program, then there are 5 ls "processes" running.
A program becomes a process by being loaded into memory and started (often by the shell, which is a process itself).
Every process is assigned a unique ID (PID) from 1 to 30000.
Each started PID gets the next sequential number.
ps = command that shows processes that are running (for the current log-in session only).
options
"ps -u username" shows all processes for that user
can use this command option to snoop on other users to see what they're running.
ps -f and ps -l options both provide more details (for current log-in session only).
-e displays every process on the system
PPID = Parent Process ID = the PID of the program that started the process .. can be the shell many times
TTY = Terminal number the process/program is running on.
Time = CPU time in seconds that process has uses, which helps determine how much load a particular process is placing on the system.
"ps -fu username" gives MORE info about a particular user
"ps -e | wc -l" (piped to wc -l) tells HOW MANY proceses are running
"ps -e | grep vi" (piped to grep) shows how many users are running vi (-f not used so can't tell who they are)
 
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
Reply #35 - Jul 25th, 2009 at 4:56pm
 
07-02 - Running Commands Asynchronously

Asynchronously = process runs in the background
Means the shell does not wait until process is done before presenting you with another prompt
Particularly useful if a process will take a long time to run
Accomplished by appending an '&' at the end of the command line.
Ctrl-c interupts running processes.
e.g. "sleep 3600 &"
3600 = number of seconds = 1 hour
sleep = a program that does absolutely nothing ("sleeps"), but does it for an arbitrary length of time (in seconds).
"sleep 10" will give you back your prompt in 10 secs.
Shell will notify you when background process is done by writing a single line of text to the screen.
Can run as many background processes as you like.
The IS a limit but it is a very large number, up in the hundreds of program/processes.
Proviso #1-> Commands that take standard input should never be run in the background.
You CAN run them (commands that take standard input), but it will error at point where it pauses to collect input from keyboard.
Because you can't type info into a program that is running in the background.
Proviso #2 -> It's possible to run a program that produces standard OUTPUT (or error) in the background, but ..
.. that program will spit its output onto the screen regardless of whatever else you might be doing.
You might be typing a long command or in the middle of editing a file.
This can be very annoying.
So its a good idea to redirect this output to a file (or /dev/null).
Proviso #3 -> Any time you log-out, all your processes that you started will be terminated.
 
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
Reply #36 - Jul 25th, 2009 at 8:27pm
 
Rad.in.UbuntuVM wrote on Jul 25th, 2009 at 4:56pm:
Proviso #3 -> Any time you log-out, all your processes that you started will be terminated. 

Its not that simple.  If you log out of a shell, any programs running in that shell will terminate.  Any programs you started in a different shell will keep working, as will any programs not tied to a shell.
 
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
Reply #37 - Jul 25th, 2009 at 8:30pm
 
Rad.in.UbuntuVM wrote on Jul 25th, 2009 at 3:21pm:
BTW - have you noticed "The Shadow" has 'disappeared'? (I kinda made a funny there.) He sent me a note saying 'Bye' a month or two ago. Why did he leave? Only 'TheShadow' knows. =)

I had noticed.  I also noticed we don't miss his input nearly as much as we miss Nigel's.
 
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
Reply #38 - Jul 25th, 2009 at 10:05pm
 
MrMagoo wrote on Jul 25th, 2009 at 8:30pm:
I had noticed.I also noticed we don't miss his input nearly as much as we miss Nigel's.

Smiley i hear ya.
 
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
Reply #39 - Jul 25th, 2009 at 10:06pm
 
07-03 - Killing Processes

kill process-id
can't do "kill ls" cuz you may have several ls's running.
e.g "kill 2532"
do a "ps" to determine Process ID # running
use kill only as a last result, cuz killing a process can have unexpected results.
for example, it might be in the middle of updating a database
if you kill it, the database might become corrupt
you can only kill processes you have PERMISSION for
root superuser can kill anything.
some programs can take 10 secs to die, so be patient.
some programs are designed to ignore the kill command
if the process won't die:
"kill -9 process-id"
no program can be designed to ignore the '9' signal
kill -9 kills a program immediately, and does not give it a chance to do a normal shutdown.
so use kill -9 only as a last resort.
 
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
Reply #40 - Jul 26th, 2009 at 4:44pm
 
07-04 - Jobs

Both Bash and the Korn shell (ksh) provide further control of the running processes (not the case with the standard Bourne shell .. sh).
Bash and ksh allow you to pause or suspend a running program.
The correct terminology is "stop"
This can be helpful if you're using a program that cannot be easily shutdown,
or you might be in the middle of a complex editing a session,
and you need access to a shell prompt to run a few other programs.
A stopped process is called a "job".
To pause of "stop" a process, use > "ctrl-z"
fg will resume the most recently stopped program
fg stands for "fore-ground" .. brins prgm back to the foreground.
It's possible to pause ("stop") several programs at once.
Can pause a program, start a second, pause that, and start a third, etc.
Can selectively resume commands by usng the 'jobs' command to list all currently stopped jobs.
These jobs will be preceded by a number, such as 1, 2 or 3
Can use fg with this number to selectively restart stopped programs
e.g. "fg 4" will resume the 4th stopped process in the list provided by 'jobs'
Programs running asynchronously (in the background) cannot be paused/stopped.
(But they shouldn't need to be paused, cuz they don't prevent you from getting a shell prompt)
 
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
Reply #41 - Jul 26th, 2009 at 6:08pm
 
07-05 - More Process Control (nice & nohup)

Each process is assigned a priority
More important programs receive a large part of processing time, so they run faster
Less important programs run more slowly.
nice = program used to adjust a program's priority (make it more or less important)
Running a program with a higher priority (faster) will cause other programs to run slower.
Highest priority = -20 (strange, cuz it's a negative number)
Lowest priority = 19 (note how highest number = lowest priority)
Defult priority = 10
Mot programs use the default
syntax > "nice -priority command [arguments]"
e.g. "nice --20 find / -name output.txt"
or "nice -20 backup /home"
don't let the double -- confuse you.
some user will not have permission to run negative number, which represent the highest priorities
root superuser has all power to do anything

nohup = no hangup
nohup used to prevent programs from terminating when you log out.
if program is started with nohup command, it won't terminate upon log-out.
syntax = "nohup command [arguments] &
e.g. "nohup backup /home &"
any standard output goes (by default) to a file named nohup.out
can be redirected elsewhere
 
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
Reply #42 - Jul 26th, 2009 at 7:52pm
 
Rad.in.UbuntuVM wrote on Jul 26th, 2009 at 4:44pm:
The correct terminology is "stop"

I've always heard it called "suspending" a process.  If someone told me to stop a process, I'd kill (end) it.

Rad.in.UbuntuVM wrote on Jul 26th, 2009 at 4:44pm:
Programs running asynchronously (in the background) cannot be paused/stopped. 

Programs detached from the shell (or 'daemonized') cannot be suspended because they aren't controlled by the shell.  Programs running in the background can easily be suspended by bringing them to the foreground (fg) and then suspending them.

Rad.in.UbuntuVM wrote on Jul 26th, 2009 at 6:08pm:
More important programs receive a large part of processing time, so they run faster
Less important programs run more slowly.

Note that the nice level is an indication of priority.  The distinction is important because process with a nice level of 19 (lowest priority) won't run much slower than a process with a nice level of 0 *unless* the processor is 100% utilized.  Then, the higher priority process gets a larger share of processing time and the lower priority one slows down.

Rad.in.UbuntuVM wrote on Jul 26th, 2009 at 6:08pm:
Defult priority = 10

I'm not sure what Unix flavor this is referring to.  The default priority on Linux is 0.

Rad.in.UbuntuVM wrote on Jul 26th, 2009 at 6:08pm:
e.g. "nice --20 find / -name output.txt"

Your example is syntacticly correct, but it would not be good practice to run things like find and backup with such a high priority.  There are important system processes that run somewhere around level -10.  Starving these system processes of cpu time could cause the system to become unstable. 

In fact, I would lower the priority of find to something like +10.  That way, it wouldn't interfere with anything important (and probably wouldn't run noticeably slower anyway.)

In practice, you usually just use the default unless you have a reason not to.  One good time I nice a process is when I'm transcoding audio or video.  I set it to a nice 19 (lowest priority.)  That way, I can still use my computer normally and the transcoding just uses any cpu time that I don't need.  I barely notice it is running. 

 
WWW  
IP Logged
 
Rad
Radministrator
*****
Offline


Sufferin' succotash

Posts: 4090
Newport Beach, California


Back to top
Re: Using the Unix/Linux shell command-line
Reply #43 - Jul 26th, 2009 at 10:07pm
 
Appreciate your comments.

Doubt I'll need all these commands, but learning the shell ropes will give (is giving) me confidence.

I'm ~ 2/3rds thru with this course.
 
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
Reply #44 - Jul 26th, 2009 at 11:53pm
 
Rad wrote on Jul 26th, 2009 at 10:07pm:
Doubt I'll need all these commands, but learning the shell ropes will give (is giving) me confidence.

Some of this is above what you need for just keeping your site up to date, but you are building a very solid foundation for getting comfortable in Linux.
 
WWW  
IP Logged
 
Pages: 1 2 3 4 5 
Send Topic Print