Linux Directories

/ (Root Directory) The top-level directory in the Linux filesystem hierarchy. It contains all other directories and files on the system.
/bin (Binary) Essential command binaries are stored here. Common system commands (like ls, cp, mv) are located in this directory.
/boot Contains the essential files needed for the system to boot, including the kernel, initial ramdisk, and bootloader configuration.
/dev (Device) Device files representing hardware devices or pseudo-devices are located here. Examples include disk drives (/dev/sda), terminals (/dev/tty), etc.
/etc (Etcetera) Configuration files for the system and installed applications are stored here. Important system-wide configuration files are found in this directory.
/home Home directories for regular users are placed here. Each user typically has a subdirectory in /home with their username.
/lib (Library) Essential shared libraries needed for system binaries are stored here. It includes dynamic link libraries required by programs in /bin and /sbin.
/lost+found Typically found at the root level of the filesystem, this directory is used by the fsck (filesystem check) utility to store recovered files after a filesystem check.
/media Mount point for removable media devices, such as USB drives and external hard disks.
/mnt (Mount) Temporary mount points for mounting filesystems, such as external drives. Users can mount devices or remote filesystems here.
/opt (Optional) Optional software packages can be installed in this directory. It provides a place for additional software not installed by the package manager.
/proc (Process) A virtual filesystem that provides information about processes and kernel parameters. It allows access to runtime information about the system and its processes.
/run A tmpfs (temporary filesystem) holding runtime information, primarily used for communication between system processes.
/run/user Holds temporary files and directories for each user running a session.
/sbin (System Binary) Similar to /bin, but it contains binaries used for system administration tasks. These binaries are typically meant for superuser (root) access.
/snap Directory for Snap packages, a packaging system designed to work across various Linux distributions.
/srv (Service) Contains data for services provided by the system, such as websites or FTP servers.
/sys (Sysfs) Another virtual filesystem that exposes information about devices, kernel modules, and kernel parameters. It is used for configuring and interacting with the kernel.
/tmp (Temporary) Temporary files are stored here. The contents of this directory are typically cleared on system reboot.
/usr (User) Secondary hierarchy containing user-readable data files and programs. It is often shared between multiple machines and is meant to be read-only.
/var (Variable) Variable files—those whose content is expected to continually change—are stored here. Examples include log files, spool directories, and temporary files.

System Information

$ man <command> # Manual of the <command> $ <command> -h # Command help ## Update System $ sudo apt update && sudo apt upgrade # Update (Debian/Ubuntu) $ sudo dnf upgrade --refresh # Update (Red Hat/Fedora) ## System and User Information $ pwd # print work directory $ whoami # show user $ date # show date and time $ uname # show info system $ uname -a # show verbose info system $ hostname # hostname system $ hostnamectl # info about the system, including hostname, OS, architecture, hardware, etc $ fastfetch $ htop <or> btop

Files and Directories

## Browsing Files and Directories $ cd directory # change to directory $ cd /etc/directory # change to specific directory $ cd .. # change to parent directory $ ls # list files $ ls -l # list files and permissions $ ls -a # list hidden files $ ll # list all the files, hidden and permissions ## Creating Files and Directories $ touch <file> # create file $ nano file.txt # Read and edit file.txt $ mkdir <folder> # Create directory $ mv <source> <destination> # Move file (or rename file) $ mv first.txt second.txt $ cp <source> <destination> # Copy file (duplicate file) $ cp second.txt third.txt $ rm <file> # Remove file (not directories) $ rm *.pdf # Remove using wildcard $ rm -f <file> # Remove without prompting (force) $ rm -d <dirname> # Remove empty directory $ rm -r <dirname> # Remove non-empty directory $ rmdir <dirname> # Remove empty directory ## Text Editing and Processing nano [file] : Opens a file in the Nano text editor. cat <file> : Displays the contents of a file. less <file> : Displays the paginated content of a file. head <file> : Shows the first few lines of a file. tail <file> : Shows the last few lines of a file. awk ‘{print}’ [file] : Prints every line in a file. ## Searching and Finding $ sudo find -name <file/package> # Find package by name $ sudo find . -name file.php # Find a file by name or extension $ sudo find . -name "*.txt" $ grep <pattern> <file> # Find text in a file

Package Management

## Install and Unistall DEB Packages (Debian/Ubuntu) $ sudo apt install <package> # From repositories $ sudo apt install ./<package.deb> # Local deb file $ sudo apt list --installed # List deb packages installed $ sudo find -name <file/package> # Find package by name $ sudo apt purge <package> # Uninstall package and its dependencies $ sudo apt autoremove. # Clean dependencies not used ## Install and Unistall RMP Packages (Red Hat/Fedora) $ sudo dnf install <package> # From repositories $ sudo dnf install ./<package.rpm> # Local rpm file $ sudo dnf remove <package> # Remove <package> $ sudo dnf autoremove # Clean obsolete dependencies ## PACKAGES Package management (APT) sudo apt install <package> : Installs a package. sudo apt install -f –reinstall <package> : Reinstalls a broken package. apt search <package> : Searches for APT packages. apt-cache policy <package> : Lists available package versions. sudo apt update : Updates package lists. sudo apt upgrade : Upgrades all upgradable packages. sudo apt remove <package> : Removes a package. sudo apt purge <package> : Removes a package and all its configuration files. Package management (Snap) snap find <package> : Search for Snap packages. sudo snap install <snap_name> : Installs a Snap package. sudo snap remove <snap_name> : Removes a Snap package. sudo snap refresh : Updates all installed Snap packages. snap list : Lists all installed Snap packages. snap info <snap_name> : Displays information about a Snap package.
## Processes $ ps # View the user current processes $ ps -e | more # View all processes $ top # View CPU, Ram and Resources $ htop System monitoring and management top : Displays real-time system processes. htop : An interactive process viewer (needs installation). df -h : Shows disk usage in a human-readable format. free -m : Displays free and used memory in MB. kill <process id> : Terminates a process. Service management sudo systemctl start <service> : Starts a service. sudo systemctl stop <service> : Stops a service sudo systemctl status <service> : Checks the status of a service. sudo systemctl reload <service> : Reloads a service’s configuration without interrupting its operation. journalctl -f : Follows the journal, showing new log messages in real time. journalctl -u <unit_name> : Displays logs for a specific systemd unit. ## Recover Desktop Ctrl + Alt + F3 sudo systemctl restart gdm # Gnome sudo systemctl restart sddm # KDE ## Power Management (MacBooks) sudo dnf install tlp sudo systemctl enable tlp ## Battery health check upower -i $(upower -e | grep BAT) upower -i /org/freedesktop/UPower/devices/battery_BAT0 ## RPM Fusion dnf repolist rpmfusion-free rpmfusion-nonfree ## Download files $ wget $ curl $ git clone ## Permissions $ chmod <mode> <file> # Change mode file (r=read, w=write, x=execute) $ chmod +x <file> # Add executable permissions to the file $ chmod 0755 helloworld.sh # change the file mode and permissions $ chmod -R 600 <dir> # Change permission to <dir> and its contents $ chown <owner:group> <file> # Change ownership of file File permissions and ownership chmod [who][+/-][permissions] <file> : Changes file permissions. chmod u+x <file> : Makes a file executable by its owner. chown [user]:[group] <file> : Changes file owner and group. ## Users $ sudo adduser <newuser> # add user $ usermod -aG sudo <newuser> # enable sudo access to <newuser> user@server:~$ sudo su # switch to root user root@server:~# # root user enabled root@server:~# su - <user> # switch to <user> $ sudo passwd <user/root> # change password to <user/root> w : Shows which users are logged in. sudo adduser <username> : Creates a new user. sudo deluser <username> : Deletes a user. sudo passwd <username> : Sets or changes the password for a user. su <username> : Switches user. sudo passwd -l <username> : Locks a user account. sudo passwd -u <username> : Unlocks a user password. Sudo change <username> : Sets user password expiration date. Group management id [username] : Displays user and group IDs. groups [username] : Shows the groups a user belongs to. sudo addgroup <groupname> : Creates a new group. sudo delgroup <groupname> : Deletes a group. $ df # Disk Free view file systems and free space $ df -h # View human-readable sizes $ rsync # Sync files between storage devices ## Gzip file.gz $ gzip filename # Compress to filename.gz $ gzip -k filename # Compress to filename.gz (Keeping original too) $ gzip -d file.gz # Unzip file.gz $ gzip -dk file.gz # Unzip file.gz (Keeping compressed file too) $ gunzip file.gz # Unzip file.gz ## Tape Archive tar.gz $ tar --create (-c) # Create a new tar archive. $ tar --extract (-x) # Extract the entire archive or one or more files from an archive. $ tar --list (-t) # Display a list of the files included in the archive $ tar -xf archive.tar.gz # Uncompress archive.tar.gz Archiving and compression tar -czvf <name.tar.gz> [files] : Compresses files into a tar.gz archive. tar -xvf <name.tar.[gz|bz|xz]> [destination] : Extracts a compressed tar archive. ## cURL (Client URL) It enables transferring data from or to a server, using HTTP, HTTPS, FTP, etc. (Postman is a UI for curl) $ curl [options / URL] $ curl https://jsonplaceholder.typicode.com/todos/1 # Quick GET method to URL $ curl -X GET https://jsonplaceholder.typicode.com/todos/1 # (-X == --request) ## Hardware $ lspci # This command displays information about PCI buses and devices connected to them. Internal devices like network adapters, sound cards, and graphic cards are often connected via PCI. $ lsusb # This command lists USB devices connected to the system. Some internal devices may also connect via USB interfaces. $ lsblk # This command lists block devices such as hard drives, SSDs, and partitions. $ lshw # This command provides detailed information about hardware components, including internal devices. $ dmidecode # This command displays information about the system's hardware components as reported by the system BIOS. It can provide details about internal devices such as memory modules, processors, etc. $ hwinfo # This command provides detailed hardware information, including internal devices, in a structured format. $ udevadm # This command can be used to query the udev device manager for information about devices.

