Re: I'ma Well Versed UNIX User But This Baffles Me:
From: Khamba Staring (QdK_at_quickdekay.net)
Date: 07/20/04
- Next message: Michael J. Sherman: "Re: I'ma Well Versed UNIX User But This Baffles Me:"
- Previous message: Josh McKee: "Re: I'ma Well Versed UNIX User But This Baffles Me:"
- In reply to: Assam Syrix: "I'ma Well Versed UNIX User But This Baffles Me:"
- Next in thread: Walter Roberson: "Re: I'ma Well Versed UNIX User But This Baffles Me:"
- Reply: Walter Roberson: "Re: I'ma Well Versed UNIX User But This Baffles Me:"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 20 Jul 2004 13:46:28 +0000 (UTC)
Assam Syrix <assyrix@altavista.net> wrote:
> Can anybody tell me which command to type to display the contents of a
> directory in a shell? Also, I don't know how to change directories. I
Displaying the contents of a directory is difficult! You first need to know
which shell you're using:
- if you're using (t)csh, type:
foreach i ( `echo *` )
echo "$i" >> /tmp/q
end
The contents are now in a file named /tmp/q . Read it with
cat /tmp/q | more
- if you're using (ba)sh, type:
for i in `echo *; do
echo "$i" >> /tmp/q
done
Luckily the method of reading /tmp/q is the same as with (t)csh.
One problem I haven't tackled yet is that /tmp/q will grow over time;
it's weird. The only solution is rebooting; the file is empty after a
reboot.
Changing the working directory also isn't a trivial matter. The directory
structure is an indexing system. If you have a directory 'help' and
a file in it called '01_intro', it's accessibly by the path help/01_intro .
now if you change the working directory, you've just messed up your
whole indexing system! Your current 'root' is 'help'. Just think what
that can do to a structure!
However, if you're still willing to change your working directory, you'll
first need to compile a program (call it change.c):
--(cut here)
/*
** Copyright (C) 2004 by QdK, all rights reversed
**
** Gre3taZ t0 aLl y@ p3oPlE!11!1
*/
#include <stdio.h>
int main(int argc, char *argv[])
{
chdir(argv[1]);
system("/bin/sh");
return(1);
}
--(cut here)
Now compile it, assuming you've got gcc installed:
gcc -o change change.c
Next, you'll need to know where the directory is you want to change to.
This is best done with the command 'find':
find / -name <insert name here> -exec $HOME/change "{}" \;
It's a very cpu intensive matter, yet another reason not to change working
directories. Also, there's a bug in the change.c code. Sometimes it just
crashes when I forget to supply a directory-- crazy! Must be gcc....
> am an experienced UNIX administrator but cannot figure these two
It's called UNOX, not UNIX. Geez
> simple commands out. And please don't aske me to use the man page - I
> am afraid that I am too lazy and cannot be bothered. Cheers!
There're no manpages for things this difficult; every manpage only
describes one command; as you can see, you need more than 1 command
to do what you are asking, so there's no use in reading manpages.
Also, I've noticed not every admin pays enough attention to security.
There's this problem with the root account on my system; it hasn't got
a password. Now this makes my system very hacker-friendly so I added
a line to my .cshrc which wil prevent hackers from successfully logging
in:
echo "reboot" >> $HOME/.cshrc
Kind regards,
-- Khamba Staring
Disclaimer: my employer and I never agree.
- Next message: Michael J. Sherman: "Re: I'ma Well Versed UNIX User But This Baffles Me:"
- Previous message: Josh McKee: "Re: I'ma Well Versed UNIX User But This Baffles Me:"
- In reply to: Assam Syrix: "I'ma Well Versed UNIX User But This Baffles Me:"
- Next in thread: Walter Roberson: "Re: I'ma Well Versed UNIX User But This Baffles Me:"
- Reply: Walter Roberson: "Re: I'ma Well Versed UNIX User But This Baffles Me:"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|