Announcement: Be excellent to each other.


Caravel Forum : Other Boards : Anything : Linux (Continued from somewhere else....)
12
Page 3 of 5
45
New Topic New Poll Post Reply
Poster Message
AlefBet
Level: Smitemaster
Rank Points: 979
Registered: 07-16-2003
IP: Logged
icon Re: Linux (+1)  
Tim wrote:
... Knoppix ... is also a very good system to use when you have to recover anything from a corrupted hard disk (it has saved me many times...)
I second that. A Knoppix live CD ought to be in any power user's toolkit, even (especially?) Windows users. I have used Knoppix to shuttle Windows data around and off drives that wanted to blue screen if booted by themselves.

____________________________
I was charged with conspiracy to commit jay-walking, and accessory to changing lanes without signaling after the fact :blush.

++Adam H. Peterson
08-23-2005 at 07:49 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
agaricus5
Level: Smitemaster
Rank Points: 1838
Registered: 02-04-2003
IP: Logged
icon Re: Linux (0)  
Continued from another thread...

Stefan wrote:
Ha! I've been using Linux for such a long time that I completely forgot about that horrible registry-thing in windows. Yeah, try changing the registry key values (with the windows on your C-drive) to point to the directory where your .dats containing your progress are located (probably "G:\\Program Files\\DROD\\Data", if I've understood correctly). That might even work...
I guess I'm a bit stupid in this respect, but I have read through this (and other threads) about Linux, and I have to admit that I'm pretty much confused about what exactly it is and does (I know it's a type of operating system, but what makes it different compared to Windows completely eludes my understanding). Normally, I'd not be interested in this sort of technical thing, but because of the rather unusual collection of people here, I have learnt that advice given, especially after much discussion, is often highly beneficial to follow, even if it sounds a bit obscure. For example, I finally switched to Firefox after reading a thread about it here, and I have to say that I'm very impressed with it and its general low-level functions (I haven't used IE in months!), although it doesn't seem to like plugins, something which I guess I'll have to investigate sooner or later.

So, to get back to what I was going to ask, in reasonably simple terms (I'm not exactly a computer expert) exactly what makes Linux different from Windows, what are the benefits and disadvantages of changing, and what sort of user would it be suitable for? Basically, would it be worth my time to switch (or possibly trying a dual-boot system)?

____________________________
Resident Medic/Mycologist
08-26-2005 at 05:09 PM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
trick
Level: Legendary Smitemaster
Rank Points: 2580
Registered: 04-12-2003
IP: Logged
icon Re: Linux (+4)  
What makes Linux different from Windows ? Where to start ... :)

Windows is an operating system. Linux is the kernel of an operating system, GNU/Linux (which is probably what you mean by Linux) is a complete operating system that uses Linux as its kernel.

The kernel of an operating system is responsible for doing all the dirty work. Except for the BIOS and the boot loader (which selects and/or loads an operating system kernel), it's the first thing that's loaded into your computer when it boots. It manages all the various devices your computer has, such as hard disks, sound and graphics cards, RAM, and so on, and it also takes care of some nifty extra stuff like virtual memory and multitasking (running several programs at once). The Windows kernel does things one way, the Linux kernel may do things another way. Which way is best has been the subject of endless discussions. Personally I think that Linux feels more stable, and I can run more things at once than in Windows. Some also say that DROD run better in Linux than in Windows, take that as you will :). In any case, both kernels improve all the time.

The distinction between the kernel and the rest of the operating system is important. In the case of Windows (and some others, like FreeBSD and Mac OS X), the two are strongly intertwined -- you don't usually use one without the other -- but in the case of Linux, there's a lot of different operating systems (called distributions, or distros) that all use Linux as their kernel. Distrowatch.com currently lists 336 different active Linux distros, and that's just the known ones. The non-kernel part of the operating system is responsible for making things work, such that you can log in, run programs, have a graphical user interface if you want one, and so on. Most of the Linux distros are similar, but some do things very differently. The vast majority (but not all) are Unix style, as Linux is a Unix-style kernel.

