Skip to content

Instantly share code, notes, and snippets.

@Baronhez
Forked from ArturLinnik/Arch.md
Last active July 29, 2022 02:58
Show Gist options
  • Save Baronhez/05e5046f34e6f793b824225ea72f1cb5 to your computer and use it in GitHub Desktop.
Save Baronhez/05e5046f34e6f793b824225ea72f1cb5 to your computer and use it in GitHub Desktop.
Arch linux useful commands.
SEE OPEN PORTS

netstat -tulpen

SCREENSHOT

import -window root screenshot.jpg https://wiki.archlinux.org/index.php/Screen_capture_(Espa%C3%B1ol)

XHOST ISSUE

https://unix.stackexchange.com/questions/209746/how-to-resolve-no-protocol-specified-for-su-user

POLYBAR INSTALLATION

https://github.com/polybar/polybar/wiki

WM POST ARCH INSTALLATION (i3)

https://www.youtube.com/watch?v=nSHOb8YU9Gw

USEFUL COMMANDS TO CONFIGURE NTCTL

https://bbs.archlinux.org/viewtopic.php?id=165549

PYWAL (sudo)

https://www.youtube.com/watch?v=Es79N_9BblE

DELETE PACMAN LOCK FILE

sudo rm /var/lib/pacman/db.lck

CHENGE PERMISSIONS OF A FILE OR A DIRECTORY

sudo chown <user>:<user> <direcotory or file>

GET UUID

sudo blkid

SEE SYSTEM CONTROL LOG

dmesg

SEE LOG INFO

w or who

SHOW USERS

users

SHOW USERS LAST LOG IN THE SYSTEM

last

SHOW USERS LAST LOG IN THE SYSTEM WITH INTERFACE

lastlog

SEE LOG OF A SERVICE

journalctl -u <service name>

GET HOW MUCH SPACE DO YOU HAVE IN THE HDD

df -h Also, you can use: duf Needs to install duf.

LESS DISPLAY

ls <PATH> | less

SYSTEM ADMIN

gotop Needs to install gotop.

LOCATE FILES BY THEIR NAMES

locate Needs to install locate.

CHANGE ROOT PASSWORD

sudo passwd

CHANGE DEFAULT GRUB CONFIG

sudo vim /etc/default/grub

GET COMMAND LINE HISTORIAL

history

GET WINDOW COMPOSITOR

inxi -Gxx | grep compositor where -G Grafic info xx Show extra info

PULSEAUDIO

pulseaudio --start --verbose start-pulseaudio-x11

BRIGHTNESS

xbacklight -set (value)

BRIGHTNESS I3 KEYS

https://www.reddit.com/r/i3wm/comments/3a6nh3/help_how_to_use_function_keys_in_i3_config/

FONT FOR URXVT

https://addy-dclxvi.github.io/post/configuring-urxvt/

RELOAD .Xresources

xrdb ~/.Xresources

CREATE NEW USER

useradd -m <username>

FONTS HELP

https://forum.manjaro.org/t/failing-to-change-font-for-urxvt/104672/3

INSTALL FONTS MANUALLY (polybar)

move to /usr/share/fonts fc-cache fc-list | grep <font-name> font-<number> = "<font-name>:style=Regular,size=8;2"

CHANGE NEOFETCH IMG

https://www.reddit.com/r/SolusProject/comments/8qlkbm/images_in_neofetch/

I3 NO BORDERS

https://www.reddit.com/r/i3wm/comments/87kclz/how_do_i_remove_borders_and_titles/

I3 GAPS

https://erikdubois.be/how-to-change-the-size-of-the-gaps-between-the-windows-in-i3/

TRANSPARENCY TERMINAL

https://bbs.archlinux.org/viewtopic.php?id=117543

POLYBAR(3) AND ICONS HELP

https://github.com/adi1090x/polybar-themes https://www.reddit.com/r/archlinux/comments/b2ox2t/siji_font_with_polybar_dropping_characters/

ROFI THEME

https://forum.archlabslinux.com/t/rofi-theming-tips/699

GOTOP DOTS PROBLEM

https://www.reddit.com/r/archlinux/comments/apqnhr/ugly_graph_in_gotop/

ROFI WITH PYWAL

https://github.com/dylanaraps/pywal/blob/master/pywal/templates/colors-rofi-dark.rasi https://github.com/dylanaraps/pywal/wiki/Customization#rofi

SHOW KEYS "NAME"

showkey
xev

CHANGE KEYBOARD LAYOUT

https://wiki.archlinux.org/index.php/Xorg/Keyboard_configuration

CHECK BATTERY

inxi -B (it needs inxi installed)

CHECK HDD INFO

smartctl -a /dev/sda Needs smartmontools

TEST HDD

smartctl long /dev/sda Needs smartmontools

Start TLP

sudo tlp start

Stats of your battery

sudo tlp stat

CHANGE BATTERY THRESHOLD

sudo vim /sys/class/power_supply/BAT0/change_stop_threshold

READ A USB

  1. Mount the USB: mount /dev/sdb1 /mnt/usb
  2. Unmount the USB: umount /mnt/usb

