PDA

View Full Version : The Linux Info Thread



Bitchkoma
05-21-2009, 02:31 AM
I am starting this thread for the purpose of not derailing too much other threads with Linux related stuff. Two things; it helps keep the other threads a bit more tidier but more importantly, it helps make looking for info on linux much much easier. As it is, the info is all over the place.

So here we go.

I'll start with a question that's been bugging me with one of the most commonly used shell command -- chmod.

How the fuck do I use this? The syntax options are incredibly complicated. Nothing I can find on the net (easily) gives me a comprehensive list of examples on how to format the options for so and so purpose. In fact, all the man, help and info pages of the shell commands are fairly useless with their examples.

And fucking sudo. It's slightly more annoying than Vista's UAC.

hp
05-21-2009, 02:40 AM
Set file permissions

[offsite:1pt38rzf]-rwxr-xr-x

This representation of the files permissions means exactly the same thing as 755. Her is how we get to that:

The first column is the filetype if this were a directory it would be d

The next three columns (rwx in our example above) are the owners permissions. In this case the owner can read, write, and execute the file.

The next three columns are the group's permissions (r-x in our example above). The group members can read and execute the file. The dash in the middle position means that the group does not have write permissions.

The next three columns are the permissions for all other users(r-x in our example above). Everyone else can read and execute the file, but they do not have write permissions.

The way that this translates into the 755 is that each type of permission has a value.

* read = 4
* write = 2
* execute = 1

Adding up the permissions allowed for each type of user gives you the three digit equivalent of the files permissions[/offsite:1pt38rzf]

