Skip to content

spabinger/server-cheat-sheet-know-how

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 

Repository files navigation

:: TOC ::

Cron
Docker
IPMI
IPTABLES
LXC
Network
Resources/Misc
Screen
SSH
Visudo
ZFS

:: Update Server ::

https://help.ubuntu.com/lts/serverguide/installing-upgrading.html do-release-upgrade


:: Cron ::


:: Network ::


IPTABLES

  • List IPTABLES
    iptables -S
    iptables -L

  • IPTABLES Links
    https://help.ubuntu.com/community/IptablesHowTo

  • Portforwardings settings
    Rules are set in /etc/rc.local

  • Portforwarding: show current setup
    iptables -t nat -v -L -n --line-number

  • Portforwarding: set rule
    iptables -t nat -A PREROUTING -i br0 -p tcp -m tcp --dport PORT -m comment --comment "COMMENT" -j DNAT --to-destination xxx.xxx.xxx.xxx:PORT
    Example:
    iptables -t nat -A PREROUTING -i br0 -p tcp -m tcp --dport 10002 -m comment --comment "My-LXC" -j DNAT --to-destination 10.0.0.10:22

  • Portforwarding: Delete rule (use line number)
    https://www.cyberciti.biz/faq/how-to-iptables-delete-postrouting-rule/
    iptables -t nat -D PREROUTING 3

:: Disks ::

  • Display block devices
    blkid -o list

  • Display all disks

parted
print all


:: ZFS ::

  • List all zfs-folders/zfs-volumes
    zfs list

  • Status of zpool
    zpool status

  • Export zpool (unmount)
    zpool export <zpoolname>

  • Remove/destroy
    zpool destroy <zpoolname>

  • Show snapshots
    zfs list -t snapshot

  • Volumes

zfs list -t volume
Volumes are listed here: /dev/zvol/tank/

  • Custom ZFS list
    zfs list -o name,mountpoint,mounted,my.custom:property

  • Zpool not showing
    openzfs/zfs#6077

zpool import <storage>   <- name of the storage
Docker not starting?
> zpool export <poolname>
> service docker stop (just for safety)
> mv var/lib/docker /var/lib/docker_bak
> zpool import <poolname>
> service docker start


:: Docker ::

docker run 
-d         detach
--name     Name of the container
--restart  Automatically restart the container -  no, always
-p         Ports
-v         Bind a volume

creates and starts a container

sudo nano /lib/systemd/system/docker.service 
    Add the dns after ExecStar. --dns 10.252.252.252 --dns 10.253.253.253 
    Should look like that: ExecStart=/usr/bin/dockerd -H fd:// --dns 10.252.252.252 --dns 10.253.253.253

systemctl daemon-reload
sudo service docker restart
1) stop the container 
2) change the file /var/lib/docker/containers/[hash_of_the_container]/hostconfig.json
3) restart your docker engine (to flush/clear config caches)
4) start the container
  • Problem restarting with network issue
docker network ls
docker network disconnect -f <networkname>
docker network rm <networkname>

moby/moby#20398

https://www.thomas-krenn.com/de/wiki/IPMI_Grundlagen https://help.ubuntu.com/community/IPMI https://www.thomas-krenn.com/de/wiki/IPMI_Konfiguration_f%C3%BCr_Supermicro_Systeme https://www.thomas-krenn.com/de/wiki/Softwaretools_f%C3%BCr_IPMI_im_%C3%9Cberblick

  • Read sensors (other way):
    /usr/sbin/ipmimonitoring

  • Read the SEL - system error log:
    ipmitool sel list
    or
    /usr/sbin/ipmi-sel

  • Clear the SEL
    ipmitool sel clear
    or /usr/sbin/ipmi-sel --clear

  • List sensor IDs
    /usr/sbin/ipmimonitoring --entity-sensor-names

:: Switch ::

Dell 5500

"Although they can work in small EQL (and other iSCSI) SAN networks they should be seen as campus-access switches and not as SAN switches." https://en.wikipedia.org/wiki/Dell_PowerConnect#5500_series