One difference that you as a user will probably notice is that the graphical user interface (GUI) is not part of the core system in Linux. The OS works perfectly without it, and as long as you don't require graphics, there's nothing you can do with the GUI that you can't do without it. The command-line interface in Linux (the shell), usually bash (Bourne Again SHell), is vastly superior to the DOS/Windows one, to the extent that you can't really compare the two (there's not any discussion about this one). In fact, many things are easier to do in text-mode, such as sending the output from one program as input to another program, which outputs to the input of yet another program, and so on. This is another difference; in Windows, you usually have one monolithic program to do exactly what you want, and not much else, while in Linux (and other Unices) you have a large amount of smaller programs that each specialize in doing a small part of the job, which you can plug together in a large variety of ways to do exactly what you want.

Of course, as a desktop user you're probably more interested in having a graphical user interface. Most desktop distros include some variant of X, the X Windows System -- usually XFree86 or Xorg (Xorg is more common these days, and have some more features). X takes care of setting up the display, input devices and such, and is responsible for doing all the drawing (hardware accelerated if possible), but it doesn't actually do much by itself. To get a desktop environment like you're used to in Windows, you want a Window Manager. There's a huge amount of window managers available, all the way from complete desktop environments with extreme amounts of eye-candy and lots of extra fluff, to minimalistic window managers that simply allow you to open windows, and nothing else. Most window managers and desktop environments support theming and are very configurable, so you can alter their look and feel and make things behave exactly the way you want. The most common desktop environments are KDE and Gnome. These give you a large amount of features, including everything you're used to from Windows and more (although some things works differently than you're used to). KDE is closer to Windows than Gnome, so you probably want to try that first. KDE is both a window manager and a desktop environment, while Gnome separates the window manager from the desktop environment, although it does come with a default wm.

One problem with Linux is that since there's so many various distros, there's many different ways to do things, so you may run into compatibility problems now and then. This has improved thanks to standards like the filesystem hierarchy and freedesktop.org, but it's still valid. Also, there's no standard GUI look, and there's many different user interface libraries that each may behave in different ways, so the desktop may not always be such a unified experience as you're used to from Windows and Mac OS X.

Another problem is that some hardware is Windows-only. This is also less of a problem these days, but you should be aware of it. There's also less commercial games (although there is a ridiculous amount of half-finished open source ones).

There's much more to be said, but I think this post is large enough by now and you're probably tired of reading it :). Linux isn't perfect for everyone, but many people seem to like it. The best way to see if it's something you could enjoy is probably to just try it yourself. You don't have to partition your hard drive, just head on over to the Knoppix site and download a LiveCD that you can burn to a CDR, pop in your CD-drive, and reboot into Linux without having to install anything. It'll even autodetect all your hardware, so you'll get right to the desktop without having to do anything except waiting for the CD to load.

Hope this helps, and good luck :)

- Gerry
08-26-2005 at 07:40 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
Chris
Level: Master Delver
Rank Points: 144
Registered: 08-12-2005
IP: Logged
icon Re: Linux (+1)  
Mattcrampy wrote:
Anyone know anything about Ubuntu?
I've been using Ubuntu for about 3 months now. I use it to play JtRH, and it works fine so long as I quit and restart the game every 4 or 5 hours. The current version (2.0.9) of JtRH has a memory leak which causes the process to grow continually. Apparently it will be fixed in the next version.

Is there anything I can help you with?

Chris.
08-28-2005 at 02:18 AM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
wackhead_uk
Level: Smiter
Avatar
Rank Points: 352
Registered: 06-21-2004
IP: Logged
icon Re: Linux (0)  
I did a little dual boot thingy with windows XP and debian and it worked pretty well, but now I'm setting my sights on getting linux onto a very old laptop I obtained for free...who needs a new laptop when I've got my desktop as well...
09-07-2005 at 12:08 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts This architect's holds Quote Reply
Chris
Level: Master Delver
Rank Points: 144
Registered: 08-12-2005
IP: Logged
icon Re: Linux (0)  
wackhead_uk wrote:
who needs a new laptop when I've got my desktop as well...
Somebody who likes playing DROD in BED?
09-07-2005 at 12:54 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
AlefBet
Level: Smitemaster
Rank Points: 979
Registered: 07-16-2003
IP: Logged
icon Re: Linux (+1)  
Ubuntu is actually based on Debian. But Knoppix is also based on Debian, so they have some similarities in how they work. (Of course, all Linuxes have some similarities to each other, but you know....) Still, they look somewhat different: Knoppix is focused on KDE and Ubuntu uses Gnome. You can use either with either; that's just what you get by default. (And both Gnome and KDE are very usable and quite newbie friendly.)

Anyway, we use Debian at my work and I've installed Ubuntu on my sister's computer and one of my own spare machines. I recommend Ubuntu for anyone that wants to try Linux; it's one of the more newbie friendly distributions, and very easy to maintain. Of course, you'll have to do a bit of googling to find out how to do some things, but the good news is that how to do stuff usually comes up pretty quick on Google.

Knoppix's live CD is great for trying it out, but Ubuntu also has a live CD if you want to try it out without bothering your hard drive.

Edit: Hmm. This post was actually in response to a stale post that had accidentally been marked as new. Oh, well. Maybe someone will find it useful.

____________________________
I was charged with conspiracy to commit jay-walking, and accessory to changing lanes without signaling after the fact :blush.

++Adam H. Peterson

[Last edited by AlefBet at 09-07-2005 05:24 PM]
09-07-2005 at 04:15 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
b0rsuk
Level: Smiter
Avatar
Rank Points: 489
Registered: 11-23-2003
IP: Logged
icon Ubuntu ? (0)  
Hey

I've got a quick question: can you tell me anything about Ubuntu ? I read on slashdot that a new version just became available. And it's named... Breezing Badger ! An omen, no doubt !

...because for the first time in several months I'm actually up to date with university program. I just finished bash script, I'll most probably finish awk one tomorrow....
And my linux distribution is broken since a long time. I didn't fix it due to lack of internet connection back home (depends on how you define home. Some say home it's where there's a decent graveyard and strangers can disappear without awkward questions). It still works, but it's an old Debian install WITHOUT net (apt-get). So it's easier to reinstall than to update it.

Err, in short, what do you think of Ubuntu ?
- it's supposed to be related to Debian, which I think is a good thing.
- it's supposed to be for humans. Not bad.
- it's meant to be easier to use than Debian. While this is a good thing in general, I have mixed feelings about this. For some reason Mandrake felt fishy to me. Too much is automated and I don't know what's happening. Give me good enough manual/net access, and I can solve problems on my own... I don't trust automatic 'wizards' and scripts too much, especially if they change with new version, ocassionaly malfunction, etc. You may say I'm paranoid, but there was a funny situation at university one day. Our java teacher didn't know how to mount a hard disk drive without fancy tools, and we had to help him.

I'm going to give it a try possibly as soon as monday (depends on how long it takes to trick someone into burning the images for me).

____________________________

http://www.gamasutra.com/features/20051128/adams_01.shtml
10-13-2005 at 09:10 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
AlefBet
Level: Smitemaster
Rank Points: 979
Registered: 07-16-2003
IP: Logged
icon Re: Linux (+2)  
I switched my work machine from Debian Etch to Ubuntu (Hoary Hedgehog) about a month and a half ago. Using Ubuntu is a lot like using Debian, except a lot of desktop-ey things have been smoothed over. (For example, flash USB drives just work without any setting stuff up.) You can still customize it about as well as you can customize Debian. It's not like it does stuff for you, it's just a bit more polished.

Some caveats about it, though: You can't use Debian Apt sources; you need to stick with Ubuntu Apt sources. (Sometimes it actually will work, but it's not recommended and can get you into dependency weirdness.) That's not a big deal in my opinion though, because the Ubuntu repositories are pretty complete. There's a lot of flow between Debian and Ubuntu, so if one has a package, the other generally has it available too or will get it pretty soon.

Also, Ubuntu is Gnome based. If you (like me) prefer Gnome to KDE, that's not a problem, but it ought to be mentioned. There's anothere project called Kubuntu, which is basically Ubuntu with KDE instead of Gnome, and you can have both KDE and Gnome installed, but the Ubuntu distro itself is Gnome focused. (This is as opposed to Debian which is desktop-agnostic, and by default gives you no desktop environment until you request one through Apt.)

And, a lot of Debian software is available in Ubuntu through the Backports repository. If something is in Debian, but isn't in Ubuntu, you can check the Backports repository and you'll probably find it there. However, I don't recommend leaving Backports in your sources list all the time. Sometimes they use slightly different library versions which can confuse Apt when doing an apt-get upgrade. So if something is in Backports that I want, I uncomment out the Backports source in my sources.list and run an "apt-get update && apt-get install package_I_want" and then recomment the Backports source out again.

