• Tab-to-complete
  • Editing a command
  • Introductiontolinux




    Download 4,86 Mb.
    Pdf ko'rish
    bet11/18
    Sana23.12.2023
    Hajmi4,86 Mb.
    #127288
    1   ...   7   8   9   10   11   12   13   14   ...   18
    Bog'liq
    introductiontolinux

    21
    Improving your 
    productivity in the CLI
    Working within the confines of the Command Line Interface can sometimes be frustrating. The lack 
    of a ‘copy / paste’ menu on the right click of the mouse can be a major headache when it comes to 
    repeating commands
    Tab-to-complete
    If you begin typing a command or path in the CLI, you can ‘auto-complete’ this by pressing the 
    ‘tab’ key. For example, if you want to navigate to ‘/etc/samba/’, you can just type ‘/et’ and then hit 
    tab, which will auto-complete it to ‘/etc/’. You can then append ‘sam’ and hit tab, and it will auto-
    complete to ‘/etc/samba/’. This is incredibly useful when accomplishing tasks quickly.
    If the command does not complete after a single tab, press it again and the system will display a list 
    of options that matches what you have entered so far. 
    Editing a command
    You can use the Left (back) and Right (forward) arrows on the keyboard to move backwards and 
    forwards through a typed command. Very useful if you want to modify something right at the 
    beginning of the long line you just typed.
    History
    At any point, you can recall previous commands that you typed by using the Up and Down arrows on 
    the keyboard. Up goes back through the commands you’ve used, in reverse order going back into 
    the past. Down brings you back to the present until you reach a blank line to input a new command.
    Your history is stored in ‘~/.bash_history’ .
    You can view it by running the command cat ~/.bash_history
    Your history does not store the output from the terminal, nor your interaction with any programs or 
    applications that have been run - only the commands that you inputted straight into the command 
    line are stored.


    22
     |
    Getting Help and Searching
    The behaviour of many commands can be modified by using ‘switches’ or ‘arguments’. These are 
    described in the online manuals (man-pages), which can be ready using the ‘man ’ command. 
    Information is also available about programming libraries and other operating system features.
    To advance through the text, use the Page Up & Page Down keys. Type ‘h’ to discover more 
    sophisticated commands, and type ‘q’ to quit the man page.
    If you’re not sure what manual page you want to see, you can use the –k option:
    Sometimes -k will give you a surprisingly long list of results. So long that it will scroll off the screen.
    You can scroll back up the screen by using Shift + Page Up & Shift + Page Down. Another method 
    of reading all the results is to pipe(|) the results into ‘less ’. Try the following commands:
    With the ‘ | less ‘ pipe invoked, the output from the ‘man –k directory ’ part of the command gets 
    piped into less, which then displays it on the screen. You will notice that at the end of the list, there 
    is a blank line with ‘:’ displayed. You can now use the return or spacebar key to move down through 
    the list. Type ‘q’ at any time to return to the command prompt.
    ls -l
    man ls
    Get a list of files and folders in 
    long format - now you need to know 
    how to interpret it...
    Opens the man (User Manual) page for 
    the ‘ls’ command. Read this to find 
    out how to interpret the output.
    man -k
    man
    Replace with your search 
    term. Once you have found your 
    desired man page you can go ahead and 
    open it like before...
    Replace with the desired 
    result from your previous search. 
    This will open the man page.
    clear
    man -k directory
    man -k directory | less
    This will clear the visible terminal 
    of all previous output. You can still 
    return to the previous screen by 
    using Shift + Page Up / Page Down to 
    scroll back through the terminal.
    This will search for a keyword that 
    displays lots of results. 
    By piping this output to another 
    command, we can filter these results.
    Use the | character to try piping hte 
    output into less - see what happens.



    Download 4,86 Mb.
    1   ...   7   8   9   10   11   12   13   14   ...   18




    Download 4,86 Mb.
    Pdf ko'rish