Cool Shortcuts

Discussion in 'Beginner Tutorials' started by Rob, Jul 9, 2013.

  1. Rob

    Rob Administrator Staff Member

    Messages:
    575
    Likes Received:
    233
    Trophy Points:
    43
    Who doesn't like shortcuts? Well, the answer is my wife. But only because my shortcuts usually double the length of our trips... Anyway, if you are going to spend any time in the Linux command line interface, I highly recommend learning a few easy shortcuts that will make your life MUCH easier!

    Auto Complete Anything You Type!

    One of the best shortcuts is the auto-complete feature in Linux. Just start typing the name of a file, directory or program and then hit <TAB>.

    ls m <TAB><TAB><TAB>
    Then push the <TAB> key. Linux is going to beep a couple of times, but you keep pushing. You will now see every file in the directory that begins with the letter 'm'

    Now add an 'o' on to `ls m` so you get `ls mo` - now push the tab key.

    ls mo <TAB>

    You should see 'motd'. This is a file that contains your startup message. SuSE has a famous one that says 'Have a lot of fun!'. I like that one so I haven't changed it, but you can change it so that Linux says anything you want when you log in.

    Linux Saves Everything That You Type In Your History File!

    Do you want to make sure that lilo.conf is still in there? You don't have to type 'lilo.conf' or even part of it and press the tab key anymore. You just have to press the up arrow. Your last commands will appear when you do that.

    Your commands are saved in a history file located in your home directory. The more times you press the up button, the farther back in time you go. Pressing the down button gets you back to your most recent commands. Just stop on the command you want and press 'enter'. You can even type the command history and all of the last 400 or so commands you've typed will be presented. As you get more proficient in Linux, you'll find that thisreally comes in handy. You can often find out the answer to the question: How did I do that? by consulting your shell history.

    The /usr directory

    Let's talk about using some options with commands.


    Code:
    cd /usr
    this will take you to the /usr directory

    Code:
    ls -l
    This will give you a more detailed view about the contents of your current directory, which happens to be the /usr directory.

    You will see more information, like dates, some numbers, letter combinations. It will say 'root' a lot. We'll get into more detail about what all of that means later in the course. You'll see mainly sub-directories here. The usr/ directory contains files and programs meant to be used by all of the users on the system.
  2. DevynCJohnson

    DevynCJohnson Well-Known Member Staff Member Staff Writer

    Messages:
    1,379
    Likes Received:
    1,094
    Trophy Points:
    113
    Why type "cd /usr #"? Why not just type "cd /usr"? I can still type "ls -l #" and get the same results whether or not I type the cd command with a "#".
  3. Rob

    Rob Administrator Staff Member

    Messages:
    575
    Likes Received:
    233
    Trophy Points:
    43

    It got messed up when i copied/pasted it.. the # was being used as a comment.. :)
    DevynCJohnson likes this.
  4. DevynCJohnson

    DevynCJohnson Well-Known Member Staff Member Staff Writer

    Messages:
    1,379
    Likes Received:
    1,094
    Trophy Points:
    113
    That makes since now. At first, I was thinking this was some old Bash feature that is no longer supported.
    Rob likes this.
  5. Rob

    Rob Administrator Staff Member

    Messages:
    575
    Likes Received:
    233
    Trophy Points:
    43
  6. Kovax

    Kovax Member

    Messages:
    34
    Likes Received:
    19
    Trophy Points:
    8
    Note- You must make sure that you are using BASH
    DevynCJohnson likes this.

Share This Page