MAKE A BACKUP

rsync -av --delete /Directory1/ /Directory2/ (from Directory1 to Directory2)

MAKE A FULL SYSTEM BACKUP

sudo rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /path/to/backup/folder

FLASH A USB (umounted)

sudo dd bs=4M if=/path/to/archlinux.iso of=/dev/sdX status=progress oflag=sync (NO NUMBER)

CHECK DISK FREE/USED SPACE

df --total -h

CHECK DISK USAGE OF A FOLDER

du -sh /path/to/folder

FORMAT USB

  1. Know the name: lsblk
  2. Unmont it: umount /dev/sdb1
  3. Format it: sudo mkfs.vfat /dev/sdb1 // sudo mkfs.ntfs /dev/sdb1 // sudo mkfs.ext4 /dev/sdb1

FORMAT USB AND ALL ITS PARTITION WITH FDISK

https://dottheslash.wordpress.com/2011/11/29/deleting-all-partitions-on-a-usb-drive/

SHUTDOWN AFTRER CERTAIN TIME

sudo shutdown -P +60 // sudo shutdown -P 1:00 // sudo shutdown -c

CHANGE SCREEN RESOLUTION TO 1920X1080

xrandr -s 1920x1080

SEE INSTALLED SHELLS

cat /etc/shells

CHANGE INSTALLED SHELL

chsh <user> /bin/<shell>

SEE IP INFO

curl ipinfo.io (the info is displayed on a website and then you get the info from there)

SHRINK PARTITION

  1. umount /dev/sda4
  2. e2fsck -f /dev/sda4
  3. resize2fs /dev/sda4 200G
  4. gdisk /dev/sda (delete partition and create a new one of the same size that the filesystem)

EXTEND A PARTITION

(the same as shrinking but you first resize the partition and then the filesystem)

CHROOT WITHOUT ERRORS

mount /dev/sda3 /rescue
mount /dev/sda4 /rescue/home
mount /dev/sda2 /rescue/boot
mount /dev/sda5 /rescue/efi
mount -t proc proc /rescue/proc
mount -t sysfs sys /rescue/sys
mount -o bind /dev /rescue/dev
mount -t devpts pts /rescue/dev/pts
chroot /rescue

CLONE A MOUNTED DIRECTORY FROM THE USB

mount --bind /sys/firmware/efi/efivars /rescue/sys/firmware/efi/efivars

UPDATE "lsblk"

partprobe /dev/sda

UPDATE GRUB

grub-mkconfig -o /boot/grub/grub.cfg

SHARED DIRECTORY

  1. Edit fstab
  2. groupadd sharedusers -g 2000
  3. chown [your_user_name]:sharedusers -R /home/artur/shared

CHANGE HOSTNAME

vim /etc/hostname
vim /etc/hosts

CHECK INTERNET SPEED

speedtest-cli

CHECK SYSTEM INFORMATION

  1. hwinfo (hardware)
  2. lspci (peripheral components)
  3. uname (basic system information)

IF HEADPHONES DOESN'T WORK

alsactl restore

VIEW PROCESSES

ps -aux

ALARM CLOCK

sleep 1h && mplayer /path/to/music.mp3

CPU BENCHMARK

geekbench

CLASS OF PROGRAM FOR I3

xprop | grep WM_CLASS | awk '{print $4}' (and click on the window)

PACMAN COMMANDS

sudo pacman -Syy Update my system -S Sync package -y download fresh package database -yy Forces download even if it is up to date

sudo pacman -Syu Upgrade my system. If you do Sudo pacman -Syu <package> you only upgrade that one package.

sudo pacman -Ss <pkg> Search one package in arch repo

sudo pacman -Si <pkg> Search one package with all his dependences

sudo pacman -S <pkg> Download and install one package

sudo pacman -Sw <pkg> Download without install one package. It is stored in /var/cache/pacman/pkg

sudo pacman -U <path> Install local packages in that path

sudo pacman -U <url> Install package from that URL

sudo pacman -Qnq | pacman -Syu - Reinstall all installed packages

sudo pacman -R <pkg> Unistall one package

sudo pacman -Rsun <pkg> Unistall package and his not used dependencies. -n Ignores backups -s Recursively -u Remove not required packages

sudo pacman -Qi <pkg> Show info about package and his dependencies

sudo pacman -Ql <pkg> List installed packages

sudo pacman -Q <pkg> >> complete_list.txt List installed packages in a generated .txt

sudo pacman -Qet List installed packages not used by other packages

sudo pacman -Qe | awk '{print $1}' Print list of installed packages not used by other packages but only displaying his names

sudo pacman -Sc Clean pacman cache

sudo pacman -Scc Clean pacman cache twice

sudo paccache -r Also clean cache

sudo pacman -Rs $(pacman -Qtdq) Delete orphan packages

Pacman files

Main config location: /etc/pacman.conf

Cache file location: /var/cache/pacman/pkg

Database location: /var/log/pacman.log

Terminal-based programs:

  • Monitoring: Gotop
  • Music Player: Cmus
  • RSS Feed Reader: Canto
  • File Manager: Ranger
  • Launcher: Rofi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment