LebGeeks

A community for technology geeks in Lebanon.

You are not logged in.

#1 May 10 2005

rolf
Member

I have lotsa linux experience

When it comes to linux, I'm the man.
So hit me with your questions!

Offline

#2 May 10 2005

darkstar
Member

Re: I have lotsa linux experience

Cool i will thanks

Offline

#3 May 11 2005

Charly
Member

Re: I have lotsa linux experience

how the HELL do u install a certain program on FC2? aw illak, where the hell can i get a list of the commands used? since, u know, without the commands, there's no use of linux

Offline

#4 May 11 2005

mahdoum
Member

Re: I have lotsa linux experience

interesting here's one for you rolf, what is the best *free* downloadable linux build?

Offline

#5 May 11 2005

rolf
Member

Re: I have lotsa linux experience

It really depends on what you want.
One of the most popular is Fedora (used to be called redhat)
i have heard about Suse linux too, supposedly easy

FreeBSD is well known for servers, although it's not really linux, it's a pretty different system.

http://www.linux.org/dist/

Offline

#6 May 22 2005

Sadus
Member

Re: I have lotsa linux experience

rolf, supposedly you're the master of the masters in Linux and yet you didn't answer a simple question as:
"where the hell can i get a list of the commands used?"

Charly, you're question is interesting, but wrong somehow.
Most of the commands in Linux are programs. Lets take "ping", its not a command, its a program. Usualy if you're a normal user all the "commands" which are "programs" are located in your /bin and
if you're root, then few extra "commands" are in /sbin/

you really don't need to memorize all of them, you just have to know what to use and what each command does.
A good way to discover this is by using the man program, which basicaly means: Manual. ex: man  mii-tool will give you:


MII-TOOL                                                                     MII-TOOL

NAME
       mii-tool - view, manipulate media-independent interface status

now, if you want do do something but you don't know which program/command to use then www.google.com/linux, if you want to know what commands you used earlier, then there is "history" which can be piped with "grep" so lets say you want to see all the latest ping commands you typed earlier then you do: history | grep ping.

another cool tool to use is "apropos", type "apropos network" and you'll have the list of tools you can use for networking for example.

Hope that helped,
join the mailing list of www.leglug.org

Offline

#7 May 22 2005

rico
Member

Re: I have lotsa linux experience

or you can press the tab key twice .. you will get a list of the programs/commands that you have.

Offline

#8 May 22 2005

Sadus
Member

Re: I have lotsa linux experience

that's not the productive way for searching a command ;)

Offline

#9 May 22 2005

rico
Member

Re: I have lotsa linux experience

hehe yea you're right ! but i wanted to help   what shall i do ?

Offline

#10 May 23 2005

rolf
Member

Re: I have lotsa linux experience

sorry charly, I missed your post.
type $PATH in your console windows, and you'll see the list af all directories that linux searches when you type a command.
If you add up all commands in these directories, you'll end up with more than 1000 for sure...

Thanks for the history and apropos tricks, I didn't know them, and I'll be using them for sure.

The tab can be very useful, but your apropos thing is much better when you dont know the name of the command.

Offline

#11 May 23 2005

Sadus
Member

Re: I have lotsa linux experience

sorry charly, I missed your post.
type $PATH in your console windows, and you'll see the list af all directories that linux searches when you type a command.
If you add up all commands in these directories, you'll end up with more than 1000 for sure...

Thanks for the history and apropos tricks, I didn't know them, and I'll be using them for sure.

The tab can be very useful, but your apropos thing is much better when you dont know the name of the command.

you mean, type: echo $PATH
typing $PATH by itself will execute whatever is in $PATH

Offline

#12 May 23 2005

rolf
Member

Re: I have lotsa linux experience

[root@summer root]# $PATH
-bash: /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin: No such file or directory

------------
"No such file or directory"
umm, you're right

Offline

#13 May 23 2005

rolf
Member

Re: I have lotsa linux experience

Thanks for the leglug link. Great idea.
Do you plan on organising any "installfests" (people get together to install linux)? Or other similar events?
And it would be nice to add a link to lebgeeks.com in the links section, to support the development of the tech community in lebanon.

Offline

#14 May 23 2005

megalomania
Member

Re: I have lotsa linux experience

Hi,

you said you do your shell scripting in PHP. Good thing you deleted that ;)
don't let anyone hear you say it.

It's like trying to read the contents of a directory by implementing "ls" in assembly.

Offline

#15 May 23 2005

rolf
Member

Re: I have lotsa linux experience

The thing is I have more than 2 years experience in PHP, and I really didn't feel like learning a new language as bizarre as bash from scratch, so I just went with PHP, and I'm actually pretty happy with it. Here I'll show you the code that I use to read the output of a command in PHP.

Offline

#16 May 23 2005

