Linux Cheat Sheet

One purpose of this blog is to have a convenient place for me and others to look up repeatable processes. In this case, it’s mostly about me. But you are welcome.

Minimal explanation here – There are good explanations of these steps elsewhere on the web. Double click the code boxes to copy (YMMV).

User-related commands

Mount Disk

Situation: You spin up a Linux instance with an additional drive, which you would like to access as /data.

sudo -i  #if necessary
lsblk    #if necessary
mkfs -t ext4 /dev/xvdb
mkdir /data
sudo mount /dev/xvdb /data
cp /etc/fstab /etc/fstab.orig
echo "/dev/xvdb   /data   ext4  defaults,nofail 0 2" >> /etc/fstab 
mount -a   #test

Basic Run Script

If your linux dist uses Upstart, put something like this into /etc/init/myapp.conf.

description "A Bamboo remote agent daemon job file for Upstart"
author "Your name"
start on runlevel [2345]
stop on shutdown
setuid bamboo
setgid bamboo
pre-start script
  logger "[`date`] Bamboo remote agent starting"
  exec /etc/init.d/ start
end script
pre-stop script
  exec /etc/init.d/ stop
  logger "[`date`] Bamboo remote agent stopping"
end script


Leave a Reply

Your email address will not be published. Required fields are marked *