HetznerDocs

Search documentation

Find a Hetzner dedicated Linux topic

List files with ls and inspect them with stat

ls means list. -l is the long listing (permissions, owner, size, date). -i adds the inode number. stat prints everything the kernel knows about one file.

After SSH, you are in a folder (usually /root). These three commands answer: what is here, which inode is it, and what is its full metadata.

ls -l — long listing

ls = LiSt. -l = long. Without -l you only get names. With it, each line is a row of facts.

Long listing of the current folder

ls -lls -l /etcls -ld /etc

ls -l /etc lists what is inside /etc. ls -ld /etc lists the directory itself (useful when you care about its permissions, not its children).

Sample output — ls -l in /root

total 36drwx------ 2 root root 4096 Apr 12 09:11 .ssh-rw-r--r-- 1 root root 3106 Apr 12 09:11 .bashrc-rw------- 1 root root  220 Apr 12 09:14 .bash_history-rw-r--r-- 1 root root  675 Apr 12 09:11 .profile-rwxr-xr-x 1 root root  512 Apr 12 10:02 setup.shlrwxrwxrwx 1 root root   13 Apr 12 09:11 hostname -> /etc/hostname
ColumnExampleMeaning
Type + mode-rw-r--r--First character is the type (- file, d directory, l symlink, b block disk). Then owner / group / other rwx.
Links1How many directory entries point at this inode. Directories are often 2 or more.
OwnerrootUser who owns the file (UID name).
GrouprootGroup that owns the file (GID name).
Size3106Bytes. Use ls -lh for KiB/MiB.
TimeApr 12 09:11Last modification time (mtime), unless you ask for another timestamp.
Namehostname -> /etc/hostnameFile name. A symlink prints the target after ->.

total 36 is disk blocks used in this listing (usually KiB), not “36 files.”

ls -li — same listing, plus inode

-i = inode. An inode (index node) is the file’s ID on that filesystem: type, size, timestamps, and where the data blocks are. The name lives in the directory; the inode is the file itself. Two names can share one inode (a hard link).

Long listing with inode numbers

ls -lils -li /etc/hostname /etc/hosts

Sample output — ls -li

total 36131074 drwx------ 2 root root 4096 Apr 12 09:11 .ssh131075 -rw-r--r-- 1 root root 3106 Apr 12 09:11 .bashrc131080 -rw------- 1 root root  220 Apr 12 09:14 .bash_history131076 -rw-r--r-- 1 root root  675 Apr 12 09:11 .profile131090 -rwxr-xr-x 1 root root  512 Apr 12 10:02 setup.sh131091 lrwxrwxrwx 1 root root   13 Apr 12 09:11 hostname -> /etc/hostname

The new first column (131075, …) is the inode. A symlink has its own inode; it points at a path, not at another inode the way a hard link does.

What an inode stores

The directory only stores the name plus this number. Everything else lives in the inode (and, on modern ext4, optional extra attributes):

InformationExample
File typeRegular file, directory, symlink, block device
Permissionsrwxr-xr-x
Owner and groupUID and GID (often 0/root)
File size512 bytes, or 1.2M with ls -lh
TimestampsAccessed, modified, metadata changed, birth
Hard-link countHow many names point at this inode
Pointers to data blocksWhere the bytes live on disk
Extended attributesExtra flags on ext4 (lsattr / getfacl)

ls -l prints a few of those fields. stat prints the rest. The filename is not inside the inode — that is why renaming is cheap and why two names can share one file.

Find every name for an inode

find / -xdev -inum 131075 2>/dev/null

stat — full metadata for one file

stat = STATus. ls -l is the summary row. stat filename is the full card: size, inode, device, mode, owner, and four timestamps.

Inspect one file

stat setup.shstat /etc/hostnamestat -c '%n  inode=%i  mode=%A  size=%s' setup.sh

Sample output — stat setup.sh

  File: setup.sh  Size: 512       	Blocks: 8          IO Block: 4096   regular fileDevice: 259,2	Inode: 131090     Links: 1Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)Access: 2026-04-12 10:05:11.120000000 +0200Modify: 2026-04-12 10:02:44.010000000 +0200Change: 2026-04-12 10:02:44.010000000 +0200 Birth: 2026-04-12 10:02:44.010000000 +0200
FieldWhat it is
FilePath you asked about. Symlinks show the link name, not the target, unless you use flags.
Size / Blocks / IO BlockLogical size in bytes, 512-byte blocks on disk, and the filesystem block size (often 4096).
DeviceWhich block device holds this filesystem (259,2 is typical for NVMe). Same idea as lsblk.
Inode / LinksThe ID from ls -li, and how many names point at it.
Access (mode)Numeric mode (0755) and the ls -l string. Uid/Gid 0 is root.
Access timeatime — last read. Many servers mount with relatime, so this does not update on every read.
Modify timemtime — last change to the file’s contents.
Change timectime — last change to metadata (mode, owner, or contents). Not “creation time.”
BirthCreation time, when the filesystem stores it (ext4 usually does). Empty on some older disks.

Related commands

Same job, extra flags. All of these work in Rescue and on the installed Ubuntu/Debian OS.

CommandWhen to use it
ls -lahLong listing, include hidden names (. files), human sizes (4.0K).
ls -l --time-style=long-isoUnambiguous dates: 2026-04-12 09:11.
ls -lSSort by size, largest first. Same idea as ls -lhS /var/log.
ls -lRRecursive. Easy to flood the screen; prefer find for hunting.
pwdPrint Working Directory — where you are before you ls.
file setup.shGuess type from contents (“Bourne-Again shell script”), not from the name.
namei -l /etc/hostnameWalk each path component and show who can traverse it.
readlink -f hostnameResolve a symlink to the real absolute path.
stat -c '%n %i %A %s'One compact line: name, inode, mode, size. Good for scripts.
getfacl / lsattrExtra ACL permissions, or ext attributes like immutable (chattr +i).

A useful first look after login

pwdls -lahls -listat /etc/hostnamefile /etc/hostnamereadlink -f /etc/hostname