How to list all symbolic links in a directory
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
add a comment |
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
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
add a comment |
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
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
command-line symbolic-link find ls
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
add a comment |
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
add a comment |
9 Answers
9
active
oldest
votes
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 "->"
5
It will return false positive if you have a file containing "->
". Try a simpletouch "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 notgrep
ing 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
|
show 1 more comment
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?
find: Unknown argument to -type: 1
– ahnbizcad
May 28 '15 at 16:39
11
@ahnbizcad: It's not1
(one) butl
(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
add a comment |
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.
1
Minor specification here... the first character of the permissions string isn't really a permission. It's the file type. As you've statedl
means it's a symbolic link.
– conner.xyz
Apr 4 '16 at 16:49
add a comment |
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
add a comment |
POSIXly:
find ! -name . -prune -type l
add a comment |
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.
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
add a comment |
To view the symbolic links in a directory:
Open a terminal and move to that directory.
Type the command:
ls -la
This shall long list all the files in the directory even if they are hidden.
The files that start with
l
are your symbolic link files.
1
-1: KasiyA's answer already covers this.
– muru
Sep 10 '14 at 5:45
add a comment |
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.
add a comment |
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.
add a comment |
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
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 "->"
5
It will return false positive if you have a file containing "->
". Try a simpletouch "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 notgrep
ing 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
|
show 1 more comment
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 "->"
5
It will return false positive if you have a file containing "->
". Try a simpletouch "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 notgrep
ing 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
|
show 1 more comment
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 "->"
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 "->"
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 simpletouch "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 notgrep
ing 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
|
show 1 more comment
5
It will return false positive if you have a file containing "->
". Try a simpletouch "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 notgrep
ing 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
grep
ing with ^l
?– Eliran Malka
Jan 18 '17 at 12:13
why not
grep
ing 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
|
show 1 more comment
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?
find: Unknown argument to -type: 1
– ahnbizcad
May 28 '15 at 16:39
11
@ahnbizcad: It's not1
(one) butl
(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
add a comment |
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?
find: Unknown argument to -type: 1
– ahnbizcad
May 28 '15 at 16:39
11
@ahnbizcad: It's not1
(one) butl
(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
add a comment |
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?
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?
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 not1
(one) butl
(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
add a comment |
find: Unknown argument to -type: 1
– ahnbizcad
May 28 '15 at 16:39
11
@ahnbizcad: It's not1
(one) butl
(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
add a comment |
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.
1
Minor specification here... the first character of the permissions string isn't really a permission. It's the file type. As you've statedl
means it's a symbolic link.
– conner.xyz
Apr 4 '16 at 16:49
add a comment |
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.
1
Minor specification here... the first character of the permissions string isn't really a permission. It's the file type. As you've statedl
means it's a symbolic link.
– conner.xyz
Apr 4 '16 at 16:49
add a comment |
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.
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.
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 statedl
means it's a symbolic link.
– conner.xyz
Apr 4 '16 at 16:49
add a comment |
1
Minor specification here... the first character of the permissions string isn't really a permission. It's the file type. As you've statedl
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
add a comment |
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
add a comment |
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
add a comment |
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
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
edited Oct 8 '15 at 14:59
Fabby
26.7k1360160
26.7k1360160
answered Oct 8 '15 at 10:22
KaliburKalibur
411
411
add a comment |
add a comment |
POSIXly:
find ! -name . -prune -type l
add a comment |
POSIXly:
find ! -name . -prune -type l
add a comment |
POSIXly:
find ! -name . -prune -type l
POSIXly:
find ! -name . -prune -type l
answered Sep 9 '14 at 18:24
cuonglmcuonglm
1,775915
1,775915
add a comment |
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
To view the symbolic links in a directory:
Open a terminal and move to that directory.
Type the command:
ls -la
This shall long list all the files in the directory even if they are hidden.
The files that start with
l
are your symbolic link files.
1
-1: KasiyA's answer already covers this.
– muru
Sep 10 '14 at 5:45
add a comment |
To view the symbolic links in a directory:
Open a terminal and move to that directory.
Type the command:
ls -la
This shall long list all the files in the directory even if they are hidden.
The files that start with
l
are your symbolic link files.
1
-1: KasiyA's answer already covers this.
– muru
Sep 10 '14 at 5:45
add a comment |
To view the symbolic links in a directory:
Open a terminal and move to that directory.
Type the command:
ls -la
This shall long list all the files in the directory even if they are hidden.
The files that start with
l
are your symbolic link files.
To view the symbolic links in a directory:
Open a terminal and move to that directory.
Type the command:
ls -la
This shall long list all the files in the directory even if they are hidden.
The files that start with
l
are your symbolic link files.
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
add a comment |
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
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Jan 9 '17 at 11:15
Sergiy KolodyazhnyySergiy Kolodyazhnyy
71.9k9148314
71.9k9148314
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
edited Jan 19 at 20:30
PerlDuck
6,55211435
6,55211435
answered Jan 19 at 20:28
odoncaoaodoncaoa
293
293
add a comment |
add a comment |
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?
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