Using crontab
Crontab is a utility found on Linux and UNIX that allows you to schedule repetitive tasks on your system, like backups, updates, etc.
The crontab command manages a table containing specially formatted lines of text which is processed periodically by the system. Each line consists of a “schedule” followed by one or more commands to be processed at the scheduled time.
If you want to use the vim, emacs or nano editor for editing cron jobs, then, set the following in your environment and in your ~/.bash_profile file:
Ansible Cheatsheet
Ping all hosts:
$ ansible all -i hosts -m ping
Ping a specific host:
$ ansible raspberry-pi -m ping
Check uptime on all hosts:
$ ansible -m shell -a 'uptime' all
Check uname on all hosts:
$ ansible -m shell -a 'uname -a' all
Run playbook on more than one host:
$ ansible-playbook playbook1.yml -l 'host1.com,host2com'
Mounting an ISO Image as a File System
If you need to get one or more files from an ISO image and don’t have a CD/DVD drive you can mount the ISO image to a directory and navigate to the file(s) you need using a terminal or file explorer. You’ll have to do this as root.
# mkdir /mnt/iso# mount -o loop -t iso9660 /home/user/Downloads/Custom-Build/custom.iso /mnt/isomount: /mnt/iso: WARNING: source write-protected, mounted read-only.# cd /mnt/iso/# lsDateBuilt System/ boot/ boot.catalog efi.img initrd linux mach_kernel slint.txt#
Using sSMTP on Slackware 15.0
How to Install and Use ssmtp to Send Emails from the Linux Terminal
ssmtp is a simple utility that can be used to send emails from a Linux system to a specified email address. It is just an MTA (Mail Transfer Agent); it does not receive mail, expand aliases, or manage a queue. Instead, it forwards automated emails to an external email address. This can be useful for forwarding system alerts or other automated emails from your system to an external email address.
How To Get Information on Linux
The manpages are historically the place to go for any information about the software and utilities installed on a Linux machine. I believe that the info page seems to be the best place for newbies to go because it is so much easier to navigate, and, like manpages, it is a still a great place to get information about your system.
Suppose you want to get information about socket. You would type:
Locking Down SSH User Access
To secure your system, you shouldn’t allow root to login remotely. Instead, if an admin needs to use the root account they should login using their own account and then su - or sudo to the root account as needed.
Edit the /etc/ssh/sshd_config file and change the following lines:
PermitRootLogin noPermitEmptyPasswords no
Some of these properties may be commented out in the file, so all you’d need to do is remove the # sign.
Make a File Immutable
You can use the chattr command (as root) to make a file “unalterable” so that even the root user cannot modify or delete it without using the chattr command to revert the change. This is done by using chattr’s +i and -i flags.
chattr changes a file’s attributes on a Linux file system.
Set the flag as root:
# chattr +i xrdp-notes.txt# lsattr xrdp-notes.txt----i---------e------- xrdp-notes.txt
Set Mac Hostname
To set the host name of your Mac (in my case macbook-pro) in the command prompt, type the following command:
$ sudo scutil --set HostName "macbook-pro"$ sudo scutil --set LocalHostName "macbook-pro"
Reset Mac Launchpad
To reset the Mac LaunchPad to default enter the following:
rm ~/Library/Application\ Support/Dock/*.db ; killall Dock
This will however put all of the Apple apps on the first page and all of your remaining apps will be sorted alphabetically on the remaining pages.
Creating a Docker Registry
Creating a docker registry is rather straightforward, but you may need to do some tweaking of your docker installation in order to get it working as indicated below.
Let’s assume that you already have docker up and running on your machine.
We are going to set up a Docker registry on our local server. This server will not have a secure connection and will only be used internally, so we will need to allow this access by creating a file in /etc/docker called daemon.json to designate this: