This is an old revision of the document!
Sticky Linux notes
This page keeps all Linux related quick commands and shortcuts, as well as useful other information.
Get OS information
Get OS information from /etc/os-release
.
Example: Debian:
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)" NAME="Debian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
Import this to a bash script via:
The var ID
is then debian
:
if [ -f /etc/os-release ]; then . /etc/os-release ID=$ID fi
Or use neofetch
:
neofetch
installed via: apt install neofetch
Sourced from: stackexchange.org
View CPU information
To view information about the CPU use
cat /proc/cpuinfo
Create .img on Linux CLI
It's quite simple to create an image of a disk, for example an SD card, therefore use the following command:
dd if=/path/to/device of=image.img
The /path/to/device
can be found out with:
lsblk
For example it can be /dev/sda
.
Remind that using this method will include also empty parts. An image of a 32 GB SD card will later have a size of 32 GB although for example 16 GB are unused.
Allow users to write to specific directory
To allow any user to read/write a directory adjust permissions with:
chmod -R 0777 /path/to/dir
-R
sets the permissions recursively.
Sourced from superuser.com - Chmod to allow read and write permissions/