For those interested, think there needs to be corrections, have neat trivia, or have some things to say: COMMENTS ARE ENCOURAGED!!!
I did a shitload of studying over the weekend. I had to stop because my head hurt. I got made because my dyslexia, which I made peace with once I got out of high school, has reminded me of why it was probably a good idea I never went back to school. Things will stick to my brain like throwing spaghetti on a wall. Some stick, others slide off no matter what I do.
Oh, how I will ramble.
Some new stuff I sort of "learned" follows. While I sort of understood these concepts, I had a lot of problems remembering what order anything was. I had to develop some mnemonics to try and remember them for the test.
ln, the link feature. It's
ln [-s] original_file link_name, like
ln -s lancelot link
(secret chimp... duh nuh nuuuuh...)
Damn, I hated that show! But Link comes second after Lancelot, so hopefully, I'll remember this. For mount, I have to thing "DM for "Dungeon master" for "Device then mount" like
mount /dev/hda6 /var
The rest I know, like -t iso9660 for loop devices, -t nfs for NFS mounts, and so on. I use the stuff all the time, but I always forget the order! Hopefully, these will help.
Next, I had to get the file permissions nailed down. Again, I got confused on order. Like It's User, Group, Other. I'd get "o" confused with "owner," which sucks. So I am trying "UG Other," so I remember "o" stands for "other." You'd think "Well, if 'u' means "user' then... " No. Because when I had a command like:
chown o+x filename
I'd think it mean, "Make the file executable by owner." I also got the order of stuff mixed up in my dyslexic brain. UGO will help (it's like UFO), but to remember "other" will be hard. Why, brain, why? OTHER OTHER OTHER!!! [sigh]
I am grateful that when I started in the UNIX days back in 1989/1990, I was told how to do everything by octal numbers, like:
chmod 755 perl_script.cgi
It was funny, I never thought of these as "octal," just "uses the numbers 0, 1, 2 and 4 in any combination to get 0-7." I just assumed we didn't use 8-9 because... well, I never thought that far. But yes, 0-7 is octal. So if you add 1 to 7, you get 10 (in octal). I bet this messes with those kids who went to school after the removed the "new math" curriculum in school (which happened around the time I went to school, so I got a combination of the old "new math" and the new "what the hell were we smoking in the 1960s to teach kids math this way?"... but I digress...)
So, with the octal numbers, you have 4 modes (like an IP address has 4 octets). Each of these access mode bits represents Special, User, Group, Other.
The new stuff (for me) was the "hidden" (for me) first three access mode bits, the SUID, the SGID, and the "sticky bit." I knew about the "sticky bit" because it was in the RHCE exam, and I thought, "OooOOooh how clever." Then never used it and promptly forgot it. I don't know if it was around when I started UNIX, I only remember the 3 octal access modes, and not the one before it. I supposed it existed back then, and I was never taught to use it.
SUID only works on executable files (not directories) and SETS the USER ID of the process run to the file OWNER (who may be different from the schmuck who launched it). Let's say you have a file owned by root, like passwd, but accessible to anyone, like passwd. Joeuser launches the executable, like passwd, but since the file, like passwd, is owned by root, the process launches AS root (not as joeuser, who would get a permission error otherwise), which you need for certain programs to give them root access, like passwd. This is great! Except when it's not, and joeuser is a hacker, and you have some other executable that will run AS root, no matter who launches it, and then joeuser starts his tomfoolery.
SGID is the same thing for an executable, but for groups. In addition, setting the directory SGID will do something really nifty: new files created in that directory will be assigned to the group ownership of the directory itself.
And then there's "the sticky but," as it's called, used to be run only on executables. But nowadays, it's most commonly used for protection of files. When it's set by the user, the only users who can delete or rename the files are the user themselves, the directory owner, and root of course. This allows a team of people to create and modify files, but only the owner can remove/ranme them (which is kind of the same thing, when you look at it).
The rest I knew. Back in the day, we did a lot of "chmod 755" stuff, which makes the file fully accessible by the user, but only readable and executable by everyone else. The order of this is
RWX, the Rude Walrus Exchange (hah, I kill me)
So you have this neat octet code. I remember when Allon first explained this to me, and how you could get any number from 0 to 7 with just four numbers. I spent a day and 3 hours thinking how nifty this was, and how it all tied in.
4 = read
2 = write
1 = execute
0 = nothing
In UNIX, this 755 is also rwx-r-xr-x
In addition, there's a "umask," which like a netmask, is a sort of filter when files are created by the current user in the current shell. The default umask is 0002, which leaves your files clean and minty fresh as 7775 (in some distros, it's 0022, so that would be 7755, check by typing umask)
chmod = change mode (the access modes)
chown = change owner
chgrp = change group
Disclaimer: While I have been managing Linux systems for almost 10 years now, but I am mostly self-taught. I have a RHCT certification, but I am taking the LPI and CompTIA Linux+ exams to "flesh out" some of the gaps that occur from too much real-world experience versus my lack of good old fashioned book learnin'. This entry in no way assures you my thoughts are correct, I will have frequent misspellings, and they may or may not help you pass the LPI. HUGE parts of the exam will be missing because I already know half of it by heart, so using me as your only study guide is a terrible idea. Please read this entry with a healthy amount of skepticim, and PLEASE feel free to correct or add comments! My ego is hardy enough to admit when I am wrong.