Unable to list all files in $HOME directory - linux

I installed the latest version of cygwin and wanted to list all files in my $HOME direcrory (in paticular .vimrc config file). I type ls -l and see 0 files, but when I try to open the file via vim it's ok. Actually (after 2 TABs):
what's wrong?

In *nix systems, prefixing a name with . causes the item to be hidden.
To include these files when you type ls -l, you will need to include the -a modifier.
You can write this as ls -la for brevity, if you like.
In the future, if you're having trouble with a program, you can type (e.g.) man ls to open the manual pages for (e.g.) ls.

Related

How to list down all the soft links only inside a directory in Linux systems

What is a shortcut command to list all the links inside a directory in linux machines. I can list all files and folders and copy output in a temp file and from there I can do a grep, but what I am looking for is a shortcut command to do the same.
and copy output in a temp file
This is exactly the situation for pipes!
ls -la | grep "^l"
The stdout of ls -la is redirected to the input of grep. It sounds like you know, but just for completeness the "^l" is a regular expression that searches for an l at the start of a line.
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.

How I can hide original directory of linked folders in terminal while i use ”ls -la”

I often use ls -la command for view hidden files in terminal.
But I'm uncomfortable with the fact that it shows and links to directories of linked folders.
Can I hide this?
The -L option may be what you are looking for, although this also changes what metadata is shown. Without -L, you get permissions, size, etc for the symlink. With -L, the symlink's name alone is shown, but with the permissions, size, etc of the target.
ls -la /usr/bin/ | awk 'BEGIN{FS="->"}{print $1}'
then you can alias it , so don't have to type all of that every time

The output of ls with -aF option is not clear

When I try the command ls with -aF option inside any directory whether it's empty or not, I always got the following:
./ ../
so what does the output mean when I have these two options together with ls command?
When you use ls, you are reading a directory file, not actually looking in a directory. Every directory listing contains an entry for the present/current directory, as well as its parent directory, just as you would expect to also see listings for sub/child directories in any directory listing.
The -A option for ls merely tells ls to display ALL files, which includes the entries of ./ & ../ for present and parent. Note that these dots are merely a shorthand that the shell (bash) uses to represent file paths for those files. In other words, what "./" really means is say ~/Desktop if you were currently in the Desktop directory doing an ls. And "../" would mean "~/" which is just another symbolic shorthand to represent your user home directory, which is probably something like /Users/your_username on macOS (OS X), or /usr/your_username for various Linux distributions. Note that those paths could also be written with the forward slash appended at the end and would mean the same thing (e.g., /Users/your_username/ is the same as /Users/your_username because they are both references to other directories (directory files).
Use the -a option for ls if you don't want to see ./ & ../, but still want to see (other) hidden files.
Using the -F option causes ls to display appended characters to the file types based on the file type. This is why directories are displayed with the forward slash appended at the end, and executables are displayed as executable* (with the asterisk appended), and regular files have no appendage (e.g., .txt, .png, .dmg).

Bash tab completion like ncftp?

In ncftp tab completion only shows the differences of matched files. E.g. with the following files
file123 file125 aa
then typing ls fil will first complete to ls file12 and show
3 5
Question
Can the same be done in Bash?
BASH supports tab-completion which is fairly robust. It is implemented through bash_completion. However, be aware that the way bash_completion is configured will depend on what options are set by default by your distribution. As for its basic functionality, it is exactly as you describe for ncftp. When a partial name is entered on the command line and tab is pressed, then a list of name-matched files are displayed. Once you have entered enough characters to make the name unique, tab will complete entry of the unique filename on the command line.
Linux also provides ls, but its behavior is not the same as you describe for ncftp. ls will return the names of files and directories that match the pattern you specified. By default, the name you provide to ls is not expanded. Meaning if you have file123 and file125 in a directory and issue the command ls file, you will be greeted by the error ls: cannot access bash: No such file or directory. But providing a wildcard (filename globbing) with ls file* will return both names.
If you have additional specific questions. Just leave a comment and we will do our best to help.

Getting the logical path in VIM when there's a symlink

I have the following setup:
mkdir /1
mkdir /1/2
mkdir /1/2/3
ln -s /1/2/3 /1/3
If I do cd /1/3, and then pwd, I get /1/3. If I use pwd -P, I can get /1/2/3, or pwd -L to force /1/3.
In VIM, I'm looking for a way to get the /1/3.
If I open a file in /1/3/foo.txt, and I use something like fnamemodify(bufname(winbufnr(0)), ':p:h'), it returns /1/2/3.
How can I tell it to give me the same directory that pwd would give?
It appears you can't, other than via system('pwd -L'). According to the vim_use mailing list Vim automatically resolves symlinks nowadays.
See the text around :h E773 for rationale; if Vim went by symlinks instead of resolved filename, it'd be possible to have the same file open in two buffers under two different names, and Vim would become confused trying to figure out where the swap file should be. See also in :h version7.txt:
Unix: When editing a file through a symlink the swap file would use the name
of the symlink. Now use the name of the actual file, so that editing the same
file twice is detected.
Short answer:
You may be able to use mount binding as a substitute for symlinks. See man mount.
Long answer:
I had a similar problem, as I have a short symlink to a mounted partition,
/e -> /media/iam/ext4test
I also have a symlink ~/.vimrc -> /e/configs/.vimrc.
I was running into trouble trying to pop into Netrw in the containing directory (I was landing in ~, but I couldn't see a robust way to avoid that, keeping in mind the desire to use Bookmarks, etc).
My solution was, after considering possibly changing the mount point, is that you can add mount points. So after unlink e, I used mount --bind /media/iam/ext4test /e.
Now, if I am in /e/configs/.vimrc and use :edit . (or :e. etc), it will pop me into Netrw in the containing directory.
Edit:
The command mount --bind makes transient changes. For a permanent bind mount, I add the following to /etc/fstab,
# <file system> <mount point> <type> <options> <dump> <pass>
/media/iam/ext4test /e none bind 0 0

Resources