Still, I highly recommend Ubuntu as a starting or experienced Linux user's desktop distribution. Debian makes a pretty good desktop too, but it's a bit better for servers now that Ubuntu is here. I personally still use Gentoo for my personal machine, but for my work machine where I want it to be customizable but still no-hassle, I use Ubuntu.

One last caveat: Breezy was just released today, so Ubuntu's servers are being hit hard. If you're downloading ISO CD images for the install CDs, definitely use a mirror. It'll be faster for you and better for everyone else too. Also, the apt repository is being hit hard right now too with everyone updating their current Hoary installations to Breezy. So you might want to wait a day or two to install or to update Apt.

____________________________
I was charged with conspiracy to commit jay-walking, and accessory to changing lanes without signaling after the fact :blush.

++Adam H. Peterson
10-13-2005 at 10:10 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
Chris
Level: Master Delver
Rank Points: 144
Registered: 08-12-2005
IP: Logged
icon Re: Linux (+2)  
He's "breezy", not "breezing", but yes, it's an omen, and you should definitely install it right now! :)

While the download servers are very busy, the bittorrent downloads are working very well.

Point your bittorrent client here:

http://ftp.ussg.iu.edu/linux/ubuntu-releases/5.10/ubuntu-5.10-install-i386.iso.torrent

for the i386 installer, or look here for other versions.
10-14-2005 at 12:27 AM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
b0rsuk
Level: Smiter
Avatar
Rank Points: 489
Registered: 11-23-2003
IP: Logged
icon Re: Linux (0)  
Hmm. I didn't try Gnome too much. I used it for a while a couple of years ago, when it was much less polished.
I don't understand why some people say it's better. More convenient ? I use shell quite a lot anyway, and I'm happy enough when I can run some fancy programs/3D games. Two more clicks once in a while doesn't sound like a big deal, unless I'm missing something....
I may as well try Gnome this time.

Kate is kde-specific text editor.... I wonder if it would be easy to install on gnome. Or perhaps there's something better.
Actually, I'm too stupid to use Emacs. I usually program in...mc.

EDIT
Important thing. Can I expect LiveCD (bootcd) to have ntfs filesystem support ? My friend recently switched to amd64 and mounting-my-hdd-as-master trick doesn't really work anymore. I need a way to transfer something from ntfs to ext3 or similar.
(before you ask, I have only 5GB on my windows partition).
And it appears that newest Ubuntu has even amd64 bootcd.

____________________________

http://www.gamasutra.com/features/20051128/adams_01.shtml

[Last edited by b0rsuk at 10-14-2005 12:43 AM]
10-14-2005 at 12:33 AM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
AlefBet
Level: Smitemaster
Rank Points: 979
Registered: 07-16-2003
IP: Logged
icon Re: Linux (0)  
b0rsuk wrote:
Kate is kde-specific text editor.... I wonder if it would be easy to install on gnome. Or perhaps there's something better.
Well, I use gvim and some Emacs, but you can run any KDE app under Gnome (and vice versa). If you install it through Apt, it will automatically get the KDE libraries you need.
Important thing. Can I expect LiveCD (bootcd) to have ntfs filesystem support ?
I don't know. I wouldn't be surprised either way. My guess would be yes. I'm pretty sure Knoppix does. It's only safe to use read-only, though.

____________________________
I was charged with conspiracy to commit jay-walking, and accessory to changing lanes without signaling after the fact :blush.

++Adam H. Peterson
10-14-2005 at 01:04 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
b0rsuk
Level: Smiter
Avatar
Rank Points: 489
Registered: 11-23-2003
IP: Logged
icon Re: Linux (0)  
....but ntfs ==> ext3 is fairly safe when running linux, right ? That's what I meant.

____________________________

http://www.gamasutra.com/features/20051128/adams_01.shtml
10-14-2005 at 07:48 AM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
AlefBet
Level: Smitemaster
Rank Points: 979
Registered: 07-16-2003
IP: Logged
icon Re: Linux (0)  
b0rsuk wrote:
....but ntfs ==> ext3 is fairly safe when running linux, right ? That's what I meant.
You mean copying files off an NTFS partition onto a Linux one (ext2, ext3, reiserfs, etc.)? That's fine. It's only changing stuff on the NTFS partition itself you need to worry about.

