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

Powershell Automation Basics - Part 1

Pentest Notes: PowerShell Automation - Basics Pentest Notes: PowerShell Automation - Basics These notes cover PowerShell automation for penetration testing, focusing on practical applications and techniques. What is PowerShell? A powerful scripting language and command-line shell built on the .NET framework, heavily integrated with Windows. Ideal for system administration and automation, making it a valuable tool for pentesters. Why PowerShell for Pentesting? Native to Windows: Pre-installed on most Windows systems. Object-oriented: Allows for complex data manipulation and interaction with APIs. Access to .NET Framework: Enables interaction with a vast library of classes and functions. Remoting capabilities: Execute commands on remote systems. Bypass security restrictions: Can be used to circumvent some security measures if not properly configured. Basic Syntax Cmdlets: Commands in PowerShell (e.g., Get-Process , Get-Service , Get-ChildItem ). P...

SQLDB Pentest

Pivoting for Red Teamers SQL Database & SQL Injection Pentesting Cheat Sheet SQL databases store crucial application data, and misconfigurations can make them vulnerable to SQL Injection (SQLi) attacks. This guide covers database enumeration, privilege escalation, and SQL injection techniques. Step 1: Identifying SQL Database Type Check the database type by sending payloads in the input fields or URL: ' OR 1=1 -- (MySQL, PostgreSQL, MSSQL) ' UNION SELECT 1,2,3 -- (Check column count) ' AND 1=CONVERT(int,@@version) -- (MSSQL Test) Observe the error messages for database identification. Step 2: Enumerating Database Tables & Columns Use SQL queries to extract database structure. For MySQL: SELECT table_name FROM information_schema.tables WHERE table_schema=DATABASE(); SELECT column_name FROM information_schema.columns WHERE table_name='user...

DAMN BASH

Bash Scripting: From Basic to Advanced Bash Scripting: From Basic to Advanced Bash (Bourne Again SHell) is a powerful command-line interpreter and scripting language commonly used in Linux and macOS environments. This post covers Bash scripting from basic commands to more advanced techniques. I. Basic Commands These commands are the building blocks of Bash scripting: Command Description ls Lists files and directories. cd Changes the current directory. pwd Prints the current working directory. mkdir Creates a new directory. rm Removes files or directories (use with caution!). cp Copies files or directories. mv Moves or renames files or directories. cat Displays file content. echo Prints text to the console. II. Variables Variables store data that can be used in your scripts: name="John Doe" echo "Hello, $name!" age=30 echo $((age + 5)) # Arithmetic operations III. Input/Output Redirection Redirect input an...