Linux command quick reference

Download original file

Use these examples in your own disposable workspace. Replace sample paths only after checking your current directory and the intended target.

Files and directories

Task Command Check
Show current directory pwd Run before using relative paths.
List files ls -lah -a includes hidden files; -h formats sizes.
Change directory cd "$HOME/project" Run pwd after changing location.
Create directories mkdir -p project/{rtl,tb,sim,logs} -p also creates missing parents.
Create an empty file touch rtl/dut.sv Existing file timestamps are updated.
Copy a file cp -i rtl/dut.sv rtl/dut_backup.sv -i asks before overwriting.
Move or rename mv -i old.sv rtl/dut.sv Verify source and destination order.
Remove a file rm -i unwanted.txt Resolve and list the target first.
Identify system cat /etc/os-release; uname -r Record release and kernel separately.
Find command type tool; command -v tool A missing command returns nonzero.
Inspect path pwd; realpath path; stat path; file path Resolve symlinks before acting.
Find files find . -type f -print Limit the starting tree.

Logs, processes, and engineering evidence

Task Command Check
Read logs less run.log; tail -n 30 run.log Preserve the original log.
Search text grep -E 'ERROR|FAIL' run.log No match returns status 1.
Count records wc -l run.log; sort names.txt | uniq -c uniq groups adjacent lines only.
Separate errors tool >out.log 2>err.log > overwrites its target.
Inspect identity id; groups; stat -c '%a %U %G' file File and directory permissions differ.
Inspect process ps -p PID -o pid,ppid,stat,cmd; pgrep -a name Confirm owner and PID before signals.
Inspect capacity df -h path; du -sh directory; free -h Quotas may impose a separate limit.
Inspect package rpm -qf /usr/bin/tool; dnf info package Check repository and signature provenance.
Read service state systemctl status unit --no-pager; journalctl -u unit -n 30 Do not restart a shared service.
Inspect network ip address; ip route; ss -ltn Do not publish private addresses in reports.
Edit source in a terminal vim rtl/dut.sv or nano rtl/dut.sv Save deliberately and review changes with diff or version control.
Verify artifact sha256sum archive.tgz; tar -tzf archive.tgz Inspect member paths before extraction.

Exit status is available as $? immediately after a command. Quoting "$path" prevents spaces and wildcard characters in a filename from changing the arguments passed to a command. sudo is not required for the Linux practice tasks.