hp
05-21-2009, 02:48 AM
A bit more - include directory permission discussion
[offsite=http://www.perlfect.com/articles/chmod.shtml:2864vnud]Directories

[nick@thekla src] $ ls -l
-rwxr-xr-x 1 nick users 382 Jan 19 11:49 bscoped.pl
drwxr-xr-x 3 nick users 1024 Jan 19 11:19 lib/
-rwxr-xr-x 1 nick users 1874 Jan 19 10:23 socktest.pl

Another interesting thing to note is that lib/ which is a directory has permissions, too. Permissions take a different meaning for directories. Here's what they mean:

* read determines if a user can view the directory's contents, i.e. do ls in it.
* write determines if a user can create new files or delete file in the directory. (Note here that this essentially means that a user with write access toa directory can delete files in the directory even if he/she doesn't have write permissions for the file! So be careful with this.)
* execute determines if the user can cd into the directory.

chmod

To set/modify a file's permissions you need to use the chmod program. Of course, only the owner of a file may use chmod to alter a file's permissions. chmod has the following syntax: chmod [options] mode file(s)

The 'mode' part specifies the new permissions for the file(s) that follow as arguments. A mode specifies which user's permissions should be changed, and afterwards which access types should be changed. Let's say for example: chmod a-x socktest.pl This means that the execute bit should be cleared (-) for all users. (owner, group and the rest of the world) The permissions start with a letter specifying what users should be affected by the change, this might be any of the following:

* u the owner user
* g the owner group
* o others (neither u, nor g)
* a all users

This is followed by a change instruction which consists of a +(set bit) or -(clear bit) and the letter corresponding to the bit that should be changed.

Strange numbers...

You might have encountered things like chmod 755 somefile and of course you will be wondering what this is. The thing is, that you can change the entire permission pattern of a file in one go using one number like the one in this example. Every mode has a corresponding code number, and as we shall see there is a very simple way to figure out what number corresponds to any mode.

Every one of the three digits on the mode number corresponds to one of the three permission triplets. (u, g and o) Every permission bit in a triplet corresponds to a value: 4 for r, 2 for w, 1 for x. If the permission bit you add this value to the number of the permission triplet. If it is cleared, then you add nothing. (Some of you might notice that in fact, the number for a triplet is the octal value corresponding to the three-bit pattern - if you don't know what an octal value is, it doesn't really matter, just follow the intstructions) So if a file has rwxr-xr-x permissions we do the following calculation:

Triplet for u: rwx => 4 + 2 + 1 = 7
Triplet for g: r-x => 4 + 0 + 1 = 5
Tripler for o: r-x => 4 + 0 + 1 = 5
Which makes : 755[/offsite:2864vnud]

Bitchkoma
05-21-2009, 02:58 AM
From the post preceding the above..

So it's

| - | rwx | r-x | r-x |

what does the "-" in the first column signify?

Bitchkoma
05-21-2009, 03:01 AM
And then..

chmod -R ugo=rwx [target]

is a fucking bad idea then?

hp
05-21-2009, 03:05 AM
The first dash means its a file, not a directory.

Setting everything to rwx for groups and others in not a good idea.

usually the owner has 7 rwx, and the group and others have r and x if the files and programs are to be viewed and executed. You might have some files that are not viewable by anyone else.

Bitchkoma
05-21-2009, 03:10 AM
Ahh... so is that's why chmod -R 666 [directory] just makes everything disappear/unexecutable? because the directory can't be cd'd in?

hp
05-21-2009, 03:15 AM
Correct. You dirs should be a 7.. Have to be careful when using recurse

edit: also means you can't run your own programs

Bitchkoma
05-21-2009, 03:23 AM
But without recursion I'd have to set everything one by one.. it's a bitch if there are many files and directories and more files and directories within the directories.

mojo
05-21-2009, 03:25 AM
:roll:

geeks.






:D





anyone for a game of D&D.

hp
05-21-2009, 03:31 AM
Just keep your files rwx. (7). when you recurse. Normally as you create file,etc you are only dealing with a few. To fix this situation then just be sure to give yourself 7. You can only set you files (you user id). Right. Set 755 and fix any special cases - files to not share or execute by group/others.

hp
05-21-2009, 03:35 AM
geeks.


Not my fault, born into it. I got into this stuff by accident and never able to leave.

mojo
05-21-2009, 03:40 AM
geeks.


Not my fault, born into it. I got into this stuff by accident and never able to leave.


haha...dont worry i was a geek too a different times, just not a computer geek.

hp
05-21-2009, 03:41 AM
chmod -R 755 from your top level dir that needs the changes

hp
05-21-2009, 03:42 AM
Computers are the only things that ever listen to me.

mojo
05-21-2009, 04:01 AM
Computers are the only things that ever listen to me.

:lol:


mine talk to me......and not in a nice way either. usually something along the lines of "what the fuck are you doing you idiot, don't touch that"

Bitchkoma
05-21-2009, 04:07 AM
So for the files|directories in /var/www/

if i want to set the permissions for all files and directories to r-x for all but the owner, it's


sudo chmod -R 755 [directory]

Got it. :cheers:

So what cases in /var/www/ would I want to set the permission to something else?

hp
05-21-2009, 10:19 AM
this on Apache Srever (http://www.devshed.com/c/a/Apache/Setting-Permissions-in-Apache/) looks informative.

pack3tg0st
05-21-2009, 11:04 AM
nice! We have a nerd thread!!! sweetness!

HP: Computers listen to me a little too well... they're always doing exactly what I tell them to do, and not what I want them to do hehehe..

Mojo: At least with linux, when it talks to you it doesn't say "Abort Retry Fail?" lol

Man, I miss the old DOS days.... sigh...

I've got all sorts of crazy books on linux commands... so when I get my books unpacked, I'll be able to help with just about everything...

Recommended book for all linux users though is the Linux Administrator's Guide.

apeci
05-21-2009, 11:12 AM
And fucking sudo. It's slightly more annoying than Vista's UAC.
You know you can just do everything as root if you want. But of course if you're not sure what you're doing you risk destroying stuff. :)

cat /dev/urandom > /dev/hd*

Bitchkoma
05-21-2009, 01:32 PM
I've got all sorts of crazy books on linux commands... so when I get my books unpacked, I'll be able to help with just about everything...

Recommended book for all linux users though is the Linux Administrator's Guide.

Damn.. that's not in the list; I found this torrent with 1100 ebooks. Madness, but also very nice. Knowledge is a right.

mojo
05-21-2009, 11:23 PM
i went looking for a beginners book but only got yahoo/amazon/google books.
the other tutorials i found were way over my fucking head.
i need something that teaches 8 year olds.

apeci
05-21-2009, 11:31 PM
The best way to learn is to take an old computer, download a distro, install and start playing around. Set an objective... like getting online. Much easier these days now that you don't have to do CHAP or PPP. Expect to royally fuck everything up and have to reinstall several times at first, but you'll figure things out pretty quick.

mojo
05-21-2009, 11:36 PM
hmmm..i do have an old hp desktop that is gathering dust since i got my laptop.

Ducky
05-21-2009, 11:43 PM
*flickin thingys resembling dirt off my table*

Fuckers are stickin there pretty good. Guess I should look for a knife to scrape em. Ahhhh fuck it...(yelling out to hubby in the background to get me a tea) Dear soul is boiling the kettle.

So fuckinnnnnnnnnn wiped here.lololololololol

I bought more beer than I thought...fuckin hell. sonsofwhores can sit in my fridge til I need em next.

yeah yeah...I'm on my own little trip yeah? so fuckiin what?

'having a good time though.

gonna sign off...drink ma tea til I can't. pretty tired. love ya all!

Night

Bitchkoma
05-22-2009, 01:08 AM
hmmm..i do have an old hp desktop that is gathering dust since i got my laptop.

For absolute beginners, Ubuntu (http://www.ubuntu.com/) is pretty good. Easy to install (even on a fucking thumbdrive), easy to get support from the forums as well. And they'll send you the install CD for free if you don't want to download the ISO image and burn it to a CD yourself. (Or if you just like having a nice factory labeled CD /*that's why I ordered it lol */).

As a matter of fact, I'm still using it to experiment around even though I've downloaded and burned a copy of the original Debian.

Bitchkoma
05-22-2009, 04:08 AM
What the fuck does cygwin do? Can't get it to start on an XP machine. Was experimenting running it along with putty to ssh into my linux box and run gui apps off it.

I just downloaded a 50+ mb bunch of nothing. :beatdown:

Cogburn
05-22-2009, 02:25 PM
http://www.thegimcrackmiscellany.com/wp-content/uploads/2008/06/linux.jpg

Carry on.

apeci
05-22-2009, 03:37 PM
Right. Only awesome people are. Kit cars kick ass.

skunk
05-22-2009, 08:07 PM
Was that a lame ass nerd insult apeci?

apeci
05-22-2009, 09:15 PM
Huh? No. It was a statement of truth.

As an aside I just acquired a dual xeon 2.4ghz box for free... my linny machine is getting an upgrade!

Bitchkoma
05-22-2009, 10:01 PM
jealousy...

apeci
05-22-2009, 11:46 PM
Correction, dual xeon 2.8ghz with hyperthreading.

Lexion
05-23-2009, 04:09 AM
[attachment=0:1ntj09rp]Apeci.jpg[/attachment:1ntj09rp]

Love ya man !!!

Lex

Eyeforalie
05-23-2009, 05:08 AM
Ape

Eyeforalie
05-23-2009, 05:52 AM
Truth

Lexion
05-23-2009, 05:57 AM
[attachment=0:tta9n2hz]derailed2.jpg[/attachment:tta9n2hz]

Eyeforalie
05-23-2009, 05:59 AM
FTW!!!

pack3tg0st
05-23-2009, 06:29 AM
http://www.redbloodedthing.com/blog/uploaded_images/linux_body_painting-792353.jpg

Its hard to derail a linux thread lol

apeci
05-23-2009, 11:03 AM
Nice.

apeci
05-24-2009, 04:46 AM
Searching for aliens makes for a nice cpu test.

http://i43.photobucket.com/albums/e354/apcphoto/seti_load-thumb.jpg (http://i43.photobucket.com/albums/e354/apcphoto/seti_load.jpg)

And while the fans barely turn during normal use they really move some air under this load. This box is sweeeeeeet.

hp
05-24-2009, 06:51 AM
Anyone still think Seti is looking for alien signals. Big brother has you volunteering to help with his monitoring.

apeci
05-24-2009, 12:07 PM
I'm a bigger fan of the folding@home project, however it still makes for a good cpu test. Bitch. :)

Bitchkoma
05-28-2009, 03:38 PM
SSH tunneling.

Ok, so I understand that tunneling can be used to bypass firewalls or to create a proxy. Can it also be used to avoid traffic shaping?

hp
05-28-2009, 03:42 PM
Nothing bypasses a firewall. Things are allowed through or blocked.

Bitchkoma
05-28-2009, 03:57 PM
then what's the point of tunneling?

Cogburn
05-28-2009, 04:35 PM
then what's the point of tunneling?
Think of it like a sodastraw of encryption through which your information passes.

The straw is then stuck into the internet at large providing a level of security against packet sniffing.

hp
05-28-2009, 04:40 PM
Cog gave a good example. Remember a firewall is to protect your stuff. The tunnel protect's all your traffic, especially if it's protocols other than http/https.