Skip to main content

Terminal

Basic Navigation

CommandDescription
cdChange directory.
cd .. Go up one directory.
lsList files and directories in the current directory.
ls -l List files in long format.
ls -a List all files, including hidden files.
pwdPrint the working directory.

Basic Actions

CommandDescription
mkdirCreate a new directory.
mkdir new_directory
rmdirRemove an empty directory.
rmRemove a file.
rmdir empty_directory
rmRemove a file.
rm file.txt
rm -r directory Remove a directory recursively (including its contents).
touchCreate a new empty file.
touch new_file.txt

File and Directory

CommandDescription
cpCopy a file or directory.
cp file.txt new_file.txt
cp -r directory new_directory
mvMove a file or directory.
mv file.txt new_location
mv -r directory new_location
lnCreate a symbolic link.
ln -s file.txt link_to_file

Text

CommandDescription
catConcatenate and print files.
cat file.txt
headPrint the first few lines of a file.
head -n 5 file.txt
tailPrint the last few lines of a file.
tail -n 5 file.txt
grepSearch for text patterns within files.
grep "pattern" file.txt
grepSearch for text patterns within files.
grep "pattern" file.txt

Process Management

CommandDescription
psList running processes.
ps -ax (list all processes)
topDisplay system activity in real-time.
killKill a process.
kill 1234 (kill process with PID 1234)
killallKill all processes with a given name.
killall firefox
niceSet the priority of a process.
nice -n 10 command (run command with lower priority)

Networking

CommandDescription
ifconfigConfigure network interfaces.
netcatVersatile network utility.
tracerouteTrace the route packets take to reach a destination.
digDNS lookup tool.

System Information

CommandDescription
sysctlView and modify system parameters.
vm_statDisplay virtual memory statistics.
diskutilManage disk drives.
system_profilerGather detailed system information.

Security

CommandDescription
firewallConfigure the firewall.
sudoExecute commands with superuser privileges.
passwdChange passwords.
sshSecure Shell for remote login.

Miscellaneous

CommandDescription
brewPackage manager for macOS.
curlTransfer data using various protocols.
wgetDownload files from the internet.