____________________________
I was charged with conspiracy to commit jay-walking, and accessory to changing lanes without signaling after the fact :blush.

++Adam H. Peterson
10-14-2005 at 08:58 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
b0rsuk
Level: Smiter
Avatar
Rank Points: 489
Registered: 11-23-2003
IP: Logged
icon Re: Linux (0)  
I've installed Kubuntu on my machine and it seems to work well. But I noticed an error message on startup (something about xserver). I can't check it now since I still have some components left to transport. The box is already here.
Of course, I don't have too much programs without net access. That's going to change soon, probably today.
-----------

What Linux distros would you recommend for Linux beginner ? Let me explain. I already have Kubuntu installed so I'll probably stick to it. But my friend, who's not so much enthusiastic about Linux as sick of Windows, would like to convert. Starting with dual boot.
I visited him with Kubuntu amd64 livecd, and... initialization stopped on "checking battery state". This is not a notebook, mind you. After some googling I found that it's a known bug related to broken nvidia drivers. It can be remedied by installing the drivers manually. I found two or so guides or Ubuntu forums.
So I'm going to visit him again next Monday. This time with normal amd64 install disk. I'll try to install Kubuntu there, and fix the driver issue immediately (If I understand correctly, in case of normal install cd the problem appears after installing broken drivers using Adept gui tool, and even with broken drivers the system can still boot in recovery mode.

So, I need to install Linux system there in up to several hours (one go). I'll try Kubuntu first, but I need backup plans. Priorities:
- such a distro should come on 1-2 cd's, no more. I have about 20-30kb/sek transfer here. On a second thought, I can ask him to download some CD's too, but you get the idea.
- it has to be newbie-friendly. Graphical configuration tools are big plus. He's a bit scared of console. On the other hand, he's rather experienced Windows user, so he's not completely computer-illiterate.
- some kind of semi-automatic package management tool benefiting from internet access (like apt, Synaptic, Adept...).
- it should be able to detect network configuration reliably. I may not be able to set it up manually, because I never had to do it myself before (my brother is married and gone, fortunatelly). Inserting dns/proxy IP into one of /etc/blah files is peak of my ability here. (but I don't expect trouble here - several years ago Mandrake managed to get it right on his machine).

If everything else fails, I need something to boot linux, mount drives, and exchange data between NTFS and ext3 partitions.
===========================
So.....
For installation, it could be Ubuntu, Xandros, Mandriva, what else ? Mandriva is commercial, Xandros has bad fame among my university collegues.

For booting, I expect Knoppix to succeed.
EDIT: by the way....

I'm struggling hard with my grep homework. I'm supposed to write a command that examines /etc/passwd and /etc/group files, and

a) prints all users with specific first name
b) same, except they have to (I simplify) belong to same group. In this case 7437. I went this far:

a----- wyciaga loginy osob z imieniem Pawel z /etc/passwd  i /etc/group
egrep '^[a-z]*:x:[0-9]*:[0-9]*:Paweł [A-Z][a-z]*:' /etc/passwd | awk '{gsub(/:.*/, //, $1); print $1}'
b------- to samo z zaocznych
grep 7437 /etc/passwd | egrep '^[a-z]*:x:[0-9]*:[0-9]*:Paweł [A-Z][a-z]*:' | awk '{gsub(/:.*/, //, $1); print $1}'


Ideally, it would use just grep (and bash). But a bit of awk for flavour is also allowed. Now I'm trying my best to redirect "last pipe" or awk output to another grep comand. BUT not for being grepped - I'm trying to make last grep search for these words (in /etc/groups).
I tried assigning it to bash variable (separated by ; and then grep
$var
) but variable's contents turns out to look like this: "user1 user2 user3" etc. Grep takes user1 as pattern and all users starting with user2 as source file.

Is there any better approach to grepping it ? I use awk just for gsub (replaces parameter1 with parameter 2 inside parameter 3). So, basically, for extracting username from longish string. I think the problem is that awk processes entire file before it passes it to next pipe. I could use cut shell tool, but I don't quite understand its syntax. And googling for something named cut is fairly hard.

____________________________

http://www.gamasutra.com/features/20051128/adams_01.shtml

