Skip to content

Instantly share code, notes, and snippets.

@petarov
Last active January 25, 2017 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petarov/d7cca7a47ab850c5935ee94f02f64dbe to your computer and use it in GitHub Desktop.
Save petarov/d7cca7a47ab850c5935ee94f02f64dbe to your computer and use it in GitHub Desktop.
Linux Scripting

Bamboo as a Systemd Service

Make Atlassian Bamboo start as a Systemd service on Linux (CentOS).

Add a new bamboo user and group as explained in the Atlassian's tutorial.

useradd --create-home -c "Bamboo role account" bamboo

Make sure the binary and home directories are owned by the new user:

chown bamboo:bamboo /opt/atlassian/bamboo
chown bamboo:bamboo /var/atlassian/application-data/bamboo

Add the following to /etc/systemd/system/bamboo.service:

[Unit]
Description=Atlassian Bamboo Service
After=syslog.target network.target postgresql.service

[Service]
User=bamboo
Group=bamboo
Type=forking
Environment=BAMBOO_HOME=/var/atlassian/application-data/bamboo
ExecStart=/opt/atlassian/bamboo/bin/start-bamboo.sh
ExecStop=/opt/atlassian/bamboo/bin/stop-bamboo.sh

[Install]
WantedBy=multi-user.target

Reload the services via:

systemctl daemon-reload

To start/stop the service run:

systemctl start bamboo
systemctl stop bamboo

To enable the service to start after reboot:

systemctl enable bamboo

Bash Shortcuts

Based on Mastering Bash and Terminal.

Commands

  • ctrl + r => search incrementally

  • ctrl + s => to go the other direction. Add stty -ixon to your .bashrc or .bash_profile for Mac.

  • ctrl + p => previous command

  • ctrl + n => next command

  • Put export HISTCONTROL=ignoreboth:erasedups in .bashrc or .bash_profile to remove duplicates from history.

Cursor

  • ctrl + a => move the cursor to the beginning of the current line
  • ctrl + e => move the cursor to the end of the current line
  • alt + b => move the cursor backwards one word
  • alt + f => move the cursor forward one word
  • ctrl + k => delete from cursor to the end of the line
  • ctrl + u => delete from cursor to the beginning of the line
  • alt + d => delete the word in front of the cursor
  • ctrl + w => delete the word behind of the cursor

Clipboard

macOS

  • pbcopy => copy to clipboard, e.g., pbcopy < filename
  • pbpaste => paste from clipboard, e.g., pbpaste >> filename

Example, pbpaste | base64 | pbcopy.

Linux

Put the following in .bashrc to create the same effect.

	alias pbcopy='xclip -selection clipboard'
	alias pbpaste='xclip -selection clipboard -o'

Directories

  • cd - => go to last directory
  • pushd /tmp => mark your current directory and cd to /tmp
  • popd => go back to last directory before pushd

Background Processes

  • ctrl + z => suspend/pause a process
  • jobs -l => list the current background processes for the current tty session
  • bg => tell the most recent background process to continue running in the background
  • fg => bring the most recent background process back to the foreground
  • disown -h => disown the most recent background job. You'll have to kill it. Example, disown -h %4 disowns the 4th job.

Files

less

  • ctrl + u => page up
  • ctrl + d => page down
  • ctrl + p => scroll up one line
  • ctrl + n => scroll down one line
  • g => go to top of file
  • G => go to bottom of file
  • / => search

find

  • find . -type f -name myfile => search for myfile
  • tree -a or tree -d => list files or directories
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment