You can use this as a guide if you are using ubuntu or ubuntu based distros. I think some of this will work to on debian distros.
If you see something like this <name> in the command, remove the brackets <> and replace it with what the bracket says. Read before copy and pasting!
Table of Contents
Update and Upgrade Packages
1
2
3
4
5
6
7
8
9
10
11
| # update the repository
sudo apt update
# list all upgradable packages
apt list --upgradable
# upgrade specific packages or upgrade a single package
sudo apt --only-upgrade install gimp code kdenlive
# upgrade all packages
sudo apt upgrade
|
Unpack .deb File
1
2
3
4
5
6
7
8
| # this will work mostly fine
sudo dpkg -i thefilename.deb
# using apt
sudo apt install ./thefilename.deb
# run this if you get any dependency errors
sudo apt install -f
|
Upgrade Major Versions
Fedora
In this example, I’m going to show you how to upgrade from fedora 36 to fedora 37.
- Make sure the packages in your system is already up-to-date.
1
2
3
| # upgrade system and reboot pc
sudo dnf upgrade
reboot
|
- Check again if it is fully upgraded.
1
| sudo dnf upgrade --refresh
|
- Install the
dnf-plugin-system-upgrade if you haven’t done that already.
1
| sudo dnf install dnf-plugin-system-upgrade
|
- Download the upgrade. Keep in mind that it is only support for 2 major releases. If you want to upgrade more please visit the official documentation.
1
| sudo dnf system-upgrade download --releasever=37
|
Change the --releasever= number if you want to upgrade to a different version.
- If you are having an issue with dependencies, you can try this command. Only if you’re having problems.
1
| sudo dnf system-upgrade download --releasever=37 --allowerasing --best
|
- When you are done with the process, trigger the
uprade-system. This will reboot the system immediately without countdown and confirmation, so close all the programs and save your work.
1
| sudo dnf system-upgrade reboot
|
Reboot process going to take longer because it needs to apply the update just before the OS (on the boot logo). Don’t touch anything assume that everything is fine even if the progress bar is not moving.
- Remove cache and unused packages from previous versions and upgrades.
1
2
3
4
5
| # remove cached metadata and transaction
sudo dnf system-upgrade clean
# remove cached packages
sudo dnf clean packages
|
Please Visit this official documentation from fedora. Because there’s a lot of things that I didn’t cover here. Source : https://docs.fedoraproject.org/en-US/quick-docs/dnf-system-upgrade/
https://linuxize.com/post/how-to-extract-unzip-tar-xz-file/
1
2
3
4
| tar xfv <file-name>.tar.xz
tar xfv <file-name>.tar.bz2
tar xfv <file-name>.tar.gz
tar xfv <file-name>.tar
|
Extract file into a directory
1
2
3
4
| tar xfv <archive-name>.tar --directory=path/to/directory
tar xfv <archive-name>.tar.gz --directory=path/to/directory
tar xfv <archive-name>.tar.bz2 --directory=path/to/directory
tar xfv <archive-name>.tar.xz --directory=path/to/directory
|
If tar gives a Cannot exec error, you may need to run sudo apt install xz-utils first.
Installing from a .tar file
1
2
3
4
5
6
7
8
9
| # if the file is .tar.gz
tar xfvz <archive-name>.tar.gz
# if the file is .tar.bz2
tar xfvj <archive-name>.tar.bz2
./configure
make
sudo make install
|
see this for more info : https://help.ubuntu.com/community/CompilingEasyHowTo
How To Clone Git Repositories
git clone <repository URL>
Example :
git clone https://github.com/get543/linux-beginner-guide
Other Tips Tutorials
Node JS
nodejs repository :
https://github.com/nodesource/distributions/blob/master/README.md#debinstall
installing nodejs :
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-20-04
yt-dlp
Download a video from youtube, how to install it.
Download the best
1
| yt-dlp -f best <link-here>
|
Config that I use
Download the highest 1080p .mp4 video-only and merge it with the best audio-only format. If no 1080p, use the highest before that.
1
| yt-dlp -S "res:1080,ext" -f "bv*+ba/b" <link_here> -o "%(title)s.%(ext)s"
|
Config explains
-f mp4 => for video format
-f best => for the best option
-f 140 => choose the number from the list
-F => display all available format
-o => C:\Users\dood\Downloads\%(title)s.%(ext)s => for the download path
--no-mtime => the time when you download it not the uploader time
More config examples
See the full list here.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
| # Download and merge the best video-only format and the best audio-only format,
# or download the best combined format if video-only format is not available
$ yt-dlp -f "bv+ba/b"
# Download best format that contains video,
# and if it doesn't already have an audio stream, merge it with best audio-only format
$ yt-dlp -f "bv*+ba/b"
# Download the best video-only format and the best audio-only format without merging them
# For this case, an output template should be used since
# by default, bestvideo and bestaudio will have the same file name.
$ yt-dlp -f "bv,ba" -o "%(title)s.f%(format_id)s.%(ext)s"
# Download the best video available but with the smallest resolution
$ yt-dlp -S "+res"
# Download the smallest video available
$ yt-dlp -S "+size,+br"
# Download the best mp4 video available, or the best video if no mp4 available
$ yt-dlp -f "bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4] / bv*+ba/b"
# Download the best video with the best extension
# (For video, mp4 > webm > flv. For audio, m4a > aac > mp3 ...)
$ yt-dlp -S "ext"
# Download the best video available with the largest resolution but no better than 480p,
# or the best video with the smallest resolution if there is no video under 480p
# Resolution is determined by using the smallest dimension.
# So this works correctly for vertical videos as well
$ yt-dlp -S "res:480"
# Download best video (that also has audio) that is closest in size to 50 MB
$ yt-dlp -f "b" -S "filesize~50M"
# Download the best video with worst codec no worse than h264,
# or the best video with best codec if there is no such video
$ yt-dlp -S "+codec:h264"
|
Switch Between Speakers and Headphones Without Unpluging
Adding Config
If you are having a problem with switching between speakers and headphones.
1
| sudo gedit /usr/share/pulseaudio/alsa-mixer/paths/analog-output-speaker.conf
|
Change or Paste :
1
2
3
4
5
6
7
8
9
10
| [Element Headphone]
switch = off
volume = merge
overide-map.1 = all
override-map.2 = all-left, all-right
[Element Speaker]
required-any = any
switch = mute
volume = off
|
Use Indicator-Sound-Switcher or Pavucontrol
1
2
| sudo apt-get install indicator-sound-switcher
sudo apt install pavucontrol
|
Enable Auto Mute on Alsamixer
Script Toggle Auto Mute on Alsamixer
- Download autokey (control the OS with Python script).
1
| sudo apt install autokey-gtk
|
Add a new script.
Name: Toggle Auto Mute.
Add this script :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| # Toggle - Disable or Enable Auto-Mute Mode
import os
# user input
# To get sound card number, open Terminal → Type → alsamixer → press Enter → press F6
sound_card_number = 2
# end of user input
###############################################################
time.sleep(0.5)
get_info_command = "amixer -c %s get 'Auto-Mute Mode'" % sound_card_number
get_info = system.exec_command(get_info_command)
time.sleep(1)
if get_info.find("Item0: 'Disabled'") is not -1: # disabled
time.sleep(0.8)
enable = "amixer -c %s set 'Auto-Mute Mode' Enabled" % sound_card_number
system.exec_command(enable)
os.system("notify-send 'Auto-Mute Mode of Sound Card Number %s' 'Enabled'" % sound_card_number)
quit()
else: # enabled
time.sleep(0.8)
disable = "amixer -c %s set 'Auto-Mute Mode' Disabled" % sound_card_number
system.exec_command(disable)
os.system("notify-send 'Auto-Mute Mode of Sound Card Number %s' 'Disabled'" % sound_card_number)
|
Change sound_card_number that has auto mute that you can disable or enable.
To do that, type this on terminal :
- Press
F6 to select sound card. And the number next to the sound card name is the sound_card_number.
Using Shell Script
You can use this shell script to change output device between headphones and speakers. It uses zenity, it comes pre-installed on Ubuntu based distros. This is the same script as the Python script the only differrence is you don’t have to download autokey.
Open Anything On Default Apps
On this example, open a video file :
1
2
3
4
5
| # open any apps on defaults apps
xdg-open <file-name.mp4>
# or you can do this to if vlc installed
vlc <filename.mp4>
|
Games To Try On Terminal
- bsdgames
- snake
- hangman
- random
- cmatrix
- cowsay
- sl
- figlet
- aafire
- espeak
Restarting gnome-shell
Check Installed Gnome Extensions
1
2
3
4
5
| # check all installed extensions
gnome-extensions list
# check enabled extensions
gnome-extensions list --enabled
|
Installing Multiple Apps on 1 Command
By Creating A Script File
1
2
3
4
5
6
7
| #! /bin/bash
sudo apt install vlc
sudo apt install obs-studio
sudo apt install simplenote
sudo apt install steam
sudo apt install -y wine
sudo apt update && sudo apt upgrade
|
By Terminal Command
Install the app using sudo apt install just put a space between each app
1
| sudo apt install vlc obs-studio simplenote steam wine
|
Show Thumbnails In File Manager
Nautilus
For Video Files
https://askubuntu.com/questions/1034595/thumbnails-not-showing-in-video-in-ubuntu-18-04
1
2
3
4
5
6
7
8
9
10
| sudo apt install ffmpegthumbnailer
# remove thumbnails folder in the .cache folder
rm -r ~/.cache/thumbnails/fail
# if that doesn't work, clear the entire thumbnails folder
rm -rf ~/.cache/thumbnails/*
# quit file manager and then you can re-open it
nautilus -q
|
For Webp Files
https://fostips.com/enable-thumbnails-webp-ubuntu-fedora/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| # add repository
sudo add-apt-repository ppa:krifa75/eog-ordissimo
# update repository
sudo apt update
# install the package
sudo apt install webp-pixbuf-loader
# remove the repository because it might break other packages
sudo add-apt-repository --remove ppa:krifa75/eog-ordissimo
# quit file manager
nautilus -q
|
Thunar File Manger
https://superuser.com/questions/258633/why-is-thunar-not-creating-and-showing-thumbnails-of-images To get thumbnail on your thunar file manager, you need to install tumbler package.
1
2
3
4
5
| # example on arch based systems
sudo pacman -Sy tumbler
# example on debian based systems
sudo apt install tumbler
|
Restart the file manager
1
2
3
4
5
| # quit the application
thunar -q
# run it again
thunar
|
Change App Icon on Ubuntu
1
2
| cd /usr/share/applications
sudo gedit <app-name>.desktop
|
Replace → Icon=/home/<current-user>/Pictures/Icons/something.png
Fonts
- office fonts for libreoffice :
sudo apt-get install ttf-mscorefonts-installer - source-code-pro : https://github.com/adobe-fonts/source-code-pro
Linux File Permission Explanation
https://linuxhandbook.com/linux-file-permissions/
Droidcam Installation
Change the webcam resolution :
- navigate to droidcam config file.
cd /etc/modprobe.d/sudo nano droidcam.conf- change the width and height and then save it.
If there is a kernel update, you have to reinstall droidcam :
1
2
3
4
5
6
7
| cd /tmp/
wget -O droidcam_latest.zip https://files.dev47apps.net/linux/droidcam_1.8.2.zip
# sha1sum: d1038e6d62cac6f60b0dd8caa8d5849c79065a7b
unzip droidcam_latest.zip -d droidcam
cd droidcam
sudo ./install-client
sudo ./install-video
|
If you have any problem,
1
2
3
4
5
| # unload the driver
sudo rmmod v4l2loopback_dc
# reload the driver with a new resolution
sudo insmod /lib/modules/`uname -r`/kernel/drivers/media/video/v4l2loopback-dc.ko width=1920 height=1080
|
List Hardware Info
lshw -short
GUI version (install it first)
lshw-gui or lshw-gtk
Beginner Arch
ArchTitus
Arch Titus → Arch Linux with a script.
Installing ArchTitus:
1
2
3
4
| pacman -Sy git
git clone https://github.com/ChrisTitusTech/ArchTitus
cd ArchTitus
./archtitus.sh
|
Regular Arch Linux Installation
https://github.com/rickellis/Arch-Linux-Install-Guide
Guide For Gaming on Linux
- Ultimate Guide → https://www.christitus.com/ultimate-linux-gaming-guide/
- Download Other Game Launcher (epic, gog, uplay) → https://lutris.net/
Run GameMode
1
2
3
4
5
| # this
gamemoderun ./game
# or this
gamemoded ./game
|
QEMU
Using QEMU on Terminal
1
2
3
4
5
| # navigate to the .iso file
cd /path/to/iso/file
# create disk image 10GB
qemu-img create -f qcow2 Image.img 10G
|
1
2
| # for windows :
qemu-system-x86_64.exe -cdrom .\manjaro-kde-20.0.3-200606-linux56.iso -boot menu=on -drive file=Image.img -m 2G -smp 2 --accel whpx
|
1
2
| # for linux :
qemu-system-x86_64 -enable-kvm -show-cursor -cdrom ./archlinux-2022.04.05-x86_64.iso -boot menu=on -drive file=Image.img -m 2G -smp $(nproc) -cpu host -vga virtio -display gtk,gl=on
|
-cpu host → sets the CPU to the hosts’ CPU.-smp 2 → sets the numbers of cores.-smp $(nproc) → use all available CPU cores.
Basic Graphics Acceleration
The -vga option can be used to specify one of various vga card emulators : -vga → Linux only
qxl offers 2D acceleration but requires kernel modules qxl and bochs_drm to be enabled : -vga qxl
virtio works much better and supports some 3D emulation : -vga virtio -display sdl,gl=on
Source : https://youtu.be/AAfFewePE7c
More Options & Explanations : https://wiki.gentoo.org/wiki/QEMU/Options
Using QEMU with GUI
Guide Virtualization on Linux (virt-manager and qemu). virt manager
Clear Swap Memory
I made my own script it is a file called freeramcache.sh. But if you want essentially the same thing as the command below.
1
2
3
4
5
6
7
8
9
10
11
12
13
| # check free memory space
free -h
# disable swap
swapoff -a
##### wait approx 30 sec
# enable swap
swapon -a
# see the amount of swap used/available, decrease over time
free -h
|
Expand or Create A New Swap Memory
- See the current status of your swap memory.
1
2
3
4
5
| # swap usage info
free -h
# swap status
swapon -s
|
1
2
| # disable swap memory
sudo swapoff -a
|
- Create or overwrite the old one with
/swapfile1G is the units8 is the integer So together they define the size.- size = 8GB It may take a while to create the file, for me it was a couple of minutes.
1
2
3
4
5
6
7
8
| # create a /swapfile that is 8GB in size
sudo dd if=/dev/zero of=/swapfile bs=1G count=8
# set the correct permissions
sudo chmod 0600 /swapfile
# set up a linux swap area
sudo mkswap /swapfile
|
To make it permanent upon restart
1
2
3
4
5
6
7
8
| # # edit the file
# sudo nano /etc/fstab
# add that line in /etc/fstab
echo "/swapfile none swap sw 0 0" > /etc/fstab
# enable swap memory
sudo swapon /swapfile
|
Restart Audio Driver
1
2
3
4
5
6
7
8
| # reload alsa driver
sudo alsa force-reload
# if it doesn't work, try using this
systemctl --user restart pulseaudio
# start it again with pulseaudio
pulseaudio --start
|
Remove a Directory on Terminal
Remove a directory with nested folders and files. rm -r or rm -rf or rm -rfv
Example :
Editing Thunar Visuals
1
2
| thunar -q
GTK_DEBUG=interactive thunar
|
Using Wget
Download a file or webpage using wget
1
2
3
| wget <URL>
wget -i <download_files.txt>
wget -O <filename> <URL>
|
Download a folder using wget
Download an entire website using wget
This is done by creating a mirror of the website.
1
| wget -m --convert-links --page-requisites website_address
|
Customise download location
1
| wget <link> -O ~/Downloads/<custom-file-name>.deb
|
Download with a redirect link and custom download location (recommended)
1
| wget -O <custom-file-name>.deb "<link>"
|
Resume incomplete downloads
Using cURL
Download a web page and put it in a file
1
| curl "<http://example.com>" --output "<filepath>"
|
Download a file from a URL and keep file name from what its given
1
| curl --remote-name "<http://example.com/filename>"
|
Download with a redirect link, auto resume if there’s an error, shows the error, and custom file path (recommended)
1
| curl --output "<filepath-or-filename>" --fail --show-error --location --continue-at - "<http://example.com/filename>"
|
Go to about:config
ui.key.menuAccessKeyFocuses change it to false
This will disable menubar when you press the alt key. But still showing when you press the alt + t or alt + h.
ui.key.menuAccessKey change it to 0
This will completely disable the menubar shortcut. The regular shortcut still work, like ctrl + w, ctrl + t.
Wifi Drivers
This works on Realtek Semiconductor Corp. 802.11n.
How to check :
How To Install :
1
2
3
4
5
6
| sudo apt-get install build-essential git dkms linux-headers-$(uname -r)
git clone https://github.com/kelebek333/rtl8188fu
sudo dkms add ./rtl8188fu
sudo dkms build rtl8188fu/1.0
sudo dkms install rtl8188fu/1.0
sudo cp ./rtl8188fu/firmware/rtl8188fufw.bin /lib/firmware/rtlwifi/
|
Configuration :
1
2
3
| sudo mkdir -p /etc/modprobe.d/
sudo touch /etc/modprobe.d/rtl8188fu.conf
echo "options rtl8188fu rtw_power_mgnt=0 rtw_enusbss=0" | sudo tee /etc/modprobe.d/rtl8188fu.conf
|
Source : https://github.com/kelebek333/rtl8188fu
Aliases
Creating temporary aliases
1
2
3
4
5
| # syntax
alias name="yourcustomcommand"
# example
alias instalation="cd ~/Documents/shell && ./install.sh"
|
Creating permanent aliases
- bash →
~/.bashrc - zsh →
~/.zshrc - fish →
~/.config/fish/config.fish
1
2
3
4
5
6
7
8
| # if you are using bash
nano ~/.bashrc
# put this aliases in that file
alias instalation="cd ~/Documents/shell && ./install.sh"
# use it as current session
source ~/.bashrc
|
Remove Aliases
1
2
3
4
5
| # remove added aliases
unalias instalation
# remove all aliases
unalias -a
|
This works by turning on gpu acceleration, by running this on terminal :
1
| discord --enable-gpu-rasterization
|
You must create or edit the discord.desktop file, so you don’t have to launch discord through terminal, like this :
- Edit or create the
discord.desktop usually located here :
1
| sudo nano /home/$USER/.local/share/applications/discord.desktop
|
1
2
3
4
5
6
7
8
9
10
11
| [Desktop Entry]
Name=Discord
StartupWMClass=discord
Comment=All-in-one voice and text chat for gamers that is free, secure, and works on both your desktop and phone.
GenericName=Internet Messenger
Exec=/usr/bin/discord --enable-gpu-rasterization
Icon=discord
Type=Application
Categories=Network;InstantMessaging;
Path=/usr/bin
Path=/usr/bin
|
CTRL + X → to save and exit.Y → to confirm.
Git Basic Command
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| # global config
git config --global user.name "get343"
# config email
git config --global user.email "blablabla@gmail.com"
# initialization
git init
# add all files in the directory
git add .
# commit
git commit -m "first commit"
# change branch to main
git branch -M main
# add a remote repository
git remote add origin "https://get543.github.io/mywebsite"
# push changes to github
git push -u origin main
# there's a change in the code and want to upload to github
git add .
git commit -m "commit message"
git push
# connecting github repository using ssh
git remote set-url origin git@github.com:get543/<project-name>.git
|
Github Cheat Sheet
https://dev.to/doabledanny/git-cheat-sheet-50-commands-free-pdf-and-poster-4gcn
Installing Node JS (Node Version Manager)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| # check what the script contains
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh
# if all good you can download and run it
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
# will refresh the bashrc
source ~/.bashrc
# list available node version
nvm list-remote
# install node js using version number
nvm install v16.15.1
# install node js using version name
nvm install lts/gallium
# check what version of node installed
node -v
|
Source :
- https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-20-04
- The Github Projects
Customise Terminal Prompt
On most system usually will look something like this :
I’m going to change it to more like this :
Step To Do
Edit the .bashrc file.
Find something like this. Now this is the special characters before adding the colour into the prompt.
And this is after adding a colour into the prompt. The colouring added before and after the special characters.
1
| PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
Just need to add a newline \n before the $ and delete : add a space after that, like this :
1
| PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\]\n\$ '
|
Source : https://www.computerhope.com/issues/ch001645.htm
Fixing OBS Error when Installing
Usually I do this when installing OBS.
1
2
3
| sudo add-apt-repository ppa:obsproject/obs-studio
sudo apt update
sudo apt install ffmpeg obs-studio
|
But it outputs this error message.
1
2
3
| The following packages have unmet dependencies:
obs-studio : Depends: libfdk-aac1 (>= 0.1.4) but it is not installable
E: Unable to correct problems, you have held broken packages.
|
You need to download the package from the debian website https://packages.debian.org/stretch/amd64/libfdk-aac1/download
And install it using this command :
1
2
3
4
5
| # navigate to the downloads folder
cd Downloads
# install it using dpkg command
sudo dpkg -i libfdk-aac1_0.1.4-2+b1_amd64.deb
|
And finally rerun the obs install command.
1
| sudo apt install obs-studio
|
Note : I experience broken theme if I use this method. Use flatpak instead.
Fixing Printer & Scanner Error
Uninstall ippusbxd.
1
| sudo apt purge ippusbxd
|
Download Both ipp-usb and sane-airscan. https://download.opensuse.org/repositories/home:/pzz/xUbuntu_20.04/amd64/
Just Install it like usual.
1
2
| sudo dpkg -i ipp-usb_0.9.22-1+52.1_amd64.deb
sudo dpkg -i sane-airscan_0.99.27-1+89.1_amd64.deb
|
Replace ‘apt’ With ‘nala’
Their github page here Copy paste guide here
Installation
- Install the volian scar repo.
1
2
| echo "deb https://deb.volian.org/volian/ scar main" | sudo tee /etc/apt/sources.list.d/volian-archive-scar-unstable.list
wget -qO - https://deb.volian.org/volian/scar.key | sudo tee /etc/apt/trusted.gpg.d/volian-archive-scar-unstable.gpg > /dev/null
|
1
| echo "deb-src https://deb.volian.org/volian/ scar main" | sudo tee -a /etc/apt/sources.list.d/volian-archive-scar-unstable.list
|
- For Ubuntu 22.04 and newer.
1
2
| sudo apt update
sudo apt install nala
|
1
2
| sudo apt update
sudo apt install nala-legacy
|
Change ‘apt’ to ‘nala’
- Add this to the end of the file.
1
2
3
4
5
6
7
8
9
10
11
12
13
| # replacing apt with nala
apt() {
command nala "$@"
}
sudo() {
if [ "$1" = "apt" ]; then
shift
command sudo nala "$@"
else
command sudo "$@"
fi
}
|
Flush DNS Cache on Linux
1
2
3
| sudo systemd-resolve --flush-caches
sudo resolvectl flush-caches
sudo systemd-resolve --statistics
|
Basic Vim Commands
:e <filename> → open filename to edit:w → save file:q → exit vim:q! → quit without saving:wq → save file and close vim:x → write file and exit:sav <filename> → saves file as filename:!pwd → execute the PWD Unix command, and returns to viyy → copies the current linep → pastes the copied textu → undo the previously executed commanddd → deletes the current line: f <filename> → rename the file
Keyboard shortcuts for the Linux terminal on Ubuntu
TAB → autocomplete the commandTAB TAB → for displaying all file names and commands that start with those lettersctrl + alt + t → for opening the terminalctrl + u → to remove the current linectrl + a → move the cursor to start of the linectrl + e → move the cursor to the end of the linectrl + c → to stop the current commandctrl + z → to put a running command to sleepfg → to continue the process that’s put to sleepbg → to continue the process in the background
Listen to your own microphone
1
2
3
4
5
| # to turn it on
pactl load-module module-loopback latency_msec=1
# to turn it off
pactl unload-module module-loopback
|
It loads a loopback module. The number 1 means the latency you receive. The latency is in miliseconds (ms). To turn it off, you just unload the module.
Add Git Branch on Bash Prompt
Before:
1
2
| user@host ~/Downloads/linux-beginner-guide
$
|
After:
1
2
| user@host ~/Downloads/linux-beginner-guide (main)
$
|
To do that you need to edit the .bashrc file in the home folder
- Open the file on text editor
- Add this function to the file
1
2
3
4
| # git branch on terminal
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
|
- Add
$(parse_git_bashrc) to run the function in bash prompt1
| PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\] \[\033[01;33m\]$(parse_git_branch)\[\033[00m\]\n\$ '
|
- Finally refresh the
.bashrc file
Connecting Git using SSH Key
‘Permission Denied (publickey)’ error
This means, on your local machine, you haven’t made any SSH keys.
How To Fix :
- Open terminal.
- Change to
.ssh directory.
1
2
3
4
5
| # for linux
cd ~/.ssh
# for windows
cd C:\Users\<your-windows-username>\.ssh\
|
- Do a listing to see what file in that directory.
1
2
3
4
5
| # listing
ls
# for long-listing
ll
|
- There should be these two files:
id_rsa and id_rsa.pub. These are the files that tell your computer how to communicate with GitHub. If those two files don’t show up, or if you have something similar just proceed to the next step, we are just going to create a new one. Your SSH keys must be named id_rsa and id_rsa.pub in order for GitHub to recognize them by default. - To create the SSH keys. Change
your_email@example.com to your github email. This will create both id_rsa and id_rsa.pub files.
1
| ssh-keygen -t rsa -C "your_email@example.com"
|
- Use the
cat command to see what’s the content inside of a file.
- Copy all of them, and paste it into your GitHub Account Settings > SSH Keys.
- Give it a name, like : Github on Linux - RSA Key
- Now that you’ve added your public key to Github, try
git push and let see if it works.
Don’t forget to connect the repository through ssh git remote set-url origin git@github.com:get543/<project-name>.git
More help on creating SSH Keys.
Blackscreen on XFCE in Virt-Manager using 3D Acceleration
This issue can be resolve by replacing default XFCE Compositor to picom.
- Boot into the VM using
QXL. - Disable the default display compositor, here is how to do that :
- search for
Window Manager Tweaks. - go to the
Compositor tab. - uncheck
Enable display compositing.
- Install the new display compositor
(picom). Install it using your distro’s default package manager.
1
2
3
4
5
| # for debian based distros
sudo apt install picom
# for arch based distros
sudo pacman -S picom
|
- Make a
picom directory in .config for start script and config file. And make the start script executable.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| # change directory
cd ~/.config
# make directory
mkdir picom
# from ~/.config change directory
cd picom
# make start.sh file
touch start.sh
# make start.sh an executable file
chmod +x start.sh
# make picom.conf file
touch picom.conf
|
- Paste this for
start.sh file
1
| sleep 2 && picom -b --config /home/$USER/.config/picom/picom.conf
|
sleep → delay the command for 2 seconds.-b → run picom in the background.--config → load a custom config path.
- Save
picom.conf file to ~/.config/picom/picom.conf. - Or this
picom.conf file for the full version, and save the file as picom.conf on ~/.config/picom/picom.conf.
- Put the
start.sh into start script at login. To do that, search for Session and Startup. - Go to the
Application Autostart tab and click Add. - Fill it like this :
- Name → Picom
- Description → Starts Picom Compositor
- Command →
/home/<username>/.config/picom/start.sh - Trigger → on login
- Click
OK and Close - Finally, reboot your VM.
Terminal Window Title Show Running Command
If you have starship installed, you can run the custom function.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| # custom starship window title function
function set_win_title() {
local cmd=" 💨 ($@)"
if [[ "$cmd" == " 💨 (starship_precmd)" || "$cmd" == " 💨 ()" ]]
then
cmd=""
fi
if [[ $PWD == $HOME ]]
then
if [[ $SSH_TTY ]]
then
echo -ne "\033]0; 🏛️ @ $HOSTNAME ~$cmd\a" < /dev/null
else
echo -ne "\033]0; 🏠 ~$cmd\a" < /dev/null
fi
else
BASEPWD=$(basename "$PWD")
if [[ $SSH_TTY ]]
then
echo -ne "\033]0; 🌩️ $BASEPWD @ $HOSTNAME $cmd\a" < /dev/null
else
echo -ne "\033]0; 📁 $BASEPWD $cmd\a" < /dev/null
fi
fi
}
starship_precmd_user_func="set_win_title"
eval "$(starship init bash)"
trap "$(trap -p DEBUG | awk -F"'" '{print $2}');set_win_title \${BASH_COMMAND}" DEBUG
|
Dealing With Disk Permissions
Unmount & remount with different permission
1
2
3
4
5
6
7
8
9
10
11
| # list all disks
lsblk
# unmount /dev/sdb1 disk
sudo umount /dev/sdb1
# make usbdrive directory in /media/$USER
mkdir /media/$USER/usbdrive
# mount /dev/sdb1 with read, write, exe permissions to usbdrive folder
sudo mount -t vfat -o rw,exec,uid=1000,gid=1000,umask=022 /dev/sdb1 usbdrive
|
Mount disk to startup applications
1
2
| # mount /dev/sdb3 disk
udisksctl mount -b /dev/sdb3
|
Change ownership of a folder
1
2
| # change owner of usbdrive folder to the current user
sudo chown -R $USER usbdrive
|
Bash Completion Case Insensitive
Add this to the ~/.bashrc file
1
| bind -s 'set completion-ignore-case on'
|
Thunar Change Default Terminal
Create a file and edit it
1
| nano ~/.config/xfce4/helpers.rc
|
Add this to the file. This is an example of kitty terminal
1
2
| TerminalEmulator=kitty
TerminalEmulatorDismissed=true
|
Change from Bash to Zsh
Zsh Installation
This wiki page covers a very detail installation of zsh with a lot of distros as an example.
1
2
3
4
5
6
7
8
| # if you are using debian or ubuntu based distros
sudo apt install zsh
# if you are using arch based distros
sudo pacman -Sy zsh
# if you are using fedora based distros
sudo dnf install zsh
|
- Run
zsh command to make sure that it is installed and create a .zshrc file as a starting point. - Change default shell to
zsh.
Installing Oh-My-Zsh
- Make sure that git and wget and curl is installed.
1
2
3
4
5
6
7
8
| # for debian
sudo apt install git curl wget
# for arch
sudo pacman -Sy git curl wget
# for fedora
sudo dnf install git curl wget
|
- Installing Oh-My-Zsh using the official script from oh-my-zsh github.
1
| sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
|
- Oh-My-Zsh will create a new file of
.zshrc and for the old one is still there just under different name. - Change theme and other cool stuff in
.zshrc. If you don’t know what to do, you can go to the official Oh-My-Zsh wiki page.
- And if you are done, you can use it as a current session with this command
Just to be safe, logout and logback in to make sure everything is set up as it should be.
Oh-My-Zsh Plugins
Some of my favourites :
Find out more: https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins
Oh-My-Zsh Theme
Some of my fovourite themes :
Find out more: https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
Change Linux Login Screen’s Resolution
XFCE (lightdm)
- Find the name of connected display
1
2
3
| Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 8192 x 8192
Virtual-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
...
|
Virtual-1 is my display
- Create a script in /usr/share with
sudo nano /usr/share/lightdmxrandr.sh
1
2
| #!/bin/sh
xrandr --output Virtual-1 --primary --mode 1920x1080
|
- Make the script executable
1
| chmod u+x /usr/share/lightdmxrandr.sh
|
1
2
3
| [Seat:*]
display-setup-script=/usr/share/lightdmxrandr.sh
greeter-setup-script=/usr/share/lightdmxrandr.sh
|
KDE Plasma (sddm)
- Find the display name with
xrandr -q, and this is the result
1
2
3
| Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 8192 x 8192
Virtual-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 403mm x 302mm
...
|
1
2
| # change display resolution
xrandr --output Virtual-1 --mode 1920x1080 --rate 60.00
|
Gnome (gdm)
Set the resolution in Settings > Display and click Apply. That will create a monitor.xml file, a configuration file for your monitor.
Copy that configuration file in the gdm .config folder.
1
2
3
4
5
| # this
sudo cp ~/.config/monitors.xml /var/lib/gdm3/.config/monitors.xml
# if it doesn't work, go with this
sudo cp ~/.config/monitors.xml /var/lib/gdm/.config/monitors.xml
|
Change Grub Theme
Look location of the current installed theme (if available).
1
| cat /etc/default/grub | grep GRUB_THEME=
|
If it shows a value to a path, that means that you have to install the theme there. Example for me :
1
| GRUB_THEME=/usr/share/grub/themes/zorin/theme.txt
|
So I have to install the theme in /usr/share/grub/themes folder.
If there’s a # in front of GRUBTHEME=, it means that no themes is being used. So, it is better to install the theme in /boot/grub/themes folder. If you don’t have it, follow this step :
- Create folder with
mkdir command. (-p to just create every folder before themes if it doesn’t exist).
1
| mkdir -p /boot/grub/themes
|
- Change the ownership of
/boot/grub/themes folder.
1
| sudo chown $USER /boot/grub/themes
|
Installing Theme
Your theme that you downloaded should have a file called theme.txt. That file you will going to put it in GRUB_THEME= in /etc/default/grub.
- So the first step you need to do is edit the config file.
1
| sudo nano /etc/default/grub
|
- Find
GRUB_THEME= and your new theme refrencing to the theme.txt.
1
2
3
4
5
| # grub theme before i changed it
GRUB_THEME=/usr/share/grub/themes/zorin/theme.txt
# the new grub theme
GRUB_THEME=/usr/share/grub/themes/legion/dedsec/theme.txt
|
1
| sudo nano /etc/default/grub
|
- Find
GRUB_GFXMODE= and change it to your disired resolution GRUB_GFXMODE=1920x1080.
Run this command everytime you make changes to the config file
1
2
3
4
5
6
7
8
| # would mostly work
sudo update-grub
# if that doesn't work, try this
sudo grub-mkconfig -o /boot/grub/grub.cfg
# if it doesn't work either, try this one
sudo grub2-mkconfig -o /boot/grub/grub.cfg
|
Please see the github repo of your theme to install it properly.
Change Boot Splash Screen on Linux
General Installation Instructions:
1
| sudo update-alternatives --install /usr/share/plymouth/themes/default.plymouth default.plymouth /usr/share/plymouth/themes/YOURTHEME/YOURTHEME.plymouth 100
|
More info : https://www.xmodulo.com/change-boot-splash-screen-ubuntu-linux-mint.html
Some Cool Themes That I Found
Theme for Arch
- https://www.gnome-look.org/p/1009531
- https://github.com/abrahammurciano/plymouth-theme-sweet-arch
- https://www.gnome-look.org/p/1000032
Another cool themes
- https://www.gnome-look.org/p/1000045
- https://store.kde.org/p/1000045
- https://github.com/vikashraghavan/dotLock
Obsidian Fix Empty Space
Fix the obsidian empty space on the left and right.
- Open Settings.
- In Editor, Turn off
Readable line length.
If you want to use custom css. This only works if you Turn On Readable line length
- find the
.obsidian file on that vault. - Open it on any text editor and add this line.
1
2
3
4
5
6
7
| .markdown-source-view.is-readable-line-width .CodeMirror,
.markdown-preview-view.is-readable-line-width .CodeMirror,
.markdown-source-view.is-readable-line-width .markdown-preview-sizer,
.markdown-preview-view.is-readable-line-width .markdown-preview-sizer {
max-width: 1000px;
margin: auto;
}
|
Linux Most Commonly Known Commands
Source : https://indianstudent.hashnode.dev/linux-commands
Navigating Directories
ls - list files and directoriescd - change directorypwd - print working directorycp - copy files or directoriesmv - move or rename files or directoriesrm - remove or delete files and directoriesmkdir - create a new directoryrmdir - remove or delete an empty directorytouch - create a new empty file or update the timestamp of an existing filecat - display the contents of a filegrep - search for a pattern in a filefind - search for files and directories
Archive
tar - create or extract a tar archivegzip - compress or decompress a file
Permissions
chmod - change the permissions of a file or directorychown - change the ownership of a file or directory
Remote
ssh - connect to a remote server using SSH protocolscp - copy files to or from a remote server using SSH protocolrsync - synchronize files between local and remote servers
Download Files
wget - download files from the internetcurl - transfer data from or to a server using various protocols
Networking
ping - test the connectivity between two network devicestraceroute - display the route that packets take to reach a network devicenetstat - display network connections and statisticsifconfig - display network interface configurationip - display and modify network interface configurationroute - display and modify the kernel routing tableiptables - set up and manage firewall rules
System
systemctl - control system servicesjournalctl - view system logstop - display the processes running on a system, along with their resource usage statisticsps - display the processes running on a systemkill - terminate a processbg - run a command in the backgroundfg - bring a background process to the foregroundjobs - display the status of background jobscron - schedule tasks to run at specific times or intervalsat - schedule a one-time task to run at a specific timeuptime - display system uptime and load average
Disk & File System
df - display disk usage informationdu - display disk usage information for a directory or filemount - mount a file systemumount - unmount a file system
Check Logs
lsof - list open files and processeswho - display who is logged inlast - display recent login historyhistory - display the command history
Read Files
less - view a file one page at a timemore - view a file one page at a time
Manipulating Text Files
head - display the first few lines of a filetail - display the last few lines of a filediff - compare two files line by linepatch - apply a patch to a fileawk - process and manipulate text filessed - process and manipulate text filessort - sort lines of text
.vmdk to .qcow2
For Windows systems using PowerShell
1
| .\qemu-img.exe convert -p -f vmdk -O qcow2 fedora-linux.vmdk fedora-linux.qcow2
|
For Linux systems using Bash
1
| qemu-img convert -p -f vmdk -O qcow2 ./fedora-linux.vmdk ./fedora-linux.qcow2
|
.qcow2 to .vmdk
For Windows systems using PowerShell
The reason I’m doing it like is because it’s not only support VMware but ESXi aswell. But I have not try this one before, I believe it’ll work just fine.
1
| .\qemu-img.exe convert -f qcow2 -O vmdk -o adapter_type=lsilogic,subformat=streamOptimized,compat6 fedora-linux.qcow2 fedora-linux.vmdk
|
For Linux systems using Bash
1
| qemu-img convert -p -f qcow2 -O vmdk fedora-linux.qcow2 fedora-linux.vmdk
|
Just a reminder for myself
[!NOTE]
Highlights information that users should take into account, even when skimming.
[!TIP] Optional information to help a user be more successful.
[!IMPORTANT]
Crucial information necessary for users to succeed.
[!WARNING]
Critical content demanding immediate user attention due to potential risks.
[!CAUTION] Negative potential consequences of an action.