UBUNTU
apt (Advanced Package Tool)
sudo nano /etc/apt/sources.list
apt update - update repos
apt dist-upgrade
apt upgrade - update packages
sudo apt full-upgrade
sudo apt update && sudo apt upgrade
apt autoremove --- to clean up unused packages
sudo apt remove nmap
apt search "keyword"
---------------------------------------------------------------------
Want details about a package before installing?
sudo apt show nmap
Fixing Broken Packages
sudo apt --fix-broken install
------------------------------------------------------
------Pro Tip for Ethical Hackers
Some hacking tools depend on specific versions of libraries.
If a tool fails, check missing deps with:
apt depends <package> # Lists dependencies
apt rdepends <package> # Lists reverse dependencies
-----------------------------------------------------
dpkg (Debian Package Manager) - Installs .deb files manually
does not handle dependencies, update packages
just used for emergency installs
dpkg -i name
--------------------------
FEDORA
dnf ---Dandified YUM
sudo dnf update
-------------------------------
SETTING THE HOSTNAME
hostname
hostname /etc/hostname - where hostname are stored
hostnamectl
sudo hostnamectl set hostname krish
sudo cat /etc/hosts
----------------------------
NAVIGATING THE FILE SYSTEM
1.
/bin – Essential User Binaries
Stores core command-line tools needed for basic system operation (even in emergency
mode).
Examples: ls, cp, mv, bash, cat.
2.
/boot – Boot Loader Files
Contains everything needed to boot the system:
vmlinuz (Linux kernel)
initramfs (temporary root filesystem)
grub/ (bootloader configs).
3.
/dev – Device Files
Hardware as files! Every device (disks, USB, terminals) appears here.
Linux philosophy: "Everything is a file."
Examples:
/dev/null (black hole).
/dev/sda (first hard disk)
/dev/tty1 (terminal)
4.
/etc – Configuration Files
System-wide configs for apps, services, and the OS.
Examples:
/etc/passwd (user accounts)
/etc/fstab (disk mounts)
/etc/apt/sources.list (APT repos).
🔹 Why It Matters:
The "control panel" of Linux.
Ethical hacking relevance:
/etc/shadow (hashed passwords)
/etc/hosts (manual DNS overrides).
6.
/lib & /lib64 – Shared Libraries
🔹 Purpose:
Shared code used by programs in /bin and /sbin.
/lib64 stores 64-bit libraries (on x86_64 systems).
🔹 Why It Matters:
Dependency central! Breaking this can crash the system.
Hacking note: Malicious .so files here can hijack programs.
7
. /media & /mnt – Mount Points
🔹 Purpose:
/media: Auto-mounted removable media (USB, CDs).
/mnt: Manual temporary mounts (e.g., sudo mount /dev/sdb1 /mnt).
🔹 Why It Matters:
Access external storage without altering /.
Forensics: Mount disks here to inspect them.
13. /usr – User Programs
🔹 Purpose:
Secondary hierarchy (most apps install here).
Subdirectories:
/usr/bin (user binaries)
/usr/lib (libraries)
/usr/local (manually compiled software).
🔹 Why It Matters:
The "main software warehouse" of Linux.
14. /var – Variable Data
🔹 Purpose:
Changing data: logs (/var/log), caches, databases.
🔹 Why It Matters:
Logs live here: auth.log, syslog (goldmine for hackers!).
Directory Contains Key Commands/Tools
/bin Core commands ls, cp, bash
/etc Configs passwd, fstab, apt/
/dev Devices sda, tty1, null
/proc Process info cpuinfo, meminfo
/var/log System logs auth.log, syslog
------------------------------------------------------------
ls COMMAND
Flag Meaning Example
ls -l Long format (permissions, owner, size, date) ls -l /home
ls -a Show hidden files (starts with .) ls -a ~
ls -lh Human-readable sizes (KB, MB, GB) ls -lh /var/log
ls -1 One file per line (for scripting) ls -1 /tmp
ls -F Adds trailing symbols (/ for dirs, * for executables) ls -F
22️⃣Sorting & Filtering Files
Flag Meaning Example
ls -t Sort by modification time (newest first) ls -lt
ls -S Sort by file size (largest first) ls -lS
ls -r Reverse order (works with -t, -S) ls -ltr (oldest first)
ls -R Recursive listing (shows subdirectories) ls -R /etc
ls *.txt Filter by extension (all .txt files) ls *.log
ls -d */ list only directories
ls --color solorised output
--------------------------------------------
PERMISSIONS
d rwx rwx rwx
user group other(neither of user and group)
drwxr-xr-x. 1 slowpoison slowpoison 596 Jul 15 17:50 Downloads
no of hardlinks size in bytes Last date
modified
chmod COMMAND
chmod u-rwx filenname
chmod g+rwx
o+rwx
a+rwx for all
chmod o=r-- file.txt sets others to read only
u=4 g=2 o=1
chmod 740 filename
chmod -R 770 filename -- to all files in this directory
chown -R batman:batman dirname
user : group
💡 Pro Tips
✅ Directories need +x to be accessible.
✅ Use umask to set default permissions for new files.
✅ chmod doesn’t work on symlinks (use chmod -h).
✅ For scripts, chmod +x makes them executable
--------------------------------------------------------
find COMMAAND
find [PATH] [OPTIONS] [ACTIONS]
find /home -name "*.txt" # Case-sensitive search
find /home -iname "*.TXT" # Case-insensitive
find /var -type f # Only files
find /var -type d # Only directories
find /var -type l # Only symlinks
find / -size +100M # Files >100MB
find / -size -10k # Files <10KB
find / -size 50M # Files exactly 50MB
+ = Larger than
- = Smaller than
Units: k (KB), M (MB), G (GB).
find / -perm 644 # Files with exact 644 permissions
find / -perm -u=r . # Files readable by owner
find / -perm /o=w # Files writable by others (dangerous!)
- = All bits must match.
/ = Any bit matches.
find / -user root # Files owned by root
find / -group admins # Files owned by group "admins"
find . -name "'*.txt" -type f -exec rm {} + or \;
{} = Placeholder for each found file.
\; = End of command (must be escaped).
----------------------------------------------------------
SYMBOLIC LINKS
A symbolic link is a special file that points to another file or directory (like a
shortcut in Windows). Unlike hard links:
ln -s TARGET LINK_NAME
ln TARGET LINK_NAME --- HARD LINK
--------------------------------------------------------
systemd or systemctl command
cd /usr/lib/systemd/system
systemctl list-unit-files --type=service
--------------------------------------------------------
FORMATTING AND MOUNTING
sudo mkfs.ext4 /dev/sdX1 # Basic ext4
sudo mkfs.ntfs -f /dev/sdX1 # Force NTFS
sudo mkfs.vfat -F32 /dev/sdX1 # FAT32
sudo mkfs.exfat /dev/sda #exfat for large files
-------------------------------------------------------