Shell Utills and not only

Arch

➕Package install

sudo pacman -S package_name

✔️ System update

sudo pacman -Syu

✖️ Package Remove

sudo pacman -R package_name

✖️ Package Remove Without dependencies

sudo pacman -Rdd package_name

📋 List installed packages sorted by size

pacman -Qi | awk -F: '$1~/^Name / { name=$2 } $1~/^Installed Size / { gsub(/ /, ""); size=$2; print size, name }' | sort -hr | column -t | less 

Debian

➕Package install

sudo apt install app_name

✖️ App remove

sudo apt remove app_name

✔️ System update

sudo apt update && sudo apt upgrade -y

Redhat

➕Package install

sudo dnf install app_name

✖️ Package remove

sudo dnf remove app_name

✔️ System update

sudo dnf upgrade --refresh

App .rpmfiles install, remove

sudo rpm -i/r app_name.rpm

Arch and not only utils

‼️ Annotation

Remember abut man command and --help flag to read how to use commands

man ls
ls --help

💽 HDD poweroff

udisksctl power-off -b /dev/sdx

🌐 Network manager cli, wifi connect

nmcli device wifi connect “SSID” password "xxxxx"

📁 Copy, move, remove files or folders

cp, mv, rm filename, rm -r foldername

🖊️ Changename

mv filename newfilename

📋 Ip adress check

ip a

💿 Create qcow2 image

qemu-img create -f qcow2 disk1.img 10G

📱 Mount android phone as storage (download android-file-tranfer)

aft-mtp-mount /mnt

💿 Mount iso file as compact disc

mount -o loop /path/to/image.iso /media/mountpoint

🗝️ Show windows product key

sudo strings /sys/firmware/acpi/tables/MSDM

🏁 Show startup times by system.d

systemd-analyze

🔓 tar.zst extract

tar -I zstd -xf

🔑 Password secured zip

zip -er outputfolder.zip Folder-to-zip/

📁 Show folder/file size

du -sh foldername

📀 Make bootable Linux drive ( dont use partition )

dd bs=4M if=path/to/input.iso of=/dev/sdX conv=fdatasync status=progress

📀 Make bootable windows by woeusb, also gui available

sudo woeusb -v --device /windows/iso/path /dev/sdx

❌Format partition to FAT32 file system.

mkfs.fat -F 32 /dev/sdXY

❌Format partition to exFAT file system. I recommend exfat file system for disk used between different operating systems.

mkfs.exfat /dev/sdXY

❌Format partition to NTFS file system (add -f flag to fast format).

mkfs.ntfs /dev/sdXY

❌Format partition to ext4 file system.

mkfs.ext4 /dev/sdXY		  

🧠 Display free and used memory.

free -m

Create file with certain size.

head -c "" /dev/zero > 
	example:
	head -c 10MB /dev/zero > file10mb

📖 Display systemd last boot journal.

journalctl -b

💿 Create iso from cd/dvd

Check sector size and sector.

isosize -x /dev/sr0

Create iso

dd if=/dev/sr0 of=discmage.iso bs=sector_size count=sector_count status=progress

🔗 Create symbolic link

ln -s /path/to/folder /path/to/place/symbolic/link

📂 Display path of current directory

pwd

✖️ ❕"Hardreset" format drives to zero

dd if=/dev/zero of=/dev/sdX bs=16M status=progress

📱 Mount iPhone

Download ifuse from AUR to be able to mount iPhone, also should work for iPads

  1. Start usbmuxd.service
  2. systemctl start usbmuxd.service
    
  3. Pair iPhone (Device must be unlocked)
  4. idevicepair pair
    

    You will need to confirm access on iPhone

  5. Mount iPhone
  6. ifuse -o allow_other /mountpoint
    

    Probably you have to change config in /etc/fuse.conf and uncomment #user_allow_other

  7. Umount iPhone
  8. fusermount -u /mountpoint 
    

🎧 Bluetooth audio device

Needed packages pulseaudio-bluetooth and bluez-utils.

  1. Start bluetooth service
  2. systemctl start bluetooth.service
    
  3. Open bluetooth utility
  4. bluetoothctl
    

    Bluetooth utility:

    [bluetooth]# power on
    [bluetooth]# agent on
    [bluetooth]# default-agent
  5. Scan for devices
  6. [bluetooth]# scan on
    
  7. Pair device
  8. [bluetooth]# pair XX:XX:XX:XX:XX (MAC)
    
  9. Connect to paired device
  10. [bluetooth]# connect XX:XX:XX:XX:XX
    
  11. For automatically connect
  12. [bluetooth]# trust XX:XX:XX:XX:XX
    [bluetooth]# scan off
    [bluetooth]# exit

To switch PulseAudio switch on connected module you need to add this line to /etc/pulse/default.pa

load-module module-switch-on-connect

Also if you want, enable auto power on bluetooth edit /etc/bluetooth/main.conf

AutoEnable=true

🌐 Share internet over Ethernet

Install dnsmasq and nm-connection-editor

  1. Run nm-connection-editor from terminal.

  2. Add a new ethernet connection.

  3. Give it some sensible name. For example "Shared Internet".

  4. Go to "IPv4 Settings".

  5. For "Method:" select "Shared to other computers".

  6. Save

  7. And thats all folks.

🌐 Share internet over Wi-Fi

Install dnsmasq and nm-connection-editor

  1. Create new wireless network

  2. Create password

  3. Choose either Hotspot or Ad-hoc as Wi-Fi mode

🧡 Git

New

git init
git add
git commit -m "commit message"
git remote add origin git@github.com:username/new_repo.git
git push origin master

Exist repo

git add .
git commit -m "commit message"
git push origin master 

Rename last no pushed commit

git commit --amend -m "commit message"

Rename last pushed commit

git commit --amend -m "commit message"
git push --force origin master

Manipulate the UEFI Boot Manager

List EFI bootorders

efibootmgr

Remove EFI bootorder

efibootmgr -b XXXX -B

Set EFI bootorder

efibootmgr -o XXXX