$ command-helper

Linux: files and permissions

Navigating, copying and finding files, disk usage, permissions and ownership.

Requires Google sign-in

Navigating and viewing

List files with details and hidden files
ls -lah
List files sorted by modification time
ls -lt
Directory tree (2 levels)
tree -L 2
Show the end of a file and follow it
tail -f <file>
Show the last 100 lines
tail -n 100 <file>
Page through a file
less <file>

Inside less: / to search, n for next match, G to jump to the end, q to quit.

Copying, moving and deleting

Copy a directory recursively
cp -r <source> <destination>
Copy preserving permissions and timestamps
cp -a <source> <destination>
Move or rename
mv <source> <destination>
Create nested directories
mkdir -p <path>
Delete a directory with its contents
rm -rf <path>

There is no trash bin — double-check the path.

Create a symbolic link
ln -s <target> <link_name>

Finding files

Find files by name
find <path> -name '*.log'
Find files larger than 100 MB
find <path> -type f -size +100M
Find files modified in the last 24 hours
find <path> -type f -mtime -1
Delete files older than 7 daysadvanced
find <path> -type f -name '*.log' -mtime +7 -delete

Run it without -delete first to see what will be removed.

Disk space

Free space on mounted filesystems
df -h
Size of a directory
du -sh <path>
Biggest items in a directory
du -sh <path>/* | sort -rh | head -20
Free inodesadvanced
df -i

A disk can be “full” with free space left if it runs out of inodes (many tiny files).

Permissions and ownership

Make a script executable
chmod +x <file>
Set permissions numerically (rw-r--r--)
chmod 644 <file>
Change owner recursively
chown -R <user>:<group> <path>
Show numeric permissions of a fileadvanced
stat -c '%a %U:%G %n' <file>

On macOS: stat -f '%Lp %Su:%Sg %N' <file>