CommandReference

Linux Version?


What linux version do yo run?


 $ lsb_release -a

or

 $ cat /etc/os-release

or

 $ uname -a

Linux Commandline Reference


cheat Alternatief voor Man pages


  • Install:
  $ sudo snap install cheat

Just some reminders, often to be applied on a new Linux system


SSH Password Less Login Creating SSH keys and copy .Pub key to remote server


  • Check if keys exist:
  $ ls -l ~/.ssh/id_*.pub
  • Generate new key pair:
   $ ssh-keygen -t ed25519 -C "your_email@example.com"

  $ ssh-keygen -t rsa -b 4096 -C "your_email@domain.com"
  • Copy the public key to the remove server:
  $ ssh-copy-id <remote_username>@<server_ip_address>
  • Login to your server using SSH keys:
  $ ssh <remote_sername>@<server_ip_address>

Set Time Zone


https://askubuntu.com/questions/3375/how-to-change-time-zone-settings-from-the-command-line


Install and Enable OpenSSH server on Ubuntu


See this: https://linuxhint.com/install-enable-openssh-ubuntu-22-04/

  • Step 1: System Update
  $ sudo apt update && sudo apt upgrade
  • Step 2: Install OpenSSH
  $ sudo apt install openssh-server
  • Step 3: Enable OpenSSH
  $ sudo systemctl enable --now ssh
  • Step 4: Evaluate OpenSSH Status
  $ sudo systemctl status ssh
  • Step 5: Connect to SSH Server
  $ ssh username@ip-address/hostname
  • Step 6: Disabling OpenSSH
  $ sudo systemctl disable ssh --now

To add a new user to Linux


  • Add User by Using Command Line;

$ sudo adduser paul

  • Verify our newly added user in our system

$ id paul

  • Grant User Sudo Privileges

$ sudo usermod -aG sudo paul

  • or via

$ sudo useradd -m paul -G sudo

  • Let’s check all the available users, and to do that, you will have to run this command:

$ less /etc/passwd

