Category: Linux

Linux Cheat Sheet – Users

Create User

useradd --create-home -c "Account to run the something app" something

Eek, reverse it

userdel -r something

SSH Instance Access

Set up an ssh key, and add it to the current user’s authorized keys.

sshgen -f company
# set it up with no password
cat >> .ssh/authorized_keys
# make sure to save off the public and private keys.  One way: 
aws s3 cp company s3://my-bucket/company
aws s3 cp s3://my-bucket/

Location for sudo privs


Also helpful:

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