Terminal
Basic Navigation
| Command | Description |
|---|---|
| cd | Change directory. |
cd .. Go up one directory. | |
| ls | List files and directories in the current directory. |
ls -l List files in long format. | |
ls -a List all files, including hidden files. | |
| pwd | Print the working directory. |
Basic Actions
| Command | Description |
|---|---|
| mkdir | Create a new directory. |
mkdir new_directory | |
| rmdir | Remove an empty directory. |
| rm | Remove a file. |
rmdir empty_directory | |
| rm | Remove a file. |
| rm file.txt | |
rm -r directory Remove a directory recursively (including its contents). | |
| touch | Create a new empty file. |
touch new_file.txt |
File and Directory
| Command | Description |
|---|---|
| cp | Copy a file or directory. |
cp file.txt new_file.txt | |
cp -r directory new_directory | |
| mv | Move a file or directory. |
mv file.txt new_location | |
mv -r directory new_location | |
| ln | Create a symbolic link. |
ln -s file.txt link_to_file |
Text
| Command | Description |
|---|---|
| cat | Concatenate and print files. |
cat file.txt | |
| head | Print the first few lines of a file. |
head -n 5 file.txt | |
| tail | Print the last few lines of a file. |
tail -n 5 file.txt | |
| grep | Search for text patterns within files. |
grep "pattern" file.txt | |
| grep | Search for text patterns within files. |
grep "pattern" file.txt |
Process Management
| Command | Description |
|---|---|
| ps | List running processes. |
ps -ax (list all processes) | |
| top | Display system activity in real-time. |
| kill | Kill a process. |
kill 1234 (kill process with PID 1234) | |
| killall | Kill all processes with a given name. |
killall firefox | |
| nice | Set the priority of a process. |
nice -n 10 command (run command with lower priority) |
Networking
| Command | Description |
|---|---|
| ifconfig | Configure network interfaces. |
| netcat | Versatile network utility. |
| traceroute | Trace the route packets take to reach a destination. |
| dig | DNS lookup tool. |
System Information
| Command | Description |
|---|---|
| sysctl | View and modify system parameters. |
| vm_stat | Display virtual memory statistics. |
| diskutil | Manage disk drives. |
| system_profiler | Gather detailed system information. |
Security
| Command | Description |
|---|---|
| firewall | Configure the firewall. |
| sudo | Execute commands with superuser privileges. |
| passwd | Change passwords. |
| ssh | Secure Shell for remote login. |
Miscellaneous
| Command | Description |
|---|---|
| brew | Package manager for macOS. |
| curl | Transfer data using various protocols. |
| wget | Download files from the internet. |