Friday, January 24, 2020

Can I install Virtualization software ex VirtualBox

So you want to run VMs.  You want to use VirtualBox, Qemu or others. Before you install any virtualization software on your *nix box you need to determine whether or not the CPU will support it.

lscpu command


lscpu  displays info about CPU architecture, includes flags








Intel CPU

If you have an Intel CPU the vmx flag indicates that it can support Intel VT technology, if you don't find it your CPU cannot support virtualization.

$ grep vmx   /proc/cpuinfo

AMD  CPU

If you have an Intel CPU the svm flag indicates that it can support AMD-V technology, if you don't find it your CPU cannot support virtualization

$ grep svm   /proc/cpuinfo

You can combine the two, using extended regex

$ grep -E "svm|vmx"   /proc/cpuinfo

Tuesday, November 8, 2016

Job scheduling with cron (edit crontab)

Cron is a job scheduling subsystem for linux. It is used for scheduling repeating jobs. If you wish to schedule a one shot job use the at subsystem.

All users on a linux box may set up cron jobs provided they are allowed by the administrator: root. Restrictions to cron are applied by modifying a combination of /etc/cron.allow and /etc/cron.deny.

On most Linux distributions there is also a system level cron configuration, that is not covered here.

Setup

First

Using your favourite editor create a cron file with a line for each job you wish to schedule, in the format:

m h d m w command

  • m minute 
  • h hour 
  • d day of month 
  • m month 1-12 
  • w weekday 0-7, Sun,Mon, etc (Sunday = 0 = 7) 
  • command the command you want to run

It is easy to remember if you think of the way one would say a date: Wednesday, July 29, at 10:30, then reverse the order.

For example, this is new.crontab:


Second

Use crontab to load your file (this informs the cron daemon (crond) about it), note it will overwrite any existing crontab file so make sure you have everything you want.


Experts, who are not afraid of VIM

You don't need to use another file you can just use crontab -e to edit  the existing crontab.

Test cron jobs

Set up a cron job to write the date to a file in your home directory, schedule it to run every 10 minutes:

After about  20 minutes tail the file, it should have put a date stamp every 10 minutes (hour, hour+10, hour +20 etc.)

If you leave it there it will keep going FOREVER, so you may want to get rid of it: crontab -r



My original post was in wikihow: https://www.wikihow.com/Set-up-a-Crontab-File-on-Linux  Someone keeps changing the screenshots and putting up incorrect information so I moved it here.

Wednesday, February 3, 2016

Using VI

Using VIM (originally VI)  Visual Improved Text Editor


VIM or VI is the de facto text editor for all Unix systems.

This post is for those who want to learn how to use VI.  I am not going to get into VI vs Emacs or any other religious wars such as Linux vs Windows etc.  The simple fact is that any Unix box you use will have VI installed so knowing at least the basics will help you in a pinch (or when your system is floundering you can rescue it.)

Start Here

Essential Commands (short quick ref for VIM)

ESC   - change to command mode. The following commands will then work:
:q!      - quit without saving
:wq    - write changes then quit
i         - insert mode (enter text)
dd      - delete one line
yy      - copy current line
p        - paste last copied /deleted line
R       - replace until ESC is hit
r         - replace one character
/text   - locate the string text search forward in the file (then n for next)

Other VIM Resources

Thursday, October 29, 2015

Fun things to do with telnet

Because it's almost useless, except for port probing...
Telnet is an old client server TCP/IP protocol that allows for clear text remote access to a shell. Because everything is sent in clear text it is really no longer used, instead we use ssh client and server.

(You can do this on any Linux box and if you must use windoze there is nothing I can do to stop you)
The protocol still exists and can be used for sh1ts and giggles:

Open a terminal and type the highlighted part:

NYAN Cat!
telnet nyancat.dakko.us

ASCII Star Wars (an IPV6 version is available too) (You can see the same thing via a web browser here http://www.asciimation.co.nz/)
telnet towel.blinkenlights.nl 

BOFH Excuse Engine, don't forget the 666,:
telnet towel.blinkenlights.nl 666



If you want to try some old BBS & MUDs  there are a few here http://www.telnet.org/htm/places.htm
and here http://www.telnetbbsguide.com/   or ask google.

Tuesday, April 22, 2014

Somebody attacking your ssh daemon??

sshd[5948]: Failed password for root from 116.10.191.220
sshd[5948]: Failed password for root from 116.10.191.220
sshd[5948]: Failed password for root from 116.10.191.220

You can stop this easily with iptables rules.  The following two rules limit connection attempts on port 22 to maximum 4 every 90 minutes, if you get more attempts they will be dropped.



iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent \
  --set
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent \
  --update --seconds 90 --hitcount 4 -j DROP

  1. First line: any NEW connections to port 22 over TCP use the recent module to keep track of the IP address; the -m recent --set takes care of this. 
  2. Second line: -m recent --update checks if the IP address of the incoming connection is in the recent list. The --seconds and --hitcount limit the match to within 90 seconds and 4 tries.
i.e.. Drop if: IP address previously in recent list AND IP address has tried to make a NEW connection within the last 90 minutes AND IP address has tried more than 4 times.

 Stops that nasty traffic!

ref: http://www.debian-administration.org/articles/187

Wednesday, April 18, 2012

tell SELinux to calm down & get out of the way

DO NOT DO THIS on an internet facing computer, this is only for crash and burn Linux boxen that you are testing in your lab and changing rapidly.

This applies to RedHat, Fedora or CentOS.  When you are in a test lab or even just trying different configurations for your server SELinux can get in your way. It may block what you are trying to do without notice or it may pop up several notices telling you that it is doing so. Either way it can be painful to test or change service configurations with it in full blown enforcing mode. So to make it less intrusive you may do the following (as root or sudo of course):
  1. Edit /etc/sysconfig/selinux with your favourite text editor
  2. You should see 
  3. Change the line SELINUX=enforcing to read
    SELINUX=permissive
  4. Save the file
  5. Reboot
That's it.  It will now log the information but not block your changes.  Of course once you are ready to go live, put it back!

To see the current status
CLI:  sestatus

By the way if you want to toggle it off and on temporarily:
CLI:  setenforce Permissive
or
CLI:  setenforce Enforcing

Friday, October 14, 2011


I am at heart a C programmer, this is sad.  One of the fathers of C hence Unix and so the grandfather of Linux has died.

DMR Denis M. Ritchie 1949-2011



Google+ post by Rob Pike
techcrunch.com