Skillnad mellan versioner av "Generic-cli"

Från wiki.soltec.se
Hoppa till: navigering, sök
(added ssh info)
Rad 131: Rad 131:
 
  Shift+P    | to sort processes as per CPU utilization
 
  Shift+P    | to sort processes as per CPU utilization
 
  Shift+O    | to Sort field via field letter
 
  Shift+O    | to Sort field via field letter
 +
 +
== SSH ==
 +
Here are two links to great sites that explain SSH, Public & Private Keys, SSH-AGENT etc.
 +
  # https://developer.github.com/v3/guides/using-ssh-agent-forwarding/
 +
  # http://www.unixwiz.net/techtips/ssh-agent-forwarding.html

Versionen från 21 oktober 2019 kl. 12.26

Disks/PV/VG/LV info

Display a more readable output of disks/vols/mountpoints on Linux

  # lsblk -i

Physical Volumes

  # pvscan
  # pvdisplay

Volume Groups

  # vgscan
  # vgdisplay
  # vgchange
  # vgrename
  # vgs

Logical Volumes

  # lvscan
  # lgscan
  # lvdisplay
  # lvchange
  # lvs
  # lvresize
  # lvextend
  # lvreduce
  # lvrename

Rename Root Vol

To change the root vol name, boot from a bootable ISO or CDROM
Login and run the following

# vgrename <old-vg> <new-vg>

Mount the root disk & required sub filesystems

# mount /dev/<new-vg> /mnt
# mount --bind /proc /mnt/proc/
# mount --bind /sys /mnt/sys/
# mount --bind /dev /mnt/dev/
# mount /dev/sda1 /mnt/boot/
# chroot /mnt

Edit the fstab and grub files

# sed -i 's/<old-vg>/<new-vg>/g' /etc/fstab
# sed -i 's/<old-vg>/<new-vg>/g' /etc/default/grub

Use grub2-mkconfig

# grub2-mkconfig -o /boot/grub/grub.cfg

Create new kernel initramfs/initrd image file using a specific kernel version.

# dracut --force --kver <choose kernel vers>

Tips! Run <uname -r > to show the active kernel version or check for different versions in </boot> for required kernel name.

Use the following to check content of new initramfs/initrd image

List entire content
# lsinitrd <path-to-image>
View a specific file from the image file
# lsinitrd -f /etc/fstab <path-to-image>

unmount chroot & reboot

# umount -f /mnt
# shutdown -h now

Remove cdrom/ISO and reboot.

RPM

Find out what pkg a file belongs to

  # rpm -qf <path-to-file/cmd>

Find out if a file was installed as part of a pkg

  # rpm -ql /usr/liblibXp.so.6

Display system-wide config files for a cmd

  # rpm -qcf /bin/bash

Check contents of RPM

  # rpm -qlp RPMTOPDIR/RPMS/x86_64/<name-of-pkg>.rpm

To view different architecture version of a pkg

 # rpm -q --queryformat "%{name}.%{arch}\n" pdksh-5.2.14-36.el5

GREP

grep for soltec in start of line

  # grep ^"soltec"

grep for soltec at end of line

  # grep "soltec"$

YUM

to install all pkgs in listed in file

  # yum install $(< test.txt) 
  # yum -y install $(cat list)

Display history

  # yum history
  # yum history info
  # yum history list

VI

 dG	delete from line to end of file
 d1G	delete to top including current line
 dgg	delete from line to start of file
 G   goto last line in file
 1G	to to first line in file
 0	goto start of line
 $	goto end of line
 :set number	 <--to display line numbers
 :color desert  <--to change display colours


Copy/Move data

To move data on the same system, use the following:

  # cd dir1 && tar -cf - . | (cd dir2 && tar -xpvf -)
  dir1 is the directory you want to copy.
  dir2 is the directory in which you want the copy to go.
  This tar’s the current directory to STDOUT, then changes directory, and untar’s the archive without ever having to find the space for a .tar file.

Use the following to do this across systems via ssh:

  # cd dir1 && tar -cf - . | ssh system2 "cd dir2 && tar -xpvf -"

RSYNC/RSYNCD

Use rysncd instead of rsync to use resources on the target system copying the data instead of source server

TOP

The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel.

Usage:
top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]

Using cli

# top
# top –u dbuser     | option will display specific User process details
# top -n 1 -b > top-output.txt     | save the running top command results output to a file
# top -n 10     |automatically exit after 10 number of repetition.

TOP interactive console

h          |help screen
z          |highlight processes in red
c          |display absolute path of running process
k          |kill a process after finding PID
d          |change default screen refresh interval  default= 3 seconds
Shift+P     | to sort processes as per CPU utilization
Shift+O     | to Sort field via field letter

SSH

Here are two links to great sites that explain SSH, Public & Private Keys, SSH-AGENT etc.

  # https://developer.github.com/v3/guides/using-ssh-agent-forwarding/
  # http://www.unixwiz.net/techtips/ssh-agent-forwarding.html