To add desktop entry to any executable, for example Appimage, Bash script, Python script...:
Allow the file to be executed, with command:
chmod +x <APP/SCRIPT_NAME>
or do this via graphical interface in Nautilus: Right click -> Properties -> Permissions -> Allow executing file as program
In Terminal navigate to /usr/share/applications/:
cd /usr/share/applications/
In that folder create new file with the .desktop extension:
sudo gedit <APP/SCRIPT_NAME>.desktop
Add the following to that file, but don't forget to change first four lines after [Desktop Entry]:
[Desktop Entry]
Name=<APP/SCRIPT_NAME>
Exec=<PATH_TO_APP/SCRIPT>
Icon=<PATH_TO_ICON_FILE>
StartupWMClass=<APP/SCRIPT_NAME>
Encoding=UTF-8
Type=Application
StartupNotify=false
Terminal=false
OnlyShowIn=Unity;GNOME;
X-UnityGenerated=true
Save the file
NAVIGATING THROUGH THE FILE SYSTEM
To change directory to root:
cd /
To go to user's Home directory, just type:
cd
To go one step back, to the parent directory of the directory you are currently in:
cd ..
As well you can go multiple steps back, for example, three steps back:
cd ../../..
To list all the files and directories in the current directory:
ls
To list all the files and directories in the current directory and to view it as a list with information about who owns it with what rights:
ls -l
or just:
ll
To list files and directories in the time order (newest ones will be in the top):
ls -lt
To print files and directories in the time order (newest ones will be at the bottom):
ls -ltr
("l" stands for list, "t" for time, "r" for reverse)
To print working directory (to tell us in which directory we are currently)
pwd
To schedule computer shutdown in certain number of minutes (30 in the following example):
shutdown +30
To schedule computer shutdown at certain time:
shutdown 15:30
To cancel scheduled shutdown:
shutdown -c
To shutdown computer immidiately:
shutdown now
To reboot computer immidiately:
reboot
Type the following command to edit /etc/hostname using nano text editor:
sudo nano /etc/hostname
Delete the old name and set up a new name.
Next Edit the /etc/hosts file:
sudo nano /etc/hosts
Replace any occurrence of the existing computer name with your new one.
Reboot the system to changes take effect:
sudo reboot
Display current Ubuntu hostname by running the command:
hostname
You can try the command line tool update-alternatives:
sudo update-alternatives --config python
If you get the error "no alternatives for python" then set up an alternative yourself with the following command:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
Change the path /usr/bin/python3 to your desired Python version accordingly.
To generate public and private SSH key, navigate to .ssh/ folder in the Terminal:
cd ~/.ssh
and type the command:
ssh-keygen -t ed25519 -C "<comment_or_email>"
in the command above "ed25519" is the signing algorithm and it doesn't have to be that one (Ed25519 is an elliptic curve signing algorithm using EdDSA and Curve25519) but it is recommended by GitLab and GitHub.
To add currently active Git branch to be displayed in the Terminal, add to the ~/.bashrc the following lines of code (open bashrc with the command: sudo gedit ~/.bashrc):
# Add currently active Git branch name to the Terminal
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;33m\]\$(git_branch)\[\033[00m\]\$ "
After the code is added and changes to the file are saved, run command (or restart the PC):
source ~/.bashrc
To check if you are currently in Xorg or Wayland session, type this in the Terminal:
echo $XDG_SESSION_TYPE
If the output is x11 you are in Xorg session, and if the output is wayland, you are in Wayland session.
For this, you need upower that usually comes with Ubuntu, so no need to install it.
Run
upower -e
to list devices. After the devices are listed, see the information about the device by running the upower -i <device _address>
For example:
upower -i /org/freedesktop/UPower/devices/battery_BAT0
If multiple SSH keys are generated and present in the ~/.ssh folder, create a config file in that folder. In that file set what key is used for what service. The file should be in the following format:
Host <NAME_IT>
HostName <ADDRESS>
User <USERNAME>
IdentityFile ~/.ssh/<PRIVATE_KEY>
Host <NAME_IT>
HostName <ADDRESS>
User <USERNAME>
IdentityFile ~/.ssh/<PRIVATE_KEY>
After setting up and saving the file, log out the user and log back in.
To make the live image of a Linux distribution on Debian/Ubuntu, follow the steps:
Open the Terminal and become root with:
sudo -i
List devices with:
lsblk
and see what is the name of the device that you want to use (e.g. sda)
If mounted, unmount the stick with:
umount /dev/sd<XY>
Use DD command to copy files:
dd if=</path/to/linux.iso> of=</dev/sdX> bs=16MB