Linux: Difference between revisions

From Piszczynski
piszczynski>Aleks
No edit summary
piszczynski>Aleks
No edit summary
Line 34: Line 34:
Other newer option is xserver-xorg-core
Other newer option is xserver-xorg-core


== Change or Set IP address ==





Revision as of 18:45, 9 September 2023

Basic Commands

Copy

Copy a file:

  • cp <file> <Destination>

copy multiple files

  • cp <file1> <file2> <Destination>

Prevent overwriting: (will overwrite files by default)

  • cp -n <source> <dest> (can also use -i option to decide for each file)

Copy directory:

  • cp -r <source> <destination>

Copy contents of directory to another directory:

  • cp <source>/. <destination>


Get Linux Info

Get current build and Linux OS data:

  • cat /etc/os-release

Remote Desktop Protocol App for linux

Remmina can be used for RDP connections to windows computers using RDP as well as VNC SSH and others


To user also need to install xrdp and tightvnc:

  • sudo apt install xrdp xorgxrdp -y
  • echo env -u SESSION_MANAGER -u DBUS_SESSION_BUS_ADDRESS cinnamon-session>~/.xsession

Other newer option is xserver-xorg-core


Change or Set IP address

Swap File

Check size of swap file:

  • swapon -s

increase swap file to 8GB:

  • sudo swapoff -a #turn off swap file
  • sudo dd if=/dev/zero of=/swapfile bs=1M count=8192 #set size of blocks for swap file and create
  • sudo chmod 0600 /swapfile #Assign it read/write permissions for root only
  • sudo mkswap /swapfile #Format the file as swap
  • sudo swapon -a #enable swap file - will also be activated on next reboot without this command


Alternate commands to make 8GB swap file

  • sudo swapoff /swapfile
  • sudo rm /swapfile
  • sudo fallocate -l 8G /swapfile

App Image

Apps can be downloaded as an appimage which is the application with everythign it needs to run in one file.

You will need to make the appimage executable to be able to run it:

  • chmod u+x <appimage file>

SSH

Enable SSH

Install openssh server:

  • sudo apt-get install openssh-server

login.

Enable login using ssh Keys

Generate keys: Be careful if you have already generated a key as this will overwrite the current key

  • ssh-keygen

This gets stored in ~/.ssh

Copy key to server (must have ssh via password enabled)

  • ssh-copy-id name@server

This gets sored on remote server in ~/.ssh/authorized_keys file. you can append keys to this fille to add more logins:

  • cat ~/.ssh/id_rsa.pub | ssh name@server "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Copy over manually:


Check public key

  • cat ~/.ssh/id_rsa.pub

Make dir:

  • mkdir -p ~/.ssh

copy key over:

  • echo <public_key_string> >> ~/.ssh/authorized_keys

Disable Password Authentication

Edit config file:

  • sudo nano /etc/ssh/sshd_config

Change:

  • PasswordAuthentication no

Restart ssh service:

  • sudo systemctl restart ssh