Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • 10 time saving tips every Linux user should know

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 428
    Comment on it

    If you are using bash, here are some time saving tips that can come handy in day to day tasks of every Linux user. This list is not exhaustive in any manner and is compiled from various Q&A sites and forums.

    1. Use CTRL+R to search through command history. Hit it again to view next search result.
    2. Use hashtags to organize your bash history and to save yourself from typing long commands repeatedly. Just append a hashtag after your command.
      Example :
    tail -f /var/log/apache2/error.log #ApacheLog
    

    Now you can search it later in reverse search. Just hit CTRL+R and type ApacheLog

    1. Tired of typing clear every time you want to clear your terminal screen, just hit CTRL+L. It also not get stored in your command history.
    2. Hit CTRL+W to remove the last word and CTRL+U to remove the entire line.
    3. Need to execute the last command with sudo, use sudo !!
      ls -l /root
      sudo !! # This is equivalent to sudo ls -l /root
      
      (!! actually repeats the last executed command).
    4. You can get the arguments of your last executed command by !$.

      Suppose you created a directory :

      mkdir /path/to/directory
      


      You might want to cd into the directory you have just created, you can just :

      cd !$
      

      Alternatively, you can also use +.(period). Pressing it repeatedly gives arguments of previous commands chronologically.

    5. If you are working with long directory paths and switch frequently, instead of using cd and typing the long path names again and again, use pushd and popd. These are the built-ins which allows you to maintain a stack of directories you have worked with.
      Example :

      pushd /home/a/b/c/d/e/f
      

      This will push your current directory onto your directory stack and move to the directory specified in the argument i.e. f. Now you can come back by simply using popd.

      popd
      

      The complete directory stack can be viewed by dirs. The first entry will always be the current directory and the stack is displayed from second entry onwards.

    6. Quickly locate a file on disk

      locate filename
      

    7. Suppose you start entering a command in your terminal, but midway you realize that you want to execute another command before this one
      a) Enter the command you want to postpone executing.
      b) Hit CTRL+U
      c) Execute one or more commands.
      d) Hit CTRL+Y
    8. If you need to compare two files and does not have any file comparison program installed, you can use diff command.
      Example :

      diff -y myfile1 myfile2
      

      and it will display the files side by side in two columns with differences marked.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: