root@sparrow:~/writeups$ cat guia-comandos-linux.md
// tools
Basic Linux Commands
22 Jul 2026
· 2 min read
A reference for basic Linux commands — navigation, file management, processes, and networking. Meant as a quick lookup, not a step-by-step tutorial, whether you're coming from Windows or just need to recall exact syntax for something.
| Type | Command reference |
| Shell | bash / sh |
Navigation and files
| Action | Command | Description |
|---|
| List folder contents | ls | Lists files and folders in the current directory |
| Detailed listing | ls -l | Shows permissions, owner, size and date |
| Include hidden files | ls -la | Includes hidden files (starting with .) |
| Change directory | cd folder | Enters a folder |
| Go up one level | cd .. | Returns to the parent directory |
| Show current path | pwd | Directory you're in (print working directory) |
| Create a folder | mkdir name | Creates a new folder |
| Create nested folders | mkdir -p path1/path2/path3 | Creates the whole path at once |
| Create an empty file | touch file.txt | Creates an empty file |
| View a file's content | cat file.txt | Shows the full content |
| View with pagination | less file.txt | Browse content page by page |
| Copy a file/folder | cp source dest / cp -r source dest | -r to copy whole folders |
| Move or rename | mv source dest | Moves or renames files/folders |
| Delete a file/folder | rm file / rm -r folder | -r for non-empty folders |
Permissions and users
| Action | Command | Description |
|---|
| Admin privileges | sudo command | Runs a specific command as root |
| Persistent root session | sudo su | Stays root so you don't repeat sudo |
| View current user | whoami | Who you are |
| View logged-in users | who | List of active sessions |
| Change password | passwd | Changes the current user's password |
| View system users | cat /etc/passwd | Lists all local accounts |
Search and filtering
| Action | Command | Description |
|---|
| Search text in a file | grep "word" file.txt | Finds text matches |
| Find files by name | find /path -name "file.txt" | Searches by name in a path |
| Count lines/words/bytes | wc file.txt | Quick file statistics |
| Count matches | curl -s https://site.com \| grep -o "word" \| wc -l | Typical combo to count how many times a term appears |
Processes, network and system
| Action | Command | Description |
|---|
| View active processes | ps aux | Lists every process on the system |
| Find a process | ps aux \| grep name | Filters the process list |
| Kill a process | kill PID | Stops a process by its ID |
| View the machine's IP | ip a / ifconfig | Interfaces and IP addresses |
| Test connectivity | ping google.com | Checks network connectivity |
| Disk space | df -h | Free/used space in human-readable form |
| Memory usage | free -h | Used and free RAM |
Redirection and chaining
| Action | Command | Description |
|---|
| Save output to a file | command > output.txt | Overwrites the file |
| Append to a file | command >> output.txt | Doesn't overwrite, appends |
| Chain commands | command1 && command2 | Runs the second only if the first succeeded |
Bash scripts
#!/bin/bash
First line ("shebang") so the file is recognised as a bash script. Run it with:
chmod +x script.sh
./script.sh