Basic Linux Commands: Difference between revisions
Jump to navigation
Jump to search
Created page with "= Linux Commands = '''Linux command-line tools''' are the building blocks of interaction, enumeration, file manipulation, and system control during any hacking operation. This page breaks down commonly used Linux commands, their usage, categories, and real-world hacking relevance. == <span id="basics"></span>Essential Commands == === Navigation === {| class="wikitable" ! Command !! Description !! Example |- | <code>pwd</code> || Show current working directory || <code..." |
No edit summary |
||
Line 1: | Line 1: | ||
= Linux Commands = | = Linux Commands = | ||
'''Linux | '''Linux command‑line tools''' are the backbone of reconnaissance, exploitation, and post‑exploitation on Unix‑like systems. This page mirrors the *Nmap* layout so each command in the tables links to a live example, and every example links back to the command list for quick navigation. | ||
== <span id=" | == <span id="commands"></span>Common Commands == | ||
=== | === Navigation & File Management === | ||
{| class="wikitable" | {| class="wikitable" | ||
! Command !! Description | ! Command !! Description | ||
|- | |- | ||
| <code>pwd</code> || | | [[#ex-pwd|<code>pwd</code>]] || Print working directory | ||
|- | |- | ||
| <code>cd</code> || Change directory | | [[#ex-cd|<code>cd</code>]] || Change directory | ||
|- | |- | ||
| <code> | | [[#ex-ls|<code>ls</code>]] || List directory contents | ||
|- | |- | ||
| <code>rmdir</code> || Remove empty directory || <code> | | [[#ex-mkdir|<code>mkdir</code>]] || Create directory | ||
|- | |||
| [[#ex-rmdir|<code>rmdir</code>]] || Remove empty directory | |||
|- | |||
| [[#ex-cp|<code>cp</code>]] || Copy files or directories | |||
|- | |||
| [[#ex-mv|<code>mv</code>]] || Move or rename files/directories | |||
|- | |||
| [[#ex-rm|<code>rm</code>]] || Delete files or directories | |||
|} | |} | ||
=== | === Viewing & Text Processing === | ||
{| class="wikitable" | {| class="wikitable" | ||
! Command !! Description | ! Command !! Description | ||
|- | |||
| [[#ex-cat|<code>cat</code>]] || Concatenate & display files | |||
|- | |- | ||
| <code> | | [[#ex-less|<code>less</code>]] || Paginate large files | ||
|- | |- | ||
| <code> | | [[#ex-head|<code>head</code>]] || Show first lines of a file | ||
|- | |- | ||
| <code> | | [[#ex-tail|<code>tail</code>]] || Show last lines / follow file | ||
|- | |- | ||
| <code> | | [[#ex-grep|<code>grep</code>]] || Search for patterns | ||
|} | |||
=== System & User Info === | |||
{| class="wikitable" | |||
! Command !! Description | |||
|- | |- | ||
| <code> | | [[#ex-whoami|<code>whoami</code>]] || Show current user | ||
|- | |- | ||
| <code> | | [[#ex-id|<code>id</code>]] || Display user/group IDs | ||
|- | |- | ||
| <code> | | [[#ex-df|<code>df</code>]] || Disk usage overview | ||
|- | |- | ||
| <code> | | [[#ex-history|<code>history</code>]] || List previously executed commands | ||
|} | |} | ||
=== | === Networking === | ||
{| class="wikitable" | {| class="wikitable" | ||
! Command !! Description | ! Command !! Description | ||
|- | |- | ||
| <code> | | [[#ex-ping|<code>ping</code>]] || Test network connectivity (ICMP) | ||
|- | |- | ||
| <code> | | [[#ex-curl|<code>curl</code>]] || Retrieve data from URLs / APIs | ||
|- | |||
| [[#ex-ssh|<code>ssh</code>]] || Secure remote shell & tunnelling | |||
|} | |} | ||
=== | === Help & Documentation === | ||
{| class="wikitable" | {| class="wikitable" | ||
! Command !! Description | ! Command !! Description | ||
|- | |||
| [[#ex-man|<code>man</code>]] || Read manual pages | |||
|- | |- | ||
| <code> | | [[#ex-echo|<code>echo</code>]] || Display text / variables | ||
|} | |} | ||
=== | == Examples == | ||
=== <span id="ex-pwd"></span>Print Working Directory === | |||
|- | <syntaxhighlight lang="bash"> | ||
| < | pwd | ||
| | </syntaxhighlight> | ||
''[[#commands|↑ Commands]]'' | |||
=== <span id="ex-cd"></span>Change Directory === | |||
<syntaxhighlight lang="bash"> | |||
cd /var/www | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
=== <span id="ex-ls"></span>List All Files (long + hidden) === | |||
<syntaxhighlight lang="bash"> | |||
ls -la | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
=== <span id="ex-mkdir"></span>Create Directory === | |||
<syntaxhighlight lang="bash"> | |||
mkdir backups | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
=== <span id="ex-rmdir"></span>Remove Empty Directory === | |||
<syntaxhighlight lang="bash"> | |||
rmdir backups | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
=== <span id="ex-cp"></span>Copy File === | |||
<syntaxhighlight lang="bash"> | |||
cp secrets.txt /tmp/secrets.bak | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
=== <span id="ex-mv"></span>Move & Rename === | |||
<syntaxhighlight lang="bash"> | |||
mv old.log archive/old.log | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
=== <span id="ex-rm"></span>Force‑Delete Directory === | |||
<syntaxhighlight lang="bash"> | |||
rm -rf /tmp/testdir | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
=== <span id="ex-cat"></span>Show File Contents === | |||
<syntaxhighlight lang="bash"> | |||
cat /etc/passwd | grep ":/bin/bash" | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
=== <span id="ex-less"></span>View Large Log === | |||
<syntaxhighlight lang="bash"> | |||
less /var/log/auth.log | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
=== <span id="ex-head"></span>First 10 Lines === | |||
<syntaxhighlight lang="bash"> | |||
head -n 10 notes.txt | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
== <span id=" | === <span id="ex-tail"></span>Follow File Growth === | ||
<syntaxhighlight lang="bash"> | |||
tail -f /var/log/nginx/access.log | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
=== | === <span id="ex-grep"></span>Search Pattern === | ||
<syntaxhighlight lang="bash"> | |||
grep -R \"passwd\" /etc | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
| | |||
== <span id=" | === <span id="ex-whoami"></span>Current User === | ||
<syntaxhighlight lang="bash"> | |||
whoami | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
=== | === <span id="ex-id"></span>User & Group IDs === | ||
<syntaxhighlight lang="bash"> | |||
id | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
| | |||
== <span id=" | === <span id="ex-df"></span>Human‑Readable Disk Usage === | ||
<syntaxhighlight lang="bash"> | |||
df -h | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
=== | === <span id="ex-history"></span>Show Last 20 Commands === | ||
<syntaxhighlight lang="bash"> | |||
history | tail -n 20 | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
|- | |||
| | |||
== | === <span id="ex-ping"></span>Ping Host 4 Times === | ||
<syntaxhighlight lang="bash"> | |||
ping -c 4 example.com | |||
</syntaxhighlight> | |||
''[[#commands|↑ Commands]]'' | |||
=== <span id="ex- | === <span id="ex-curl"></span>Download Web Page === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
curl -o index.html http://example.com | |||
</syntaxhighlight> | </syntaxhighlight> | ||
''[[#commands|↑ Commands]]'' | |||
=== <span id="ex- | === <span id="ex-ssh"></span>SSH on Custom Port === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
ssh -p 2222 user@target | |||
</syntaxhighlight> | </syntaxhighlight> | ||
''[[#commands|↑ Commands]]'' | |||
=== <span id="ex- | === <span id="ex-man"></span>Read Manual Page === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
man ssh | |||
</syntaxhighlight> | </syntaxhighlight> | ||
''[[#commands|↑ Commands]]'' | |||
=== <span id="ex- | === <span id="ex-echo"></span>Write to File === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
echo \"hacked\" > /tmp/proof.txt | |||
</syntaxhighlight> | </syntaxhighlight> | ||
''[[#commands|↑ Commands]]'' | |||
== | == See Also == | ||
* [[ | * [[Bash Scripting Basics]] | ||
* [[Privilege Escalation]] | |||
* [[Netcat]] |
Revision as of 15:38, 12 May 2025
Linux Commands
Linux command‑line tools are the backbone of reconnaissance, exploitation, and post‑exploitation on Unix‑like systems. This page mirrors the *Nmap* layout so each command in the tables links to a live example, and every example links back to the command list for quick navigation.
Common Commands
Command | Description |
---|---|
pwd |
Print working directory |
cd |
Change directory |
ls |
List directory contents |
mkdir |
Create directory |
rmdir |
Remove empty directory |
cp |
Copy files or directories |
mv |
Move or rename files/directories |
rm |
Delete files or directories |
Viewing & Text Processing
Command | Description |
---|---|
cat |
Concatenate & display files |
less |
Paginate large files |
head |
Show first lines of a file |
tail |
Show last lines / follow file |
grep |
Search for patterns |
System & User Info
Command | Description |
---|---|
whoami |
Show current user |
id |
Display user/group IDs |
df |
Disk usage overview |
history |
List previously executed commands |
Networking
Command | Description |
---|---|
ping |
Test network connectivity (ICMP) |
curl |
Retrieve data from URLs / APIs |
ssh |
Secure remote shell & tunnelling |
Help & Documentation
Command | Description |
---|---|
man |
Read manual pages |
echo |
Display text / variables |
Examples
Print Working Directory
pwd
Change Directory
cd /var/www
ls -la
Create Directory
mkdir backups
Remove Empty Directory
rmdir backups
Copy File
cp secrets.txt /tmp/secrets.bak
Move & Rename
mv old.log archive/old.log
Force‑Delete Directory
rm -rf /tmp/testdir
Show File Contents
cat /etc/passwd | grep ":/bin/bash"
View Large Log
less /var/log/auth.log
First 10 Lines
head -n 10 notes.txt
Follow File Growth
tail -f /var/log/nginx/access.log
Search Pattern
grep -R \"passwd\" /etc
Current User
whoami
User & Group IDs
id
Human‑Readable Disk Usage
df -h
Show Last 20 Commands
history | tail -n 20
Ping Host 4 Times
ping -c 4 example.com
Download Web Page
curl -o index.html http://example.com
SSH on Custom Port
ssh -p 2222 user@target
Read Manual Page
man ssh
Write to File
echo \"hacked\" > /tmp/proof.txt