The small linux problem thread

The -O .env option means that example.env will be saved as a file with the name .env.

Files starting with a . are ‘hidden’ files, and are not reported by ls -l. To list ALL files in a directory (including the hidden ones) use ls -al.

$ man ls

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
    List  information  about  the FILEs (the current directory by default).
    Sort entries alphabetically if none of -cftuvSUX nor --sort  is  speci‐
    fied.

    Mandatory  arguments  to  long  options are mandatory for short options
    too.

        -a, --all
            do not ignore entries starting with .

If you are using wget to fetch a single file, and want to retain the filename, simply omit the -O .env option entirely. You’ll end up with a local file named example.env which, because it does not start with a . is not considered to be a hidden file and thus will be reported by ls -l.

1 Like

Files starting with a dot are hidden, and ls will show them when using -a or -A. Please also read ls --help and/or man ls for more info.

1 Like

Thank you, I understand now. Out of curiosity, is there a reason to have this file hidden?

Well yes, the filename you gave it.

As noted above, dot-files are hidden files. It’s just how it is. Whereas Windows has a separate file-attribute for it, such an attribute doesn’t exist on unixoid systems so it is handled by filename.

Files beginning with a . are generally either directory references or involved in configuration/preferences.

On Unix-like systems . refers to the current directory, and .. refers to the previous (parent) directory. These two entries appear in every single directory.

Installed programs and system utilities (e.g. Steam, bash) also create directories and/or files in which they store user preferences and data. Users can spend a lot (a lot) of time tweaking their systems to work just the way they want it to, and config files contain those tweaks.

Unfortunately, there are a lot of programs and utilities on Unix-like systems, so there tend to be a lot of configuration files as well. For historic reasons, their locations are not centralised — they are scattered all over the place. The sheer number and distribution of config files makes directory listings look “messy” and makes it harder to find the file you are actually interested in. They often/usually act as clutter.

So, the developers of Unix — eons ago — came up with a convention of using a . prefix in the filename itself to mark those useful (but rarely accessed) files, and utilities such as ls ignore/hide them by default because, in all likelihood, “these are not the files you are looking for”.

tl;dr: Prefixing files with a . to hide them is a quality-of-life convention that improves the signal:noise ratio of directory listings.

PS: If you are, instead, asking why your specific file was hidden, it’s because you instructed it to be hidden by using the -O option in your wget command and giving it a filename which marked it as hidden. We can’t read your mind, so we don’t know why you deliberately used the -O option to rename the file. There is nothing special about your particular file. ALL files that have filenames starting with . are hidden by default by utilities such as ls.

PPS: If you didn’t devise/write that wget command yourself, and merely copy-pasted it from somewhere else, then the only person on the planet who knows why renaming example.env to .env during download might be a good idea is the original author who wrote that wget command. We know nothing about the software you are dealing with — what it does, where it goes, what files contain what or do what.

1 Like

Conveniently, this article just got published:

I got a seemingly simple question that I can’t find a simple(r) answer for.
Suppose I want to debug some permissions issues with someone, and I need the permissions of a directory’s contents as well as said directory itself.
i.e. say I have a directory/file structure like this:

$ ls -R test2
test2:
a  b  c  d

test2/a:
e

test2/b:
f

test2/c:
g

test2/d:
h

And I need both the permissions on directory test2, as well as its subdirectories a, b, c, and d. Let’s say for simplicity I don’t care about the permissions on the files e, f, g, and h.

I can do this:

$ cd test2
$ ls -ld $PWD && ls -l
drwxr-xr-x. 6 tarulia tarulia 4096 Jan 13 03:42 /home/tarulia/test/test2
total 16
drwxr-xr-x. 2 tarulia tarulia 4096 Jan 13 03:42 a
drwxr-xr-x. 2 tarulia tarulia 4096 Jan 13 03:42 b
drwxr-xr-x. 2 tarulia tarulia 4096 Jan 13 03:42 c
drwxr-xr-x. 2 tarulia tarulia 4096 Jan 13 03:42 d

But is there a shorter way to do this? In man ls I don’t see anything obvious to include the current directory itself into the listing like this.

ls -la or similar.
The . entry is the current dir.

You can limit it to just directories with: ls -laF | grep /$

1 Like

Oh right the easiest thing -_- forgot that it listed the permissions on . there as well…

ls -lad * (or ls -lad .?* * if you also need hidden directories) works for that too :slight_smile:

ls -lad .? * will also show all files, not just the folders. The -d will only keep it from showing the contents of folders matched by *, not hide matching files.

1 Like

Hey there everyone, does anyone know how I can stop NetworkManager from creating new connection for freshly attached wired interfaces. I have a computer I need to switch network cards in from time to time and each time connections for the new interfaces get created and I want to stop that.

Put this into your NetworkManager.conf

[main]
no-auto-default=*

See the man

1 Like

Did not think of NetworkManager having a conf file as well. But of course there is, thanks mate.