PDA

View Full Version : understandin man pages.



LT72884
11-10-2006, 08:19 PM
<<im using knoppix 5.01 installed on the HDD and im in the GUI>>


ok so i have been trying to understand the man pages for copmmands but they use terms in there that i dont understand. its like it was writin for advance users only. for example i do the man page for su and i look at the option -c. this is what it says...."specify a command that will be invoked by the shell by its...." and thats it. what does that mean. i thought the command was su so what is the -c doing to su. also every time i run this command su -c kwrite it says can not connect to x server. what the heck is x server. and the option - what does it mean by sets up the enviroment to what the user would expect if they had logged in directly. i dont uinderstand what they mean by log in directly. direct;ly to what. im sorry if these are all stupid questions, its just i wish the man pages where easier to understand. they have so many terms i dont even understand or ever heard of.

OErjan
11-10-2006, 09:17 PM
su -c "command" let you run that command ONCE ONLY as root! a neat way to get one step safer, no unneeded root access...
same reason I always do minimal installs, security, the more programs availabe and the more often rootprivileges are used the more securityholes/mistakes... are possible and things get harder to keep track of.
if I was to install say a ftpserver, the total size would likely land around 200meg, yes I know I could likely trim it some (ok lot), but I like to have some things "extra" like mc, ssh and links.

LT72884
11-10-2006, 09:25 PM
so the su -c you have to put a command after the -c. so it runs what ever command you specify such as this.
su -c cd /home/LT72884/LFS/sources. that should take me to my sorces folder right.

marhleet
11-11-2006, 07:50 AM
uhm, spose
but he said it would do it once
then it's going to drop out of su mode

instead of
su
command this
command that
accidentally fdisk the entire drive cos you forgot you're in su mode you could do the
su -c tricky command
and then you'd be back as your own plain user again


and, if you run the dos prompt window from the desktop, then you would be able to access the X server
if you try it from the alt-F1(-6) screen, it wouldn't as the Xserver runs on window 7
i think ;-)

OErjan
11-11-2006, 11:02 AM
actualy you HAVE to have the "" in the comand. otherwise linux waits for more input...
so

su -c "command" wold work but
su -c command most likely will not. just a small thing but...
say you type

su -c "konqueror"
that would start konqueror as root, and you could do lots of things there. or you could do
su -c "kill pid"
where pid you can get with comand ps (or better ps ax).
look for the line with name of whatever you want to kill (crashed program or process you dont want running...)
pid is first number in the line, ps aux will give username aswell.
you can even do
ps ax|grep konqueror and get only lines with konqueror in them.

grep is a nice program to use when wading trouhg lots of lines of output looking for something specific
just pipe (the | caracter) output from the previous progrm trough it and is looks for the patern you have givien, in this case "konueror".. you can pipe output from many programs to another, like ls to less or more, and ls to grep for that matter...
keep asking, we will try to answer

LT72884
11-13-2006, 03:54 PM
whoa holly crap thats confusing. so whats the point of the "" what does that mean to the system.

OErjan
11-13-2006, 06:24 PM
in most cases "" means to take what is between " and " as ONE input, say to copy a filename with spaces and such.
in some cases you use \ to tell program that you want the space(or whatever) to be treated as a part of the name.
say you type

touch /home/knoppix/test\ file.txt
that creates a emty file named "test file.txt" in /home/knoppix/
now type

cp /home/knoppix/test file.txt /home/knoppix/test file 2.txt
this wont work (atleast shoud not), this as cp takes it to mena that it should find a file called test and copy it and name the copy file, but you have no file named test so...

cp /home/knoppix/test\ file.txt /home/knoppix/test\ file\ 2.txt
will work, this as you told cp that it should treat space as a caracter in the name with the \ infront of the space.

and if you have understood you know that
cp "/home/knoppix/test file.txt" "/home/knoppix/test file 3.txt" should also work and give you a new copy of the test.txt file.

and you are rigt manpages can be hard to understand, they are made more to aid the ones with knowlege to cope with slightly differing versions and syntax between environments, but you are getting closer each answer you get i hope.

one nasty ting some jokers do (if you leave you compter unatended and still logged in) is make a file that fills our /home/username and name it
-Rf *, if you try to delete that without thinking you delete your entire home, can you figure out how to delete it?

LT72884
11-13-2006, 07:58 PM
ok so what does the file do to your /home/username folder. and you want me to try and create the file and delete it.

so what is -Rf, is that the code the jokers use.

OErjan
11-13-2006, 08:37 PM
NO do not create a file named "-RF *", just be aware of it.
The file is NAMED "-Rf *" which is BAD if you just try to delete it, as "-Rf *" means Recursive+forced (that is everything in this directory and all under it) in most *ix variants, so when you use rm (delete in Linux) it wili interpret -Rf as delete everything.
just think on it and type what you think is answer here.

Some info on everything up to (but NOT including) the phrase "one nasty ting".
my file is named
test file.txt
and
test file 2.txt
test file 3.txt

and has this info if i type ls -al and paste nfo for test file.txt

-rw------- 1 knoppix users 0 2006-11-13 20:16 test file.txt

that is 0 in size (the 0 just infront of 2006), it has no text in it yet, it is just a name.

LT72884
11-13-2006, 08:50 PM
hmm interesting, my koppix wont let me creat a file named -Rf, says names of files cant have a dash in front of them. maybe its to prevent that very thing. i think to delete it you would need to put the actual file name in quates so it sees that thats the file it needs to manipulate.

OErjan
11-13-2006, 09:35 PM
yes that is ONE possibility (would likely work in knoppix), but you have to ceck in the manpage for every time you try, this is as older versions and other systems may react different to "", a quick check is apropriate.
keep asking.
EDIT
you are actualy asking good questons to start understanding things.
seems you have read some, nice to have one such for a change, you are willing to work some and do not ask for patent solutions to everything but want to UNDERSTAND things, it is hard just now but will make it easy later.
keep asking
OErjan

LT72884
11-13-2006, 10:18 PM
OHHHH thanx so much for that compliment. im sooo glad someone other than myself understands me. I am the type of person who is very logical and if i dont understand the smallest thing in a command or a certian subject besides english,lol. i will not grasp the subject/command very well. i have to know why every little thing is doing what its doing. hence why i asked about the ""'s in a command. now i know. I love to try and understand things, and sometimes that involves killing my system like i did with photorec but i went in and found a way to fix it. i just hope when i go to school in january that my professor will be able to help me. the hardest thing for me to comprahend is when someone says " thats just the way it is, accept it" no, i dis agree. the is a reason to all things, and i have to know. lol

ok im done with my spell on my logical personality. any way im still thinkin of another way to remove the file name -Rf with out the rm command reading the-Rf as part of itself or an option of the rm command

Oh another question. what is oyur opinion of these classes im gonna take. im just wondering what people think about them. i just hope we get to mess with wireless internet/networx
The program is Cyber Security.

classes.

CCNA 1
Fndmntls Linux
Linux Ntwrks Admin
Adv Linux Admin
Info Systems Security
Adv Sec Arch/Models

OErjan
11-14-2006, 11:41 AM
it gives you a platform to stand on, I guess that you are going to progress to higher levels than i have in time (too easy as i have not been student for almost a decade)...

LT72884
11-14-2006, 03:36 PM
yeah i think they will be good classes to take.

mkdir /home/matt/lfs test

why does that command NOT make the directory test inside the lfs folder. i have no idea where it puts it. the lfs folder is there but when i list the contents of it, the test folder is not there.

also this comman mkdir /home/matt/lfs /test does soemthing wierd to.

maxIT
11-14-2006, 07:44 PM
... also every time i run this command su -c kwrite it says can not connect to x server. what the heck is x server...

This is due to the fact that debian (and hence knoppix) since long time don't allow you to run graphics apps as root. To do that you have to log in in X (the graphich interface) in a tricky way (not via kdm), such as booting the sistem as "knoppix/linux single", login as root, and then load X directly via "startx" or "init 5".

OErjan
11-14-2006, 07:52 PM
mkdir /home/matt/lfs test
will make two dir's in /home/matt one is called lfs and another that is caled test

LT72884
11-14-2006, 08:11 PM
thats wierd, cuz when i did that mkdir /home/matt/lfs test it made the lfs folder but put the test folder in the current directy i was in. it took a while to find it. why did it put it in my current directy instead of the lfs folder. i think it might have something to do with the space i put in after /home/lfs(space)test. im thinkin the space made the bash think i was doing a seperate path/option for the mkdir command.

maxIT
11-15-2006, 06:17 AM
thats wierd, cuz when i did that mkdir /home/matt/lfs test it made the lfs folder but put the test folder in the current directy i was in. it took a while to find it. why did it put it in my current directy instead of the lfs folder. i think it might have something to do with the space i put in after /home/lfs(space)test. im thinkin the space made the bash think i was doing a seperate path/option for the mkdir command.

Try mkdir -p /home/matt/lfs/test

According the 'mkdir man page': wasn't the topic? :-P

-p, --parents
no error if existing, make parent directories as needed

LT72884
11-15-2006, 05:02 PM
hmm, interesting. yeah the -p i have tryed before where it makes all parent directories. i already had the /home/matt/lfs folder and so when i wanted to make the test folder inside lfs and i put that space there, it for some reason put it into my current directory i was in.

LT72884@box# mkdir /home/matt/lfs test
can not create directories. you do not have permission
LT72884@box# su
password*******
root@box$ cd /home/matt
root@box$ ls
lfs sources files
root@box$ cd /
root@box$ mkdir /home/matt/lfs test
root@box$ cd /home/matt/lfs/test
no directory named test
root@box$ cd /home/matt/lfs
root@box$ ls

root@box$ cd /
root@box$ ls
bin,boot,dev,home,etc,mnt, test(there is my folder i made),lib,config,files, etc etc etc

so theres the command i did. i dont know why it didnt put the test folde into the lfs folder. the lfs folder is there and why it didnt put it in there .

OErjan
11-20-2006, 05:12 PM
yes that would be the case as you gave no path for it, then it assumes you want it just where you stand