Skip to main content

Linux Terminologies

Linux Commands: From Basic to Advanced

Linux Commands: From Basic to Advanced

This post explores essential Linux commands, covering everything from navigating the file system to managing processes and more. It's a journey from basic to advanced usage.

I. Basic File System Navigation

These commands are your bread and butter for navigating the Linux file system:

CommandDescription
lsLists files and directories in the current directory. Use ls -l for detailed information, ls -a to show hidden files, and ls -h for human-readable file sizes.
cdChanges the current directory. cd .. goes up one directory, cd ~ goes to your home directory.
pwdPrints the current working directory.
mkdirCreates a new directory (e.g., mkdir my_directory). Use mkdir -p path/to/new/directory to create parent directories as needed.
rmRemoves files (e.g., rm my_file.txt). Use rm -r directory to remove a directory and its contents (be very careful with this!). rm -rf forces removal without prompting (use with extreme caution).
cpCopies files or directories (e.g., cp file1.txt file2.txt, cp -r directory1 directory2).
mvMoves or renames files or directories (e.g., mv old_file.txt new_file.txt, mv file.txt /path/to/destination/).
catDisplays file content. Use cat file.txt. For large files use less file.txt or more file.txt.
echoPrints text to the console (e.g., echo "Hello, world!").

II. Working with Files

Beyond basic manipulation, these commands offer powerful file management:

CommandDescription
touchCreates an empty file (e.g., touch new_file.txt). Also updates file timestamps.
nano/vim/viText editors for creating and editing files.
headDisplays the first few lines of a file (e.g., head -n 10 file.txt for the first 10 lines).
tailDisplays the last few lines of a file (e.g., tail -f file.txt to follow changes in real-time).
wcCounts words, lines, and bytes in a file (e.g., wc -l file.txt for line count).
grepSearches for patterns in files (e.g., grep "pattern" file.txt, grep -r "pattern" directory for recursive search).
findFinds files based on various criteria (e.g., find . -name "file.txt", find . -type d for directories).

III. User and Permissions Management

These commands are crucial for system security:

CommandDescription
sudoExecutes a command with superuser privileges.
useraddAdds a new user (e.g., sudo useradd -m -s /bin/bash newuser).
passwdChanges a user's password (e.g., sudo passwd newuser).
usermodModifies user accounts (e.g., sudo usermod -aG groupname username to add a user to a group).
userdelDeletes a user (e.g., sudo userdel -r username to remove the user's home directory as well).
chmodChanges file permissions (e.g., chmod 755 file.txt).
chownChanges file ownership (e.g., chown user:group file.txt).

IV. Process Management

Control and monitor running processes:

CommandDescription
psLists running processes (e.g., ps aux for a detailed view).
topDisplays real-time process activity.
killTerminates a process (e.g., kill 1234 to kill process ID 1234). Use kill -9 (SIGKILL) as a last resort.
pkillKills processes by name (e.g., pkill firefox).
bgPuts a process in the background.
fgBrings a background process to the foreground.
jobsLists background jobs.

V. Networking

Commands for network diagnostics and configuration:

CommandDescription
ip a or ifconfigDisplays network interface information.
pingTests network connectivity to a host.
netstat or ssDisplays network connections, routing tables, and interface statistics.
tracerouteTraces the route packets take to a destination.
digDNS lookup utility.
curl or wgetDownloads files from the internet.

VI. System Information

Retrieve information about the system:

CommandDescription
unamePrints system information (e.g., uname -a for all information).
dfDisplays disk space usage.
duEstimates file space usage.
freeDisplays memory usage.
uptimeShows how long the system has been running.
whoShows who is logged on.

This is a starting point. Linux has a vast array of commands. Use the man command (e.g., man ls) to get detailed information about any command.

Comments

Popular posts from this blog

Thread Modelling Cheatsheet: Know Your Weaknesses Before Attackers Do!

Threat Modelling Part - 1 What is Threat Modelling?      Threat modelling is the process of identifying, assessing, and mitigating potential security threats before they happen. It helps teams anticipate how systems can be attacked and build defences proactively , not reactively. Key Concepts Threat: Something (like a hacker or malware) that could exploit a weakness. Vulnerability: A flaw in your system that can be exploited. Risk: The chance that a threat will exploit a vulnerability to cause damage. Analogy : Threat = Burglar Vulnerability = Unlocked door Risk = Getting robbed because the door is open in a bad neighborhood  Threat Modelling Process (High-Level) Define the Scope – What systems/apps are you evaluating? Identify Assets – What needs protection? (e.g. data, services) Identify Threats – Think like an attacker. What could go wrong? Analyze Vulnerabilities – What weaknesses exist? Prioritize Ri...

DNS Pentest - Port 53

Recon Banner Grabbing - Identify DNS Server Versions # Use dig to determine DNS server versions dig version.bind CHAOS TXT @DNS # Alternatively, use nmap script to grab the banner nmap --script dns-nsid <DNS_IP> # Alternatively, use telnet to grab the banner nc -nv -u <DNS_IP> 53 DNS Server Discovery # Using dig dig NS <target-domain> # Using nslookup nslookup -type=NS <target-domain> Enumeration Using DNS enum dnsenum --dnsserver <DNS_IP> --enum -p 0 -s 0 -o subdomains.txt -f <WORDLIST> <DOMAIN> Using dig # Query DNS records dig hackviser.com # Query specific type of DNS records (e.g., A record) dig A hackviser.com # Perform a reverse DNS lookup dig -x <IP_ADDRESS> # Query a specific DNS server dig @<DNS_SERVER_IP> hackviser.com Using nslookup # Perform DNS queries nslookup hackviser.com # Query a specific type of DNS record (e.g., MX record) nslookup -type=MX hackviser.com # Query a specific DNS server nslookup ha...

SMTP (Simple Mail Transfer Protocol) Pentesting - Port 25

 SMTP (Simple Mail Transfer Protocol) is a communication protocol for electronic mail transmission.it is used for sending e-mail. POP3 or IMAP are used for receiving e-mail. Default ports are 25 (SMTP), 465 (SMTPS), 587 (SMTPS)   Connect We can use Telnet to connect to the remote server. Here is a command using Telnet: telnet example.com 25 Enumeration Identifying a SMTP Server You can use Nmap to check if there's an Telnet server on a target host like this: nmap -p25,465,587 -sV -Pn target.com Additional Nmap commands for enumeration nmap --script smtp-brute -p 25,465,587 "target-ip" nmap --script smtp-commands -p 25,465,587 "target-ip" nmap --script smtp-enum-users -p 25,465,587 "target-ip" nmap --script smtp-ntlm-info --script-args smtp-ntlm-info.domain=example.com -p 25,465,587 "target-ip" nmap --script smtp-vuln-cve2011-1764 -p 25,465,587 "target-ip" nmap --script smtp-* -p 25,465,587 "target-ip" Enumer...