rolf
Member

Re: I have lotsa linux experience

for example to know if host 1.2.3.4 is up and report unreachability in the syslog:

#!/usr/bin/php -q

$ip = 1.2.3.4;

exec("ping $ip -c 2 -W 2|grep "64 bytes"", $aOut);
if (count($aOut)!=2) {
            exec("logger Host $ip is down.");
        }

It is true that you have to write more code to process the output, but on the other hand I find PHP to be more readable and it has a lot of additional features, like tons of extensions, objects, etc... But I have to say reason n.1 is that I already know it inside out.

One PHP feature that I use for example is raw sockets. I use it to automatically log me into the GDS login page. This way I always stay connected and never see that annoying login page.

Offline

#17 May 23 2005

megalomania
Member

Re: I have lotsa linux experience

#!/usr/bin/php -q

$ip = 1.2.3.4;

exec("ping $ip -c 2 -W 2|grep "64 bytes"", $aOut);
if (count($aOut)!=2) {
            exec("logger Host $ip is down.");
        }

not only is this too much code, everything you need is already there, and you're adding the PHP syntactic sugar around it, here's the one line bash version:

$  (ping google.com -c 1 | grep "64 bytes") || logger "Host google.com is down.";

it's no point to use PHP since you're exec'ing the commands already.

Offline

#18 May 23 2005

Sadus
Member

Re: I have lotsa linux experience

rolf,
If you wanna become a *NIX system administrator, or apply advanced tasks on *NIX, then Bash/Perl are essential. Along with mastering regular expressions and tools (grep,awk, sed...)

Offline

#19 May 23 2005

rolf
Member

Re: I have lotsa linux experience

Yeah, I am planning on starting perl.
I have already used regular expressions in PHP. I'll look into awk and sed, thanks!

megalomania, this is from the grep manpage:
      Normally, exit status is 0 if selected lines are found and 1 otherwise.
       But the exit status is 2 if an error occurred, unless the -q or --quiet
       or --silent option is used and a selected line is found.


how does that map to true/false?

Offline

#20 May 23 2005

megalomania
Member

Re: I have lotsa linux experience

megalomania, this is from the grep manpage:
      Normally, exit status is 0 if selected lines are found and 1 otherwise.
       But the exit status is 2 if an error occurred, unless the -q or --quiet
       or --silent option is used and a selected line is found.


how does that map to true/false?

0 is false, everything else is true.
(Update: in shell it's the opposite, 0 is success (so true) and everything else is not. So the above statement is wrong, the reverse is true.)

with that in mind, you only care to see if grep matched, which should return 0, otherwise, you consider a failure.

"2 if an error occurred" is not what you think it is. This is an error in "grep", and not in "ping", which does not mean that the host is down.

So in any case, you only care if you get a ping reply, which should match in grep, and which should return you a 0. Otherwise there may be a million reason why the ping didn't return, but since you don't account for these in your original code, I didn't account for them in mine.

Offline

#21 May 23 2005

rolf
Member

Re: I have lotsa linux experience

Ok, I got it. And this would do the opposite:
(! ping 127.0.0.1 -c 1 | grep "64 bytes") || echo  "Host is up.";

Offline

#22 May 23 2005

megalomania
Member

Re: I have lotsa linux experience

Ok, I got it. And this would do the opposite:
(! ping 127.0.0.1 -c 1 | grep "64 bytes") || echo  "Host is up.";

umm.. no, the NOT (!) should be outside the parenthesis, although I'm no bash expert to know what that eventually should mean.

Sso the opposite should be:

(ping 127.0.0.1 -c 1 | grep "64 bytes") && echo  "Host is up.";

Update: I have updated my previous post.

Offline

#23 May 23 2005

rolf
Member

Re: I have lotsa linux experience

Ok, I got it. And this would do the opposite:
(! ping 127.0.0.1 -c 1 | grep "64 bytes") || echo  "Host is up.";

umm.. no, the NOT (!) should be outside the parenthesis, although I'm no bash expert to know what that eventually should mean.

[root@summer root]# (! ping 127.0.0.1 -c 1 | grep "64 bytes") || echo "Host is up."
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.196 ms
Host is up.
[root@summer root]# !(ping 127.0.0.1 -c 1 | grep "64 bytes") || echo "Host is up."
-bash: !: event not found


Actually in the bash manpage, the ! is referenced 3 times:

In "Pipelines":
  If the reserved word !  precedes a pipeline, the exit  status  of  that
  pipeline  is  the  logical  NOT of the exit status of the last command.

In "Expressions":
example: ! expression
True if expression is false.

In "Parameters":
!  Expands to the process ID of the most  recently  executed  back-
    ground (asynchronous) command.

Now dont ask me how the shell chooses between the "expressions" context and the "parameters" context.

Offline

Board footer