:: KVM ::

kvm list machines: virsh list --all
kvm shutdown: virsh shutdown vm-name
kvm shutdown: connect to the machine via ssh and type "init 0"
kvm start: virsh start vm-name


:: LXC ::

lxc-create -t download -n my-container
-- enter the distribution
-- enter the release
-- enter the architecture
lxc-start -n my-container -d
lxc-attach -n my-container
lxc-stop -n $NAME
cd /var/lib/lxc
tar --numeric-owner -czvf container_fs.tar.gz $NAME
rsync -avh container_fs.tar.gz user@newserver:/var/lib/lxc/
rsync -avPrh -e "ssh -p 10009" folder user@SERVER:/DEST/

:: Services ::

  • List all running services
    service --status-all


:: Visudo ::

sudo visudo Be aware that adding a user to the sudo group overrides the entries in sudoers


:: SSH ::


:: Resources / Misc ::

Add vers=3.0 if 'Mount error(5):Input/output error on mount'
//ADDRESS	/mnt/xy	cifs	credentials=.mycreds,uid=1000,gid=1000,vers=3.0	0	0

:: RSYNC ::

  • Use only limited bandwith:
    rsync --bwlimit=<kb/second> <source> <dest>

:: FIO (IO Performance testing ::

:: Useful information ::

  1. Move to the previous directory - We all use cd .. to move to move to an upper directory. You can also use cd - to move to the previous directory - just like a back button.
test@linoxide:~/Downloads$ cd -
 /home/xy
test@linoxide:~$ cd -
 /home/xy/Downloads
  1. Repeat your last command - To replay as the previous command, just type !!
$ apt install vlc
 E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
$ sudo !!
 sudo apt install vlc
  1. Keep executing a command until it succeeds - use the exit code of the command directly. The command kept running until it found run.sh and printed out its content.
$ while ! ./run.sh; do sleep 1; done
cat: run.sh: No such file or directory
linoxide.com
  1. View progress of file transfers In Linux, you cannot really know the rate of a file transfer progress until it's done. Using the pv command, you can monitor the progress of file transfers.
$ pv access.log | gzip > access.log.gz
 611MB 0:00:11 [58.3MB/s] [=> ] 15% ETA 0:00:59
  1. Easily schedule events Using the at command, you can easily schedule events at anytime.
echo wget https://sample.site/test.mp4 | at 2:00 PM
To view the queued jobs, type 
atq
  1. Display at output as a table When you use the ls command or other commands to throw outputs, they are often very long and need scrolling. You can easily display all the outputs in a table form using the column -t command.
$ cat /etc/passwd | column -t
  1. Keyboard Tricks
  • The clear command clears the terminal screen with a blank one. Pressing Ctrl + L on your keyboard does the same thing, but faster.
  • To go through previous commands, press Alt + . .
  • Ctrl + U clears the content you've typed already. Try this when you want to clear the password field in the command line.
  • To reverse search your command history, press Ctrl + R
  1. Compress, split and encrypt files Trying to transfer large files across computers is a tedious task. We can easily do this by compressing the files and creating a multi-part archive if the files are extremely large. To encrypt, we add the -e switch.
$ zip -re test.zip AdbeRdr11010_en_US.exe run.sh Smart_Switch_pc_setup.exe
 Enter password:
 Verify password:
 adding: AdbeRdr11010_en_US.exe (deflated 0%)
 adding: run.sh (stored 0%)
 adding: Smart_Switch_pc_setup.exe (deflated 2%)
  1. Stress test your battery - Try this command:
$ cat /dev/urandom > /dev/null
  1. Renaming/moving files with suffixes - If you want to quickly rename or move a bunch of files with suffix, try this command.
$ cp /home/sample.txt{,-old}
This will translate to:
$ cp /home/sample.txt /home/sample.txt-old
To rename files of a particular extension in batch, try this:
$ rename 's/comes_here_/goes_there/' *.txt

Releases

No releases published

Packages

No packages published