Networking

## Networking Commands $ ip address # Formerly "ifconfig" $ sudo apt install net-tools $ ip route # View the IP routing table $ sudo ip address add 192.168.121.241/24 dev eth0 $ ping <host> $ dhclient -r # Release IP address $ dhclient # Get a new IP address ip addr show : Displays network interfaces and IP addresses. ip -s link : Shows network statistics. ss -l : Shows listening sockets. ping <host> : Pings a host and outputs results. Netplan configuration (read more at netplan.io) cat /etc/netplan/*.yaml : Displays the current Netplan configuration. sudo netplan try : Tests a new configuration for a set period of time. sudo netplan apply : Applies the current Netplan configuration. $ nmap -sT <host> ## DNS $ dig # (Domain Information Groper) Lookup info from DNS servers $ cat # Concatenate (Link together in a series) $ dig domain.com # get IP information $ dig domain.com TXT # get DNS TXT record info $ nslookup domain.com # get IP information $ whois domain.com # get domain information

Local Firewall Server

## Security Firewall $ sudo apt install ufw $ sudo ufw enable $ sudo ufw disable $ sudo ufw app list $ sudo ufw status $ sudo ufw status verbose $ sudo ufw status numbered $ sudo ufw delete <number> $ sudo ufw allow 'Nginx Full' $ sudo ufw allow Apache $ sudo ufw delete allow 'Nginx HTTP' $ sudo ufw delete allow Apache $ sudo ufw deny from <ip> $ sudo ufw allow from <ip> to any port 3306 $ sudo ufw deny out <port> # close <port> sudo ufw status : Displays the status of the firewall. sudo ufw enable : Enables the firewall. sudo ufw disable : Disables the firewall. sudo ufw allow <port/service> : Allows traffic on a specific port or service. sudo ufw deny <port/service> : Denies traffic on a specific port or service. sudo ufw delete allow/deny <port/service> : Deletes an existing rule.

chmod command modes

#
Permission
r w x
7
Read, Write, Execute
rwx
6
Read, Write
rw-
5
Read, Execute
r-x
4
Read
r—
3
Write, Execute
-wx
2
Write
-w-
1
Execute
—x
0
-
—-

Gnome Tweaks, Extensions and Flatpak

gsettings set org.gnome.shell.extensions.dash-to-dock show-apps-at-top true gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close' sudo apt install gnome-tweaks sudo apt install flatpak sudo apt install gnome-software-plugin-flatpak # Install packages using ubuntu software flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo # Add Flathub repo (Restart) flatpak install flathub <app-id> flatpak install flathub com.mattjakeman.ExtensionManager dash-to-panel@jderose9.github.com dash-to-dock@micxgx.gmail.com zwallpaper@azwallpaper.gitlab.com blur-my-shell@aunetx kiwimenu@kemma fastfetch htop btop neo -m "SYSTEM OVERRIDE" gradia onlyoffice thunderbird localsend planify

Displaylink Lenovo Driver

## Synaptics APT Repository for Ubuntu https://www.synaptics.com/products/displaylink-graphics/downloads/ubuntu sudo apt install ./Downloads/synaptics-repository-keyring.deb sudo apt update sudo apt install displaylink-driver

Compose Key Multilingual

Desired Character
Sequence (After pressing Compose)
é
' then e
à
` then a
ç
, then c
ñ
~ then n
ô
^ then o
ü
" then u
¿
? then ?
œ
o then e
« »
< then < | > then >