'''


SS & NETSTAT


Analysing network activity #1 - netstat, ss and lsof https://www.net7.be/blog/article/network_activity_analysis_1_netstat.html(goedkeuren URLs)


Install SSHFS Mounting Remote File Systems with SSHFS


  • install the SSHFS application;
  $ sudo apt install sshfs
  • go to Mount d(/mnt) directory:
  $ cd /mnt
  • create directory to be shared:
  $ sudo mkdir [share] 
  • set personal user priv to share directory:
  $ sudo chown <username>:<groupname>  [share]

SSH Welcome/Warning at login prompt /etc/issue and etc/issues.net


Both /etc/issue.net and /etc/issue are used to display a banner (e.g. welcome line/ warning..) to SSH users before the login prompt:

/etc/issue.net is shown to the users who connect from the network. /etc/issue is shown to both local users and network users unless /etc/issue.net is present and configured. Also, to configure them to be displayed when you login via SSH, you need to uncomment #Banner and specify the desired filename at /etc/ssh/sshd_config, like:

Banner /etc/issue.net

The filename /etc/issue.net is the historical location for pre-login banners for network logins using protocols like telnet or rlogin. Some Unix vendors had a version of telnetd, rshd and/or rlogind that used /etc/issue for network logins too; others made it configurable like sshd does now.

Banner Generator: https://patorjk.com/software/taag/#p=display&f=Graffiti&t=Type%20Something%20

Any other MOTD messages can be found in folder: /etc/update-motd.d/ ...

How to Disable MOTD banners on Ubuntu:


Change Hostname on Ubuntu via CLI (No Reboot)


https://phoenixnap.com/kb/ubuntu-20-04-change-hostname


Change Console Font Size


 $ sudo nano /etc/default/console-setup
  • Find the lines for FONTFACE and FONTSIZE.
  • Set FONTFACE="Terminus" (or FONTFACE="TerminusBold" for bold).
  • Choose a size from the available options (e.g., FONTSIZE="16x32"). Valid sizes for Terminus include 6x12, 8x14, 8x16, 10x20, 12x24, 14x28, and 16x32.
  • for example:

ACTIVE_CONSOLES="/dev/tty[1-6]"
CHARMAP="UTF-8"
CODESET="guess"
FONTFACE="Terminus"
FONTSIZE="16x32"
SCREEN_WIDTH="80"

* Apply the changes:
(Run the following command in the terminal to activate the new font settings or restart)\\:

 $ sudo setupcon
  • (Optional) Verify the font: You can use the showconsolefont command to see the character set for the active font.
 $ showconsolefont

Environment-Variables in Linux



How to set all locale settings in Ubuntu?


A remote installed application has some encoding problems and on my local machine it is running fine. What is the best way to "copy" my locales to the remote machine? The locales on my personal machine are configured like this:

$ locale

 LANG=de_DE.UTF-8
 LANGUAGE=de_DE:en
 LC_CTYPE="de_DE.UTF-8"
 LC_NUMERIC=en_US.UTF-8
 LC_TIME=en_US.UTF-8
 LC_COLLATE="de_DE.UTF-8"
 LC_MONETARY=en_US.UTF-8
 LC_MESSAGES="de_DE.UTF-8"
 LC_PAPER=en_US.UTF-8
 LC_NAME=en_US.UTF-8
 LC_ADDRESS=en_US.UTF-8
 LC_TELEPHONE=en_US.UTF-8
 LC_MEASUREMENT=en_US.UTF-8
 LC_IDENTIFICATION=en_US.UTF-8
 LC_ALL=

You can set locale manually using update-locale:

$ sudo update-locale LANG=de_DE.UTF-8 LC_MESSAGES=POSIX

 (Read the man page for more information)

Alternatively, you can manually change your system's locale entries by modifying the file /etc/default/locale. For example, on a German system, to prevent system messages from being translated, you may use:

  LANG=de_DE.UTF-8
  LC_MESSAGES=POSIX

How to check what DNS Server is active on Linux? (debian based)


You can install several DNS utilities by:

  • $ sudo install dnsutils

Look what DNS is active via:

  • $ cat /etc/resolv.conf (zonder e er achter!)

To look at the actual status of the DNS, use:

  • $ resolvectl (not on Raspberry)

For users of NetworkManager, you can also check the DNS server through the command line using nmcli:

  • $ nmcli dev show | grep 'IP4.DNS'

How to check if an attached SSD device is SATA or PCIe on Linux?


  • This will identify all the block devices, i.e., drives:

$ lsblk -io NAME,TYPE,SIZE,MOUNTPOINT,FSTYPE,MODEL

  • where X is each drive letter found. If the result contains SATA, well, it's the SATA drive:

$ sudo hdparm -I /dev/sd*X* | grep SATA

  • Alternatively you can use, this will identify all the PCI devices, including PCIe;

$ lspci

  • You can use 'lshw' , it will show disk type in the description field;

$ lshw


Disable IPv6 on Raspberry Pi OS /etc/issue and etc/issues.net


  • Change to the /boot directory. If you’re logged in to your raspberry, you can: $ cd /boot
  • If you still have the SDcard in your PC, the /boot partition is the one that’s visible on the card. Use notepad.exe to edit cmdline.txt. In LINUX, you need to edit /boot/cmdline.txt as follows: $ sudo nano /boot/cmdline.txt

console=serial0,115200 console=tty1 root=/dev/sda1 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles

  • and now just add ”ipv6.disable=1″ to the end of the line, so it looks something like this:

console=serial0,115200 console=tty1 root=/dev/sda1 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles ipv6.disable=1


CRONTAB?


$ crontab -l (list) $ crontab -e (edit)

  # Output of the crontab jobs (including errors) is sent through
  # email to the user the crontab file belongs to (unless redirected).
  # 
  # For example, you can run a backup of all your user accounts
  # at 5 a.m every week with:
  # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
  # 
  # For more information see the manual pages of crontab(5) and cron(8)
  # 
  # m h  dom mon dow   command  


  # ----------------------------------
  # Send email at every Job
  # ----------------------------------
  MAILTO=notify@conzult.nl


  # ----------------------------------
  # Backup ALPHA everyday at 10:01 in 
  # the morning
  # ----------------------------------
  # m h dom mon dow   command
  1 10 * * * /home/xxxxx/_backupme/backupnow.sh


  # ----------------------------------
  # Log every reboot in text file 
  # systemrebooted.log
  # ----------------------------------
  @reboot date >> /home/xxxxx/systemrebooted.log

How to Start Ubuntu in Text Mode


How to Start Ubuntu in Text Mode

On Ubuntu, text mode means booting without the graphical desktop (X/Wayland) and getting a TTY login prompt.

1. Temporary (for the next boot only)

You can stop the graphical session after boot:

sudo systemctl isolate multi-user.target

Or, if you want it from boot but only this time:

  1. At the GRUB menu, highlight your Ubuntu entry.
  2. Press e to edit.
  3. Find the line starting with linux and replace quiet splash with text.
  4. Press Ctrl+X or F10 to boot.

This won’t persist after a reboot.

2. Permanent (always boot to text mode)

Change the systemd default target:

sudo systemctl set-default multi-user.target

Then reboot:

sudo reboot

To get back to the GUI later:

sudo systemctl set-default graphical.target

3. With older GRUB approach (legacy way)

Edit /etc/default/grub:

sudo nano /etc/default/grub

Find:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

Change it to:

GRUB_CMDLINE_LINUX_DEFAULT="text"

Update GRUB:

sudo update-grub

Reboot.


If you want to boot into text mode but still start the desktop manually when needed, run:

sudo systemctl start graphical.target

WATCH



Tools & Utilities:


awk* sudo apt install awkawk
batcat* sudo apt install batbatcat viewer
mc* sudo apt install mcmidnight commander
cmatrix* sudo apt install cmatrixcmatrix screensaver
nmap* sudo apt install namp
netcat* sudo apt install netcat
dnsutils* sudo apt install dnsutils
cifs-utils* sudo apt install cifs-utils
htop* sudo apt install htop
iftop* sudo apt install iftop
btop* sudo apt install btop
net-tools* sudo apt install net-tools
curl* sudo apt install curl
lshw* sudo apt install lshwList Hardware
ipcalc* sudo apt install ipcalc
wget* sudo apt install wget
neofetch* sudo apt install neofetch
wireguard* sudo apt install wireguard
remina* sudo apt install remmina
draw.io*
ntpsec* sudo apt install ntpsecntpq / ntptrace
terminus* sudo apt install terminusterminus
telix* sudo apt install tilixtilix
cool retro term* sudo apt install cool-retro-termCoolRetroTerm
Mosquitto MQTT Clients* sudo apt install mosquitto-clientsMosquitto MQTT client package
Pagina laatst gewijzigd op 25 September 2025 om 21:18
Powered by PmWiki