[Last edited by b0rsuk at 10-19-2005 01:35 PM]
10-19-2005 at 12:11 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
Chris
Level: Master Delver
Rank Points: 144
Registered: 08-12-2005
IP: Logged
icon Re: Linux (+1)  
First off, you don't need to google for "cut", you need to read the manual. In a terminal, type "man cut".

You'll see that -d sets the delimiter and -f says which field to use.

So:

$ cut -d: -f5 /etc/passwd

will give you all the full name strings.

It sounds like you want to run your 2nd grep for each of the names that the first one returns.

The best way to do this is to put a loop in the pipe, like this:

$ grep ":Pavel" /etc/passwd | cut -d: -f1 | while read name; do grep "$name" /etc/group | ...; done

The while loop will read each name from the grep and run use grep on each one in turn to find matching lines in /etc/group.

10-19-2005 at 03:41 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
AlefBet
Level: Smitemaster
Rank Points: 979
Registered: 07-16-2003
IP: Logged
icon Re: Linux (+1)  
The distributions I can think of that install from one disk are Ubuntu, Kubuntu, Debian, Knoppix, and Gentoo. I'm sure there are others (maybe Slackware, LFS, or BSD -- which isn't really Linux), but I've only used or seen about 8 distros. Mandriva may not work for you because I believe it comes on threeish disks. If not for that, it would be pretty newbie friendly. Fedora Core is basically the same story, pretty newbie friendly but uses four install disks. Gentoo is powerful, but I only recommend it for experienced Linuxers.

Any of Ubuntu, Kubuntu, Debian, and Knoppix would be great for beginners. However, they're all Debian-based, so if one is having a problem, the others may as well. Ubuntu and Kubuntu are more related to each other than the other two, though, so you might want to bring either Ubuntu or Kubuntu and then also Debian. And you may be bringing Knoppix with you anyway, as a quickie tool.

With regard to your grep/awk question, I generally do that type of stuff with Perl and I've never used awk (except a couple of lines I've copied out of man pages for other tools). But your variable name problem can be solved by putting the variable in quotes. You can also go back and forth between single quotes and double quotes, such as:
grep -e '^first_part_of_regex'"$variable"'last_part_of_regex$' file1 file2 ...
In single quotes, variable interpolation doesn't occur, while in double quotes, variable interpolation and escape sequence translation does happen. Also, double quotes will cause your variable to be interpreted as a single word (unless it's an array expression) rather than as a sequence of tokens.

HTH

____________________________
I was charged with conspiracy to commit jay-walking, and accessory to changing lanes without signaling after the fact :blush.

++Adam H. Peterson
10-19-2005 at 04:34 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
Chris
Level: Master Delver
Rank Points: 144
Registered: 08-12-2005
IP: Logged
icon Re: Linux (+1)  
I don't think quote will help.

var is set to "user1 user2 user3".

He wants to find lines in /etc/group containing 'user1' or 'user2' or 'user3'.

Quoting $var will find lines containing "user1 user2 user3", of which there are none.
10-19-2005 at 04:41 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
trick
Level: Legendary Smitemaster
Rank Points: 2580
Registered: 04-12-2003
IP: Logged
icon Re: Linux (+1)  
That's easy to fix. Just change any spaces in "$var" to \\| (grep -e) or | (grep -E). Here's one way to do it:
echo $var:/etc/passwd | sed 'y/ :/| /' | xargs grep -E

:)


Edit: If this is just for fully bash-compatible shells, it's even easier:
grep -E ${var/ /|} /etc/passwd

- Gerry

[Last edited by trick at 10-19-2005 08:17 PM]
10-19-2005 at 06:04 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
b0rsuk
Level: Smiter
Avatar
Rank Points: 489
Registered: 11-23-2003
IP: Logged
icon Re: Linux (0)  
Ummm...

Chriss's solution came closest. Especially because it was only one that worked like it should.

Except...
Except that
 grep "$name" /etc/group 
is a stupid thing to do. I learned this hard way. That's because grep prints entire line.... So the output is exceptionally ugly.

I tried something hardcore(or stupid). I added the following to the end of my command. Yes, it's if nested inside while, and it's still in the same line.

 ... | cut -d: -f1 | while read name; do if [ grep "$name" /etc/group ]; then echo "$name"; fi; done


