What command lines do you use, and what are they for?

2»

Comments

  • Reply 21 of 35
    pyr3pyr3 Posts: 946member
    [quote]Originally posted by DaveGee:

    <strong>Don't forget our friend the pipe!



    ls -al (will do a 'directory listing')

    wc (will count things such as lines of text and number of characters)



    Now if you add a pipe you can do things like this:



    % ls -al | wc

    16 137 884



    The directory listing that would have been displayed was a total of 16 lines and those lines had total of 137 'words' (anything broken by a tab or a space) and the total number of bytes that made up the listing was 884.



    The pipe | can (and is) used ALOT and allows for some really cool things.



    Another cool symbol is &gt;



    % ls -al &gt; mydirectory



    Will take the directory listing that would have normally been output to the screen and instead redirect it to a file called mydirectory.



    You can then open that file in any text editor you like.



    One more cool symbol is &lt;



    %wc &lt; mydirectory



    The above command will PUSH the text found in that text file I just created in the last example INTO the unix app called wc (see above). The output from wc was displayed to the screen as usual.



    %wc &lt; mydirectory &gt; newfile



    In that last example the output from wc was NOT displayed to the screen but instead written to a file called newfile.



    While these examples are kinda lame they do show some of the really wild things you can do with unix.



    Dave



    [ 07-29-2002: Message edited by: DaveGee ]</strong><hr></blockquote>



    Just to clarify to newbs, the pipe takes the output from the first program and sends it to the second program as input. Neither of these programs know what is going on. In his example, ls still thinks that it is writing to the screen and ws thinks that the input is coming from the user. The OS takes care of routing the output and input around.



    An alternative way of piping would be:



    ls -al &gt; mydirectory

    ws &lt; mydirectory



    These two commands together perform the same things as the pipe, only the pipe doesn't create a file as a middleman.



    [ 07-30-2002: Message edited by: pyr3 ]</p>
  • Reply 22 of 35
    serranoserrano Posts: 1,806member
    apps, check out my sig.

    nmap - THE port scanner

    nc - port connection swiss army knife

    &gt; - basicaly your print to file command

    | - pipe is God! pipes results from one app into another

    grep - search through files for text patterns

    curl - download swiss army knife

    ftp - duh

    ssh - your non gaping security hole telnet

    pico - for my rudimentary shell scripting and alias binding



    personal aliases

    l - a more complete directory listing (thanks stimuli)

    atc - downloads NPR's All Things Considered .smil

    me - same as above, except Morning Edition



    [ 07-31-2002: Message edited by: serrano ]</p>
  • Reply 23 of 35
    I'm no *nix geek, but these are the commands I have to use since they're not (satisfactory) implemented in a GUI form under OS X.



    sudo

    mv

    rm

    nslookup

    whois



    Sing along, you know the lyrics...
  • Reply 24 of 35
    stimulistimuli Posts: 564member
    A couple of things, and these took me a while to figure out and learn:



    Control-C kills an app. So let's say you are surfing the web in w3m, and it stalls while loading a page. Control-C, and you are back in the terminal, ready to give another shell command.



    Control-Z : Makes a process dormant. So let's say, even though you are on OSX, you are a confused newbie, and are compiling the linux kernel... CPU is maxxed out. But you just downloaded a bunch of mpegs of, let's say, groverat's mother. You can't play them back at a decent FPS while compiling a kernel. So to 'postpone' the compile, you hit:



    Control-Z . You can either continue using the same term, or just leave it. When you want to resume the compile, just type either:



    fg to 'foreground' the app compiling

    bg to 'background' the app compiling

    %2 (I think, I forget) starts a second dormant app (assuming the is a second dormant app).



    Keen, eh?



    But the real magic of bash is 'bash scripting', just like serrano's NPR aliases (a bash script and an alias are essentially the same). I've got bash scripts coming out the yin-yang. They're not for OSX, however, so you can't have them.



    Basically, you write a string of commands to a text file using nano/pico/whatever, then chmod + x them. I then move them to /usr/local/sbin or similar, and they can be executed like any other command.



    It is pretty sweet.
  • Reply 25 of 35
    telnet, ftp, and ipfw are some of the ones i use as well...the best thing is to be able to compile *nix source code (./configure, make; make install) and run free software! (web analyzer or what not)
  • Reply 26 of 35
    As of late, I've found lsof to be useful in finding open files. Ever have a disk image that just refuses to eject because it claims a file is open? Use lsof to find that open file.
  • Reply 27 of 35
    ahhh, here we go. i was trying to write up a list of command lines and needed to find this stupid thread.



    dunno if this was already in here or not, but here's another good one.



    sudo update_prebinding -root /



    speeds stuff up nice...
  • Reply 28 of 35
    I can't believe some of you people actually use pico as your editor. Grow some balls and use vi, its a real man's editor.
  • Reply 29 of 35
    [quote]Originally posted by alcimedes:

    <strong>

    sudo update_prebinding -root /

    </strong><hr></blockquote>



    When you put that in will it ask you for your password? Thanks.
  • Reply 30 of 35
    yes, it asks for a password, but will also run as long as you know the root password, even if the root account is disabled.
  • Reply 31 of 35
    keshkesh Posts: 621member
    At work, we've got an Apple demo running on some of the machines, and the demo software doesn't show up when I bring up the Force Quit menu. We had to quit the demo when updating the machines to Jaguar, so it was a bit of a dilemma.



    So, I opened Terminal and ran top to find out which Process ID (PID) it was using, then kill to get rid of it. Voila! No more demo.



    At home, I use sudo occasionally to get rid of stubborn files, by logging in as root to perform an rm (remove) command.



    Oh, and ls is the one you'll use the most, for listing the directory contents, and cd for changing directories.



    [ 10-01-2002: Message edited by: Kesh ]



    [ 10-01-2002: Message edited by: Kesh ]</p>
  • Reply 32 of 35
    Here's my favorite after an all nighter surfing the web:





    make love



    [ 10-03-2002: Message edited by: ThinkingDifferent ]</p>
  • Reply 33 of 35
    moogsmoogs Posts: 4,296member
    curl and wget



    both a set of commands that are used for uploading and downloading files via FTP and HTTP, as well as other data retrieval tasks over the ether.
  • Reply 34 of 35
    Unpleasant feature I discovered recently:

    Jaguar has not /usr/local/bin in his default PATH.

    So maybe you can't use (or have some problem with) some of the commands cited above if running jaguar (ex.: gcc and other compilers......).



    To add that path to the default ones, simply write:



    setenv PATH /usr/local/bin:$PATH



    in the file /etc/csh.login

    (you have to be root......)



    <img src="graemlins/smokin.gif" border="0" alt="[Chilling]" />
  • Reply 35 of 35
    bigcbigc Posts: 1,224member
    whats the one that tells me my router IP address behind my Airport running PPoE\\DHCP. Forgot
Sign In or Register to comment.