====== Linux ======
-**[[linux:bash|Bash]]**
-**[[linux:git|Git basics]]**
-**[[linux:eGPU|Razer Core eGPU]]**
-**[[linux:RBS|Razer Blade Stealth in Linux]]**
====== System & Diagnostics ======
===== Logs =====
Common system logs:
/var/log/syslog
View recent entries:
tail -f /var/log/syslog
List recently modified log files:
ls -lt /var/log
**Notes:**
* ''tail -f'' follows logs in real time
* On systemd systems, ''journalctl'' is often preferred
===== System information =====
=== General overview: ===
inxi -F
=== Distribution: ===
lsb_release -d
=== Kernel: ===
uname -snrm
Flags:
*''s'': kernel name
*''n'': network node hostname
*''r'': kernel relase number
*''m'': machine hardware name
=== CPU: ===
lscpu
cat /proc/cpuinfo
=== Memory: ===
free -h
=== Mounted filesystems: ===
df -h
=== Kernel modules: ===
lsmod
=== Bash history: ===
history
----
===== Diagnostics =====
uptime # load average
dmesg -T | tail # recent kernel messages
vmstat 1 # system performance
mpstat -P ALL 1 # CPU usage per core
pidstat # process statistics
free -h # memory usage
====== Storage & Filesystems ======
===== Mounting =====
=== List mounts: ===
findmnt
=== List disks: ===
lsblk
=== Mount: ===
sudo mkdir -p /media/DRIVE
sudo mount /dev/sdX# /media/DRIVE
=== Unmount: ===
sudo umount /media/DRIVE
----
==== Samba ====
Manage service:
sudo systemctl start smbd
sudo systemctl stop smbd
sudo systemctl restart smbd
----
===== Mount/Repair NTFS =====
If an NTFS volume mounts as read-only, it is usually due to an unclean shutdown or filesystem inconsistency.
Attempt repair:
sudo ntfsfix /dev/sdX#
Then remount:
sudo mount -t ntfs3 /dev/sdX# /mnt/ntfs
Create mount point if needed:
sudo mkdir -p /mnt/ntfs
**Notes:**
* ''ntfsfix'' performs basic repairs and clears the "dirty" flag
* Full repair should be done from Windows using ''chkdsk''
* If the issue persists, ensure Windows Fast Startup is disabled
===== Repair FAT32 filesystem errors =====
If a FAT32 filesystem mounts as read-only, it is often due to detected corruption.
Check kernel logs:
dmesg
Typical errors:
FAT-fs (sdb1): error, corrupted directory (invalid entries)
FAT-fs (sdb1): Filesystem has been set read-only
FAT-fs (sdb1): error, invalid access to FAT
Repair the filesystem:
sudo umount /dev/sdX#
sudo fsck.vfat -a -w /dev/sdX#
* ''-a'' automatically repair filesystem
* ''-w'' write changes to disk
Note: Ensure the correct device is targeted before running ''fsck''.
====== File & Data Operations ======
===== Shell toolbox =====
==== File operations ====
=== Mass renaming ===
Uppercase .JPG to lowercase .jpg
for i in *.JPG; do mv "$i" "${i/.JPG/.jpg}"; done
Alternative (rename tool):
rename 's/\.JPG$/.jpg/' *.JPG
----
=== Empty a file ===
: > /path/to/file
----
==== Text processing ====
=== cut ===
Extract part of a string:
date | cut -c17-24
----
==== Archives ====
=== tar ===
# Extract
tar -xvf file.tar
tar -xvzf file.tar.gz
# Create
tar -cvf file.tar /path/folder
tar -cvzf file.tar.gz /path/folder
Flags:
* ''c'' create archive
* ''x'' extract archive
* ''v'' verbose (list files processed)
* ''f'' specify archive file
* ''z'' gzip compression
----
====== User Environment ======
===== PATH =====
PATH is the //environment variable// containing a list of directories searched for executables.
# Print PATH
printenv PATH
echo "$PATH"
# Example resolution
ping 127.0.0.1
PATH=/bin:/sbin:/usr/bin:/usr/sbin
│ │
│ └── /sbin/ping ? found
└── /bin/ping ? not found
# Add a folder to PATH (current session only)
PATH=$PATH:/path/to/app/folder
==== Local installs of binaries and PATH ====
=== Install locations ===
Common locations for manually installed binaries:
/opt/ # bundled applications
/usr/local/bin/ # system-wide manual installs
~/.local/bin/ # user-only installs (recommended)
/home/USER/opt/ # alternative user-only location
[[http://refspecs.linuxfoundation.org/fhs.shtml|FHS Reference]]
=== Add to PATH ===
Add to ''~/.profile'' or ''~/.bashrc'':
export PATH="/path/to/bin:$PATH"
Apply without logout:
source ~/.profile
Note: PATH must point to the **directory**, not the binary itself.
=== Locate a binary ===
type man
# man is /usr/bin/man
----
===== AppImages =====
Run an AppImage:
chmod +x example.AppImage
./example.AppImage
Some support automatic install:
./example.AppImage --install
Manual extraction:
./your.AppImage --appimage-extract
=== Tools ===
* AppImageLauncher → integrates AppImages into the system (recommended)
* AppImage Daemon → older alternative
==== Add application to Cinnamon menu ====
Launch menu editor:
cinnamon-menu-editor
=== Manual method ===
User-level entries:
~/.local/share/applications/
Place or create a ''.desktop'' file in this directory.
Example minimal file:
[Desktop Entry]
Name=My App
Exec=/path/to/executable
Type=Application
Terminal=false
The entry should appear automatically in the menu.
**Note:** Avoid using ''/usr/share/applications/'' unless a system-wide install is required.
----
===== GRUB =====
Config file:
/etc/default/grub
Line for background image:
GRUB_BACKGROUND=/path/to/image.jpg
----
===== Limit CPU usage =====
Using ''cpulimit'':
cpulimit -P /path/to/executable -l 40 -b
----
===== Fonts install =====
System-wide:
sudo cp -r /path/to/fonts /usr/share/fonts/
sudo fc-cache -f -v
User-only:
~/.local/share/fonts/
Then refresh cache:
$ sudo fc-cache -f -v
----
===== PDF manipulation =====
==== Reorder / split / merge ====
CLI:
pdf-stapler cat in.pdf 2-3 out.pdf
GUI (recommended):
* pdfarranger → lightweight, modern, actively maintained
==== Reducing PDF size ====
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
''-dPDFSETTINGS'' presets:
* ''/screen'' low-resolution output, smallest file, lowest quality
* ''/ebook'' medium-resolution output, good size/quality compromise
* ''/printer'' print-oriented output, larger file, higher quality
* ''/prepress'' prepress-oriented output, larger file, higher quality
* ''/default'' general-purpose output, can produce larger files
**Note:** Ghostscript rewrites the PDF.
It often reduces file size, especially with image-heavy PDFs, but this is not guaranteed.
===== Video playback (minimal UI) =====
==== mpv (recommended) ====
Lightweight video player with minimal UI, suitable for clean output on external displays.
Example:
mpv --fs --no-border --ontop --geometry=+3200 --osd-level=0 video.mp4
Common options:
--fs # fullscreen
--no-border # remove window decorations
--ontop # keep window above others
--geometry=+X+Y # window position (multi-display setups)
--osd-level=0 # disable on-screen display
Configuration file:
~/.config/mpv/mpv.conf
----
==== mplayer (legacy) ====
Legacy setup kept for reference.
Configuration files:
*/etc/mplayer/mplayer.conf
*~/.mplayer/config
*~/.mplayer/input.conf
*~/.mplayer/menu.conf
Example options:
fs=yes
noborder=yes
ontop=yes
geometry=+3200
osdlevel=0
====== Specialized & Recovery ======
===== Data recovery =====
Use **TestDisk** / **PhotoRec** as a first recovery tool.
* **TestDisk** attempts partition repair and file undelete when filesystem metadata is still usable.
* **PhotoRec** performs file carving by signature. It can recover files from damaged filesystems, but filenames and folder structure are usually lost.
Do not write recovered files to the source disk.
==== PhotoRec: recovered MOV files ====
For some recovered ''.mov'' files, PhotoRec may split the video into separate ''ftyp'' and ''mdat'' parts.
In PhotoRec ''FileOpts'', enable:
[X] mov/mdat Recover mdat atom as a separate file
Sort recovered files by name, then try concatenating matching parts:
cat f123_ftyp.mov f456_mdat.mov > recovered_1.mov
cat f456_mdat.mov f123_ftyp.mov > recovered_2.mov
One order may produce a usable file.
Sometimes the header/container part may be ''.mp4'' while the media data part is ''.mov'':
cat f54114560.mp4 f51781632_mdat.mov > recovered.mov
Note: This is a recovery attempt, not a guaranteed repair method. For valuable data, stop using the disk immediately and clone/image it before experimenting.
===== Using Apple USB SuperDrive =====
The Apple USB SuperDrive requires a vendor-specific command to activate on non-Apple systems.
=== Required package ===
sudo apt install sg3-utils
=== Identify device ===
Usually appears as ''/dev/sr0'':
lsblk
=== Send activation command ===
sudo sg_raw /dev/sr0 EA 00 00 00 00 00 01
The drive should become usable immediately after.
**Note:** This command must be reissued after reconnecting the drive.
===== QCAD (plugin location) =====
NOTE : MOVE TO BOTTOM 'MISC' SECTION AFTER REWRITE
To locate the QCAD plugin directory:
Go to:
* Help > About > Plugins (Linux / Windows)
* QCAD > About > Plugins (macOS)
Click on any plugin name to reveal its file location.
**Note:** Useful for locating and removing plugins related to trial limitations.
===== Screen recording =====
==== Recommended ====
* **OBS Studio** → full-featured, actively maintained, works for both simple and advanced recording
==== Lightweight alternatives ====
* simplescreenrecorder → lightweight, reliable on X11
* vokoscreenNG → simple GUI, good for quick recordings
==== Notes ====
* Older tools such as Kazam or gtk-recordmydesktop are largely unmaintained and may not work reliably on modern systems
* Wayland sessions may require OBS or desktop-native recording tools
===== Samba =====
==== List available shares ====
smbclient -L //host -U username
* ''host'' → hostname or IP of the server
* prompts for password
----
==== Access a share (temporary mount) ====
sudo mount -t cifs //host/share /mnt/share -o username=user
Create mount point if needed:
sudo mkdir -p /mnt/share
----
==== GUI mounts (file manager) ====
When mounting via a file manager (Nautilus, Nemo, etc.), shares are typically mounted under:
/run/user/UID/gvfs/
----
==== Notes ====
**Notes:**
* ''smbclient -L'' is useful for discovery and debugging access issues
* ''mount -t cifs'' provides a standard way to mount shares in scripts or system configs
* SMB1 is deprecated and may be disabled on modern systems
===== Alias =====
Create an alias:
alias name='command'
Example:
alias ll='ls -lah'
Aliases are active for the current session only.
To make them persistent, add them to:
~/.bashrc
Reload configuration:
source ~/.bashrc
# or
. ~/.bashrc
----
==== Manage aliases ====
List aliases:
alias
Remove an alias:
unalias name
===== Mouse button mapping =====
==== X11 method (xbindkeys) ====
Install tools:
sudo apt install xbindkeys xvkbd
Identify button codes:
xev | grep button
Create configuration:
touch ~/.xbindkeysrc
Example:
# Send Enter on mouse button 8
"xvkbd -text '\r'"
b:8
Start xbindkeys:
xbindkeys
----
**Notes:**
* Works on X11 sessions only
* Wayland sessions generally do not support this method
* ''xvkbd'' simulates keypresses; alternative tools may be preferred depending on use case
==== Package management ====
=== Fix broken packages ===
sudo dpkg --configure -a
sudo apt --fix-broken install
----
===== Additional Ressources =====
***[[https://en.wikipedia.org/wiki/Magic_SysRq_key#Configuration|SysRq Keys]]** -- Best combo is ''Alt + SysRq + R E I S U B''
***[[https://www.guruadvisor.net/en/software-saas/465-advanced-linux-troubleshooting-methods-and-tools-for-diagnostics-and-problem-identification|Advanced Linux Troubleshooting]]**
***[[https://wiki.networksecuritytoolkit.org/nstwiki/index.php?title=HowTo_Create_A_GPT_Disk_With_EFI_System_And_exFAT_Partitions_Using_Parted|Creating GPT/exFAT partitions using CLI]]**