How-to:
nvidia-smi
error after system update- Add directory to the $PATH
- Allow IP-address
- Allow
sudo
commands and write permissions - Calculator
- Clear out Git history
- Create user
- Change Desktop and Login managers
- Change password
- Change SSH Port
- Check Linux version
- Coral USB Accelerator
- Delete package
- Delete user account
- End user session
- Errors
- Exclude packages from
sudo apt upgrade
- Find file by name
- Find files owned by the user
- Install deb file
- Jupyter clear output
- Jupyter notebook via remote server
- Kill the tty
- List all environment variables
- List installed packages
- Lock screen
- Lock screen time
- Manage software updates
- Mount USB
- Open console
- Open image in Midnight Commander
- Restart system
- Run scripts on start up
- Set environment variable
- Show the model of the computer
- Static IP address
- Switch language hotkey
- System info and benchmarks
- Take screenshot
- Update system packages
- Upgrade Ubuntu from 22.04 to 24.04
- View computer resources
- View disk usage
- View screen resolution
- View temperature sensors
- Who is logged in
Sometimes, there is nvidia-smi
error after system update:
Failed to initialize NVML: Driver/library version mismatch
NVML library version: 550.120
nvidia-smi
# Failed to initialize NVML: Driver/library version mismatch
# Check the kernel version used by the graphics card driver
cat /proc/driver/nvidia/version
# Remove the Nvidia Driver
sudo apt purge nvidia-*
sudo apt purge libnvidia-*
# The output of the following command should be empty
dpkg -l | grep -i nvidia
# Find available driver versions
ubuntu-drivers devices
# Reinstall the correct (recommended) driver
sudo apt install nvidia-driver-550
# Or automatically install the recommended version driver
#sudo ubuntu-drivers autoinstall
# Restart the system
sudo reboot
# Verify the issue is fixed
nvidia-smi
Deprecated info:
- for DL3 server reinstall nVidia drivers again.
- for DL4 server Nvidia driver installation.
# For the local current user
nano ~/.profile
# export PATH="/path/to/dir:$PATH"
source ~/.profile
# For the local current user
nano ~/.bashrc
# Add the following line to the bashrc file:
# export PATH="/path/to/dir:$PATH"
# Run bashrc file to effect changes.
source ~/.bashrc
# Temporary addition
export PATH="/path/to/dir:$PATH"
# Permanently add to PATH for ALL users
sudo nano /etc/environment
# Edit the file. Make sure that the path is something like this:
# PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/ASAP/bin"
# Run environment file to effect changes.
. /etc/environment
It is possible, that your IP-addres get into black list
of /etc/hosts.deny
file.
Check log file for failed attempts and delete all logs with user attempts:
cat /var/log/auth.log | grep -n username
cat /var/log/auth.log | grep -n ip-address
sudo nano -c /var/log/auth.log
Add IP-mask to the /etc/hosts.allow
file.
Secondly delete you IP-address from /etc/hosts.deny
file.
# Edit /etc/hosts.allow file
sudo nano /etc/hosts.allow
Add the something like this:
# Use this address to calculate the mask:
# http://jodies.de/ipcalc?host=80.94.164.1&mask1=24
ALL : 80.94.164.0/24
ALL : 80.94.162.0/24
ALL : 80.94.171.0/24
Make sure that your IP-addres is not in the blacklist of /etc/hosts.deny
file.
Actually IP-address can re-appear after several minutes, but if it was excepted in
/etc/hosts.allow
file, then SSH connection should work anyway.
To search in the nano
editor. Ctrl + W
is the shortcut for searching.
The same effect can be achieved by pressing the F6
key.
After entering the search term, press Enter
.
To repeat the search, issue Alt + W
.
In this menu, you can select earlier searches using the arrow up/down keys.
To toggle backwards searching, you need to press Alt + B
in the search dialog.
For more shortcuts, press F1
.
cat /etc/hosts.deny | grep -n "80.94." # -n - show line numbers
# Delete IP-address if necessary
sudo nano -c /etc/hosts.deny # -c - show line numbers
How-to allow sudo
commands and write permission into system directories
Set default group upon file modification and creation.
Make sure new files are owned by the default group,
set g+s
and set the default permissions to read, write and execute.
sudo chgrp -R mygroup /dir/path # 1st option
#sudo chown -R :mygroup /dir/path # 2nd option
sudo chmod -R g+s /dir/path # set default group
sudo chmod -R g+rwx /dir/path # 1st option
#sudo setfacl -d -m g::rwx /dir/path # 2nd option
# check it
ls -hal
gnome-calculator &> /dev/null
Steps to clear out the history of a git/github repository.
# Remove history from Git directory
rm -rf .git
# Recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
# Push to the github remote repos ensuring you overwrite history
git remote add origin https://github.com/foobar167/articles
# Or try this: git remote add origin [email protected]:<YOUR ACCOUNT>/<YOUR REPOS>.git
# Or try this: git remote add origin https://github.com/USERNAME/REPOSITORY.git
# But try it from the beginning (rm -rf .git, etc.)
git push -u --force origin master
- Create user with GUI
Press <Super>
(<Win>
) key and type Users.
Users and groups window with Users Settings will open
Click Add button to add new user.
- Create user via console
Press <Ctrl>+<Alt>+<T>
and open console window.
# Show list of all users
cat /etc/passwd
# or
cut -d: -f1 /etc/passwd
# Show list of all goups
cat /etc/group
# To create user with questions, directory and sceleton files
sudo adduser username
# Add existing user to the group
sudo adduser username groupname
# or without questions, dir and files (not recommended)
#sudo useradd username
# To delete user
sudo deluser username
# or (not recommended)
#sudo userdel username
# Delete directory
#sudo rm -r /home/username # use with caution!
# To delete user from a group
sudo deluser username groupname
# Change user name
usermod -l new_username old_username
# Change user password
sudo passwd username
# Change shell for a user
sudo chsh username
# Change user detailes (name, phone, etc.)
sudo chfn username
# Create group
sudo addgroup groupname
# Add existing user to the group
sudo usermod -a -G groupname username
Enable or disable the user account:
sudo adduser tempuser # create temporal user
sudo usermod -L tempuser # disable user account
sudo usermod -U tempuser # enable user account
sudo deluser tempuser # delete user
sudo rm -r /home/tempuser # use with caution!
cat /etc/group | grep temp # check
ls /home | grep temp # check
# If error: "userdel: user tempuser is currently used by process 1864"
sudo kill -9 1864 # kill the process
sudo deluser -f tempuser # try again
More info on how to backup and delete deprecated user accounts.
Links:
- Install LXDE Desktop
- Change The Default Display Manager
- 5 login managers and how to change the one you use
Set LXDE desktop and LXDM login manager.
sudo apt install lxde
sudo apt install lxdm
sudo dpkg-reconfigure lxdm
sudo reboot now
# After reboot terminal login by default. To change on GUI press:
# <Ctrl>+<Alt>+<F7>
Change Password from GUI
Click the system menu at the top right corner, select your user name and click on Account Settings menu.
Users window will open.
On the Users window select Password.
Enter current password. Enter new password, verify new password once again and click on Change button.
Change Password from Command Line
Open console and enter passwd
.
Type current password, type new password and retype new password.
passwd
Changing password for lab225.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
lab225@deeplab3:~$
# To change other users password
sudo passwd username
How to Change SSH Port in Ubuntu 24.04
Changing the SSH port on Ubuntu 24.04 differs from that on Ubuntu 22.04 and older.
Since Ubuntu 22.10, the SSH daemon (sshd) uses socket-based activation, which means that the traditional method of changing the port in /etc/ssh/sshd_config is no longer sufficient. In addition, you need to modify the socket configuration to specify the new port using the ListenStream directive.
sudo apt install -y openssh-server # install SSH
sudo systemctl status ssh # verify
#sudo systemctl enable ssh
#sudo systemctl start ssh
#sudo ufw allow ssh
#sudo ufw enable
#sudo ufw status
sudo ss -tuln # show sockets
#sudo ss -tuln | grep ':2222'
# Change the SSH socket port
sudo nano /lib/systemd/system/ssh.socket
# Change ListenStream from 22 to 2222
ListenStream=2222
sudo systemctl daemon-reload # reload the systemd daemon
# For Ubuntu < 22.10
sudo nano /etc/ssh/sshd_config
# Change #Port 22 to 2222
Port 2222
sudo systemctl restart ssh # restart the SSH service
sudo ufw allow 2222/tcp # enable 2222 port
sudo ufw delete allow 22/tcp # desable 22 port
sudo iptables -A INPUT -p tcp --dport 2222 -j ACCEPT
sudo iptables -D INPUT -p tcp --dport 22 -j ACCEPT
#sudo iptables-save > /etc/iptables/rules.v4
# Use `-p` flag to specify SSH port number
ssh [email protected] -p 2222
How to check operating system version in Linux command line
# Find OS name and version
cat /etc/os-release
lsb_release -a
hostnamectl
# Find kernel version
uname -r
# Find Linux distribution
lsb_release -cs
# Even more options
cat /proc/version
cat /etc/issue
Get started with the USB Accelerator
For Ubuntu 22.04 with system Python 3.10 use instruction below:
# Add package repository to the Ubuntu 22.04:
echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt update
# Install the Edge TPU runtime (standard, not maximum package):
sudo apt install libedgetpu1-std
# Reconnect the USB Accelerator to your computer using the provided USB 3.0 cable.
# This command doesn't work for Ubuntu 22.04:
# sudo apt-get install python3-pycoral
# Use Conda virtual environment with Python 3.9. Download and install wheel files:
wget https://github.com/google-coral/pycoral/releases/download/v2.0.0/pycoral-2.0.0-cp39-cp39-linux_aarch64.whl
wget https://github.com/google-coral/pycoral/releases/download/v2.0.0/tflite_runtime-2.5.0.post1-cp39-cp39-linux_aarch64.whl
pip install tflite_runtime-2.5.0.post1-cp39-cp39-linux_aarch64.whl
pip install pycoral-2.0.0-cp39-cp39-linux_aarch64.whl
# Download the example code from GitHub:
mkdir coral && cd coral
git clone https://github.com/google-coral/pycoral.git
cd pycoral
# Download the model, labels, and bird photo:
bash examples/install_requirements.sh classify_image.py
# Run the image classifier with the bird photo:
python examples/classify_image.py \
--model test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \
--labels test_data/inat_bird_labels.txt \
--input test_data/parrot.jpg \
--top_k 3 \
--count 15
# In the file `classify_image.py` change `Image.ANTIALIAS` on `Image.LANCZOS`.
# Results should be like this:
# ----INFERENCE TIME----
# Note: The first inference on Edge TPU is slow because it includes loading the model into Edge TPU memory.
# 11.8ms
# 3.0ms
# 2.8ms
# 2.9ms
# 2.9ms
# -------RESULTS--------
# Ara macao (Scarlet Macaw): 0.75781
# Remove package
sudo apt remove packagename
# Remove user data and configuration files
sudo apt purge packagename
# Remove unused dependences
sudo apt autoremove
# Clean
sudo apt clean
# Or do this
sudo apt purge --auto-remove packagename
See Backup and delete deprecated user accounts in the web-site section.
killall -user username # end all processes for the user
pkill -u username
kill -9 -1 # end all processes you can
Various errors on Ubuntu system.
The following upgrades have been deferred due to phasing:
This is not an error.
Ignore it. Or explicitly install them with
sudo apt install
command.
libdvd-pkg:
apt-get checkfailed, you may have broken packages. Aborting...
# Reinstall and re-run the package
sudo apt install libdvd-pkg
sudo dpkg-reconfigure libdvd-pkg
Read how to exclude packages from apt-get upgrade
# Using apt
sudo apt-mark hold package_name
sudo apt-mark unhold package_name
# Using dpkg
echo "package_name hold" | sudo dpkg --set-selections
echo "package_name install" | sudo dpkg --set-selections
# Using aptitude
sudo aptitude hold package_name
sudo aptitude unhold package_name
# List packages on hold
sudo dpkg --get-selections | grep "hold"
How to search files from the terminal on Linux 14 Practical Examples of Linux Find Command for Beginners
locate
command
The reason for this unmatched speed is that the locate
command isn't actually searching your local hard disks
for the files or directories that you need to find, but more like reads through the mlocate.db
database file which contains all file paths in your system.
sudo apt install locate # install locate tool
sudo updatedb # update the mlocate.db database before first use
locate $HOME/*.py # search for Python files in the $HOME dir
locate -c $HOME/*.py # count Python files in the $HOME dir
locate -ic $HOME/*.py # count Python files and ignore case
# Example
sudo updatedb
locate -ic Home
1491350
locate -c Home
3
locate Home
/etc/gufw/Home.profile
/usr/share/man/man3/FcConfigEnableHome.3.gz
/usr/share/man/man3/FcConfigHome.3.gz
find
command
The “find” command is a much more powerful but also slower searching utility.
Contrary to the locate
command, find
actually searching your disks for the files
and directories that the user is after.
find
can search for files that belong to a certain user or group of users,
files that were modified or accessed recently, files that of a specific size range,
hidden files, executables, read-only files, and files with certain permissions.
find / -name "*name*" 2> /dev/null # search in / root directory (everything)
find / -iname "*name*" 2> /dev/null # ignore case
# Search in $HOME dir for Python files bigger than 1MB of size.
find ~/ -size +1M -iname "*.py" 2> /dev/null
# Search for Python files bigger than 700 kB of size.
find / -iname "*.py" -and -size +700k 2> /dev/null
# This does not work and I donot why: find / -iname "*.py" -and -size +700k -and -size -1M 2> /dev/null
# BUT this works for Ubuntu 18.04 :-) Note: 1M vs 1000k
find / -iname '*.py' -and -size +700k -and -size -1000k 2> /dev/null
find ~/ -cmin -3 2> /dev/null # changed less than 3 minutes ago
find ~/ -ctime -3 -iname "*.png" 2> /dev/null # changed less than 3 days ago
find ~/ -amin -3 2> /dev/null # accessed less than 3 minutes ago
find ~/ -atime -3 -iname "*.png" 2> /dev/null # accessed less than 3 days ago
find . -iname "*.jpg" | wc -l 2>/dev/null # count JPG files in the local dir
Find all the files owned by a particular user / group
How to find files by users vivek
and wendy
# Match files only
find / -type f -user vivek -o -user wendy
# Match dirs only
find / -type d -user vivek -o -user wendy
sudo dpkg -i my.deb
If there are broken dependences:
sudo apt --fix-broken install
# and then
sudo dpkg -i my.deb
When you open a large Jupyter Notebook, the browser crashes link.
jupyter nbconvert --clear-output --inplace filename.ipynb
- How to run a jupyter notebook through a remote server on local machine
- How to connect to a remote Jupyter notebook server
Open 2 console terminals
# In the 1st terminal: login to the server,
# start your virtual environment, and run jupyter notebook
ssh [email protected] -p 22 # login
conda activate python3.12 # activate virtual env
jupyter notebook # default port 8888
# or
jupyter notebook --no-browser --port=8892
# In the 2nd terminal: 8891 - local port, 8892 - server port
ssh -NL localhost:8891:localhost:8892 [email protected] -p 22
# Enter URL in the local browser
localhost:8891
# or copy-paste the URL with token from the 1st console if required
http://localhost:8891/tree?token=23969122fd30a51a7b210dde6255313ed425e8af6aa42a6d
# but with local port 8891 instead of 8892
Note: better use the default port 8888 everywhere.
# Show who is logged in
who
username :1 2018-12-22 17:11 (:1)
username pts/7 2018-12-24 10:54 (178.120.33.235)
username pts/9 2018-12-24 12:17 (178.120.33.235)
# Get the PIDs
ps -ft pts/7
UID PID PPID C STIME TTY TIME CMD
username 25058 25057 0 10:54 pts/7 00:00:00 -bash
root 26850 25058 0 11:09 pts/7 00:00:00 su admin
admin 26859 26850 0 11:09 pts/7 00:00:00 bash
admin 26878 26859 0 11:09 pts/7 00:00:00 mc
# Use the PIDs to kill the processes
kill 25058 26850 26859 26878
-bash: kill: (26859) - Operation not permitted
-bash: kill: (26878) - Operation not permitted
# If the process doesn't gracefully terminate,
# forcefully kill it by sending a SIGKILL
kill -9 26859 26878
# or
kill -SIGKILL 26859 26878
printenv # list all or part of environment
env # list all or run a program in a modified environment
# or
printenv | less
# or
printenv | more
A list of the commonly used variables in Linux
sudo apt list --installed
sudo apt list --installed | less
sudo apt list --installed | grep -i nvidia
sudo dpkg -l
sudo dpkg -l | grep -i nvidia
To lock your screen press keys <Ctrl>+<Alt>+<L>
.
If it does n't work then press keys <Win>+<L>
or
(<Super>+<L>
).
Also click on the System icon in the top right corner of the screen and select Lock Screen icon/menu.
From console type:
# Lock the screen
gnome-screensaver-command -l
When your screen is locked, and you want to unlock it,
press <Esc>
, or swipe up from the bottom of the screen
with your mouse. Then enter your password, and press
<Enter>
or click Unlock.
Alternatively, just start typing your password and the lock
curtain will be automatically raised as you type.
Open Settings → Privacy → Screen Lock:
Launch Menu --> Preferences --> Software & Updates
Use sheet "Other Software" to manage repositories for updates. Use sheet "Updates" to manage updates check.
Also check file /etc/apt/sources.list
and directory /etc/apt/sources.list.d
which containes list of sources to update Ubuntu 18.04.
Manage PPA via console. When update with command sudo apt update
,
some PPA has been removed and no longer exist and ther is an error:
Err:5 https://dl.yarnpkg.com/debian stable InRelease
The following signatures were invalid: EXPKEYSIG 23E7166788B63E1E Yarn Packaging <[email protected]>
# Delete the expired key
sudo apt-key del 23E7166788B63E1E
# Delete the PPA for yarn
sudo rm yarn.list
# Clean the local repository and remove unnecessary packages
sudo apt clean
sudo apt autoclean
sudo apt autoremove
# Update the packages again
sudo apt update
By default, storage devices that are plugged into the system
mount automatically in the /media/<username>
directory.
Press <CTRL>+<ALT>+<T>
keys or press <Win>
key and enter terminal
.
Set ImageMagick as default Jpeg viewer for Midnight Commander.
Edit ~/.config/mc/mc.ext
file.
Note that editing /etc/mc/mc.ext
sets the system-wide configuration.
In MC press F9 -> Command -> Edit extension file
.
The View
command is used when F3
is pressed.
The Open
command is used when Enter
is pressed.
To use geeqie
as Jpeg viewer for MC set Open=geeqie %f
.
type/^JPEG
Open=geeqie %f
#Open=display %f
View=%view{ascii} /usr/lib/mc/ext.d/image.sh view jpeg
Include=image
sudo reboot now
# force reboot
sudo reboot -f
sudo systemctl reboot
There are several ways to run scripts on start up:
- systemd (
man systemd.service
) - SysV (
man update-rc.d
). System V init (also known as classic init). - Add script to
/etc/rc.local
file. - cron (
man cron
) - Use
~/.config/systemd/
or/.config/autostart/
directories for user sessions. Only after user login.
For Ubuntu 14.04 and older one can use Upstart.
1. Create systemd
unit files. Links:
- How to run scripts on start up
- Writing unit files
- systemd.service - Service unit configuration
- systemd.service - Service unit configuration. Copy
Create /etc/systemd/system/slide_analysis_api.service
containing:
[Unit]
Description=uWSGI instance to serve slide_analysis_api
After=network.target
[Service]
User=malyshevvalery
Group=www-data
WorkingDirectory=/home/malyshevvalery/Slide_Analysis
Environment="PATH=/home/malyshevvalery/Slide_Analysis"
ExecStart=/home/malyshevvalery/Slide_Analysis/venv/bin/uwsgi --ini /home/malyshevvalery/Slide_Analysis/slide_analysis_api.ini
[Install]
WantedBy=multi-user.target
Then run:
# Add slide_analysis_api to autorun
sudo systemctl daemon-reload
sudo systemctl enable slide_analysis_api.service
You can run multiple commands from the same service file,
using multiple ExecStart
lines:
[Service]
ExecStart=/some/command
ExecStart=/another/command some args
ExecStart=-/a/third/command ignore failure
The command must always be given with the full path.
If any command fails, the rest aren't run.
A -
before the path tells systemd to ignore a non-zero exit status
(instead of considering it a failure).
2. Create script file /etc/init.d/myscript.sh
. Run the commands:
# To add use
sudo update-rc.d myscript.sh defaults # default run levels are: 2,3,4 and 5
# To remove use
sudo update-rc.d -f myscript.sh remove
More info:
- Part 1: How to config service to autostart after crash or reboot
- Part 2: How to config service to autostart after crash or reboot
- How to Enable or Disable Services in Ubuntu Systemd/Upstart
- How can I configure a service to run at startup
3. Edit the file /etc/rc.local
.
sudo nano /etc/rc.local
Add commands, but make sure that the line exit 0
is at the end.
If command runs continuously (in an infinite loop) or is likely not to exit,
you must be sure to fork the process by adding an ampersand &
to the end
of the command, like so:
python3 /home/pi/myscript.py &
❗ Add ampersand &
otherwise, the script will not end
and the system will not boot. ❗
The ampersand allows the command to run in a separate process and continue booting with the process running.
4. One approach is to add an @reboot cron task:
- Running
crontab -e
will allow you to edit your cron. - Adding a line like this to it:
@reboot /path/to/script
will execute that script once your computer boots up.
5. For user sessions, you can create the systemd unit in
~/.config/systemd
instead. This should work with 16.04 onwards,
but not earlier releases of Ubuntu with systemd
(since those still used Upstart for user sessions).
User session units can be controlled with the same commands
as with system services, but with the --user
option added:
systemctl --user daemon-reload
systemctl --user status foo.service
A shell script named .gnomerc
in your home directory is automatically
sourced each time you log in to a GNOME session. You can put arbitrary
commands in there; environment variables that you set in this script
will be seen by any program that you run in your session.
Note that the session does not start until the .gnomerc
script
is finished; therefore, if you want to autostart some long-running program,
you need to append &
to the program invocation,
in order to detach it from the running shell.
The menu option System -> Preferences -> Startup Applications allows
to define what applications should be started when your graphical session starts
(Ubuntu predefines quite some). This has almost the same purpose and scope
of the .gnomerc
script, except you don't need to know sh
syntax
(but neither can you use any sh
programming construct).
PYTHONPATH=/usr/lib/python3/dist-packages/caffe
export PYTHONPATH
# The first line will be product name.
sudo lshw | grep product
# or
sudo dmidecode -t system
sudo dmidecode -s bios-release-date # show release date
sudo dmidecode -s baseboard-product-name # show product name
sudo dmidecode -s baseboard-manufacturer # show manufacturer
# Install GUI application
sudo apt install xsysinfo
xsysinfo &
Ubuntu Static IP configuration
The simplest approach on how to configure a static IP address on Ubuntu Desktop is via GNOME graphical user interface.
- Open network settings Ubuntu Desktop.
- Click on the settings icon to start IP address configuration.
- Select IPv4 tab.
- Select manual and enter your desired IP address, netmask, gateway
and DNS settings. Once ready click
Apply
button. - Turn OFF and ON switch to apply your new network static IP config settings.
- Click on the network settings icon once again to confirm your new static IP address settings.
Configure static IP address on Ubuntu server via networkd
daemon.
Open /etc/netplan/
directory. There is a default netplan configuration file
called 50-cloud-init.yaml
or 01-network-manager-all.yaml
.
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
ens9f0:
addresses:
- ××.××.×××.××/24
gateway4: ××.××.×××.1
nameservers:
addresses: [8.8.4.4,8.8.8.8,××.××.×××.2,××.××.×××.3]
# Once ready apply changes with
sudo netplan apply
# In case you run into some issues execute
sudo netplan --debug apply
On Ubuntu 18.04 the default shortcut is <Win>+<Space>
.
<Win>
key is also called <Super>
key.
Instructions for Ubuntu 18.04 LTS with Gnome desktop from Gnome Tweaks.
# Install Gnome Tweaks
sudo apt-get install gnome-tweaks
# Open Gnome Tweaks
sudo gnome-tweaks &
- Open Gnome Tweaks (
gnome-tweaks &
). - Select Keyboard & Mouse tab
- Click Additional Layout Options button
- Expand Switching to another layout menu
- Select checkbox Alt+Shift there
Links:
- Khadas Edge2 Pro review – A Rockchip RK3588S SBC tested with Ubuntu 22.04
- Thomas Kaiser sbc-bench script. The small set of different CPU performance tests focuses on 'headless' operation only (no GPU/display stuff, no floating point number crunching).
- Browser benchmark with Speedometer 2.0.
- How to benchmark your Ubuntu Linux servers with the Phoronix Test Suite
- Phoronix Test Suite HowTo
Show system parameters:
cat /etc/lsb-release
uname -a
free -mh
df -mh
# Install and run inxi command line tool
# sudo apt install inxi
sudo inxi -Fc0
# Linux monitor
# sudo apt install htop
htop
ps -aux | grep X # list processes with `X`
View CPU load and temperature sensors here.
Run some Linux console benchmarks:
# CPU default to the performance governor
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
# sbc-bench.sh from Thomas kaiser
# wget https://raw.githubusercontent.com/ThomasKaiser/sbc-bench/master/sbc-bench.sh
sudo /bin/bash ./sbc-bench.sh -r # or "-c" for shorter tests
Phoronix Test Suite:
# Install Phoronix Test Suite
# sudo apt install phoronix-test-suite
# or
# wget https://phoronix-test-suite.com/releases/repo/pts.debian/files/phoronix-test-suite_10.8.4_all.deb
# sudo dpkg -i ~/Downloads/phoronix-test-suite_10.8.4_all.deb
# To fix broken dependencies
sudo apt --fix-broken install
# or
# sudo apt install -f
# Install OPTIONAL but recommended extensions
sudo apt install php-gd bzip2 sqlite3 curl
# Check installation
phoronix-test-suite version
phoronix-test-suite
# List tests compatible with your OS
phoronix-test-suite list-recommended-tests
# List all available tests
phoronix-test-suite list-available-tests
# List the tests by group
phoronix-test-suite list-available-suites
# Run the Numpy test suite (or pts/machine-learning)
phoronix-test-suite info numpy 2>&1 | less # show info in the terminal
sudo phoronix-test-suite install numpy # install necessary software
phoronix-test-suite run numpy # run benchmark suite
# Use `benchmark` to install and run
phoronix-test-suite benchmark numpy # install and run in 1 command
# Show info about some other tests
phoronix-test-suite info tensorflow-lite stress-ng
Run some stress tests:
sudo apt install stress
stress --help # show options
stress --cpu 8 --io 4 --vm 4 --vm-bytes 256M --hdd 4 --hdd-bytes 1024M --timeout 10s
# Stress-ng is an updated implementation of Stress tool
sudo apt install stress-ng
How to take a screenshot on Ubuntu 18.04
Press <Win>
key on the keyboard and enter screenshot
.
Or enter in console gnome-screenshot&
, but this works only in Gnome.
Screen shot application will appear.
- Flameshot GUI
sudo apt install flameshot # install Flameshot
flameshot gui # start it
There is an icon on the panel menu after flameshot gui
is started.
- Kazam (Flameshot tool is better)
sudo apt install kazam # install Kazam
kazam & # start it in background mode
sudo apt update
# sudo apt dist-upgrade
sudo apt upgrade
# If message: `The following packages have been kept back`
sudo apt install <list of packages kept back>
- How to Upgrade from Ubuntu 22.04 LTS to Ubuntu 24.04 LTS
- How to Upgrade Ubuntu 22.04 to 24.04 LTS: A Complete Guide
Step 1: Back Up Your Important Data
# Copy Home dir
#rsync -a –progress /home/your_username /path_to_backup_location/home_backup
# Backup system config files
sudo rsync -a –progress /etc /path_to_backup_location/etc_backup
# Backup list of all installed packages
dpkg --get-selections > /path_to_backup_location/package_list.txt
# To reinstall all packages type
#sudo dpkg –-set-selections < package_list.txt
#sudo apt-get dselect-upgrade
Step 2: Upgrade All the System Packages
sudo apt update && sudo apt upgrade -y
sudo reboot
Step 3: Prepare TCP Port 1022
During the upgrade process, various services and configurations may be restarted or reloaded, including the SSH daemon. If something goes wrong during these operations, having an additional port configured can help to avoid losing remote access to the server.
sudo ufw allow 1022/tcp
sudo ufw reload # reload to apply the rule
sudo ufw status
Step 4: Upgrade from Ubuntu 22.04 LTS to Ubuntu 24.04 LTS Version
sudo apt-get install ubuntu-release-upgrader-core
sudo do-release-upgrade -d
Step 5: Verify Proper and Finish
# Verify upgrade
lsb_release -a
cat /etc/os-release
# Close 1022 port
sudo ufw delete allow 1022/tcp
# Uncomment and remove the # sign at the beginning
# of each line for each repository
ls -l /etc/apt/sources.list.d/
sudo apt autoremove ––purge
If too many packages are kept back
The following packages have been kept back
ignore them or try this commands
sudo apt dist-upgrade
sudo apt --fix-broken install
sudo dpkg --configure -a
sudo apt-get -f install
# Install Full Update
sudo apt update
sudo apt full-upgrade
Note: durint update choose
N or O : keep your currently-installed version
to keep your configuration files.
If error Failed to fetch http://archive.ubuntu.com/ubuntu/dists/noble/InRelease Could not resolve 'archive.ubuntu.com'
# Add a DNS server to the system
sudo apt install systemd-resolved
#sudo systemctl start systemd-resolved.service
#sudo systemctl enable systemd-resolved.service
sudo systemctl status systemd-resolved.service
To remove message from sudo apt upgrade
Get more security updates through Ubuntu Pro with 'esm-apps' enabled
cd /etc/apt/apt.conf.d/
sudo mkdir -p apt_relocated_backup
sudo mv 20apt-esm-hook.conf apt_relocated_backup/
# Check
sudo apt upgrade
- GPU
# View NVIDIA resources
nvidia-smi
# or in non-stop mode (exit with Ctrl+C)
watch -n 0.5 nvidia-smi
- CPU
# Check memory and CPU usage per process
top
- HTOP
HTOP is a lightweight text-mode process viewer packed with handy features such as killing processes without entering their PID, displaying full command lines, etc with a colour display.
# Install HTOP interactive processes viewer
sudo apt install htop
# Run it
htop
# To quit press F10 or <Q> key.
- System monitor GUI
Press <Super>
or <Win>
key, type "system monitor".
Run Gnome System Monitory from command line:
# Run Gnome System Monitor in background
gnome-system-monitor &
- Show system status
systemctl status
Navigate with arrow keys and
<Home>
, <End>
, <Page Up>
, <Page Down>
keys.
Exit with <Q>
key.
- Memory usage
# Display memory usage in MBs
free -m
# Read /proc/meminfo file
cat /proc/meminfo
# Memory usage statistics
vmstat -s
- Hardware info
# DMI table decoder
sudo dmidecode
# Show BIOS info
sudo dmidecode -t bios
Show disk usage or directory size
gnome-disks& # open disks utility in background mode
# Disk Usage Analyzer - view only bootable disk
sudo apt install baobab # install it
baobab& # launch it
df -h /home/
sudo du -sh /home 2> /dev/null
# Show directory size
du -sh /home/username 2> /dev/null
# View all account sizes
for ACCOUNT in $(ls /home); do
du -sh /home/$ACCOUNT 2> /dev/null
done
# Show all partitions usage on disks
df -h $(ls /dev/sd[a-z][1-9])
You can list all the attached disks on your computer from Ubuntu
using the lsblk
command.
sudo lsblk
# Hide loop (-e7) and CD/DVD (-e11) devices
sudo lsblk -e7 -e11
# List attached disks with their vendor and model information
sudo lsblk --scsi
xrandr
or open System Settings → Display. There you'll see a Resolution drop-down menu.
#Install lm-sensors
sudo apt install lm-sensors
# After installation type the following in terminal
sudo sensors-detect
# You may also need to run
sudo service kmod start
# It will ask you few questions. Answer Yes for all of them.
watch -n 2 sensors # press <Ctrl>+<C> to exit
# To see HDD temperature Install hddtemp
sudo apt install hddtemp
sudo hddtemp /dev/sda /dev/sdb /dev/sdc
# Use psensor tool
sudo apt install psensor
psensor
# Use conky tool
sudo apt install conky
conky &
# Use hardinfo
sudo apt install hardinfo
hardinfo &
who