linux:start

This is an old revision of the document!


Linux

System & Diagnostics

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

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

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

List mounts:

findmnt

List disks:

lsblk

Mount:

sudo mkdir -p /media/DRIVE
sudo mount /dev/sdX# /media/DRIVE

Unmount:

sudo umount /media/DRIVE

Manage service:

sudo systemctl start smbd
sudo systemctl stop smbd
sudo systemctl restart smbd

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

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

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

cut

Extract part of a string:

date | cut -c17-24

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 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

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

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

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

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.


Config file:

/etc/default/grub

Line for background image:

GRUB_BACKGROUND=/path/to/image.jpg

Using cpulimit:

cpulimit -P /path/to/executable -l 40 -b

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

CLI:

pdf-stapler cat in.pdf 2-3 out.pdf

GUI (recommended):

  • pdfarranger → lightweight, modern, actively maintained
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.

Specialized & 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.

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.

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

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

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.

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.

  • OBS Studio → full-featured, actively maintained, works for both simple and advanced recording
  • simplescreenrecorder → lightweight, reliable on X11
  • vokoscreenNG → simple GUI, good for quick recordings
  • 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
smbclient -L //host -U username
  • host → hostname or IP of the server
  • prompts for password

sudo mount -t cifs //host/share /mnt/share -o username=user

Create mount point if needed:

sudo mkdir -p /mnt/share

When mounting via a file manager (Nautilus, Nemo, etc.), shares are typically mounted under:

/run/user/UID/gvfs/

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

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

List aliases:

alias

Remove an alias:

unalias name

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

Fix broken packages

sudo dpkg --configure -a
sudo apt --fix-broken install

  • linux/start.1777234613.txt.gz
  • Last modified: 2026/04/26 22:16
  • by mh