← All articles

LINUX / NETWORKING / DEVOPS TOOLKIT

50 Linux and DevOps commands worth knowing

A quick-reference list grouped by task. Learn what each command shows, adapt placeholders, and check scope before running commands on shared or production systems.

Use with care: Some commands reveal host, user, process, network, or cluster details. Run them only where authorized, avoid sharing sensitive output, and review flags before adding commands that modify state. Placeholders such as <namespace> are not literal values.

1–8. File and filesystem management

#CommandUse
1pwdPrint the current working directory.
2ls -lahList files with hidden entries and human-readable sizes.
3find ./logs -type f -name '*.log'Find matching files within a scoped directory.
4du -sh ./dataSummarize apparent directory usage.
5df -hShow filesystem capacity and available space.
6df -iCheck inode availability when file creation fails.
7stat ./config.yamlInspect file metadata, timestamps, and permissions.
8rsync -avn ./source/ ./backup/Preview a directory sync; -n prevents changes.

9–15. Process and resource management

#CommandUse
9ps auxfInspect processes and parent-child relationships.
10topView live CPU and process activity.
11free -hCheck memory and swap summary.
12uptimeCheck uptime, load averages, and logged-in users.
13vmstat 1 5Sample CPU, memory, and I/O activity for five intervals.
14pgrep -af nginxFind matching processes and their command lines.
15systemctl status nginxInspect one systemd service and recent status details.

16–23. Networking and name resolution

#CommandUse
16ip addrShow network interfaces and assigned addresses.
17ip routeInspect the local routing table.
18ss -tulpnList listening TCP/UDP sockets; process details may need privilege.
19dig example.comQuery DNS records for a public example domain.
20getent hosts service-nameResolve a name using configured system name services.
21curl -I https://example.comRequest response headers from a known endpoint.
22traceroute example.comTrace a route where network policy allows it.
23nc -vz host.example 443Check TCP connectivity to an authorized host and port.

24–30. Logs and diagnostics

#CommandUse
24journalctl -u nginx --since todayRead this service’s journal entries for the current day.
25journalctl -p warning -bShow warning-or-higher journal entries for this boot.
26journalctl --disk-usageInspect journal storage before cleanup.
27tail -n 100 /var/log/syslogRead the last 100 lines from a common system log path.
28grep -i 'error' ./app.logSearch a local log for case-insensitive matches.
29dmesg --level=err,warnInspect recent kernel warning and error messages.
30logrotate --debug /etc/logrotate.confPreview logrotate decisions without performing rotation.

31–36. Identity and security inspection

#CommandUse
31idShow the current user and group IDs.
32groupsList groups for the current user.
33sudo -lReview the current user’s configured sudo permissions.
34namei -l /path/to/fileInspect permissions along a path’s directory components.
35getfacl /path/to/fileInspect file access-control lists where supported.
36sha256sum ./artifact.tarCalculate a file digest for integrity comparison.

37–43. Docker operations

#CommandUse
37docker psList running containers.
38docker ps -aList running and stopped containers.
39docker imagesList local images and their tags.
40docker system dfSummarize Docker storage usage.
41docker inspect <container>Inspect one container’s configuration and state.
42docker logs --tail 100 <container>Read the last 100 lines from a container’s logs.
43docker stats --no-streamTake a one-time resource-usage snapshot.

44–50. Kubernetes operations

#CommandUse
44kubectl config current-contextConfirm the active cluster context before acting.
45kubectl get pods -A -o wideList pods across namespaces with node placement.
46kubectl describe pod <pod> -n <ns>Inspect one pod’s conditions, events, and configuration.
47kubectl logs <pod> -n <ns> --previousRead logs from the previous container instance.
48kubectl get events -n <ns> --sort-by=.lastTimestampReview recent events in one namespace.
49kubectl top pods -n <ns>View current pod resource usage if metrics are available.
50kubectl rollout status deployment/<name> -n <ns>Check status of a specific deployment rollout.

Make commands part of a safe workflow

Commands are most useful when you understand the layer they inspect and the access they require. Check context, scope, and output first. Prefer read-only inspection during initial diagnosis; before any mutating action, confirm the target, owner, expected effect, and recovery path.

Build the troubleshooting habit behind the command.

Continue with the Kubernetes troubleshooting guide, or browse all engineering notes.