Basic Commands
1. pwd (Print Working Directory):
Description: This command displays the current directory you are in.
2. ls (List):
Description: Use `ls` to view files and directories in the current directory.
3. cd (Change Directory):
Description: Navigate through directories using `cd`.
4. touch:
Description: Create empty files by using the `touch` command.
5. cp (Copy):
Description: Duplicate files using the `cp` command.
6. mv (Move):
Description: Relocate files with the `mv` command. This command is also used for renaming files.
7. rm (Remove):
Description: Delete files permanently using the `rm` command. Exercise caution with this command.
File Operations
Files are at the heart of any system. Here are some useful commands for handling files:
8. nano:
Description: A simple text editor to create and edit files.
9. cat:
Description: Concatenate and display the content of a file.
10. grep:
11. head:
Description: Display the beginning of a file.
This is the first line.
This is the second line.
12. tail:
Description: Display the end of a file.
This is the ninth line.
This is the tenth line.
Directory Management
Managing directories is crucial during ethical hacking. Here’s how:
13. mkdir (Make Directory):
Description: Create a new directory using the `mkdir` command.
14. rmdir (Remove Directory):
Description: Delete an empty directory using the `rmdir` command.
15. rm -r (Remove Recursive):
Description: Remove a directory with all its contents using the `rm -r` command.
File Permissions
Understanding and managing file permissions are essential for ethical hacking. Here are some commands to help you with that:
16. chmod (Change File Permissions):
Description: Change file permissions (read, write, execute) for users.
17. chown (Change File Ownership):
Description: Change file ownership.
Process Management
In ethical hacking, understanding, and controlling processes are essential. Here’s how:
18. ps (Process Status):
Description: View information about active processes.
345 pts/0 00:00:00 bash
912 pts/0 00:00:00 ps
19. top:
Description: Monitor real-time system processes.
20. kill:
Description: Terminate a process by identifying its PID (Process ID).
Networking
Discovering network information is vital in penetration testing. Let’s explore some relevant commands:
21. ifconfig:
Description: Obtain network interface configuration details.
eth0
flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.100 netmask 255.255.255.0 broadcast 192.168.0.255
22. ping:
Description: Check connectivity to a target host by pinging it.
23. nmap:
Description: Perform network exploration and security auditing.
24. netstat:
Description: Show network statistics.
Archiving and Compression
Archiving and compression are useful for managing files efficiently. Here are some commands to help with that:
25. tar:
Description: Create or extract tar archives.
26. gzip:
Description: Compress files.
27. gunzip:
Description: Decompress gzip files.
28. zip and unzip:
Description: Create or extract zip archives.
zip archive.zip file1.txt file2.txt
unzip archive.zip
System Information
Knowing the system’s details is crucial for understanding its capabilities. Here are some commands for that:
29. uname:
Description: Display system information.
uname -a
Linux myhostname 4.15.0-65-generic #74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
30. df:
Description: Show disk space usage.
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 100G 30G 70G 30% /
31. free:
Description: Display memory usage.
free -h
total used free shared buff/cache available
Mem: 7.8G 2.3G 3.1G 207M 2.3G 5.2G
Swap: 2.0G 0B 2.0G
32. who:
Description: Show users currently logged in.
who
user pts/0 Jul 26 15:30 (192.168.0.101)
Advanced Commands for Ethical Hacking
As an ethical hacker, you need powerful tools for network analysis and security assessment. Here are some advanced commands:
33. netcat:
Description: Network utility for reading from and writing to network connections.
34. wireshark:
Description: Analyze network traffic in real-time.
35. tcpdump:
Description: Capture network packets.
36. ssh:
Description: Securely connect to remote systems.
37. scp:
Description: Securely copy files between local and remote systems.
scp file1.txt user@remote_host:/home/user/documents
38. openssl:
Description: Perform cryptographic operations.
openssl
enc -aes256 -salt -in file.txt -out encrypted_file.enc
File Analysis
Files often conceal valuable information. Here are commands to help you analyze files:
39. file:
Description: Determine file type.
file file1.txt
file1.txt: ASCII tex
40. strings:
Description: Extract human-readable strings from binary files.
User and Group Management
Managing users and groups is crucial for controlling access and privileges. Here are some commands to help with that:
41. useradd:
Description: Add a new user.
42. passwd:
Description: Change user password.
43. groupadd:
Description: Add a new group.
44. usermod:
Description: Modify user settings.
45. groupmod:
Description: Modify group settings.