Skip to content
Log In Sign Up info@muvcloud.com

Show Hidden Files

ls -a
ls -A
ls -lA ~
ls -ld .*

A file or folder is hidden when its name starts with a dot, such as .bashrc or .ssh. A plain ls skips those names. ls -a lists everything, ls -A lists everything except the . and .. entries, ls -lA ~ lists your home folder with details, and ls -ld .* lists only the hidden entries. The general options of ls are in the ls command guide; this page goes into hidden files themselves.

What Makes a File Hidden

Linux file systems have no hidden attribute. The leading dot is a naming convention: ls and the shell's * pattern leave dot names out, and nothing else changes. Anyone with read permission on the folder can list the file with -a, and anyone with read permission on the file can open it. Programs use dot names for settings, which keeps home folders and project folders tidy.

ls -a vs ls -A

CommandShows
lsVisible names only
ls -aAll names, plus . and ..
ls -AAll names, without . and ..

. is the folder itself and .. is its parent. They exist in every folder, so -A is usually the more useful choice. Combine it with other options, for example ls -lhA.

List Only the Hidden Files

ls -ld .*
ls -A | grep '^\.'
find . -mindepth 1 -maxdepth 1 -name '.*'

The shell expands .* into every name that starts with a dot. The -d matters: without it, ls also lists the contents of each hidden folder. Bash 5.2 and later, on Debian, Ubuntu, and AlmaLinux and Rocky Linux 10, skip . and .. in this pattern; bash 5.1 on release 9 includes them. The grep and find forms avoid the difference. In find, -mindepth 1 leaves out the start folder . itself.

Find Hidden Files Below a Folder

find /var/www -name '.*'
find /var/www -type d -name '.*'
find /var/www -type f -name '.env'

The first command lists every hidden file and folder in the tree, the second only hidden folders, and the third searches for one name. This is the quickest way to spot files in a web root that should not be there, such as an uploaded .git folder or a stray .env file with database passwords. More tests are in the find command guide.

Hidden Files You Will Meet on a Server

NamePurpose
.bashrcShell settings for your user
.profileSettings read at login
.ssh/Keys and allowed keys for SSH
.bash_historyCommands you typed
.envApp settings, often secrets
.htaccessApache rules for a folder
.git/A Git repository
.well-known/Certificate checks and similar

Read what .bashrc is and how to edit it before changing shell settings.

Wildcards Skip Hidden Files

cp -r site/* /var/www/new/
cp -r site/. /var/www/new/

The first command misses site/.htaccess and every other dot file, because * does not match a leading dot. The second copies the full contents, hidden files included, as the cp command guide explains. In bash, shopt -s dotglob makes * include dot names for the rest of the session. Check what a pattern matches with echo site/* before you copy, move, or delete with it.

Hiding a File Does Not Protect It

mv notes.txt .notes.txt
chmod 600 .notes.txt

Renaming a file with a leading dot hides it from a plain ls; the mv command guide covers renaming. To keep other users out, set permissions: chmod 600 lets only the owner read and write the file. Web servers do not treat dot files as private either. Nginx serves a .env or .git file from the web root to anyone who requests it unless a rule blocks it. A common rule in the server block denies every dot path except .well-known, which certificate checks need:

location ^~ /.well-known/acme-challenge/ {
}
location ~ /\.(?!well-known/) {
    deny all;
}

Nginx uses the first regular-expression location that matches, so put the deny rule above other regex locations, such as the one for PHP. The ^~ prefix location keeps certificate checks working whatever regex rules follow. Test the configuration with sudo nginx -t before you reload. The response this rule sends is explained in 403 Forbidden in Nginx.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations