Linux Basic Commands Reference
This list covers common commands for navigating the filesystem, managing files and directories,
working with text, handling processes, and basic system information.
Filesystem Navigation & Information
1. pwd: Print working directory. Shows the current directory you are in.
2. ls: List directory contents. Displays files and subdirectories.
3. ls -l: Long listing format. Shows detailed information about files and directories (permissions,
owner, size, date).
4. ls -a: List all files, including hidden ones (starting with a dot).
5. ls -lh: Long listing with human-readable sizes (e.g., KB, MB).
6. cd <directory>: Change directory. Navigates to a specified directory.
7. cd ..: Go up one directory level.
8. cd ~: Go to your home directory.
9. cd -: Go to the previously visited directory.
10. tree: List contents of directories in a tree-like format (may need to be installed).
11. du: Disk usage. Shows disk space used by files and directories.
12. du -sh: Summarized, human-readable disk usage for a directory.
13. df: Disk free. Shows free and used disk space on mounted filesystems.
14. df -h: Human-readable disk free information.
File & Directory Management
15. mkdir <directory_name>: Make directory. Creates a new directory.
16. mkdir -p <path/to/new/directory>: Creates parent directories if they don't exist.
17. rmdir <directory_name>: Remove directory (only if empty).
18. touch <file_name>: Create an empty file or update its timestamp.
19. cp <source> <destination>: Copy files or directories.
20. cp -r <source_dir> <destination_dir>: Recursively copy directories and their contents.
21. mv <source> <destination>: Move or rename files/directories.
22. rm <file_name>: Remove (delete) files.
23. rm -r <directory_name>: Recursively remove directories and their contents.
24. rm -f <file_name>: Force remove, ignore non-existent files and never prompt.
25. rm -rf <directory_name>: Forcefully and recursively remove directories (use with extreme
caution!).
26. ln <target> <link_name>: Create a hard link.
27. ln -s <target> <link_name>: Create a symbolic (soft) link.
Viewing & Editing File Content
28. cat <file_name>: Concatenate and display file content.
29. less <file_name>: View file content page by page (can scroll back).
30. more <file_name>: View file content page by page (cannot scroll back easily).
31. head <file_name>: Display the first 10 lines of a file.
32. head -n <number> <file_name>: Display the first 'number' lines of a file.
33. tail <file_name>: Display the last 10 lines of a file.
34. tail -n <number> <file_name>: Display the last 'number' lines of a file.
35. tail -f <file_name>: Follow (monitor) a file for new content (e.g., log files).
36. nano <file_name>: A simple, user-friendly text editor.
37. vi <file_name> / vim <file_name>: A powerful, command-line text editor (Vi Improved).
Searching & Finding
38. grep <pattern> <file_name>: Search for a pattern within files.
39. grep -i <pattern> <file_name>: Case-insensitive search.
40. grep -r <pattern> <directory>: Recursively search for a pattern in files within a directory.
41. find <path> -name <file_name>: Search for files and directories by name.
42. find <path> -type f -name <pattern>: Find files by pattern.
43. find <path> -type d -name <pattern>: Find directories by pattern.
44. which <command>: Shows the full path of a command.
45. whereis <command>: Locates the binary, source, and manual page files for a command.
Process Management
46. ps: Process status. Displays currently running processes.
47. ps aux: Display all running processes in a detailed format.
48. top: Display dynamic real-time view of running processes (like Task Manager).
49. htop: An interactive process viewer (more user-friendly than top, may need installation).
50. kill <PID>: Terminate a process by its Process ID (PID).
51. killall <process_name>: Terminate processes by name.
52. bg: Send a suspended process to the background.
53. fg: Bring a background process to the foreground.
54. jobs: List processes running in the background/foreground.
55. &: Run a command in the background (append to a command).
56. Ctrl+C: Interrupt/terminate the current foreground process.
57. Ctrl+Z: Suspend the current foreground process.
User & Permissions Management
58. whoami: Display your current username.
59. id: Print user and group IDs.
60. passwd: Change your user password.
61. sudo <command>: Execute a command with superuser (root) privileges.
62. su -: Switch to the root user.
63. chmod <permissions> <file>: Change file permissions.
64. chmod +x <file>: Make a file executable.
65. chmod 755 <file>: Set rwx for owner, rx for group and others (common for scripts).
66. chown <user> <file>: Change file owner.
67. chgrp <group> <file>: Change file group.
68. adduser <username>: Add a new user (requires root/sudo).
69. deluser <username>: Delete a user (requires root/sudo).
70. usermod: Modify user account properties.
71. groups: Display the groups a user is a member of.
System Information & Utilities
72. uname -a: Print all system information (kernel name, hostname, version, etc.).
73. hostname: Print or set the system's hostname.
74. date: Display or set the system date and time.
75. cal: Display a calendar.
76. uptime: Show how long the system has been running and load average.
77. history: Display previously executed commands.
78. clear: Clear the terminal screen.
79. echo <text>: Display a line of text.
80. man <command>: Display the manual page for a command.
81. whatis <command>: Display a one-line manual page description.
82. alias <name>='<command>': Create a shortcut for a command.
83. unalias <name>: Remove an alias.
84. gzip <file>: Compress files.
85. gunzip <file.gz>: Decompress gzipped files.
86. tar -cvf <archive.tar> <files>: Create a tar archive.
87. tar -xvf <archive.tar>: Extract files from a tar archive.
88. tar -czvf <archive.tar.gz> <files>: Create a gzipped tar archive.
89. tar -xzvf <archive.tar.gz>: Extract files from a gzipped tar archive.
90. zip <archive.zip> <files>: Create a zip archive.
91. unzip <archive.zip>: Extract files from a zip archive.
92. wget <URL>: Download files from the web.
93. curl <URL>: Transfer data from or to a server.
94. ping <IP_address_or_hostname>: Check network connectivity to a host.
95. ip addr (or ifconfig on older systems): Display network interface information.
96. ssh <user>@<host>: Secure Shell; connect to a remote server.
97. scp <source> <destination>: Secure copy files between hosts.
98. netstat: Display network connections, routing tables, interface statistics.
99. reboot: Restart the system (requires root/sudo).
100. shutdown -h now: Shut down the system immediately (requires root/sudo).