Linux Tips and Tricks

    & , && – when ever you need to compile two or more files you can use these to execute them.

    • & – which means execute the first as well as the next
    • && – which means execute the next command only if the before command is successful

    Locate files on computer

      First run updatedb as super user(su) or sudo and use locate command to find the file and file names. You can also use find to find files.

    Go to your home directory even in any directory?

    • Simply use cd ~
      [shell_test@localhost tmp]$ pwd
      /tmp
      [shell_test@localhost tmp]$ cd ~
      [shell_test@localhost ~]$ pwd
      /home/shell_test
      [shell_test@localhost ~]$

    Navigate to parent directory using

    • Navigate to just one directory above cd ..
      [shell_test@localhost test3]$ pwd
      /tmp/test1/test2/test3
      [shell_test@localhost test3]$ cd ..
      [shell_test@localhost test2]$ pwd
      /tmp/test1/test2
      [shell_test@localhost test2]$
    • Navigate to 2 directories above cd ../..
      [shell_test@localhost test2]$ pwd
      /tmp/test1/test2
      [shell_test@localhost test2]$ cd ../..
      [shell_test@localhost tmp]$ pwd
      /tmp
      [shell_test@localhost tmp]$
    Run resume paused command or run commands simultaneously or run commands one after the other

    • Pause a command ctrl+z the command will be paused next run command in back ground using bg :
      [root@localhost shell_test]# updatedb
      ^Z
      [1]+ Stopped updatedb
      [root@localhost shell_test]# bg
      [1]+ updatedb &
      [root@localhost shell_test]#
      Even you can resume command in foreground by using fg in the similar way but I feel bg(back ground) is a better option.
    • Run command in back ground :
      [root@localhost shell_test]# updatedb &
      [1] 2907
      [root@localhost shell_test]#
      [1]+ Done updatedb
      [root@localhost shell_test]#
    • Execute two independent commands simultaneously
      [root@localhost shell_test]# ls & cd /tmp
      [1] 2909
      [root@localhost tmp]# Desktop Download Music Public Videos
      Documents listoffiles Pictures Templates
    • Execute command one after other : this execution happens only if the previous command is successful
      1. success full commands
        [root@localhost tmp]# ls -l && cd ~
        total 19820
        -rw-rw-r–. 1 gpvprasad gpvprasad 6 2009-11-18 06:18 blueman-applet-500
        -rw-rw-r–. 1 shell_test shell_test 6 2009-11-14 09:58 blueman-applet-501
        -rw-r–r–. 1 root root 55501 2009-11-08 20:15 firstbootX.log
        -rw——-. 1 gpvprasad gpvprasad 9575970 2009-11-10 13:57 FlashTq8VPV
        -rw——-. 1 gpvprasad gpvprasad 60110 2009-11-16 07:03 FlashX3BRGH
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-18 06:25 kde-gpvprasad
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-08 21:59 keyring-1jzdcI
        drwx——. 2 shell_test shell_test 4096 2009-11-11 07:53 keyring-67Zz4c
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-18 06:18 keyring-iBwaSe
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-11 20:59 keyring-oxgV2D
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-11 07:21 keyring-RV8dci
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-08 19:05 keyring-xfs7bJ
        -rw-r–r–. 1 root root 710 2009-11-14 12:00 last-queue.yumex
        -rw——-. 1 gpvprasad gpvprasad 4830557 2009-11-12 18:57 moz-screenshot-1.png
        -rw——-. 1 gpvprasad gpvprasad 4830557 2009-11-12 18:57 moz-screenshot.png
        drwx——. 2 gdm gdm 4096 2009-11-18 06:18 orbit-gdm
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-18 06:25 orbit-gpvprasad
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-08 19:08 plugtmp
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-18 06:30 plugtmp-1
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-18 06:18 pulse-NHMkC8Hpqptl
        drwx——. 2 shell_test shell_test 4096 2009-11-14 09:58 pulse-o35KrWjV2fET
        drwx——. 2 gdm gdm 4096 2009-11-18 06:18 pulse-Q53w5sDZdexN
        srw——-. 1 gpvprasad gpvprasad 0 2009-11-14 12:18 scim-panel-socket:0-gpvprasad
        drwxrwxr-x. 2 shell_test shell_test 4096 2009-11-14 09:57 test
        drwxrwxr-x. 3 shell_test shell_test 4096 2009-11-16 21:27 test1
        drwx——. 2 root root 4096 2009-11-08 16:59 tmpBJxaAz
        -rw——-. 1 shell_test shell_test 653006 2009-11-11 06:43 tmp.xpi
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-08 20:15 virtual-gpvprasad.0aW2bl
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-14 06:35 virtual-gpvprasad.38DNpf
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-08 19:18 virtual-gpvprasad.3tCwjI
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-11 20:59 virtual-gpvprasad.3vq7xC
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-11 20:03 virtual-gpvprasad.CsY5M2
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-17 19:08 virtual-gpvprasad.cYH3ne
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-13 17:19 virtual-gpvprasad.dpxCk1
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-14 11:47 virtual-gpvprasad.dx7aGu
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-14 11:48 virtual-gpvprasad.EG7NVU
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-14 11:03 virtual-gpvprasad.eQBt59
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-14 11:57 virtual-gpvprasad.Hfnqm6
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-12 17:35 virtual-gpvprasad.hgVw00
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-09 07:48 virtual-gpvprasad.Hq4adE
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-18 06:18 virtual-gpvprasad.IrfHxg
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-16 20:54 virtual-gpvprasad.jLPLlV
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-17 20:45 virtual-gpvprasad.JzoEr5
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-12 22:22 virtual-gpvprasad.K0hGCt
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-12 06:46 virtual-gpvprasad.Ku2mDH
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-15 09:48 virtual-gpvprasad.Kx9K06
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-15 22:49 virtual-gpvprasad.LWQFHp
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-08 21:59 virtual-gpvprasad.NV5HWF
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-17 06:49 virtual-gpvprasad.o4VX1a
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-16 06:53 virtual-gpvprasad.Q492oZ
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-09 06:30 virtual-gpvprasad.RH1v6Q
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-08 19:05 virtual-gpvprasad.rhyIbp
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-13 22:56 virtual-gpvprasad.uMhEPY
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-12 07:56 virtual-gpvprasad.WtYYZd
        drwx——. 2 gpvprasad gpvprasad 4096 2009-11-11 07:21 virtual-gpvprasad.ZONzNq
        drwx——. 2 shell_test shell_test 4096 2009-11-11 06:46 virtual-shell_test.3qeGZ9
        drwx——. 2 shell_test shell_test 4096 2009-11-11 06:22 virtual-shell_test.mVCcs8
        drwx——. 2 shell_test shell_test 4096 2009-11-14 09:58 virtual-shell_test.Rf9MYh
        drwx——. 2 shell_test shell_test 4096 2009-11-09 06:29 virtual-shell_test.xfMz0U
        -rw——-. 1 root root 61440 2009-11-08 17:49 whatis.wfiuSW
        -rw-r–r–. 1 root root 0 2009-11-08 12:06 yum.log
        [root@localhost ~]#
      2. This example first command is a failure hence second command is never executed.
        [root@localhost ~]# cd /tmp/test20 && ls -l
        bash: cd: /tmp/test20: No such file or directory
        [root@localhost ~]#

స్పందించండి

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / మార్చు )

Twitter picture

You are commenting using your Twitter account. Log Out / మార్చు )

Facebook photo

You are commenting using your Facebook account. Log Out / మార్చు )

Google+ photo

You are commenting using your Google+ account. Log Out / మార్చు )

Connecting to %s