Bash complains that it expects binary operator (inside of if condition). If I change the condition to true or false, it works. But I don't know how to make it work if it's successfuly grepped. I tried to put it between
` `
, and it worked... but at that point bash just goes crazy.
Another thing: if I put true or false in place of grep condition, otput for false and true is exactly the same ! How ?
just while loop, without if, would be enough if I could somehow extract
$name
from grep output. Preferably without further 20 lines of script.
By the way, cut works much better than gsub, because gsub insists on adding number of successful operations to the end of string.
As for man pages, they're quite unreadable for me. They almost never contain examples. When I use them it's mostly for -blah options.

____________________________

http://www.gamasutra.com/features/20051128/adams_01.shtml

[Last edited by b0rsuk at 10-20-2005 12:11 AM]
10-20-2005 at 12:05 AM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
trick
Level: Legendary Smitemaster
Rank Points: 2580
Registered: 04-12-2003
IP: Logged
icon Re: Linux (0)  
b0rsuk wrote:
 ... | cut -d: -f1 | while read name; do if [ grep "$name" /etc/group ]; then echo "$name"; fi; done


Bash complains that it expects binary operator (inside of if condition).
What you're doing there is checking if the strings "grep", "$name" and "/etc/group" are true, which doesn't make sense. First, you need to actually run the grep command, second, you need to compare something. Here's one solution (untested, but should work):
... ; do grep -q "$name" /etc/group; if [ -z $? ]; then echo "$name"; fi; done

The -q option to grep tells it to not print anything. [ -z $? ] checks if the exit code ($?) of the last command (the grep) was the integer zero (-z), which is true if grep found a match. (If you wanted to check for a non-match, you could change the check to [ ! -z $? ]).

Edit: Er, never mind that, I'm stupid. This is better:
...; do grep -q "$name" /etc/group && echo "$name"; done


- Gerry

[Last edited by trick at 10-20-2005 12:27 AM]
10-20-2005 at 12:23 AM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
b0rsuk
Level: Smiter
Avatar
Rank Points: 489
Registered: 11-23-2003
IP: Logged
icon Re: Linux (0)  
Thanks, the last line with "and" is great - simple and elegant. It appears that you don't really need double quote there, it works anyway.

____________________________

http://www.gamasutra.com/features/20051128/adams_01.shtml
10-20-2005 at 09:07 AM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
jamie
Level: Smiter
Rank Points: 365
Registered: 04-15-2005
IP: Logged
icon Re: Linux (0)  
AlefBet wrote:
The distributions I can think of that install from one disk are Ubuntu, Kubuntu, Debian, Knoppix, and Gentoo. I'm sure there are others (maybe Slackware, LFS, or BSD -- which isn't really Linux)

"really" ? Pffft. Isn't, FULL STOP! :P

FreeBSD installs off one disk, there are also numerous versions that run off a live-cd.

Still, you are after a Linux distro, and Linux isn't really FreeBSD ;-)

____________________________
#f3i2g# Disclaimer: I'm Welsh, left-handed, and stupid. #f3i2g#
10-20-2005 at 10:02 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
b0rsuk
Level: Smiter
Avatar
Rank Points: 489
Registered: 11-23-2003
IP: Logged
icon Re: Linux (0)  
We have been told that Linux and *BSD are both branches of unix. Of a bit different unices, but still.

By the way: Can anyone explain to me, once and for all, what's the difference between

find -perm -022
and
find -perm +022
?
The one with + seems less restrictive, but I need to know exact meaning.
The plus is supposed to mean "any of bytes is set" and minus "all of bytes are set".

Man find is quite cryptic.... does it mean that -perm -022 finds files which allow writing by both "anyone" and "group", whereas -perm +022 finds files which allow writing by "anyone" OR "group" ?
-----------

I created a directory, and applied chmod 777 to it. Why can't I find it with find /path -type d -perm -002 ?



____________________________

http://www.gamasutra.com/features/20051128/adams_01.shtml

[Last edited by b0rsuk at 10-20-2005 12:09 PM]
10-20-2005 at 12:01 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
Chris
Level: Master Delver
Rank Points: 144
Registered: 08-12-2005
IP: Logged
icon Re: Linux (0)  
b0rsuk wrote:
Ummm...

Chriss's solution came closest. Especially because it was only one that worked like it should.

Except...
Except that
 grep "$name" /etc/group 
is a stupid thing to do. I learned this hard way. That's because grep prints entire line.... So the output is exceptionally ugly.

But I wrote:
while read name; do grep "$name" /etc/group | ...; done

Notice the "..."? That means "and so on" - you were supposed to pipe the output of the grep into something which pulled out the parts you wanted.
10-20-2005 at 01:26 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
Chris
Level: Master Delver
Rank Points: 144
Registered: 08-12-2005
IP: Logged
icon Re: Linux (0)  
b0rsuk wrote:
By the way: Can anyone explain to me, once and for all, what's the difference between

find -perm -022
and
find -perm +022
?

This is copied from the find(1) man page. I don't know why people have a hard time understanding manuals - is there anything unclear about the following text?

"find . -perm +022" matches files which are writable by either their owner or their group. The files don't have to be writable by both the owner and group to be matched; either will do.

"find . -perm -022" matches files which are writable by both their owner and their group.

As for your mode 777 directory, both +022 and -022 should find it. I don't know what you're doing wrong. Paste a copy of the terminal session where you make the directory, chmod it, and try finding it, and I'll try to tell you what's wrong. Here's how it went when I tried:
$ mkdir /tmp/dir
$ chmod 777 /tmp/dir
$ find /tmp/dir -type d -perm -022
/tmp/dir
$ find /tmp/dir -type d -perm +022
/tmp/dir

10-20-2005 at 01:36 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
Chris
Level: Master Delver
Rank Points: 144
Registered: 08-12-2005
IP: Logged
icon Re: Linux (+1)  
b0rsuk wrote:
I tried something hardcore(or stupid). I added the following to the end of my command. Yes, it's if nested inside while, and it's still in the same line.

 ... | cut -d: -f1 | while read name; do if [ grep "$name" /etc/group ]; then echo "$name"; fi; done


You need to get rid of the square brackets:

 ... | cut -d: -f1 | while read name; do if grep "$name" /etc/group; then echo "$name"; fi; done


You probably also want to make grep throw away its output or you'll see it on the screen - either use a flag to tell grep to be quiet, which will work with GNU grep but not in a lot of proprietary greps:

 ... | cut -d: -f1 | while read name; do if grep --quiet "$name" /etc/group; then echo "$name"; fi; done


or explicitly redirect grep's output to /dev/null:

 ... | cut -d: -f1 | while read name; do if grep "$name" /etc/group > /dev/null; then echo "$name"; fi; done


As a third alternative, you can get rid of the 'if/then/fi' and use "&&" instead. writing "a && b" will only run b if a is 'successful':

 ... | cut -d: -f1 | while read name; do grep "$name" /etc/group > /dev/null && echo "$name"; done


(I won't write the 4th alternative, which involves using && with --quiet - you can work that one out for yourself)

One question, however. You're running 'grep' to search for each username in the group file. Every user is in at least one group, and so the grep will always succeed. What are you really trying to do?

[Last edited by Chris at 10-20-2005 01:45 PM : oops - forgot to remove the 'fi' when removing the 'if']
10-20-2005 at 01:44 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
Mattcrampy
Level: Smitemaster
Avatar
Rank Points: 2388
Registered: 05-29-2003
IP: Logged
icon Re: Linux (0)  
Boy, I see Linux has got that user-friendly UI down pat.

:p

____________________________
What do you call an elephant at the North Pole?
Click here to view the secret text

10-20-2005 at 02:11 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
Chris
Level: Master Delver
Rank Points: 144
Registered: 08-12-2005
IP: Logged
icon Re: Linux (0)  
This is the command line, not the GUI.

Try doing the same thing from the Windows command line and see how far you get.
10-20-2005 at 03:20 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
trick
Level: Legendary Smitemaster
Rank Points: 2580
Registered: 04-12-2003
IP: Logged
icon Re: Linux (+1)  
Try doing the same thing from the Windows command line and see how far you get.
I think that's missing the point. The Windows command line (aka DOS prompt) has been outdated for decades. Anyway, the point is, try doing the same thing from a GUI :).

It's not impossible, but some things are just much easier to do in the shell. You can chain together existing, highly specialized tools in an infinite amount of ways and make them do exactly what you want without having to make any new tools for the job.

- Gerry
10-20-2005 at 07:47 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
12
Page 3 of 5
45
New Topic New Poll Post Reply
Caravel Forum : Other Boards : Anything : Linux (Continued from somewhere else....)
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.