Skip to content

Instantly share code, notes, and snippets.

@jdomingu19
Last active May 7, 2026 00:33
Show Gist options
  • Select an option

  • Save jdomingu19/7cff73494558e441c5f2e45667aa5595 to your computer and use it in GitHub Desktop.

Select an option

Save jdomingu19/7cff73494558e441c5f2e45667aa5595 to your computer and use it in GitHub Desktop.

Useful BASH Commands

A curated list of bash commands, organized from beginner to advanced. Each command includes a short explanation and a ready‑to‑copy snippet.

header_hello_bash

Basic Commands

These are the fundamental commands every developer should know. They cover file and directory management, navigation, and basic inspection.

1. Create a directory: Make a new folder.

mkdir <directory-name>

2. Change directory: Move into a folder.

cd <directory-name>

3. List files: Show contents of the current directory.

ls
> ```

4. Show current path: Display the working directory.

pwd

5. Create a file: Generate an empty file.

touch <file-name>

6. Copy a file: Duplicate a file to another location.

cp <source> <destination>

7. Move or rename a file: Relocate or rename files.

mv <source> <destination>

8. Remove a file: Delete a file permanently.

rm <file-name>

9. Remove a directory: Delete a folder and its contents.

rm -r <directory-name>

10. View file contents: Print the file to the terminal.

cat <file-name>

Intermediate Commands

These commands help you inspect, measure, and manipulate files and processes more effectively.

11. Disk usage of a folder: Show folder size.

du -sh <directory-name>

12. Disk usage of a file: Show file size.

du -sh <file-name>

13. Find files by name: Search recursively.

find . -name "<pattern>"

14. Count lines in a file: Useful for scripts or logs.

wc -l <file-name>

15. Search text in files: Find occurrences of a string.

grep "<text>" <file-name>

16. Copy directory recursively: Duplicate entire folders.

cp -r <source-directory> <destination-directory>

17. Show hidden files: Include dotfiles in listing.

ls -a

18. Show running processes: Inspect active tasks.

ps aux

19. Kill a process: Terminate by PID.

kill <pid>

20. Monitor system activity: Real‑time process viewer.

top

Advanced Commands

These commands provide powerful ways to automate, analyze, and manage your system.

21. Archive files: Create a .tar archive.

tar -cvf archive.tar <files>

22. Extract archive: Unpack .tar files.

tar -xvf archive.tar

23. Compress with gzip: Reduce file size.

gzip <file-name>

24. Decompress gzip: Restore compressed files.

gunzip <file-name>.gz

25. Redirect output: Save command output to a file.

command > output.txt

26. Append output: Add results to an existing file.

command >> output.txt

27. Pipe commands: Chain multiple commands together.

command1 | command2

28. Find large files: Sort by size.

du -ah . | sort -rh | head -n 10

29. Check network connections: Inspect open ports.

netstat -tuln

30. Schedule tasks: Run commands at intervals.

crontab -e

Built with '\u{2665}' (♥) by Jesús Domínguez @jdomingu19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment