- by x32x01 ||
If you’re learning penetration testing, ethical hacking, or cybersecurity, installing Metasploit Framework on Linux is a must
Open the Terminal and Install Metasploit
First, open your Linux terminal.Then run the following command to download and install Metasploit directly from the official Rapid7 repository:
Code:
curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && chmod 755 msfinstall && ./msfinstall
Start Metasploit Console (msfconsole)
After installation finishes, start Metasploit by typing: msfconsoleWhen prompted to set up a new database, type y or yes.
This step is important because many Metasploit features rely on a database
Initial Database Setup Explained
If everything works correctly, you’ll see messages like: Code:
Creating database at ~/.msf4/db
Starting Postgresql
Creating database users
Creating initial database schema
** Metasploit Framework Initial Setup Complete **
[*] Starting the Metasploit Framework console...
[*] The initial module cache will be built in the background (2–5 minutes) This means Metasploit is ready to use.
Verify Database Connection
To make sure Metasploit is connected to the database, run: db_statusIf successful, you’ll see:
postgresql connected to msf
Managing the Metasploit Database
If you skipped database creation during the first launch, no worries.You can manage everything using the msfdb command.
Initialize the Database
Code:
msfdb init Useful Database Management Commands
Code:
msfdb reinit # Delete and recreate the database
msfdb delete # Remove the database completely
msfdb start # Start the database service
msfdb stop # Stop the database service
msfdb status # Check database status
Why the Database Matters in Metasploit
The database allows Metasploit to:- Store discovered hosts
- Track open ports and services
- Save vulnerabilities
- Manage exploit sessions
Final Tips for Beginners
- Always run Metasploit as a normal user, not root unless needed
- Keep Metasploit updated
- Use it only in legal and authorized environments
Last edited: