Linux tools I find useful
Distro
How to tell what linux distro you're currently on?
lsb_release -d
NVM
Note Version Manager: because this is the easiest and fastest way to download, install, and switch between different node versions.
Install (link may be obsolete!):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
Then
nvm install 16
Fish
The Friendly Shell. This takes away a bunch of hustles when dealing with the terminal.
sudo apt update && sudo apt install fish
fish
# Fisher is it's plugin manager.
curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
# NVM for FISH
fisher install jorgebucaran/nvm.fish
# To load it to fish shell by default:
`set --universal nvm_default_version`
To install CTRL+R search support for fish: use fzf
sudo apt install fzf
mkdir -p ~/.config/fish/functions/
echo fzf_key_bindings > ~/.config/fish/functions/fish_user_key_bindings.fish
... however I should consider using ZSH.
PoP OS Gnome Extensions and Apps
For smart clipboard history. Use Super+Shift+V for toggling menu. Middle click close windows on activities overview as Cinnamon does this. Custom hot corners: because the default configuration is sad after Cinnamon. Hide Top Bar: it's also not in there by default.
Open as root option to nautilus:
sudo apt install nautilus-admin
After install run nautilus -q
.
Chrome from repo:
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/chrome.list
sudo apt-get update
sudo apt-get install google-chrome-stable
DEB file install
To change the default application for a file extension, just Right Click -> Properties -> Open With.
If you are in the same directory where the deb file is located, use it like this: ref
sudo apt install ./deb_file.deb
Networking
# nmap is a network tool to scan open ports, guess systems.
sudo apt install nmap
# Scan local network for other devices
nmap -sP 192.168.0.1/24
### Network Utils
# detailed, current flow
nethogs
# generic how much traffic is going through
vnstat
# list open ports
sudo netstat -tnlp
Register SSH key passphrase on a trusted computer
... so you only have to type it in once.
if [ ! -S ~/.ssh/ssh_auth_sock ]; then
echo "'ssh-agent' has not been started since the last reboot. Starting 'ssh-agent' now."
eval "$(ssh-agent -s)"
ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
fi
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
# see if any key files are already added to the ssh-agent, and if not, add them
ssh-add -l > /dev/null
if [ "$?" -ne "0" ]; then
echo "No ssh keys have been added to your 'ssh-agent' since the last reboot. Adding default keys now."
ssh-add
fi
NVidia GPU
List GPU settings with nvidia-smi
Persistence mode
From the Docs: Under Linux systems where X runs by default on the target GPU the kernel mode driver will generally be initalized and kept alive from machine startup to shutdown, courtesy of the X process. On headless systems or situations where no long-lived X-like client maintains a handle to the target GPU, the kernel mode driver will initilize and deinitialize the target GPU each time a target GPU application starts and stops. In HPC environments this situation is quite common. Since it is often desireable to keep the GPU initialized in these cases, NVIDIA provides two options for changing driver behavior: Persistence Mode (Legacy) and the Persistence Daemon.
VSCode
sudo apt-get install wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg
sudo apt update
sudo apt install code
Environmental variables
Look under dropbox_private/redacted/env.bashrc
Extend it with export
each line, and copy it to .bashrc
Setting up fish
run: export (cat env_file.txt |xargs -L 1)
File Watchers
Linux has a pretty low default file watcher limit in the OS, here is how you can change that (useful for vscode or any dev envs)
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
HDD-SSD fix
When a drive is mounted in "read only" - it may get fixed by running:
sudo fsck.ext4 -f /dev/sda1
Sound
DeaDBeeF Media Player
DeaDBeeF is my goto player as it resembles much to FooBar from back in my windows days. Found the repo here.
sudo add-apt-repository ppa:starws-box/deadbeef-player
sudo apt-get update
sudo apt-get install deadbeef
Simple Path Column: $directory_path($substr(%path%, 22, $len(%path%)))
Open containing folder script :
PulseAudio
Volume control gui for
sudo apt install pavucontrol
Fix Windows file endings
sed -i 's/\r$//' filename*
or
sudo apt install dos2unix
dos2unix *.sh
Crontab
To run a script and export it to the active terminal every minute:
* * * * * python3 clock/clock.py > /dev/tty1 2>&1
The 2>&1
makes sure that both stderr
and stdout
gets out.
When appending a log file, use >>
instead of >
- like this:
* * * * * cd /home/pi/dev/scraper/ && ts-node src/scraper.ts >> cache/debug.log 2>&1
Mind that the relative paths may not work when using sudo crontab -e
Context Menu - open folder in VSCode in Nautilus
code-nautilus - uses python nautilus
wget -qO- https://raw.githubusercontent.com/harry-cpp/code-nautilus/master/install.sh | bash
less
Just remember: less is more
.
Ctrl C, PgUp, PgDwn to navigate
Shift + F => tail -f
G => Jump to front
Shift G => Jump to end
& => filter
/ => search
N => Next result
Shift + N => Previous result
Q => Quit
Random output in hex
/dev/random | xxd
Random Password Generation
cat /dev/random | base64 | head
Verbose for Any comment
Just add -v -vv or -vvv
to any command
How to tell the Version of a lib
Use apt policy.
sudo apt-cache policy <package-name>
Find
How to find a file in the file system? Do not show the permission denied errors:
find /path/to/search -name "filename" 2>/dev/null
Terminal chatGPT
Want access to chatGPT without a browser? tgpt!
curl -sSL https://raw.githubusercontent.com/aandrew-me/tgpt/main/install | bash -s /usr/local/bin
tmux
You can have terminal tabs using tmux
sudo apt install tmux
Hotkeys
CTRL + B C
- Create tab
CTRL + B N
- Next tab
CTRL + B %
- Split window horizontally
CTRL + B [Space]
- Layout switch
CTRL + B [Arrow]
- switch active window
When GDM freezes
sudo systemctl restart gdm
If the X ate all your memory, or became laggy, on Gnome systems you can usually do the command:
ALT+F2 R ENTER
- which will restart the window manager.
File Manager
Midnight Commander is the two-pane editor of choice in the terminal. However Double Commander is a good Total Commander alternative, it's almost the same UI and it has the mass rename tool!
sudo add-apt-repository ppa:alexx2000/doublecmd
sudo apt update
sudo apt install doublecmd-gtk
Services
How to see what services are running?
systemctl list-units --type=service --state=running
How to find where is the runner for a service?
systemctl status service_name
Bluetooth devices
List them all:
sudo hcitool dev
Debugging Linux Apps
You ever wondered what are the system calls an app makes? You can log this using a tool named strace
An example we used to debug what command line arguments does VSCode uses in a specific scenario:
strace -ff -s 2048 -e trace=process code &> /tmp/code.log
Where -s 2048
sets the buffer size so that it does not truncate long lines.
Then from code.log
you can dig out what you need with less
, or if you know what you are looking for and you know that it's going to be in one line, you can pipe it through grep:
strace -ff -e trace=process code 2>&1 | grep "command-line-tool-vscode-launches"
Analyzing the time needs of processes to boot
This will list the services and their boot needs on linux based systems, so you can optimize boot speeds.
systemd-analyze plot > chain.svg
Fingerprint Reader for X1 Carbon gen 4 - Mint
Driver for Validity Sensors, Inc. VFS7500 Touch Fingerprint Sensor By default, no fingerprint driver is available for this model, a few lines will enable the custom driver:
sudo cat > /etc/apt/sources.list.d/libfprint-vfs0090.list << EOF deb http://ppa.launchpad.net/3v1n0/libfprint-vfs0090/ubuntu focal main deb-src http://ppa.launchpad.net/3v1n0/libfprint-vfs0090/ubuntu focal main EOF
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys BE6CFC9508199102F68B6F683166F0E44FB01EAB
sudo apt-get update sudo apt-get install libfprint-2-tod-vfs0090 libpam-fprintd sudo apt-mark hold libfprint-2-tod-vfs0090
Add finger:
fprintd-enroll
Enable auth in
pam-auth-update
Tick the right methods for your use case!
Hard Drive usage
See what's taking so much space!
df -h
-> what's the percentages of different devices?
ncdu -x -q
-> actual disk analyzation tool: show the folders with their respected sizes.
Debug Bash
bash -x script_name
Writes out, what runs line by line. Useful to debug any bash code, like environmental issues.
DisplayLink: USB Display driver
git clone https://github.com/AdnanHodzic/displaylink-debian.git
cd displaylink-debian
sudo ./displaylink-debian.sh
linux
network
fish
nmap
node
nvm