How to list all symbolic links in a directory












111















I have a symbolic link in my /var/www/ directory that links to WordPress. When I run the command ls -la from the /var/www/ directory the link to WordPress doesn't show up. Is there a way to list all of the symbolic links that are in a directory?










share|improve this question

























  • That looks useful. Thanks for the tip!

    – wisaac407
    Sep 9 '14 at 18:19











  • possible duplicate of How to find and list all the symbolic links created for a particular file?

    – Avinash Raj
    Sep 10 '14 at 9:28
















111















I have a symbolic link in my /var/www/ directory that links to WordPress. When I run the command ls -la from the /var/www/ directory the link to WordPress doesn't show up. Is there a way to list all of the symbolic links that are in a directory?










share|improve this question

























  • That looks useful. Thanks for the tip!

    – wisaac407
    Sep 9 '14 at 18:19











  • possible duplicate of How to find and list all the symbolic links created for a particular file?

    – Avinash Raj
    Sep 10 '14 at 9:28














111












111








111


50






I have a symbolic link in my /var/www/ directory that links to WordPress. When I run the command ls -la from the /var/www/ directory the link to WordPress doesn't show up. Is there a way to list all of the symbolic links that are in a directory?










share|improve this question
















I have a symbolic link in my /var/www/ directory that links to WordPress. When I run the command ls -la from the /var/www/ directory the link to WordPress doesn't show up. Is there a way to list all of the symbolic links that are in a directory?







command-line symbolic-link find ls






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 2 '16 at 7:12









Sylvain Pineau

48.9k16107150




48.9k16107150










asked Sep 9 '14 at 17:56









wisaac407wisaac407

6902713




6902713













  • That looks useful. Thanks for the tip!

    – wisaac407
    Sep 9 '14 at 18:19











  • possible duplicate of How to find and list all the symbolic links created for a particular file?

    – Avinash Raj
    Sep 10 '14 at 9:28



















  • That looks useful. Thanks for the tip!

    – wisaac407
    Sep 9 '14 at 18:19











  • possible duplicate of How to find and list all the symbolic links created for a particular file?

    – Avinash Raj
    Sep 10 '14 at 9:28

















That looks useful. Thanks for the tip!

– wisaac407
Sep 9 '14 at 18:19





That looks useful. Thanks for the tip!

– wisaac407
Sep 9 '14 at 18:19













possible duplicate of How to find and list all the symbolic links created for a particular file?

– Avinash Raj
Sep 10 '14 at 9:28





possible duplicate of How to find and list all the symbolic links created for a particular file?

– Avinash Raj
Sep 10 '14 at 9:28










9 Answers
9






active

oldest

votes


















68














You can use grep with ls command to list all the symbolic links present in the current directory.



This will list all the links present in the current directory.



ls -la /var/www/ | grep "->"





share|improve this answer





















  • 5





    It will return false positive if you have a file containing "->". Try a simple touch "foo->"

    – Sylvain Pineau
    Sep 9 '14 at 18:32






  • 7





    please don't copy&paste content of another answer to your own answer. -1

    – αғsнιη
    Sep 10 '14 at 5:14








  • 1





    why not greping with ^l?

    – Eliran Malka
    Jan 18 '17 at 12:13






  • 2





    As usual, the best answer is the one with highest +

    – FractalSpace
    Dec 10 '17 at 19:19











  • Nice! → .bash_alias: alias listlinks='ls -l --color | grep "->"' 8-)

    – Frank Nocke
    Apr 11 '18 at 3:08



















216














Parsing ls is a Bad Idea®, prefer a simple find in that case:



find . -type l -ls


To only process the current directory:



find . -maxdepth 1 -type l -ls


Credits: How do I make the shell to recognize the file names returned by a `ls -A` command, and these names contain spaces?






share|improve this answer


























  • find: Unknown argument to -type: 1

    – ahnbizcad
    May 28 '15 at 16:39








  • 11





    @ahnbizcad: It's not 1 (one) but l (link)

    – Sylvain Pineau
    May 28 '15 at 17:51






  • 3





    Great answer! I adjusted mine to not descend down directory path like this: find /<your_directory> -maxdepth 1 -type l -ls 2>/dev/null Thank you!

    – bgs
    Feb 4 '16 at 18:47








  • 3





    For only the current directory (i.e. not recursive) add -maxdepth 1.

    – Joshua Pinter
    Apr 8 '16 at 14:32



















9














the ls -la command show all files and folders and also symbolic linked directory, if this command doesn't show any symbolic directory it means you don't have a symbolic link to WordPress.



see the result of running ls -la:



kasiya@kasiya-pc:~$ cd /sys/devices/platform/sony-laptop
kasiya@kasiya-pc:/sys/devices/platform/sony-laptop$ ls -la
total 0
drwxr-xr-x 3 root root 0 Sep 9 19:57 .
drwxr-xr-x 14 root root 0 Sep 10 2014 ..
-r--r--r-- 1 root root 4096 Sep 9 22:32 battery_care_health
-rw-r--r-- 1 root root 4096 Sep 9 22:32 battery_care_limiter
lrwxrwxrwx 1 root root 0 Sep 9 19:57 driver -> ../../../bus/platform/drivers/sony-laptop
-r--r--r-- 1 root root 4096 Sep 9 22:32 modalias
drwxr-xr-x 2 root root 0 Sep 9 22:32 power
lrwxrwxrwx 1 root root 0 Sep 9 22:32 subsystem -> ../../../bus/platform
-rw-r--r-- 1 root root 4096 Sep 9 22:32 touchpad
-rw-r--r-- 1 root root 4096 Sep 9 19:57 uevent


You will see all symbolic directory has l permission at the begging of permissions flags. and if you take a grep with ^l you can list only symbolic files or directory:



kasiya@kasiya-pc:/sys/devices/platform/sony-laptop$ ls -la |grep ^l
lrwxrwxrwx 1 root root 0 Sep 9 19:57 driver -> ../../../bus/platform/drivers/sony-laptop
lrwxrwxrwx 1 root root 0 Sep 9 22:32 subsystem -> ../../../bus/platform
kasiya@kasiya-pc:/sys/devices/platform/sony-laptop$


driver and subsystem directory are symbolic link to other directory in here.






share|improve this answer





















  • 1





    Minor specification here... the first character of the permissions string isn't really a permission. It's the file type. As you've stated l means it's a symbolic link.

    – conner.xyz
    Apr 4 '16 at 16:49



















4














grep is your friend:



ls -lhaF | grep ^l   # list links
ls -lhaF | grep ^d # list directories
ls -lhaF | grep ^- # list files


This will list lines starting with "l" which represent Links in the perms column in place of l use d for directories and - for files






share|improve this answer

































    3














    POSIXly:



    find ! -name . -prune -type l





    share|improve this answer































      0














      Type ls -lai,it will list all the files and subdirectories with corresponding inode numbers.You know files with same inode number are the links(hard or soft) and this solution also works for the symbolic links.






      share|improve this answer


























      • ls -lai does not show the same inode number for a file and its symbolic links. Unlike hard links, symbolic links have their own separate inode entries. This is what it looks like.

        – Eliah Kagan
        Sep 12 '14 at 6:19





















      0














      To view the symbolic links in a directory:




      1. Open a terminal and move to that directory.



      2. Type the command:



        ls -la


        This shall long list all the files in the directory even if they are hidden.



      3. The files that start with l are your symbolic link files.







      share|improve this answer





















      • 1





        -1: KasiyA's answer already covers this.

        – muru
        Sep 10 '14 at 5:45



















      0














      Can be done with python as well:



      $ python -c "import os,sys; print 'n'.join([os.path.join(sys.argv[1],i) for i in os.listdir(sys.argv[1]) if os.path.islink(os.path.join(sys.argv[1],i))])" /path/to/dir


      Sample run:



      $ python -c "import os,sys; print 'n'.join([os.path.join(sys.argv[1],i) for i in os.listdir(sys.argv[1]) if os.path.islink(os.path.join(sys.argv[1],i))])" /etc
      /etc/vtrgb
      /etc/printcap
      /etc/resolv.conf
      /etc/os-release
      /etc/mtab
      /etc/localtime


      This can be extended to be recursive via os.walk function, but it's sufficient to use simple list generation for listing links in a single directory as I showed above.






      share|improve this answer































        0














        This returns all symbolically linked items (both dirs & fns) in a directory:



        find . -maxdepth 1 -type l -print | cut -c3- | grep -v "#"


        However, in order to distinguish between actual symbolically linked item types:



        ls -lhaF | grep ^l | grep -v "#" | cut -c42- | grep -v "/" | cut -d' ' -f1


        Returns symbolically linked filename items only. And,



        ls -lhaF | grep ^l | grep -v "#" | cut -c42- | grep "/" | cut -d' ' -f1


        Returns symbolically linked dirname items only.






        share|improve this answer
























          protected by Sylvain Pineau Jun 20 '16 at 11:58



          Thank you for your interest in this question.
          Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



          Would you like to answer one of these unanswered questions instead?














          9 Answers
          9






          active

          oldest

          votes








          9 Answers
          9






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          68














          You can use grep with ls command to list all the symbolic links present in the current directory.



          This will list all the links present in the current directory.



          ls -la /var/www/ | grep "->"





          share|improve this answer





















          • 5





            It will return false positive if you have a file containing "->". Try a simple touch "foo->"

            – Sylvain Pineau
            Sep 9 '14 at 18:32






          • 7





            please don't copy&paste content of another answer to your own answer. -1

            – αғsнιη
            Sep 10 '14 at 5:14








          • 1





            why not greping with ^l?

            – Eliran Malka
            Jan 18 '17 at 12:13






          • 2





            As usual, the best answer is the one with highest +

            – FractalSpace
            Dec 10 '17 at 19:19











          • Nice! → .bash_alias: alias listlinks='ls -l --color | grep "->"' 8-)

            – Frank Nocke
            Apr 11 '18 at 3:08
















          68














          You can use grep with ls command to list all the symbolic links present in the current directory.



          This will list all the links present in the current directory.



          ls -la /var/www/ | grep "->"





          share|improve this answer





















          • 5





            It will return false positive if you have a file containing "->". Try a simple touch "foo->"

            – Sylvain Pineau
            Sep 9 '14 at 18:32






          • 7





            please don't copy&paste content of another answer to your own answer. -1

            – αғsнιη
            Sep 10 '14 at 5:14








          • 1





            why not greping with ^l?

            – Eliran Malka
            Jan 18 '17 at 12:13






          • 2





            As usual, the best answer is the one with highest +

            – FractalSpace
            Dec 10 '17 at 19:19











          • Nice! → .bash_alias: alias listlinks='ls -l --color | grep "->"' 8-)

            – Frank Nocke
            Apr 11 '18 at 3:08














          68












          68








          68







          You can use grep with ls command to list all the symbolic links present in the current directory.



          This will list all the links present in the current directory.



          ls -la /var/www/ | grep "->"





          share|improve this answer















          You can use grep with ls command to list all the symbolic links present in the current directory.



          This will list all the links present in the current directory.



          ls -la /var/www/ | grep "->"






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 20 '16 at 9:31









          muru

          1




          1










          answered Sep 9 '14 at 18:02









          g_pg_p

          12.6k24461




          12.6k24461








          • 5





            It will return false positive if you have a file containing "->". Try a simple touch "foo->"

            – Sylvain Pineau
            Sep 9 '14 at 18:32






          • 7





            please don't copy&paste content of another answer to your own answer. -1

            – αғsнιη
            Sep 10 '14 at 5:14








          • 1





            why not greping with ^l?

            – Eliran Malka
            Jan 18 '17 at 12:13






          • 2





            As usual, the best answer is the one with highest +

            – FractalSpace
            Dec 10 '17 at 19:19











          • Nice! → .bash_alias: alias listlinks='ls -l --color | grep "->"' 8-)

            – Frank Nocke
            Apr 11 '18 at 3:08














          • 5





            It will return false positive if you have a file containing "->". Try a simple touch "foo->"

            – Sylvain Pineau
            Sep 9 '14 at 18:32






          • 7





            please don't copy&paste content of another answer to your own answer. -1

            – αғsнιη
            Sep 10 '14 at 5:14








          • 1





            why not greping with ^l?

            – Eliran Malka
            Jan 18 '17 at 12:13






          • 2





            As usual, the best answer is the one with highest +

            – FractalSpace
            Dec 10 '17 at 19:19











          • Nice! → .bash_alias: alias listlinks='ls -l --color | grep "->"' 8-)

            – Frank Nocke
            Apr 11 '18 at 3:08








          5




          5





          It will return false positive if you have a file containing "->". Try a simple touch "foo->"

          – Sylvain Pineau
          Sep 9 '14 at 18:32





          It will return false positive if you have a file containing "->". Try a simple touch "foo->"

          – Sylvain Pineau
          Sep 9 '14 at 18:32




          7




          7





          please don't copy&paste content of another answer to your own answer. -1

          – αғsнιη
          Sep 10 '14 at 5:14







          please don't copy&paste content of another answer to your own answer. -1

          – αғsнιη
          Sep 10 '14 at 5:14






          1




          1





          why not greping with ^l?

          – Eliran Malka
          Jan 18 '17 at 12:13





          why not greping with ^l?

          – Eliran Malka
          Jan 18 '17 at 12:13




          2




          2





          As usual, the best answer is the one with highest +

          – FractalSpace
          Dec 10 '17 at 19:19





          As usual, the best answer is the one with highest +

          – FractalSpace
          Dec 10 '17 at 19:19













          Nice! → .bash_alias: alias listlinks='ls -l --color | grep "->"' 8-)

          – Frank Nocke
          Apr 11 '18 at 3:08





          Nice! → .bash_alias: alias listlinks='ls -l --color | grep "->"' 8-)

          – Frank Nocke
          Apr 11 '18 at 3:08













          216














          Parsing ls is a Bad Idea®, prefer a simple find in that case:



          find . -type l -ls


          To only process the current directory:



          find . -maxdepth 1 -type l -ls


          Credits: How do I make the shell to recognize the file names returned by a `ls -A` command, and these names contain spaces?






          share|improve this answer


























          • find: Unknown argument to -type: 1

            – ahnbizcad
            May 28 '15 at 16:39








          • 11





            @ahnbizcad: It's not 1 (one) but l (link)

            – Sylvain Pineau
            May 28 '15 at 17:51






          • 3





            Great answer! I adjusted mine to not descend down directory path like this: find /<your_directory> -maxdepth 1 -type l -ls 2>/dev/null Thank you!

            – bgs
            Feb 4 '16 at 18:47








          • 3





            For only the current directory (i.e. not recursive) add -maxdepth 1.

            – Joshua Pinter
            Apr 8 '16 at 14:32
















          216














          Parsing ls is a Bad Idea®, prefer a simple find in that case:



          find . -type l -ls


          To only process the current directory:



          find . -maxdepth 1 -type l -ls


          Credits: How do I make the shell to recognize the file names returned by a `ls -A` command, and these names contain spaces?






          share|improve this answer


























          • find: Unknown argument to -type: 1

            – ahnbizcad
            May 28 '15 at 16:39








          • 11





            @ahnbizcad: It's not 1 (one) but l (link)

            – Sylvain Pineau
            May 28 '15 at 17:51






          • 3





            Great answer! I adjusted mine to not descend down directory path like this: find /<your_directory> -maxdepth 1 -type l -ls 2>/dev/null Thank you!

            – bgs
            Feb 4 '16 at 18:47








          • 3





            For only the current directory (i.e. not recursive) add -maxdepth 1.

            – Joshua Pinter
            Apr 8 '16 at 14:32














          216












          216








          216







          Parsing ls is a Bad Idea®, prefer a simple find in that case:



          find . -type l -ls


          To only process the current directory:



          find . -maxdepth 1 -type l -ls


          Credits: How do I make the shell to recognize the file names returned by a `ls -A` command, and these names contain spaces?






          share|improve this answer















          Parsing ls is a Bad Idea®, prefer a simple find in that case:



          find . -type l -ls


          To only process the current directory:



          find . -maxdepth 1 -type l -ls


          Credits: How do I make the shell to recognize the file names returned by a `ls -A` command, and these names contain spaces?







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 13 '17 at 12:24









          Community

          1




          1










          answered Sep 9 '14 at 18:21









          Sylvain PineauSylvain Pineau

          48.9k16107150




          48.9k16107150













          • find: Unknown argument to -type: 1

            – ahnbizcad
            May 28 '15 at 16:39








          • 11





            @ahnbizcad: It's not 1 (one) but l (link)

            – Sylvain Pineau
            May 28 '15 at 17:51






          • 3





            Great answer! I adjusted mine to not descend down directory path like this: find /<your_directory> -maxdepth 1 -type l -ls 2>/dev/null Thank you!

            – bgs
            Feb 4 '16 at 18:47








          • 3





            For only the current directory (i.e. not recursive) add -maxdepth 1.

            – Joshua Pinter
            Apr 8 '16 at 14:32



















          • find: Unknown argument to -type: 1

            – ahnbizcad
            May 28 '15 at 16:39








          • 11





            @ahnbizcad: It's not 1 (one) but l (link)

            – Sylvain Pineau
            May 28 '15 at 17:51






          • 3





            Great answer! I adjusted mine to not descend down directory path like this: find /<your_directory> -maxdepth 1 -type l -ls 2>/dev/null Thank you!

            – bgs
            Feb 4 '16 at 18:47








          • 3





            For only the current directory (i.e. not recursive) add -maxdepth 1.

            – Joshua Pinter
            Apr 8 '16 at 14:32

















          find: Unknown argument to -type: 1

          – ahnbizcad
          May 28 '15 at 16:39







          find: Unknown argument to -type: 1

          – ahnbizcad
          May 28 '15 at 16:39






          11




          11





          @ahnbizcad: It's not 1 (one) but l (link)

          – Sylvain Pineau
          May 28 '15 at 17:51





          @ahnbizcad: It's not 1 (one) but l (link)

          – Sylvain Pineau
          May 28 '15 at 17:51




          3




          3





          Great answer! I adjusted mine to not descend down directory path like this: find /<your_directory> -maxdepth 1 -type l -ls 2>/dev/null Thank you!

          – bgs
          Feb 4 '16 at 18:47







          Great answer! I adjusted mine to not descend down directory path like this: find /<your_directory> -maxdepth 1 -type l -ls 2>/dev/null Thank you!

          – bgs
          Feb 4 '16 at 18:47






          3




          3





          For only the current directory (i.e. not recursive) add -maxdepth 1.

          – Joshua Pinter
          Apr 8 '16 at 14:32





          For only the current directory (i.e. not recursive) add -maxdepth 1.

          – Joshua Pinter
          Apr 8 '16 at 14:32











          9














          the ls -la command show all files and folders and also symbolic linked directory, if this command doesn't show any symbolic directory it means you don't have a symbolic link to WordPress.



          see the result of running ls -la:



          kasiya@kasiya-pc:~$ cd /sys/devices/platform/sony-laptop
          kasiya@kasiya-pc:/sys/devices/platform/sony-laptop$ ls -la
          total 0
          drwxr-xr-x 3 root root 0 Sep 9 19:57 .
          drwxr-xr-x 14 root root 0 Sep 10 2014 ..
          -r--r--r-- 1 root root 4096 Sep 9 22:32 battery_care_health
          -rw-r--r-- 1 root root 4096 Sep 9 22:32 battery_care_limiter
          lrwxrwxrwx 1 root root 0 Sep 9 19:57 driver -> ../../../bus/platform/drivers/sony-laptop
          -r--r--r-- 1 root root 4096 Sep 9 22:32 modalias
          drwxr-xr-x 2 root root 0 Sep 9 22:32 power
          lrwxrwxrwx 1 root root 0 Sep 9 22:32 subsystem -> ../../../bus/platform
          -rw-r--r-- 1 root root 4096 Sep 9 22:32 touchpad
          -rw-r--r-- 1 root root 4096 Sep 9 19:57 uevent


          You will see all symbolic directory has l permission at the begging of permissions flags. and if you take a grep with ^l you can list only symbolic files or directory:



          kasiya@kasiya-pc:/sys/devices/platform/sony-laptop$ ls -la |grep ^l
          lrwxrwxrwx 1 root root 0 Sep 9 19:57 driver -> ../../../bus/platform/drivers/sony-laptop
          lrwxrwxrwx 1 root root 0 Sep 9 22:32 subsystem -> ../../../bus/platform
          kasiya@kasiya-pc:/sys/devices/platform/sony-laptop$


          driver and subsystem directory are symbolic link to other directory in here.






          share|improve this answer





















          • 1





            Minor specification here... the first character of the permissions string isn't really a permission. It's the file type. As you've stated l means it's a symbolic link.

            – conner.xyz
            Apr 4 '16 at 16:49
















          9














          the ls -la command show all files and folders and also symbolic linked directory, if this command doesn't show any symbolic directory it means you don't have a symbolic link to WordPress.



          see the result of running ls -la:



          kasiya@kasiya-pc:~$ cd /sys/devices/platform/sony-laptop
          kasiya@kasiya-pc:/sys/devices/platform/sony-laptop$ ls -la
          total 0
          drwxr-xr-x 3 root root 0 Sep 9 19:57 .
          drwxr-xr-x 14 root root 0 Sep 10 2014 ..
          -r--r--r-- 1 root root 4096 Sep 9 22:32 battery_care_health
          -rw-r--r-- 1 root root 4096 Sep 9 22:32 battery_care_limiter
          lrwxrwxrwx 1 root root 0 Sep 9 19:57 driver -> ../../../bus/platform/drivers/sony-laptop
          -r--r--r-- 1 root root 4096 Sep 9 22:32 modalias
          drwxr-xr-x 2 root root 0 Sep 9 22:32 power
          lrwxrwxrwx 1 root root 0 Sep 9 22:32 subsystem -> ../../../bus/platform
          -rw-r--r-- 1 root root 4096 Sep 9 22:32 touchpad
          -rw-r--r-- 1 root root 4096 Sep 9 19:57 uevent


          You will see all symbolic directory has l permission at the begging of permissions flags. and if you take a grep with ^l you can list only symbolic files or directory:



          kasiya@kasiya-pc:/sys/devices/platform/sony-laptop$ ls -la |grep ^l
          lrwxrwxrwx 1 root root 0 Sep 9 19:57 driver -> ../../../bus/platform/drivers/sony-laptop
          lrwxrwxrwx 1 root root 0 Sep 9 22:32 subsystem -> ../../../bus/platform
          kasiya@kasiya-pc:/sys/devices/platform/sony-laptop$


          driver and subsystem directory are symbolic link to other directory in here.






          share|improve this answer





















          • 1





            Minor specification here... the first character of the permissions string isn't really a permission. It's the file type. As you've stated l means it's a symbolic link.

            – conner.xyz
            Apr 4 '16 at 16:49














          9












          9








          9







          the ls -la command show all files and folders and also symbolic linked directory, if this command doesn't show any symbolic directory it means you don't have a symbolic link to WordPress.



          see the result of running ls -la:



          kasiya@kasiya-pc:~$ cd /sys/devices/platform/sony-laptop
          kasiya@kasiya-pc:/sys/devices/platform/sony-laptop$ ls -la
          total 0
          drwxr-xr-x 3 root root 0 Sep 9 19:57 .
          drwxr-xr-x 14 root root 0 Sep 10 2014 ..
          -r--r--r-- 1 root root 4096 Sep 9 22:32 battery_care_health
          -rw-r--r-- 1 root root 4096 Sep 9 22:32 battery_care_limiter
          lrwxrwxrwx 1 root root 0 Sep 9 19:57 driver -> ../../../bus/platform/drivers/sony-laptop
          -r--r--r-- 1 root root 4096 Sep 9 22:32 modalias
          drwxr-xr-x 2 root root 0 Sep 9 22:32 power
          lrwxrwxrwx 1 root root 0 Sep 9 22:32 subsystem -> ../../../bus/platform
          -rw-r--r-- 1 root root 4096 Sep 9 22:32 touchpad
          -rw-r--r-- 1 root root 4096 Sep 9 19:57 uevent


          You will see all symbolic directory has l permission at the begging of permissions flags. and if you take a grep with ^l you can list only symbolic files or directory:



          kasiya@kasiya-pc:/sys/devices/platform/sony-laptop$ ls -la |grep ^l
          lrwxrwxrwx 1 root root 0 Sep 9 19:57 driver -> ../../../bus/platform/drivers/sony-laptop
          lrwxrwxrwx 1 root root 0 Sep 9 22:32 subsystem -> ../../../bus/platform
          kasiya@kasiya-pc:/sys/devices/platform/sony-laptop$


          driver and subsystem directory are symbolic link to other directory in here.






          share|improve this answer















          the ls -la command show all files and folders and also symbolic linked directory, if this command doesn't show any symbolic directory it means you don't have a symbolic link to WordPress.



          see the result of running ls -la:



          kasiya@kasiya-pc:~$ cd /sys/devices/platform/sony-laptop
          kasiya@kasiya-pc:/sys/devices/platform/sony-laptop$ ls -la
          total 0
          drwxr-xr-x 3 root root 0 Sep 9 19:57 .
          drwxr-xr-x 14 root root 0 Sep 10 2014 ..
          -r--r--r-- 1 root root 4096 Sep 9 22:32 battery_care_health
          -rw-r--r-- 1 root root 4096 Sep 9 22:32 battery_care_limiter
          lrwxrwxrwx 1 root root 0 Sep 9 19:57 driver -> ../../../bus/platform/drivers/sony-laptop
          -r--r--r-- 1 root root 4096 Sep 9 22:32 modalias
          drwxr-xr-x 2 root root 0 Sep 9 22:32 power
          lrwxrwxrwx 1 root root 0 Sep 9 22:32 subsystem -> ../../../bus/platform
          -rw-r--r-- 1 root root 4096 Sep 9 22:32 touchpad
          -rw-r--r-- 1 root root 4096 Sep 9 19:57 uevent


          You will see all symbolic directory has l permission at the begging of permissions flags. and if you take a grep with ^l you can list only symbolic files or directory:



          kasiya@kasiya-pc:/sys/devices/platform/sony-laptop$ ls -la |grep ^l
          lrwxrwxrwx 1 root root 0 Sep 9 19:57 driver -> ../../../bus/platform/drivers/sony-laptop
          lrwxrwxrwx 1 root root 0 Sep 9 22:32 subsystem -> ../../../bus/platform
          kasiya@kasiya-pc:/sys/devices/platform/sony-laptop$


          driver and subsystem directory are symbolic link to other directory in here.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Sep 9 '14 at 18:56

























          answered Sep 9 '14 at 18:32









          αғsнιηαғsнιη

          24.4k2296157




          24.4k2296157








          • 1





            Minor specification here... the first character of the permissions string isn't really a permission. It's the file type. As you've stated l means it's a symbolic link.

            – conner.xyz
            Apr 4 '16 at 16:49














          • 1





            Minor specification here... the first character of the permissions string isn't really a permission. It's the file type. As you've stated l means it's a symbolic link.

            – conner.xyz
            Apr 4 '16 at 16:49








          1




          1





          Minor specification here... the first character of the permissions string isn't really a permission. It's the file type. As you've stated l means it's a symbolic link.

          – conner.xyz
          Apr 4 '16 at 16:49





          Minor specification here... the first character of the permissions string isn't really a permission. It's the file type. As you've stated l means it's a symbolic link.

          – conner.xyz
          Apr 4 '16 at 16:49











          4














          grep is your friend:



          ls -lhaF | grep ^l   # list links
          ls -lhaF | grep ^d # list directories
          ls -lhaF | grep ^- # list files


          This will list lines starting with "l" which represent Links in the perms column in place of l use d for directories and - for files






          share|improve this answer






























            4














            grep is your friend:



            ls -lhaF | grep ^l   # list links
            ls -lhaF | grep ^d # list directories
            ls -lhaF | grep ^- # list files


            This will list lines starting with "l" which represent Links in the perms column in place of l use d for directories and - for files






            share|improve this answer




























              4












              4








              4







              grep is your friend:



              ls -lhaF | grep ^l   # list links
              ls -lhaF | grep ^d # list directories
              ls -lhaF | grep ^- # list files


              This will list lines starting with "l" which represent Links in the perms column in place of l use d for directories and - for files






              share|improve this answer















              grep is your friend:



              ls -lhaF | grep ^l   # list links
              ls -lhaF | grep ^d # list directories
              ls -lhaF | grep ^- # list files


              This will list lines starting with "l" which represent Links in the perms column in place of l use d for directories and - for files







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Oct 8 '15 at 14:59









              Fabby

              26.7k1360160




              26.7k1360160










              answered Oct 8 '15 at 10:22









              KaliburKalibur

              411




              411























                  3














                  POSIXly:



                  find ! -name . -prune -type l





                  share|improve this answer




























                    3














                    POSIXly:



                    find ! -name . -prune -type l





                    share|improve this answer


























                      3












                      3








                      3







                      POSIXly:



                      find ! -name . -prune -type l





                      share|improve this answer













                      POSIXly:



                      find ! -name . -prune -type l






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Sep 9 '14 at 18:24









                      cuonglmcuonglm

                      1,775915




                      1,775915























                          0














                          Type ls -lai,it will list all the files and subdirectories with corresponding inode numbers.You know files with same inode number are the links(hard or soft) and this solution also works for the symbolic links.






                          share|improve this answer


























                          • ls -lai does not show the same inode number for a file and its symbolic links. Unlike hard links, symbolic links have their own separate inode entries. This is what it looks like.

                            – Eliah Kagan
                            Sep 12 '14 at 6:19


















                          0














                          Type ls -lai,it will list all the files and subdirectories with corresponding inode numbers.You know files with same inode number are the links(hard or soft) and this solution also works for the symbolic links.






                          share|improve this answer


























                          • ls -lai does not show the same inode number for a file and its symbolic links. Unlike hard links, symbolic links have their own separate inode entries. This is what it looks like.

                            – Eliah Kagan
                            Sep 12 '14 at 6:19
















                          0












                          0








                          0







                          Type ls -lai,it will list all the files and subdirectories with corresponding inode numbers.You know files with same inode number are the links(hard or soft) and this solution also works for the symbolic links.






                          share|improve this answer















                          Type ls -lai,it will list all the files and subdirectories with corresponding inode numbers.You know files with same inode number are the links(hard or soft) and this solution also works for the symbolic links.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Sep 9 '14 at 18:42

























                          answered Sep 9 '14 at 18:18









                          saptarshi nagsaptarshi nag

                          3751212




                          3751212













                          • ls -lai does not show the same inode number for a file and its symbolic links. Unlike hard links, symbolic links have their own separate inode entries. This is what it looks like.

                            – Eliah Kagan
                            Sep 12 '14 at 6:19





















                          • ls -lai does not show the same inode number for a file and its symbolic links. Unlike hard links, symbolic links have their own separate inode entries. This is what it looks like.

                            – Eliah Kagan
                            Sep 12 '14 at 6:19



















                          ls -lai does not show the same inode number for a file and its symbolic links. Unlike hard links, symbolic links have their own separate inode entries. This is what it looks like.

                          – Eliah Kagan
                          Sep 12 '14 at 6:19







                          ls -lai does not show the same inode number for a file and its symbolic links. Unlike hard links, symbolic links have their own separate inode entries. This is what it looks like.

                          – Eliah Kagan
                          Sep 12 '14 at 6:19













                          0














                          To view the symbolic links in a directory:




                          1. Open a terminal and move to that directory.



                          2. Type the command:



                            ls -la


                            This shall long list all the files in the directory even if they are hidden.



                          3. The files that start with l are your symbolic link files.







                          share|improve this answer





















                          • 1





                            -1: KasiyA's answer already covers this.

                            – muru
                            Sep 10 '14 at 5:45
















                          0














                          To view the symbolic links in a directory:




                          1. Open a terminal and move to that directory.



                          2. Type the command:



                            ls -la


                            This shall long list all the files in the directory even if they are hidden.



                          3. The files that start with l are your symbolic link files.







                          share|improve this answer





















                          • 1





                            -1: KasiyA's answer already covers this.

                            – muru
                            Sep 10 '14 at 5:45














                          0












                          0








                          0







                          To view the symbolic links in a directory:




                          1. Open a terminal and move to that directory.



                          2. Type the command:



                            ls -la


                            This shall long list all the files in the directory even if they are hidden.



                          3. The files that start with l are your symbolic link files.







                          share|improve this answer















                          To view the symbolic links in a directory:




                          1. Open a terminal and move to that directory.



                          2. Type the command:



                            ls -la


                            This shall long list all the files in the directory even if they are hidden.



                          3. The files that start with l are your symbolic link files.








                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Sep 12 '14 at 6:16









                          Eliah Kagan

                          82.1k21227366




                          82.1k21227366










                          answered Sep 10 '14 at 5:43









                          sandeep srivastav vaddiparthysandeep srivastav vaddiparthy

                          235




                          235








                          • 1





                            -1: KasiyA's answer already covers this.

                            – muru
                            Sep 10 '14 at 5:45














                          • 1





                            -1: KasiyA's answer already covers this.

                            – muru
                            Sep 10 '14 at 5:45








                          1




                          1





                          -1: KasiyA's answer already covers this.

                          – muru
                          Sep 10 '14 at 5:45





                          -1: KasiyA's answer already covers this.

                          – muru
                          Sep 10 '14 at 5:45











                          0














                          Can be done with python as well:



                          $ python -c "import os,sys; print 'n'.join([os.path.join(sys.argv[1],i) for i in os.listdir(sys.argv[1]) if os.path.islink(os.path.join(sys.argv[1],i))])" /path/to/dir


                          Sample run:



                          $ python -c "import os,sys; print 'n'.join([os.path.join(sys.argv[1],i) for i in os.listdir(sys.argv[1]) if os.path.islink(os.path.join(sys.argv[1],i))])" /etc
                          /etc/vtrgb
                          /etc/printcap
                          /etc/resolv.conf
                          /etc/os-release
                          /etc/mtab
                          /etc/localtime


                          This can be extended to be recursive via os.walk function, but it's sufficient to use simple list generation for listing links in a single directory as I showed above.






                          share|improve this answer




























                            0














                            Can be done with python as well:



                            $ python -c "import os,sys; print 'n'.join([os.path.join(sys.argv[1],i) for i in os.listdir(sys.argv[1]) if os.path.islink(os.path.join(sys.argv[1],i))])" /path/to/dir


                            Sample run:



                            $ python -c "import os,sys; print 'n'.join([os.path.join(sys.argv[1],i) for i in os.listdir(sys.argv[1]) if os.path.islink(os.path.join(sys.argv[1],i))])" /etc
                            /etc/vtrgb
                            /etc/printcap
                            /etc/resolv.conf
                            /etc/os-release
                            /etc/mtab
                            /etc/localtime


                            This can be extended to be recursive via os.walk function, but it's sufficient to use simple list generation for listing links in a single directory as I showed above.






                            share|improve this answer


























                              0












                              0








                              0







                              Can be done with python as well:



                              $ python -c "import os,sys; print 'n'.join([os.path.join(sys.argv[1],i) for i in os.listdir(sys.argv[1]) if os.path.islink(os.path.join(sys.argv[1],i))])" /path/to/dir


                              Sample run:



                              $ python -c "import os,sys; print 'n'.join([os.path.join(sys.argv[1],i) for i in os.listdir(sys.argv[1]) if os.path.islink(os.path.join(sys.argv[1],i))])" /etc
                              /etc/vtrgb
                              /etc/printcap
                              /etc/resolv.conf
                              /etc/os-release
                              /etc/mtab
                              /etc/localtime


                              This can be extended to be recursive via os.walk function, but it's sufficient to use simple list generation for listing links in a single directory as I showed above.






                              share|improve this answer













                              Can be done with python as well:



                              $ python -c "import os,sys; print 'n'.join([os.path.join(sys.argv[1],i) for i in os.listdir(sys.argv[1]) if os.path.islink(os.path.join(sys.argv[1],i))])" /path/to/dir


                              Sample run:



                              $ python -c "import os,sys; print 'n'.join([os.path.join(sys.argv[1],i) for i in os.listdir(sys.argv[1]) if os.path.islink(os.path.join(sys.argv[1],i))])" /etc
                              /etc/vtrgb
                              /etc/printcap
                              /etc/resolv.conf
                              /etc/os-release
                              /etc/mtab
                              /etc/localtime


                              This can be extended to be recursive via os.walk function, but it's sufficient to use simple list generation for listing links in a single directory as I showed above.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Jan 9 '17 at 11:15









                              Sergiy KolodyazhnyySergiy Kolodyazhnyy

                              71.9k9148314




                              71.9k9148314























                                  0














                                  This returns all symbolically linked items (both dirs & fns) in a directory:



                                  find . -maxdepth 1 -type l -print | cut -c3- | grep -v "#"


                                  However, in order to distinguish between actual symbolically linked item types:



                                  ls -lhaF | grep ^l | grep -v "#" | cut -c42- | grep -v "/" | cut -d' ' -f1


                                  Returns symbolically linked filename items only. And,



                                  ls -lhaF | grep ^l | grep -v "#" | cut -c42- | grep "/" | cut -d' ' -f1


                                  Returns symbolically linked dirname items only.






                                  share|improve this answer






























                                    0














                                    This returns all symbolically linked items (both dirs & fns) in a directory:



                                    find . -maxdepth 1 -type l -print | cut -c3- | grep -v "#"


                                    However, in order to distinguish between actual symbolically linked item types:



                                    ls -lhaF | grep ^l | grep -v "#" | cut -c42- | grep -v "/" | cut -d' ' -f1


                                    Returns symbolically linked filename items only. And,



                                    ls -lhaF | grep ^l | grep -v "#" | cut -c42- | grep "/" | cut -d' ' -f1


                                    Returns symbolically linked dirname items only.






                                    share|improve this answer




























                                      0












                                      0








                                      0







                                      This returns all symbolically linked items (both dirs & fns) in a directory:



                                      find . -maxdepth 1 -type l -print | cut -c3- | grep -v "#"


                                      However, in order to distinguish between actual symbolically linked item types:



                                      ls -lhaF | grep ^l | grep -v "#" | cut -c42- | grep -v "/" | cut -d' ' -f1


                                      Returns symbolically linked filename items only. And,



                                      ls -lhaF | grep ^l | grep -v "#" | cut -c42- | grep "/" | cut -d' ' -f1


                                      Returns symbolically linked dirname items only.






                                      share|improve this answer















                                      This returns all symbolically linked items (both dirs & fns) in a directory:



                                      find . -maxdepth 1 -type l -print | cut -c3- | grep -v "#"


                                      However, in order to distinguish between actual symbolically linked item types:



                                      ls -lhaF | grep ^l | grep -v "#" | cut -c42- | grep -v "/" | cut -d' ' -f1


                                      Returns symbolically linked filename items only. And,



                                      ls -lhaF | grep ^l | grep -v "#" | cut -c42- | grep "/" | cut -d' ' -f1


                                      Returns symbolically linked dirname items only.







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Jan 19 at 20:30









                                      PerlDuck

                                      6,55211435




                                      6,55211435










                                      answered Jan 19 at 20:28









                                      odoncaoaodoncaoa

                                      293




                                      293

















                                          protected by Sylvain Pineau Jun 20 '16 at 11:58



                                          Thank you for your interest in this question.
                                          Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                          Would you like to answer one of these unanswered questions instead?



                                          Popular posts from this blog

                                          flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                                          Mangá

                                           ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