Add a new user
$ useradd <USERNAME> -u <USER_ID> -s /bin/bash
$ useradd ktrushin -u 1000 -g 1000 --create-home --user-group
Add an existing user to an existing group
$ sudo usermod -aG <group_name> <user_name>
Change user uid and gid
$ usermod -u <NEWUID> <LOGIN>
$ groupmod -g <NEWGID> <GROUP>
Merge two directories:
$ rsync -a source_dir/* dest_dir/
Memory a process consumes (in KB)
$ ps --no-header -C <process_command> -o rss | awk '{rss += $1};END{print rss}'
$ smem -P <process_command> -c pss -H | \
python3 -c "from fileinput import input; print(sum(map(int, input())))"
List hardware on a PC
$ lshw
$ lspci
$ lsusb
$ inxi
Get date as unixtime
$ date +%s
Convert a date to unixtime
$ date -d "2015-09-04 13:35:00" +%s
Convert unixtime to a date
$ date -d @1451573940
Fix Ctrl-Shift-e in terminator
$ ibus-setup
Then remove the keybinding for Emoji
Restart GUI:
- change to another virtual console using <ctrl+alt+f2>
- login
- run
sudo systemctl restart systemd-logind
orsudo systemctl restart gdm
- change back to the virtual console where GUI is bind to using <ctrl+alt+f7>
Install system monitor GNOME extentions on Ubuntu 20.04:
- install required packages
$ sudo apt-get install gir1.2-gtop-2.0 gir1.2-nm-1.0 gir1.2-clutter-1.0 \ gnome-system-monitor gnome-shell-extension-system-monitor
- restart the machine
Install system monitor GNOME extentions on Ubuntu 22.04:
- remove
chrome-gnome-shell
$ sudo apt-get purge chrome-gnome-shell
- install
gnome-browser-connector
of version 42.0 or higher$ sudo apt-get update && sudo apt-get install gnome-browser-connector
- alternatively, compile
gnome-browser-connector
from source and install manually$ sudo apt-get install git meson $ git clone https://gitlab.gnome.org/nE0sIghT/gnome-browser-connector.git $ cd gnome-browser-connector $ meson --prefix=/usr builddir $ sudo install -C builddir
- install required packages
$ sudo apt-get install gir1.2-gtop-2.0 gir1.2-nm-1.0 gir1.2-clutter-1.0 \ gnome-system-monitor
- restart the machine
- install the
system-monitor-next
GHOME extension
Lock screen when lid is closed:
- In Gnome Tweaks, enable
General -> Suspend when laptop lid is closed
- In
/etc/systemd/logind.conf
, uncomment theHandleLidSwitch
andHandleLidSwitchExternalPower
and change their values as follows:
HandleLidSwitch=lock
HandleLidSwitchExternalPower=lock
Install Windows 11 into VirtualBox: before installing, disable Setting -> System -> Enable EFI (special OSes only)
Install HP MFP m137fnw:
- Connect the printer to the Wi-Fi network via HP Smart app
- Discover the printer via Settings->Printers menu
- Install airscan:
$ sudo apt-get install sane-airscan
- Go to here, choose Linux -> Ubuntu and download the driver.
- Untar the driver and execute
install.sh
with sudo - In the
Settings->Printers
menu select the printer settings, hit thePrinter Details
button, update the printer name to the desired one and hit theInstall PPD file
button, choose the/usr/share/ppd/uld-hp/HP_Laser_MFP_13x_Series.ppd
file.
A data scrubbing command to prevent a bit rot on an external flash-memory-based drive (SSD, USB flash drive):
$ sudo dd if=/dev/disk/by-label/<drive_name> of=/dev/null iflag=nocache status=progress