Ultimate Newbie Guide to the GNU/Linux Shell (presented by Icrontic)
Linc
OwnerDetroit Icrontian
Our Alternative OS guru drasnor has authored a guide for beginners looking to get their feet wet in the GNU/Linux shell.
Ultimate Newbie Guide to the GNU/Linux Shell
Great work, drasnor!
Ultimate Newbie Guide to the GNU/Linux Shell
Great work, drasnor!
0
Comments
Skryking
Excellent primer, drasnor! I wish I had this a few years back when I was starting to have to use unix
All filenames and directories can be specified using absolute or relative paths.
Lets say that you have this simple file tree:
/ (the highest level directory)
/mnt (a directory where removable storage is often mounted to, allowing you to access it)
/mnt/cdrom (common path to the cdrom)
/mnt/cdrom/adir (some directory on a cdrom)
/home (a directory that usually holds all the users of a system's home directories)
/home/shwaip (my home directory)
/home/shwaip/docs (a documents directory)
lets say you're in your home directory, and you want to copy something into your docs directory. As drasnor said, you can do this:
cp archive.tgz docs/
This is using relative paths; it is much easier in this case. However, say we want to copy from from the folder on the cdrom to my docs directory. To do this with relative paths, we'd need this (assuming we're in our home directory):
cp ../../mnt/cdrom/adir/file.ext docs/
That's extra typing, and that's only if we're two directories deep in our home folder. Using only absolute paths, that becomes:
cp /mnt/cdrom/adir/file.ext /home/shwaip/docs/
Note that the '/' character is first in absolute paths. This says "look in the highest level directory (/) for the "mnt" folder, rather than the current directory. Notice that I'm also using an absolute path for the docs folder. Once again, provided that we are in our home folder, this is excessive. You can mix absolute and relative paths to minimize typing as follows:
cp /mnt/cdrom/adir/file.ext docs/
-drasnor
You can't use TOP for most things though as it only lists things that are using the most CPU usage (or most of something else) where as you can use ps to check through other things, like ps -e | grep progname which is normally the main use for ps anyway.
pushd .
in a directory and then go about what ever you need to do in other directories...when you are done and need to go back just do:
popd
it takes you back to the directory you pushed earlier.
Skryking
-drasnor
dir | more
Skryking: pushd and popd are so sweet. thank you for sharing that, that will make my life better
yeah, I been known to "lay out some pipe" on the windows shell:
dir /b > list.txt |for /f %i in (list.txt) do attrib %i or whatever | some other command
Great for doing something on hundreds of files at once, etc.
Also the && works too:
dir && cls
&& = command one executes and then goes on to command two if successful.
Comes in really handy when you have to write some jacked up .bat that changes enviornment varibles and whatnot.
UNIX still wins for having a command called "mount" though...
For some reason that made me think of this picture. I had Picasa search My Documents the other day and I found this lovely gem again.
...leave it to you guys
the funny thing is that if you issue that command, you get an ASCII representation of that exact picture.
_______
http://www.mylinuxgang.com/
The way articles are handled changed a little while back and not all of these threads have been updated.
Welcome to Icrontic!
-drasnor
Top is ok if you remember the commands associated when running it, but try htop (will need package install) it's more graphical and uses function keys for common commands.