Catalog / FreeBSD Command Line Cheatsheet

FreeBSD Command Line Cheatsheet

A quick reference for navigating and managing FreeBSD systems from the command line. Includes essential commands and shortcuts for system administration and general usage.

Basic Commands

System Information

uname -a

Display kernel information (kernel name, hostname, kernel release, version, machine hardware name).

freebsd-version

Show the FreeBSD version running.

dmesg

Display boot-time messages from the kernel. Useful for hardware info.

sysctl hw

Show hardware information.

top

Display and update sorted information about processes.

ps aux

Show all processes running on the system.

File System Navigation

ls

List directory contents.

cd

Change directory.

pwd

Print working directory.

mkdir

Create a new directory.

rmdir

Remove an empty directory.

find . -name <filename>

Find files by name in the current directory.

Package Management

pkg Commands

pkg update

Update the package repository.

pkg upgrade

Upgrade installed packages to the latest versions.

pkg install <package_name>

Install a new package.

pkg remove <package_name>

Remove an installed package.

pkg search <keyword>

Search for packages matching a keyword.

pkg info

List all installed packages.

pkg autoremove

Remove automatically installed packages no longer required.

pkg clean

Clean the package cache.

User and Permissions

User Management

adduser

Add a new user.

rmuser

Remove an existing user.

passwd <username>

Change a user’s password.

su <username>

Switch to another user.

whoami

Display the current user’s username.

groups <username>

Display the groups a user belongs to.

File Permissions

chmod <permissions> <file>

Change file permissions.

chown <user> <file>

Change file owner.

chgrp <group> <file>

Change file group.

ls -l

List files with detailed permissions.

umask

Show or set the file creation mask.

Networking

Network Configuration

ifconfig

Display network interface configuration.

netstat -rn

Display the routing table.

ping <hostname>

Test network connectivity to a host.

traceroute <hostname>

Trace the route packets take to a host.

ssh <user>@<host>

Securely connect to a remote host.

scp <file> <user>@<host>:<destination>

Securely copy files to/from a remote host.

Hostname and DNS

hostname

Display the system’s hostname.

nslookup <hostname>

Query DNS for information about a hostname.

cat /etc/resolv.conf

View DNS resolver configuration.